You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(13) |
Aug
(151) |
Sep
(21) |
Oct
(6) |
Nov
(70) |
Dec
(8) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(47) |
Feb
(66) |
Mar
(23) |
Apr
(115) |
May
(24) |
Jun
(53) |
Jul
(10) |
Aug
(279) |
Sep
(84) |
Oct
(149) |
Nov
(138) |
Dec
(52) |
2003 |
Jan
(22) |
Feb
(20) |
Mar
(29) |
Apr
(106) |
May
(170) |
Jun
(122) |
Jul
(70) |
Aug
(64) |
Sep
(27) |
Oct
(71) |
Nov
(49) |
Dec
(9) |
2004 |
Jan
(7) |
Feb
(38) |
Mar
(3) |
Apr
(9) |
May
(22) |
Jun
(4) |
Jul
(1) |
Aug
(2) |
Sep
(2) |
Oct
|
Nov
(15) |
Dec
(2) |
2005 |
Jan
(1) |
Feb
(1) |
Mar
|
Apr
(1) |
May
(28) |
Jun
(3) |
Jul
(11) |
Aug
(5) |
Sep
(1) |
Oct
(5) |
Nov
(2) |
Dec
(3) |
2006 |
Jan
(8) |
Feb
(3) |
Mar
(8) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Jeff M. <je...@cu...> - 2002-04-13 15:21:00
|
On Thu, 2002-04-11 at 23:59, Steve Freeman wrote: > I'd prefer to keep the test classes separate, I only put them together > when writing demos. That's not a reason! > > True, you can strip them out by name, but Ant isn't the only development > environment and there's scope for getting this wrong in a framework for > supporting testing. There's scope for the tests becoming ignored as I see it. > > b.t.w. are you using an IDE? Yes VIm (I've tried everything else and I'm not impressed). Still waiting for someone to convince me otherwise. > > Steve > > From: "Jeff Martin" <je...@cu...> > > I'm currently seperating out the jdk classes from the core mockobject > > classes hopefully we'll end up with something like this. > > > > src/core/ > > src/jdk/common/ > > /1.1/ > > /1.2/ > > /1.3/ > > /1.4/ > > src/j2ee/common > > /1.2/ > > /1.3/ > > > > and a build process which builds mock-core.jar, mock-jdk.x.x.jar > > mock-j2ee.x.x.jar or something similar. > > > > The thing I've just come up against is the test package with currently > > sites in core. This contains the TestExpectationSqlRow which needs to > be > > moved to src/jdk/common but I don't think we should have a test > package > > in each area. I'd much rather see the tests sit in the same package as > > the class it's testing, as it makes it obvious there is a test for a > > class. Tests can then be striped out of the final dist by excluding > > **/Test*.class. > > > -- Jeff Martin Memetic Engineer http://www.custommonkey.org/ |
From: Jeff M. <je...@cu...> - 2002-04-13 15:17:37
|
Sorry Scott I got there before you. Your patch is now redundent ;) Totally agree with you about the build file. Simple is best and I've still not got my head around everything that's in there. On Fri, 2002-04-12 at 21:29, Scott Lamb wrote: > I was trying to make some changes to the SQL stuff and noticed problems with > the build system. > > Specifically, clicking on a java compilation error would bring my editor to > out/src/blah.java, a copy of the code that is made immediately before > compiling. This is a pain because I would make changes that would be > overwritten. > > Also, the entire system seems to be rebuilt after any change, because the > modification dates are not preserved in this copy. (Looks like Jeff Martin > noted this on the list about a month ago.) > > Apparently this was done to allow filtering @version@, @year@, and @today@ for > the Javadocs. None of these tokens are used now in the source code. (Though > they are used in the manifest.) > > So, the attached patch compiles the source in-place instead of copying first. > I think I've got the correct files compiled in all cases by building a path to > be compiled and adding the appropriate j2ee stuff as necessary. Please try it > and apply it. > > I also tried to simplify things a bit. I removed some targets that just define > properties. These were pretty confusing to me. I left the check-availabilities > one, because <available/> only works inside a target. > > I think many of the properties being set could be removed to simplify things > further - setting properties doesn't make sense to me unless something is > long/complicated or you'd want to override it. Stuff like this strikes me as > extraneous: > > <property name="src.dir" value="src"/> > <property name="src.core.dir" value="${src.dir}/core"/> > <property name="src.j2ee.dir" value="${src.dir}/j2ee"/> > <property name="src.examples.dir" value="${src.dir}/examples"/> > > When would you ever want src.core.dir to be anything other than > "${src.dir}/core"? I think just saying the latter is more clear. > > Thanks. > > -- > Scott Lamb > ---- > > Index: build.xml > =================================================================== > RCS file: /cvsroot/mockobjects/mockobjects-java/build.xml,v > retrieving revision 1.19 > diff -u -r1.19 build.xml > --- build.xml 23 Feb 2002 19:20:49 -0000 1.19 > +++ build.xml 5 Apr 2002 00:43:40 -0000 > @@ -44,75 +44,72 @@ > <property file="${user.home}/build.properties" /> > <property file="build.properties" /> > > - <target name="project-properties"> > - <property name="project.fullname" value="Mock Objects"/> > - <property name="project.version" value="0.03"/> > - <property name="project.name" value="mockobjects"/> > - > - <!-- Miscellaneous settings --> > - <property name="year" value="2002"/> > - <property name="debug" value="on"/> > - <property name="optimize" value="off"/> > - <property name="deprecation" value="off"/> > - </target> > - > - <target name="source-locations"> > - <property name="src.dir" value="src"/> > - <property name="src.core.dir" value="${src.dir}/core"/> > - <property name="src.j2ee.dir" value="${src.dir}/j2ee"/> > - <property name="src.examples.dir" value="${src.dir}/examples"/> > - <property name="conf.dir" value="conf"/> > - <property name="doc.dir" value="doc"/> > - <property name="xdoc.dir" value="${doc.dir}/xdocs"/> > - <property name="skin.dir" value="${doc.dir}/skins"/> > - <property name="lib.dir" value="lib"/> > - </target> > - > - <target name="build-locations"> > - <!-- Destination locations for the build (relative to the basedir as > - specified in the basedir attribute of the project tag) --> > - <property name="out.dir" value="out"/> > - <property name="out.doc.dir" value="${out.dir}/doc"/> > - <property name="out.javadoc.dir" value="${out.doc.dir}/javadoc"/> > - <property name="out.classes.dir" value="${out.dir}/classes"/> > - <property name="out.site.dir" value="${out.dir}/site"/> > - <property name="out.src.dir" value="${out.dir}/src"/> > - <property name="out.src.examples.dir" value="${out.src.dir}/examples"/> > - <property name="out.conf.dir" value="${out.dir}/conf"/> > - <property name="out.xdoc.doc.dir" value="${out.dir}/xdoc/doc"/> > - <property name="out.xdoc.site.dir" value="${out.dir}/xdoc/site"/> > - </target> > - > - <target name="deliverable-names" > - depends="project-properties"> > - <property name="dist.dir" value="dist"/> > - > - <property name="jar.base.name" value="mocks"/> > - <property name="sources.zip.name" value="${project.name}-src"/> > - > - <!-- The project web site in a zip file (without the Javadoc but > - with a link pointing to javadoc : <htdocs>/javadoc/index.html --> > - <property name="site.name" value="${project.name}-website"/> > - <property name="javadoc.name" value="${project.name}-javadoc"/> > - > - <property name="project.zip.name" value="${project.name}-${project.version}"/> > - </target> > - > - <target name="useful-file-patterns"> > - <!-- All conf files (including test files) --> > - <patternset id="nonjava.src.files"> > - <include name="**/*.txt"/> > - <include name="**/*.xml"/> > - <include name="**/*.properties"/> > - </patternset> > - > - <patternset id="java.src.files"> > - <include name="**/*.java"/> > - </patternset> > - </target> > + <!-- > + - Project properties > + --> > + <property name="project.fullname" value="Mock Objects"/> > + <property name="project.version" value="0.03"/> > + <property name="project.name" value="mockobjects"/> > + > + <!-- Miscellaneous settings --> > + <property name="year" value="2002"/> > + <property name="debug" value="on"/> > + <property name="optimize" value="off"/> > + <property name="deprecation" value="off"/> > + > + <!-- > + - Source locations > + --> > + <property name="src.dir" value="src"/> > + <property name="src.core.dir" value="${src.dir}/core"/> > + <property name="src.j2ee.dir" value="${src.dir}/j2ee"/> > + <property name="src.examples.dir" value="${src.dir}/examples"/> > + <property name="conf.dir" value="conf"/> > + <property name="doc.dir" value="doc"/> > + <property name="xdoc.dir" value="${doc.dir}/xdocs"/> > + <property name="skin.dir" value="${doc.dir}/skins"/> > + <property name="lib.dir" value="lib"/> > + > + <!-- > + - Destination locations for the build (relative to the basedir as > + - specified in the basedir attribute of the project tag) > + --> > + <property name="out.dir" value="out"/> > + <property name="out.doc.dir" value="${out.dir}/doc"/> > + <property name="out.javadoc.dir" value="${out.doc.dir}/javadoc"/> > + <property name="out.classes.dir" value="${out.dir}/classes"/> > + <property name="out.site.dir" value="${out.dir}/site"/> > + <property name="out.conf.dir" value="${out.dir}/conf"/> > + <property name="out.xdoc.doc.dir" value="${out.dir}/xdoc/doc"/> > + <property name="out.xdoc.site.dir" value="${out.dir}/xdoc/site"/> > + > + <!-- > + - Deliverable names > + --> > + <property name="dist.dir" value="dist"/> > + > + <property name="jar.base.name" value="mocks"/> > + <property name="sources.zip.name" value="${project.name}-src"/> > + > + <!-- The project web site in a zip file (without the Javadoc but > + with a link pointing to javadoc : <htdocs>/javadoc/index.html --> > + <property name="site.name" value="${project.name}-website"/> > + <property name="javadoc.name" value="${project.name}-javadoc"/> > + > + <property name="project.zip.name" value="${project.name}-${project.version}"/> > + > + <!-- > + - Useful file patterns > + --> > + > + <!-- All conf files (including test files) --> > + <patternset id="nonjava.src.files"> > + <include name="**/*.txt"/> > + <include name="**/*.xml"/> > + <include name="**/*.properties"/> > + </patternset> > > - <target name="check-availabilities" > - depends="source-locations"> > + <target name="check-availabilities"> > > <path id="lib.classpath"> > <fileset dir="${lib.dir}"> > @@ -129,6 +126,11 @@ > <available property="j2ee.version" value="1.3" > classpathref="lib.classpath" classname="javax.servlet.Filter" /> > > + <property name="src.path" value="${src.core.dir}" /> > + <available property="src.path" > + value="${src.path}:${src.j2ee.dir}/common:${src.j2ee.dir}/${j2ee.version}" > + classpathref="lib.classpath" classname="javax.servlet.Servlet" /> > + > <!-- sorry about this. It seems to be the easiest way to set a marker to describe > which j2ee the .jar supports. Later versions of Ant include an 'isset' > condition, which should do the trick --> > @@ -137,8 +139,7 @@ > classpathref="lib.classpath" classname="javax.servlet.Servlet" /> > </target> > > - <target name="call-me-first" > - depends="project-properties, useful-file-patterns, check-availabilities"> > + <target name="call-me-first" depends="check-availabilities"> > <!-- Initialize the build. Must be called by all targets --> > > <tstamp/> > @@ -182,7 +183,7 @@ > </target> > > <target name="_copy-from-src" > - depends="useful-file-patterns, _copy-from-j2ee" > > + depends="_copy-from-j2ee" > > <!-- requires copy.todir, src.patternset.id --> > > <copy todir="${copy.todir}" > @@ -194,23 +195,8 @@ > </copy> > </target> > > - <target name="clear-class-files" > - depends="build-locations"> > - <antcall target="_flush-dir"> > - <param name="flush.dir" value="${out.classes.dir}" /> > - </antcall> > - </target> > - > - <target name="copy-java-files" > - depends="source-locations, build-locations, check-availabilities"> > - <antcall target="_copy-from-src"> > - <param name="copy.todir" value="${out.src.dir}" /> > - <param name="src.patternset.id" value="java.src.files" /> > - </antcall> > - </target> > - > <target name="compile" > - depends="call-me-first, clear-class-files, copy-java-files" > + depends="call-me-first" > description="Compile all the java files for included libraries" > > > <javac destdir="${out.classes.dir}" > @@ -218,7 +204,7 @@ > deprecation="${deprecation}" > verbose="true" > optimize="${optimize}" > - srcdir="${out.src.dir}"> > + srcdir="${src.path}"> > <classpath> > <path refid="lib.classpath"/> > <pathelement path="${java.class.path}"/> > @@ -248,8 +234,7 @@ > </junit> > </target> > > - <target name="copy-nonjava-files" > - depends="source-locations, build-locations, check-availabilities, call-me-first"> > + <target name="copy-nonjava-files" depends="check-availabilities, call-me-first"> > <antcall target="_copy-from-src"> > <param name="copy.todir" value="${out.classes.dir}" /> > <param name="src.patternset.id" value="nonjava.src.files" /> > @@ -271,7 +256,7 @@ > </target> > > <target name="make-jar-name" > - depends="deliverable-names, check-availabilities"> > + depends="check-availabilities"> > <property name="jar.name" > value="${jar.base.name}${project.version}_jdk${jdk.version}${jar.j2ee.name}" /> > </target> > @@ -289,20 +274,19 @@ > </jar> > </target> > > - <target name="prepare-javadoc" > - depends="build-locations, copy-java-files" > > + <target name="prepare-javadoc"> > <antcall target="_flush-dir"> > <param name="flush.dir" value="${out.javadoc.dir}" /> > </antcall> > </target> > > <target name="javadoc" > - depends="call-me-first, deliverable-names, prepare-javadoc" > + depends="call-me-first, prepare-javadoc" > unless="javadoc.notrequired" > description="Generate the javadoc for the current version" > > > <javadoc > - sourcepath="${out.src.dir}" > + sourcepath="${src.path}" > packagenames="com.mockobjects.*" > destdir="${out.javadoc.dir}" > author="true" > @@ -407,7 +391,7 @@ > ======================================================================== > --> > <target name="prepare-site" > - depends="build-locations, deliverable-names, call-me-first"> > + depends="call-me-first"> > > <mkdir dir="${out.site.dir}"/> > <mkdir dir="${out.site.dir}/images"/> > @@ -450,7 +434,7 @@ > > <!-- Generate the web site --> > <target name="site" > - depends="build-locations, deliverable-names, prepare-site, zip-javadoc-for-website" > + depends="prepare-site, zip-javadoc-for-website" > unless="stylebook.site.notrequired" > description="Generate the web site"> > > @@ -496,10 +480,9 @@ > <mkdir dir="${dist.dir}"/> > </target> > > - <target name="zip-java-sources" > - depends="build-locations, deliverable-names"> > + <target name="zip-java-sources"> > <zip zipfile="${out.dir}/${sources.zip.name}.zip" > - basedir="${out.src.dir}" /> > + basedir="${src.path}" includes="**/*.java"/> > </target> > > <target name="dist" > @@ -511,7 +494,7 @@ > <include name="${jar.name}.jar"/> > </zipfileset> > <zipfileset dir="${out.doc.dir}" prefix="doc"/> > - <zipfileset dir="${out.dir}" prefix="src"> > + <zipfileset dir="${out.dir}" prefix="src"> > <include name="${src.name}.zip"/> > </zipfileset> > </zip> -- Jeff Martin Memetic Engineer http://www.custommonkey.org/ |
From: Jeff M. <je...@cu...> - 2002-04-13 15:15:52
|
The jdk mocks have now been moved out of the core area into their own jdk area. The build files has changed quite a bit and it now builds three jars mockobjects-core.jar mockobjects-jdkx.x.jar and mockobjects-j2ee-x.x.jar. I've probably stuffed something somewhere, but as far as I can tell it's all there. Complaints to the usual address. <rant> I've left the tests where they were. But none of you have come up with anything like a reason for no moving them in with the classes they test. (Neatness isn't a reason!) </rant> -- Jeff Martin Memetic Engineer http://www.custommonkey.org/ |
From: Jeff M. <cus...@us...> - 2002-04-13 15:08:26
|
Update of /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com/mockobjects/io In directory usw-pr-cvs1:/tmp/cvs-serv12990/src/jdk/common/com/mockobjects/io Added Files: MockOutputStream.java MockPrintStream.java MockPrintWriter.java Log Message: Move none core mocks out of the core area --- NEW FILE: MockOutputStream.java --- package com.mockobjects.io; import java.io.*; import junit.framework.*; import com.mockobjects.*; import com.mockobjects.util.Verifier; public class MockOutputStream extends OutputStream implements Verifiable { private ExpectationValue myWriteWasCalled = new ExpectationValue("MockOutputStream.writeWasCalled"); private ExpectationCounter myCloseCalls= new ExpectationCounter("MockOutputStream.close()"); private ByteArrayOutputStream myBuffer = new ByteArrayOutputStream(); private boolean shouldThrowException = false; public MockOutputStream() { super(); } public void clearActualBuffer() { myBuffer = new ByteArrayOutputStream(); } public void close() throws IOException { myCloseCalls.inc(); } public String getContents() { return myBuffer.toString(); } public void setExpectedCloseCalls(int closeCall) { myCloseCalls.setExpected(closeCall); } public void setExpectingWriteCalls(boolean expectingWriteCall) { myWriteWasCalled.setExpected(expectingWriteCall); } public void setupThrowIOException(boolean throwException) { shouldThrowException = throwException; } public void verify() { Verifier.verifyObject(this); } public void write(int b) throws IOException { myWriteWasCalled.setActual(true); if (shouldThrowException) { throw new IOException("Test IOException generated by request"); } myBuffer.write(b); } } --- NEW FILE: MockPrintStream.java --- package com.mockobjects.io; import java.io.*; import junit.framework.*; import com.mockobjects.*; import com.mockobjects.util.*; public class MockPrintStream extends PrintStream { private ExpectationCounter myPrintlnCalls = new ExpectationCounter("MockPrintStream.println calls"); private ExpectationSegment mySegment = new ExpectationSegment("String segment"); private PrintStream myOldErrorStream; private String myLastPrintedString; public MockPrintStream() { this(null); } public MockPrintStream(OutputStream out) { super(out); } public MockPrintStream(OutputStream out, boolean autoFlush) { super(out, autoFlush); } public void becomeErrorStream() { myOldErrorStream = System.err; System.setErr(this); } public void println(Object anObject) { myPrintlnCalls.inc(); } public void println(String aString) { println((Object) aString); myLastPrintedString = aString; mySegment.setActual(aString); } public void restoreErrorStream() { System.setErr(myOldErrorStream); } public void setExpectedPrintlnCalls(int calls) { myPrintlnCalls.setExpected(calls); } public void setExpectedStringSegment(String aString) { mySegment.setExpected(aString); } public void verify() { Verifier.verifyObject(this); } } --- NEW FILE: MockPrintWriter.java --- package com.mockobjects.io; import com.mockobjects.*; import junit.framework.Assert; import java.io.*; /** * @author: st...@m3... */ public class MockPrintWriter extends PrintWriter implements Verifiable { private ExpectationSegment mySegment = new ExpectationSegment("String segment"); private ExpectationCounter myCloseCalls = new ExpectationCounter("close calls"); public MockPrintWriter() { this(new StringWriter()); } private MockPrintWriter(Writer writer) { super(writer); } public void close() { super.close(); myCloseCalls.inc(); } public void setExpectedCloseCalls(int calls) { myCloseCalls.setExpected(calls); } public void setExpectedSegment(String aString) { mySegment.setExpected(aString); } public void verify() { mySegment.verify(); myCloseCalls.verify(); } public void write(String s) { super.write(s); mySegment.setActual(s); } } |
From: Jeff M. <cus...@us...> - 2002-04-13 15:08:26
|
Update of /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com/mockobjects/beans In directory usw-pr-cvs1:/tmp/cvs-serv12990/src/jdk/common/com/mockobjects/beans Added Files: MockPropertyChangeListener.java Log Message: Move none core mocks out of the core area --- NEW FILE: MockPropertyChangeListener.java --- package com.mockobjects.beans; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import com.mockobjects.ExpectationCounter; import com.mockobjects.ExpectationValue; import com.mockobjects.MockObject; /** * Mock object for a PropertyChangeListener. * This mock object can be used in verifying the event propagation mechanism * of beans. You can set the information you expect from a PropertyChangeEvent * as well as the number of events. If you expect more than one event, only the * actual values of the last event are stored. * * @author Ringo De Smet - <a href="http://www.mediagenix.com">MediaGeniX NV</a> */ public class MockPropertyChangeListener extends MockObject implements PropertyChangeListener { protected ExpectationValue propertyName; protected ExpectationValue oldValue; protected ExpectationValue newValue; protected ExpectationCounter eventCount; public MockPropertyChangeListener(String name) { propertyName = new ExpectationValue(name + ".propertyName"); oldValue = new ExpectationValue(name + ".oldValue"); newValue = new ExpectationValue(name + ".newValue"); eventCount = new ExpectationCounter(name + ".expectedNrOfEvents"); } public MockPropertyChangeListener() { this("MockPropertyChangeListener"); } public void propertyChange(PropertyChangeEvent event) { propertyName.setActual(event.getPropertyName()); oldValue.setActual(event.getOldValue()); newValue.setActual(event.getNewValue()); eventCount.inc(); } public void setExpectedNewValue(Object expectedNewValue) { newValue.setExpected(expectedNewValue); } public void setExpectedOldValue(Object expectedOldValue) { oldValue.setExpected(expectedOldValue); } public void setExpectedEventCount(int expectedEventCount) { eventCount.setExpected(expectedEventCount); } public void setExpectedPropertyName(String expectedPropertyName) { propertyName.setExpected(expectedPropertyName); } } |
From: Jeff M. <cus...@us...> - 2002-04-13 15:08:26
|
Update of /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com/mockobjects/sql In directory usw-pr-cvs1:/tmp/cvs-serv12990/src/jdk/common/com/mockobjects/sql Added Files: ExpectationSqlRow.java MockConnection.java MockDriver.java MockMultiRowResultSet.java MockPreparedStatement.java MockResultSet.java MockSingleRowResultSet.java MockStatement.java Log Message: Move none core mocks out of the core area --- NEW FILE: ExpectationSqlRow.java --- package com.mockobjects.sql; import java.sql.SQLException; import java.util.Map; import java.util.Iterator; import com.mockobjects.*; import com.mockobjects.util.*; public class ExpectationSqlRow implements Verifiable { private ExpectationMap values; public ExpectationSqlRow(String name) { super(); values = new ExpectationMap(name); values.setExpectNothing(); } public ExpectationSqlRow(String name, Object[] indexedValues) { this(name); addExpectedIndexedValues(indexedValues); } public ExpectationSqlRow(String name, String[] columnNames, Object[] values) { this(name); addExpectedNamedValues(columnNames, values); } public void addExpectedIndexedValues(Object[] indexedValues) { for (int i = 0; i < indexedValues.length; ++i) { values.addExpected(new Integer(i + 1), indexedValues[i]); } } public void addExpectedNamedValues(Map map) { Iterator columnNames = map.keySet().iterator(); while (columnNames.hasNext()) { Object key = columnNames.next(); values.addExpected(key, map.get(key)); } } public void addExpectedNamedValues(String[] columnNames, Object[] someValues) { for (int i = 0; i < someValues.length; ++i) { values.addExpected(columnNames[i], someValues[i]); } } public Object get(int oneBasedIndex) throws SQLException { return get(new Integer(oneBasedIndex)); } public Object get(Object key) throws SQLException { Object result = values.get(key); if (result instanceof SQLException) { throw (SQLException)result; } return result; } public void verify() { values.verify(); } } --- NEW FILE: MockConnection.java --- package com.mockobjects.sql; import java.sql.*; import java.util.*; import com.mockobjects.*; public class MockConnection extends MockObject implements Connection { private ExpectationCounter myCommitCalls = new ExpectationCounter("MockConnection.commit"); private ExpectationCounter myRollbackCalls = new ExpectationCounter("MockConnection.rollback"); private ExpectationCounter myCloseCalls = new ExpectationCounter("MockConnection.close"); private ExpectationCollection myPreparedStatementStrings = new ExpectationList("MockConnection.preparedStatementString"); private ArrayList myPreparedStatements = new ArrayList(); private SQLException myStatementException = null; private ExpectationCounter myCreateStatementCalls = new ExpectationCounter("MockConnection.createStatement"); private ExpectationValue myAutoCommit = new ExpectationValue("MockConnection.setAutoCommit"); private Statement myStatement; private boolean myIsClosed; private SQLException myIsClosedException; private SQLException myCloseException; public MockConnection() { super(); } public void setExpectedCloseCalls(int callCount) { myCloseCalls.setExpected(callCount); } public void setExpectedCommitCalls(int callCount) { myCommitCalls.setExpected(callCount); } public void setExpectedCreateStatementCalls(int calls) { myCreateStatementCalls.setExpected(calls); } public void addExpectedPreparedStatementString(String sql) { myPreparedStatementStrings.addExpected(sql); } public void setExpectedRollbackCalls(int callCount) { myRollbackCalls.setExpected(callCount); } public void setupAddPreparedStatement(PreparedStatement prepared) { myPreparedStatements.add(prepared); } public void setupStatement(Statement statement) { myStatement = statement; } public void setupThrowExceptionOnPrepareOrCreate(SQLException exception) { myStatementException = exception; } public void clearWarnings() throws SQLException { } public void setupCloseException(SQLException aCloseException){ myCloseException = aCloseException; } public void close() throws SQLException { if(myCloseException!=null){ throw myCloseException; } myCloseCalls.inc(); } public void commit() throws SQLException { myCommitCalls.inc(); } public Statement createStatement() throws SQLException { myCreateStatementCalls.inc(); throwStatementExceptionIfAny(); return myStatement; } public Statement createStatement( int resultSetType, int resultSetConcurrency) throws SQLException { throw new UnsupportedOperationException(); } public boolean getAutoCommit() throws SQLException { throw new UnsupportedOperationException(); } public String getCatalog() throws SQLException { throw new UnsupportedOperationException(); } public DatabaseMetaData getMetaData() throws SQLException { throw new UnsupportedOperationException(); } public int getTransactionIsolation() throws SQLException { throw new UnsupportedOperationException(); } public Map getTypeMap() throws SQLException { throw new UnsupportedOperationException(); } public SQLWarning getWarnings() throws SQLException { throw new UnsupportedOperationException(); } public void setupIsClosedException(SQLException aIsClosedException){ myIsClosedException = aIsClosedException; } public void setupIsClose(boolean aIsClosed){ myIsClosed = aIsClosed; } public boolean isClosed() throws SQLException { if(myIsClosedException!=null){ throw myIsClosedException; } return myIsClosed; } public boolean isReadOnly() throws SQLException { throw new UnsupportedOperationException(); } public String nativeSQL(String sql) throws SQLException { throw new UnsupportedOperationException(); } public CallableStatement prepareCall(String sql) throws SQLException { throw new UnsupportedOperationException(); } public CallableStatement prepareCall( String sql, int resultSetType, int resultSetConcurrency) throws SQLException { throw new UnsupportedOperationException(); } public PreparedStatement prepareStatement(String sql) throws SQLException { myPreparedStatementStrings.addActual(sql); throwStatementExceptionIfAny(); return (PreparedStatement) myPreparedStatements.remove(0); } public PreparedStatement prepareStatement( String sql, int resultSetType, int resultSetConcurrency) throws SQLException { throw new UnsupportedOperationException(); } public void rollback() throws SQLException { myRollbackCalls.inc(); } public void setExpectedAutoCommit(boolean autoCommit) { myAutoCommit.setExpected(autoCommit); } public void setAutoCommit(boolean autoCommit) throws SQLException { myAutoCommit.setActual(autoCommit); } public void setCatalog(String catalog) throws SQLException { throw new UnsupportedOperationException(); } public void setReadOnly(boolean readOnly) throws SQLException { throw new UnsupportedOperationException(); } public void setTransactionIsolation(int level) throws SQLException { throw new UnsupportedOperationException(); } public void setTypeMap(Map map) throws SQLException { throw new UnsupportedOperationException(); } private void throwStatementExceptionIfAny() throws SQLException { if (null != myStatementException) { throw myStatementException; } } } --- NEW FILE: MockDriver.java --- package com.mockobjects.sql; import java.sql.*; import java.util.*; public class MockDriver implements Driver{ public static MockDriver myDriver = new MockDriver(); private Connection myConnection; static{ try{ DriverManager.registerDriver(myDriver); }catch(SQLException e){ e.printStackTrace(); } } public void setupConnect(Connection aConnection){ this.myConnection = aConnection; } public boolean acceptsURL(String url){ return true; } public Connection connect(String url, Properties info){ return myConnection; } public int getMajorVersion(){ return 0; } public int getMinorVersion(){ return 0; } public DriverPropertyInfo[] getPropertyInfo(String url, Properties info){ return null; } public boolean jdbcCompliant(){ return false; } } --- NEW FILE: MockMultiRowResultSet.java --- package com.mockobjects.sql; import java.sql.*; import java.sql.Date; import java.util.*; import java.math.BigDecimal; import java.io.InputStream; import java.io.Reader; import junit.framework.Assert; import junit.framework.AssertionFailedError; import com.mockobjects.*; /** * This is a simple implementation of a MockResultSet. * It returns values for multiple rows. */ public class MockMultiRowResultSet extends MockResultSet { private Object[][] myRows = new Object[0][0]; private String[] myColumnNames; private int myRowOffset = -1; private SQLException myGetException = null; public MockMultiRowResultSet() { super(); } public void setupColumnNames(String[] columnNames) { myColumnNames = columnNames; } public void setupRows(Object[][] rows) { myRows = rows; } public void setupThrowExceptionOnGet(SQLException exception) { myGetException = exception; } public Object getObject(int columnIndex) throws SQLException { throwGetExceptionIfAny(); return myRows[myRowOffset][columnIndex - 1]; } public Object getObject(String columnName) throws SQLException { throwGetExceptionIfAny(); return getObject(findIndexForColumnName(columnName)); } public boolean next() throws SQLException { myNextCalls.inc(); if (myRowOffset + 1 >= myRows.length) { return false; } myRowOffset++; return true; } public int getRow() throws SQLException { return myRowOffset + 1; } private void throwGetExceptionIfAny() throws SQLException { if (null != myGetException) { throw myGetException; } } private int findIndexForColumnName(String columnName) throws SQLException { for (int i = 0; i < myColumnNames.length; ++i) { if (myColumnNames[i].equalsIgnoreCase(columnName)) { return i + 1; } } throw new SQLException("Column name not found"); } } --- NEW FILE: MockPreparedStatement.java --- package com.mockobjects.sql; import java.sql.*; import java.util.Calendar; import java.io.Reader; import java.math.BigDecimal; import com.mockobjects.*; public class MockPreparedStatement extends MockStatement implements PreparedStatement { private ExpectationSet mySetParameters = new ExpectationSet("MockPreparedStatement.setParameters"); private ExpectationCounter myClearParametersCalls = new ExpectationCounter("MockPreparedStatement.clearParameters() calls"); public MockPreparedStatement() { super(); } public void addExpectedSetParameter(int parameterIndex, int intValue) { addExpectedSetParameter(parameterIndex, new Integer(intValue)); } public void addExpectedSetParameter(int parameterIndex, Object parameterValue) { mySetParameters.addExpected(new MapEntry(new Integer(parameterIndex), parameterValue)); } public void addExpectedSetParameters(Object[] parameters) { for (int i = 0; i < parameters.length; ++i) { addExpectedSetParameter(i + 1, parameters[i]); } } public void clearParameters() throws SQLException { myClearParametersCalls.inc(); } public boolean execute() throws SQLException { innerExecute(); return false; } public void setExpectedClearParametersCalls(int callCount) { myClearParametersCalls.setExpected(callCount); } public void setExpectingNoSetParameters() { mySetParameters.setExpectNothing(); } public ResultSet executeQuery() throws SQLException { return executeQuery(""); } public int executeUpdate() throws SQLException { return executeUpdate(""); } public void setInt(int parameterIndex, int x) throws SQLException { setObject(parameterIndex, new Integer(x)); } public void setString(int parameterIndex, String x) throws SQLException { setObject(parameterIndex, x); } public void setTimestamp(int param, Timestamp timestamp) throws SQLException { setObject(param, timestamp); } public void setClob(int param, Clob clob) throws SQLException { setObject(param, clob); } public void setLong(int param, long aLong) throws SQLException { setObject(param, new Long(aLong)); } public void addBatch() throws SQLException { throw new UnsupportedOperationException(); } public void setNull(int param, int param1) throws SQLException { setObject(param, null); } public void setArray(int param, Array array) throws SQLException { setObject(param, array); } public void setShort(int param, short aShort) throws SQLException { setObject(param, new Short(aShort)); } public void setTime(int param, Time time, Calendar calendar) throws SQLException { setObject(param, time); } public void setObject(int param, Object obj, int targetSqlType, int scale) throws SQLException { throw new UnsupportedOperationException(); } public void setObject(int param, Object obj, int targetSqlType) throws SQLException { throw new UnsupportedOperationException(); } public void setRef(int param, Ref ref) throws SQLException { setObject(param, ref); } public void setDate(int param, Date date) throws SQLException { setObject(param, date); } public void setFloat(int param, float aFloat) throws SQLException { setObject(param, new Float(aFloat)); } public void setBlob(int param, Blob blob) throws SQLException { setObject(param, blob); } public void setCharacterStream(int param, Reader reader, int length) throws SQLException { throw new UnsupportedOperationException(); } public void setAsciiStream(int param, java.io.InputStream inputStream, int length) throws SQLException { throw new UnsupportedOperationException(); } public void setDate(int param, Date date, Calendar calendar) throws SQLException { setDate(param, date); } public void setBinaryStream(int param, java.io.InputStream inputStream, int length) throws SQLException { throw new UnsupportedOperationException(); } public void setUnicodeStream(int param, java.io.InputStream inputStream, int length) throws SQLException { throw new UnsupportedOperationException(); } public void setBytes(int param, byte[] values) throws SQLException { setObject(param, values); } public void setObject(int param, Object obj) throws SQLException { mySetParameters.addActual(new MapEntry(new Integer(param), obj)); } public void setByte(int param, byte aByte) throws SQLException { setObject(param, new Byte(aByte)); } public void setDouble(int param, double aDouble) throws SQLException { setObject(param, new Double(aDouble)); } public ResultSetMetaData getMetaData() throws SQLException { throw new UnsupportedOperationException(); } public void setTimestamp(int param, Timestamp timestamp, Calendar calendar) throws SQLException { throw new UnsupportedOperationException(); } public void setTime(int param, Time time) throws SQLException { setObject(param, time); } public void setBoolean(int param, boolean aBoolean) throws SQLException { setObject(param, new Boolean(aBoolean)); } public void setNull(int param, int param1, String typeName) throws SQLException { throw new UnsupportedOperationException(); } public void setBigDecimal(int param, BigDecimal bigDecimal) throws SQLException { setObject(param, bigDecimal); } } --- NEW FILE: MockResultSet.java --- package com.mockobjects.sql; import java.sql.*; import java.sql.Date; import java.util.*; import java.math.BigDecimal; import java.io.InputStream; import java.io.Reader; import junit.framework.Assert; import junit.framework.AssertionFailedError; import com.mockobjects.*; /** * This is the base implementation of a mock result set. * It manages converting objects from the current row into a other types. * Entries can be found by either column index or column name. * For basic java types (e.g. int, boolean), insert an instance of * the appropriate object (e.g. Integer, Boolean) * It also counts close() and next() calls * To force throwing a SQLException on a getter, set the corresponding value to be of type SQLException. */ abstract public class MockResultSet extends MockObject implements ResultSet { private ExpectationCounter myCloseCalls = new ExpectationCounter("MockResultSet.close"); protected ExpectationCounter myNextCalls = new ExpectationCounter("MockResultSet.next"); private ResultSetMetaData myMetaData; private Statement myStatement; public MockResultSet() { super(); } /** * Used as the base implementation for getting all types of object, * based on 1-based column index * @see java.sql.ResultSet#getObject(int) */ abstract public Object getObject(int columnIndex) throws SQLException; /** * Used as the base implementation for getting all types of object, * based on columnName * @see java.sql.ResultSet#getObject(int) */ abstract public Object getObject(String columnName) throws SQLException; abstract public boolean next() throws SQLException; abstract public int getRow() throws SQLException; public void setExpectedCloseCalls(int calls) { myCloseCalls.setExpected(calls); } public void setExpectedNextCalls(int calls) { myNextCalls.setExpected(calls); } public void setupMetaData(ResultSetMetaData metaData) { myMetaData = metaData; } public void setupStatement(Statement statement) { myStatement = statement; } public void close() throws SQLException { myCloseCalls.inc(); } public Array getArray(int i) throws SQLException { return (Array)getObject(i); } public Array getArray(String colName) throws SQLException { return (Array)getObject(colName); } public InputStream getAsciiStream(int columnIndex) throws SQLException { return (InputStream)getObject(columnIndex); } public InputStream getAsciiStream(String columnName) throws SQLException { return (InputStream)getObject(columnName); } public BigDecimal getBigDecimal(String columnName, int scale) throws SQLException { return getBigDecimal(columnName); } public BigDecimal getBigDecimal(int columnIndex) throws SQLException { return (BigDecimal)getObject(columnIndex); } public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException { return (BigDecimal)getObject(columnIndex); } public BigDecimal getBigDecimal(String columnName) throws SQLException { return (BigDecimal)getObject(columnName); } public InputStream getBinaryStream(int columnIndex) throws SQLException { return (InputStream)getObject(columnIndex); } public InputStream getBinaryStream(String columnName) throws SQLException { return (InputStream)getObject(columnName); } public Blob getBlob(int i) throws SQLException { return (Blob)getObject(i); } public Blob getBlob(String colName) throws SQLException { return (Blob)getObject(colName); } public boolean getBoolean(int columnIndex) throws SQLException { return ((Boolean)getObject(columnIndex)).booleanValue(); } public boolean getBoolean(String columnName) throws SQLException { return ((Boolean)getObject(columnName)).booleanValue(); } public byte getByte(int columnIndex) throws SQLException { return ((Byte)getObject(columnIndex)).byteValue(); } public byte getByte(String columnName) throws SQLException { return ((Byte)getObject(columnName)).byteValue(); } public byte[] getBytes(int columnIndex) throws SQLException { return (byte[])getObject(columnIndex); } public byte[] getBytes(String columnName) throws SQLException { return (byte[])getObject(columnName); } public Reader getCharacterStream(int columnIndex) throws SQLException { return (Reader)getObject(columnIndex); } public Reader getCharacterStream(String columnName) throws SQLException { return (Reader)getObject(columnName); } public Clob getClob(int i) throws SQLException { return (Clob)getObject(i); } public Clob getClob(String colName) throws SQLException { return (Clob)getObject(colName); } public String getCursorName() throws SQLException { throw new AssertionFailedError("MockResultSet getCursorName not implemented"); } public int getConcurrency() throws SQLException { throw new AssertionFailedError("MockResultSet getConcurrency not implemented"); } public Date getDate(int columnIndex) throws SQLException { return (Date)getObject(columnIndex); } public Date getDate(String columnName) throws SQLException { return (Date)getObject(columnName); } public Date getDate(int columnIndex, Calendar cal) throws SQLException { return getDate(columnIndex); } public Date getDate(String columnName, Calendar cal) throws SQLException { return getDate(columnName); } public double getDouble(int columnIndex) throws SQLException { return ((Double)getObject(columnIndex)).doubleValue(); } public double getDouble(String columnName) throws SQLException { return ((Double)getObject(columnName)).doubleValue(); } public int getFetchDirection() throws SQLException { throw new AssertionFailedError("MockResultSet getFetchDirection not implemented"); } public int getFetchSize() throws SQLException { throw new AssertionFailedError("MockResultSet getFetchSize not implemented"); } public float getFloat(int columnIndex) throws SQLException { return ((Float)getObject(columnIndex)).floatValue(); } public float getFloat(String columnName) throws SQLException { return ((Float)getObject(columnName)).floatValue(); } public int getInt(int columnIndex) throws SQLException { return ((Integer) getObject(columnIndex)).intValue(); } public int getInt(String columnName) throws SQLException { return ((Integer) getObject(columnName)).intValue(); } public long getLong(int columnIndex) throws SQLException { return ((Long) getObject(columnIndex)).longValue(); } public long getLong(String columnName) throws SQLException { return ((Long) getObject(columnName)).longValue(); } public ResultSetMetaData getMetaData() throws SQLException { return myMetaData; } public Object getObject(int i, Map map) throws SQLException { throw new AssertionFailedError("MockResultSet getObject not implemented"); } public Object getObject(String colName, Map map) throws SQLException { throw new AssertionFailedError("MockResultSet getObject not implemented"); } public Ref getRef(int i) throws SQLException { return (Ref)getObject(i); } public Ref getRef(String colName) throws SQLException { return (Ref)getObject(colName); } public short getShort(String columnName) throws SQLException { return ((Short)getObject(columnName)).shortValue(); } public short getShort(int columnIndex) throws SQLException { return ((Short)getObject(columnIndex)).shortValue(); } public Statement getStatement() throws SQLException { return myStatement; } public String getString(int columnIndex) throws SQLException { return (String)getObject(columnIndex); } public String getString(String columnName) throws SQLException { return (String)getObject(columnName); } public Time getTime(int columnIndex) throws SQLException { return (Time)getObject(columnIndex); } public Time getTime(String columnName) throws SQLException { return (Time)getObject(columnName); } public Time getTime(int columnIndex, Calendar cal) throws SQLException { return getTime(columnIndex); } public Time getTime(String columnName, Calendar cal) throws SQLException { return getTime(columnName); } public Timestamp getTimestamp(int columnIndex) throws SQLException { return (Timestamp)getObject(columnIndex); } public Timestamp getTimestamp(String columnName) throws SQLException { return (Timestamp)getObject(columnName); } public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException { return getTimestamp(columnIndex); } public Timestamp getTimestamp(String columnName, Calendar cal) throws SQLException { return getTimestamp(columnName); } public int getType() throws SQLException { throw new AssertionFailedError("MockResultSet getType not implemented"); } public InputStream getUnicodeStream(int columnIndex) throws SQLException { return (InputStream)getObject(columnIndex); } public InputStream getUnicodeStream(String columnName) throws SQLException { return (InputStream)getObject(columnName); } public SQLWarning getWarnings() throws SQLException { throw new AssertionFailedError("MockResultSet getWarnings not implemented"); } public void clearWarnings() throws SQLException { throw new AssertionFailedError("MockResultSet clearWarnings not implemented"); } public int findColumn(String columnName) throws SQLException { throw new AssertionFailedError("MockResultSet findColumn not implemented"); } public boolean isBeforeFirst() throws SQLException { throw new AssertionFailedError("MockResultSet isBeforeFirst not implemented"); } public boolean isAfterLast() throws SQLException { throw new AssertionFailedError("MockResultSet getFetchSize not implemented"); } public boolean isFirst() throws SQLException { throw new AssertionFailedError("MockResultSet isFirst not implemented"); } public boolean isLast() throws SQLException { throw new AssertionFailedError("MockResultSet isLast not implemented"); } public void beforeFirst() throws SQLException { throw new AssertionFailedError("MockResultSet beforeFirst not implemented"); } public void afterLast() throws SQLException { throw new AssertionFailedError("MockResultSet afterLast not implemented"); } public boolean first() throws SQLException { throw new AssertionFailedError("MockResultSet first not implemented"); } public boolean last() throws SQLException { throw new AssertionFailedError("MockResultSet last not implemented"); } public boolean absolute(int row) throws SQLException { throw new AssertionFailedError("MockResultSet absolute not implemented"); } public boolean relative(int rows) throws SQLException { throw new AssertionFailedError("MockResultSet relative not implemented"); } public boolean previous() throws SQLException { throw new AssertionFailedError("MockResultSet previous not implemented"); } public void setFetchDirection(int direction) throws SQLException { throw new AssertionFailedError("MockResultSet setFetchDirection not implemented"); } public void setFetchSize(int rows) throws SQLException { throw new AssertionFailedError("MockResultSet setFetchSize not implemented"); } public boolean rowUpdated() throws SQLException { throw new AssertionFailedError("MockResultSet rowUpdated not implemented"); } public boolean rowInserted() throws SQLException { throw new AssertionFailedError("MockResultSet rowInserted not implemented"); } public boolean rowDeleted() throws SQLException { throw new AssertionFailedError("MockResultSet rowDeleted not implemented"); } public void updateNull(int columnIndex) throws SQLException { throw new AssertionFailedError("MockResultSet updateNull not implemented"); } public void updateBoolean(int columnIndex, boolean x) throws SQLException { throw new AssertionFailedError("MockResultSet updateBoolean not implemented"); } public void updateByte(int columnIndex, byte x) throws SQLException { throw new AssertionFailedError("MockResultSet updateByte not implemented"); } public void updateShort(int columnIndex, short x) throws SQLException { throw new AssertionFailedError("MockResultSet updateShort not implemented"); } public void updateInt(int columnIndex, int x) throws SQLException { throw new AssertionFailedError("MockResultSet updateInt not implemented"); } public void updateLong(int columnIndex, long x) throws SQLException { throw new AssertionFailedError("MockResultSet updateLong not implemented"); } public void updateFloat(int columnIndex, float x) throws SQLException { throw new AssertionFailedError("MockResultSet updateFloat not implemented"); } public void updateDouble(int columnIndex, double x) throws SQLException { throw new AssertionFailedError("MockResultSet updateDouble not implemented"); } public void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException { throw new AssertionFailedError("MockResultSet updateBigDecimal not implemented"); } public void updateString(int columnIndex, String x) throws SQLException { throw new AssertionFailedError("MockResultSet updateString not implemented"); } public void updateBytes(int columnIndex, byte x[]) throws SQLException { throw new AssertionFailedError("MockResultSet updateBytes not implemented"); } public void updateDate(int columnIndex, Date x) throws SQLException { throw new AssertionFailedError("MockResultSet updateDate not implemented"); } public void updateTime(int columnIndex, Time x) throws SQLException { throw new AssertionFailedError("MockResultSet updateTime not implemented"); } public void updateTimestamp(int columnIndex, Timestamp x) throws SQLException { throw new AssertionFailedError("MockResultSet updateTimestamp not implemented"); } public void updateAsciiStream(int columnIndex, InputStream x, int length) throws SQLException { throw new AssertionFailedError("MockResultSet updateAsciiStream not implemented"); } public void updateBinaryStream(int columnIndex, InputStream x, int length) throws SQLException { throw new AssertionFailedError("MockResultSet updateBinaryStream not implemented"); } public void updateCharacterStream(int columnIndex, Reader x, int length) throws SQLException { throw new AssertionFailedError("MockResultSet updateCharacterStream not implemented"); } public void updateObject(int columnIndex, Object x, int scale) throws SQLException { throw new AssertionFailedError("MockResultSet updateObject not implemented"); } public void updateObject(int columnIndex, Object x) throws SQLException { throw new AssertionFailedError("MockResultSet updateObject not implemented"); } public void updateNull(String columnName) throws SQLException { throw new AssertionFailedError("MockResultSet updateNull not implemented"); } public void updateBoolean(String columnName, boolean x) throws SQLException { throw new AssertionFailedError("MockResultSet updateBoolean not implemented"); } public void updateByte(String columnName, byte x) throws SQLException { throw new AssertionFailedError("MockResultSet updateByte not implemented"); } public void updateShort(String columnName, short x) throws SQLException { throw new AssertionFailedError("MockResultSet updateShort not implemented"); } public void updateInt(String columnName, int x) throws SQLException { throw new AssertionFailedError("MockResultSet updateInt not implemented"); } public void updateLong(String columnName, long x) throws SQLException { throw new AssertionFailedError("MockResultSet updateLong not implemented"); } public void updateFloat(String columnName, float x) throws SQLException { throw new AssertionFailedError("MockResultSet updateFloat not implemented"); } public void updateDouble(String columnName, double x) throws SQLException { throw new AssertionFailedError("MockResultSet updateDouble not implemented"); } public void updateBigDecimal(String columnName, BigDecimal x) throws SQLException { throw new AssertionFailedError("MockResultSet updateBigDecimal not implemented"); } public void updateString(String columnName, String x) throws SQLException { throw new AssertionFailedError("MockResultSet updateString not implemented"); } public void updateBytes(String columnName, byte x[]) throws SQLException { throw new AssertionFailedError("MockResultSet updateBytes not implemented"); } public void updateDate(String columnName, Date x) throws SQLException { throw new AssertionFailedError("MockResultSet updateDate not implemented"); } public void updateTime(String columnName, Time x) throws SQLException { throw new AssertionFailedError("MockResultSet updateTime not implemented"); } public void updateTimestamp(String columnName, Timestamp x) throws SQLException { throw new AssertionFailedError("MockResultSet updateTimestamp not implemented"); } public void updateAsciiStream(String columnName, InputStream x, int length) throws SQLException { throw new AssertionFailedError("MockResultSet updateAsciiStream not implemented"); } public void updateBinaryStream(String columnName, InputStream x, int length) throws SQLException { throw new AssertionFailedError("MockResultSet updateBinaryStream not implemented"); } public void updateCharacterStream(String columnName, Reader reader, int length) throws SQLException { throw new AssertionFailedError("MockResultSet updateCharacterStream not implemented"); } public void updateObject(String columnName, Object x, int scale) throws SQLException { throw new AssertionFailedError("MockResultSet updateObject not implemented"); } public void updateObject(String columnName, Object x) throws SQLException { throw new AssertionFailedError("MockResultSet updateObject not implemented"); } public void insertRow() throws SQLException { throw new AssertionFailedError("MockResultSet insertRow not implemented"); } public void updateRow() throws SQLException { throw new AssertionFailedError("MockResultSet updateRow not implemented"); } public void deleteRow() throws SQLException { throw new AssertionFailedError("MockResultSet deleteRow not implemented"); } public void refreshRow() throws SQLException { throw new AssertionFailedError("MockResultSet refreshRow not implemented"); } public void cancelRowUpdates() throws SQLException { throw new AssertionFailedError("MockResultSet cancelRowUpdates not implemented"); } public void moveToInsertRow() throws SQLException { throw new AssertionFailedError("MockResultSet moveToInsertRow not implemented"); } public void moveToCurrentRow() throws SQLException { throw new AssertionFailedError("MockResultSet moveToCurrentRow not implemented"); } public boolean wasNull() throws SQLException { throw new AssertionFailedError("MockResultSet wasNull not implemented"); } } --- NEW FILE: MockSingleRowResultSet.java --- package com.mockobjects.sql; import java.sql.SQLException; import java.util.*; /** * This is a simple implementation of a MockResultSet. * It verifies that the values fed to it have been retrieved. * These can be found by either column index or column name. * For basic java types (e.g. int, boolean), insert an instance of * the appropriate object (e.g. Integer, Boolean) * To force throwing a SQLException on a getter, set the corresponding value to be of type SQLException. */ public class MockSingleRowResultSet extends MockResultSet { private ExpectationSqlRow myRow = new ExpectationSqlRow("single row"); private int myNextCallCount = 0; public MockSingleRowResultSet() { super(); } public MockSingleRowResultSet(Object[] values) { this(); addExpectedIndexedValues(values); } public MockSingleRowResultSet(String[] names, Object[] values) { this(); addExpectedNamedValues(names, values); } public MockSingleRowResultSet(Map map) { this(); addExpectedNamedValues(map); } public void addExpectedIndexedValues(Object[] values) { myRow.addExpectedIndexedValues(values); } public void addExpectedNamedValues(String[] names, Object[] values) { myRow.addExpectedNamedValues(names, values); } public void addExpectedNamedValues(Map map) { myRow.addExpectedNamedValues(map); } public boolean next() throws SQLException { myNextCalls.inc(); myNextCallCount++; return myNextCallCount == 1; } public int getRow() throws SQLException { return myNextCallCount; } public Object getObject(int columnIndex) throws SQLException { return myRow.get(columnIndex); } public Object getObject(String columnName) throws SQLException { return myRow.get(columnName); } } --- NEW FILE: MockStatement.java --- package com.mockobjects.sql; import java.sql.*; import junit.framework.*; import com.mockobjects.*; public class MockStatement extends MockObject implements Statement { protected ExpectationCounter myCloseCalls = new ExpectationCounter("MockStatement.closeCalls"); protected ExpectationCounter myExecuteCalls = new ExpectationCounter("MockStatement.executeCalls"); protected ExpectationValue myQueryString = new ExpectationValue("MockStatement.queryString"); protected MockResultSet myResultSet; private int myUpdateCount = 0; private SQLException myExecuteException = null; public MockStatement() { super(); } public void setExpectedExecuteCalls(int callCount) { myExecuteCalls.setExpected(callCount); } public void setExpectedQueryString(String queryString) { myQueryString.setExpected(queryString); } public void setExpectedCloseCalls(int callCount) { myCloseCalls.setExpected(callCount); } public void setupResultSet(MockResultSet aResultSet) { myResultSet = aResultSet; } public void setupThrowExceptionOnExecute(SQLException exception) { myExecuteException = exception; } public void setupUpdateCount(int updateCount) { myUpdateCount = updateCount; } protected void innerExecute() throws SQLException { myExecuteCalls.inc(); if (null != myExecuteException) { throw myExecuteException; } } public void close() throws SQLException { myCloseCalls.inc(); } public boolean execute(String sql) throws SQLException { throw new UnsupportedOperationException(); } public ResultSet executeQuery(String sql) throws SQLException { myQueryString.setActual(sql); innerExecute(); return myResultSet; } public int executeUpdate(String sql) throws SQLException { myQueryString.setActual(sql); innerExecute(); return myUpdateCount; } public int getMaxFieldSize() throws SQLException { throw new UnsupportedOperationException(); } public void setMaxFieldSize(int max) throws SQLException { throw new UnsupportedOperationException(); } public int getMaxRows() throws SQLException { throw new UnsupportedOperationException(); } public void setMaxRows(int max) throws SQLException { throw new UnsupportedOperationException(); } public void setEscapeProcessing(boolean enable) throws SQLException { throw new UnsupportedOperationException(); } public int getQueryTimeout() throws SQLException { throw new UnsupportedOperationException(); } public void setQueryTimeout(int seconds) throws SQLException { throw new UnsupportedOperationException(); } public void cancel() throws SQLException { throw new UnsupportedOperationException(); } public SQLWarning getWarnings() throws SQLException { throw new UnsupportedOperationException(); } public void clearWarnings() throws SQLException { throw new UnsupportedOperationException(); } public void setCursorName(String name) throws SQLException { throw new UnsupportedOperationException(); } public ResultSet getResultSet() throws SQLException { throw new UnsupportedOperationException(); } public int getUpdateCount() throws SQLException { return myUpdateCount; } public boolean getMoreResults() throws SQLException { throw new UnsupportedOperationException(); } public void setFetchDirection(int direction) throws SQLException { throw new UnsupportedOperationException(); } public int getFetchDirection() throws SQLException { throw new UnsupportedOperationException(); } public void setFetchSize(int rows) throws SQLException { throw new UnsupportedOperationException(); } public int getFetchSize() throws SQLException { throw new UnsupportedOperationException(); } public int getResultSetConcurrency() throws SQLException { throw new UnsupportedOperationException(); } public int getResultSetType() throws SQLException { throw new UnsupportedOperationException(); } public void addBatch(String sql) throws SQLException { throw new UnsupportedOperationException(); } public void clearBatch() throws SQLException { throw new UnsupportedOperationException(); } public int[] executeBatch() throws SQLException { throw new UnsupportedOperationException(); } public Connection getConnection() throws SQLException { throw new UnsupportedOperationException(); } } |
From: Jeff M. <cus...@us...> - 2002-04-13 15:08:26
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/sql In directory usw-pr-cvs1:/tmp/cvs-serv12990/src/core/com/mockobjects/sql Removed Files: ExpectationSqlRow.java MockConnection.java MockDriver.java MockMultiRowResultSet.java MockPreparedStatement.java MockResultSet.java MockSingleRowResultSet.java MockStatement.java Log Message: Move none core mocks out of the core area --- ExpectationSqlRow.java DELETED --- --- MockConnection.java DELETED --- --- MockDriver.java DELETED --- --- MockMultiRowResultSet.java DELETED --- --- MockPreparedStatement.java DELETED --- --- MockResultSet.java DELETED --- --- MockSingleRowResultSet.java DELETED --- --- MockStatement.java DELETED --- |
From: Jeff M. <cus...@us...> - 2002-04-13 15:08:26
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/io In directory usw-pr-cvs1:/tmp/cvs-serv12990/src/core/com/mockobjects/io Removed Files: MockOutputStream.java MockPrintStream.java MockPrintWriter.java Log Message: Move none core mocks out of the core area --- MockOutputStream.java DELETED --- --- MockPrintStream.java DELETED --- --- MockPrintWriter.java DELETED --- |
From: Jeff M. <cus...@us...> - 2002-04-13 15:08:25
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/beans In directory usw-pr-cvs1:/tmp/cvs-serv12990/src/core/com/mockobjects/beans Removed Files: MockPropertyChangeListener.java Log Message: Move none core mocks out of the core area --- MockPropertyChangeListener.java DELETED --- |
From: Jeff M. <cus...@us...> - 2002-04-13 15:08:25
|
Update of /cvsroot/mockobjects/mockobjects-java In directory usw-pr-cvs1:/tmp/cvs-serv12990 Modified Files: build.xml Log Message: Move none core mocks out of the core area Index: build.xml =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/build.xml,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- build.xml 23 Feb 2002 19:20:49 -0000 1.19 +++ build.xml 13 Apr 2002 15:08:23 -0000 1.20 @@ -1,5 +1,4 @@ <?xml version="1.0"?> - <!-- ============================================================================= Build file for the mockobjects project. @@ -38,496 +37,596 @@ ============================================================================= --> <project name="mockobjects" default="jar" basedir="."> - - <!-- Give user a chance to override without editing this file [...1093 lines suppressed...] - <!-- Be careful, it's going to reformat all code ! --> - <include name="**/*.java"/> - </fileset> - </pretty> - - </target> - + <target name="format" depends="call-me-first" + description="reformats all java code"> + <taskdef name="pretty" classname="org.acm.seguin.ant.Pretty" /> + + <pretty settingsdir="${conf.dir}"> + <fileset dir="${src.dir}"> +<!-- Be careful, it's going to reformat all code ! --> + <include name="**/*.java" /> + </fileset> + </pretty> + </target> </project> + |
From: Jeff M. <cus...@us...> - 2002-04-13 15:04:26
|
Update of /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com/mockobjects/sql In directory usw-pr-cvs1:/tmp/cvs-serv12182/jdk/common/com/mockobjects/sql Log Message: Directory /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com/mockobjects/sql added to the repository |
From: Jeff M. <cus...@us...> - 2002-04-13 15:04:26
|
Update of /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com/mockobjects/naming In directory usw-pr-cvs1:/tmp/cvs-serv12182/jdk/common/com/mockobjects/naming Log Message: Directory /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com/mockobjects/naming added to the repository |
From: Jeff M. <cus...@us...> - 2002-04-13 15:04:26
|
Update of /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com/mockobjects/io In directory usw-pr-cvs1:/tmp/cvs-serv12182/jdk/common/com/mockobjects/io Log Message: Directory /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com/mockobjects/io added to the repository |
From: Jeff M. <cus...@us...> - 2002-04-13 15:04:26
|
Update of /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com/mockobjects/beans In directory usw-pr-cvs1:/tmp/cvs-serv12182/jdk/common/com/mockobjects/beans Log Message: Directory /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com/mockobjects/beans added to the repository |
From: Jeff M. <cus...@us...> - 2002-04-13 15:03:52
|
Update of /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com/mockobjects In directory usw-pr-cvs1:/tmp/cvs-serv12010/jdk/common/com/mockobjects Log Message: Directory /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com/mockobjects added to the repository |
From: Jeff M. <cus...@us...> - 2002-04-13 15:03:11
|
Update of /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com In directory usw-pr-cvs1:/tmp/cvs-serv11836/jdk/common/com Log Message: Directory /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com added to the repository |
From: Jeff M. <cus...@us...> - 2002-04-13 15:02:47
|
Update of /cvsroot/mockobjects/mockobjects-java/src/jdk/1.3 In directory usw-pr-cvs1:/tmp/cvs-serv11705/jdk/1.3 Log Message: Directory /cvsroot/mockobjects/mockobjects-java/src/jdk/1.3 added to the repository |
From: Jeff M. <cus...@us...> - 2002-04-13 15:02:47
|
Update of /cvsroot/mockobjects/mockobjects-java/src/jdk/common In directory usw-pr-cvs1:/tmp/cvs-serv11705/jdk/common Log Message: Directory /cvsroot/mockobjects/mockobjects-java/src/jdk/common added to the repository |
From: Jeff M. <cus...@us...> - 2002-04-13 15:02:09
|
Update of /cvsroot/mockobjects/mockobjects-java/src/jdk In directory usw-pr-cvs1:/tmp/cvs-serv11502/jdk Log Message: Directory /cvsroot/mockobjects/mockobjects-java/src/jdk added to the repository |
From: Scott L. <sl...@sl...> - 2002-04-12 20:32:19
|
I was trying to make some changes to the SQL stuff and noticed problems with the build system. Specifically, clicking on a java compilation error would bring my editor to out/src/blah.java, a copy of the code that is made immediately before compiling. This is a pain because I would make changes that would be overwritten. Also, the entire system seems to be rebuilt after any change, because the modification dates are not preserved in this copy. (Looks like Jeff Martin noted this on the list about a month ago.) Apparently this was done to allow filtering @version@, @year@, and @today@ for the Javadocs. None of these tokens are used now in the source code. (Though they are used in the manifest.) So, the attached patch compiles the source in-place instead of copying first. I think I've got the correct files compiled in all cases by building a path to be compiled and adding the appropriate j2ee stuff as necessary. Please try it and apply it. I also tried to simplify things a bit. I removed some targets that just define properties. These were pretty confusing to me. I left the check-availabilities one, because <available/> only works inside a target. I think many of the properties being set could be removed to simplify things further - setting properties doesn't make sense to me unless something is long/complicated or you'd want to override it. Stuff like this strikes me as extraneous: <property name="src.dir" value="src"/> <property name="src.core.dir" value="${src.dir}/core"/> <property name="src.j2ee.dir" value="${src.dir}/j2ee"/> <property name="src.examples.dir" value="${src.dir}/examples"/> When would you ever want src.core.dir to be anything other than "${src.dir}/core"? I think just saying the latter is more clear. Thanks. -- Scott Lamb |
From: <rin...@me...> - 2002-04-11 13:42:27
|
Hello Jeff, > If you put tests in another directory not just the same package your > removing them from direct sight. You can arrange and ide to > make it look > like it's in the same directory, but you don't have to, so there's a > good chance people won't. There's also people like me who don't use an > ide. I don't want to give people an option of looking at tests, I want > to force them to do it. For an IDE, I suggest Eclipse! :-) Concerning the unit tests: I think most people will not have direct commit access into the CVS repo. If someone wants to contribute, you are free to reject a submission/patch that is not accompanied by the required unit test= code! Ringo |
From: <Vin...@ge...> - 2002-04-11 13:32:52
|
Jeff, > -----Original Message----- > From: moc...@li... > [mailto:moc...@li...]On Behalf Of > Jeff Martin > Sent: Thursday, April 11, 2002 5:09 AM > To: MockObjects > Subject: Re: [Fwd: RE: [MO-java-dev] Location of test source] > > > Why would I want to compile tests selectively. The only things I might > want to do in sections is core then jdk and then j2ee. Let me rephrase. You can build selectively quite easily. You compile src/java to a build dir and generate the mock jar from the build dir. Excluding tests in the jar is just the question of not compiling src/test to the same build dir. It's just convenient, I'm not saying it's the only way to do it though. > > The way the build should work is, you never attempt to > compile the code, > you attempt to run the tests. This means compilation is a prerequisite > of testing not and end in itself. > > If you put tests in another directory not just the same package your > removing them from direct sight. You can arrange and ide to > make it look > like it's in the same directory, but you don't have to, so there's a > good chance people won't. I agree it does require extra care. > There's also people like me who don't use an > ide. Try IntelliJ ;-) > I don't want to give people an option of looking at tests, I want > to force them to do it. I see your point and that's an issue with the solution proposed. In that case go for the tests in the same directory, which I think is better than having them in a test dir. -- Vincent > > > On Thu, 2002-04-11 at 01:08, Vincent Tence wrote: > > Guess I have to learn to use Reply to All correctly :-) > > ---- > > > > > From: Vincent Tence <vt...@sy...> > > To: rin...@me... > > Subject: RE: [MO-java-dev] Location of test source > > Date: 10 Apr 2002 08:20:49 -0400 > > > > I second that. That way tests lie in the same packages as > sources and > > ant can easily compiles the source selectively. > > > > Vincent > > > > > > On Wed, 2002-04-10 at 06:55, rin...@me... wrote: > > > Hello Jeff, > > > > > > > I'm currently seperating out the jdk classes from the > core mockobject > > > > classes hopefully we'll end up with something like this. > > > > > > > > src/core/ > > > > src/jdk/common/ > > > > /1.1/ > > > > /1.2/ > > > > /1.3/ > > > > /1.4/ > > > > src/j2ee/common > > > > /1.2/ > > > > /1.3/ > > > > > > > > > > What about appending each of this folders with java and > test, like they do > > > in a number of Apache projects? e.g: > > > > > > src/core/java > > > src/core/test > > > src/jdk/common/java > > > src/jdk/common/test > > > ... > > > > > > In Apache style, configuration files are placed in a > third subdirectory > > > named conf, e.g. > > > > > > src/core/conf > > > src/jdk/common/conf > > > ... > > > > > > Within each of these subdirectories you can take the same > package structure. > > > Then you don't have to filter on the source files to > distinguish between > > > production and test code. > > > > > > Ringg > > > > > > _______________________________________________ > > > Mockobjects-java-dev mailing list > > > Moc...@li... > > > https://lists.sourceforge.net/lists/listinfo/mockobjects-java-dev > > > -- > > > _______________________________________________ > Mockobjects-java-dev mailing list > Moc...@li... > https://lists.sourceforge.net/lists/listinfo/mockobjects-java-dev > |
From: <Vin...@ge...> - 2002-04-11 13:17:43
|
Sorry Jeff this was supposed to go to the list. Doh that makes twice in one day! > -----Original Message----- > From: Vincent Tencé [mailto:vin...@ge...] > Sent: Wednesday, April 10, 2002 1:34 PM > To: 'Jeff Martin' > Subject: RE: [MO-java-dev] Location of test source > > > I think it's a small price to pay compared to the benefits of > the structure described by Ringo. I usually go > src/java > src/test > src/mockobjects > and it's pretty convenient. > > Vincent > > > -----Original Message----- > > From: moc...@li... > > [mailto:moc...@li...]On > Behalf Of > > Jeff Martin > > Sent: Wednesday, April 10, 2002 10:54 AM > > To: MockObjects > > Subject: RE: [MO-java-dev] Location of test source > > > > > > I much prefer to keep tests in the same place as the java > files. As an > > example, I've never really looked at the mock objects test > package. I > > probably should but unless I know that there is a test I need > > to update > > I'm not going to look in there just to see if the change I > make should > > be tested. If the test in the the same package as the class > it's much > > harder for me to miss the test. > > > > On Wed, 2002-04-10 at 11:55, rin...@me... wrote: > > > Hello Jeff, > > > > > > > I'm currently seperating out the jdk classes from the > > core mockobject > > > > classes hopefully we'll end up with something like this. > > > > > > > > src/core/ > > > > src/jdk/common/ > > > > /1.1/ > > > > /1.2/ > > > > /1.3/ > > > > /1.4/ > > > > src/j2ee/common > > > > /1.2/ > > > > /1.3/ > > > > > > > > > > What about appending each of this folders with java and > > test, like they do > > > in a number of Apache projects? e.g: > > > > > > src/core/java > > > src/core/test > > > src/jdk/common/java > > > src/jdk/common/test > > > ... > > > > > > In Apache style, configuration files are placed in a third > > subdirectory > > > named conf, e.g. > > > > > > src/core/conf > > > src/jdk/common/conf > > > ... > > > > > > Within each of these subdirectories you can take the same > > package structure. > > > Then you don't have to filter on the source files to > > distinguish between > > > production and test code. > > > > > > Ringg > > > > > > _______________________________________________ > > > Mockobjects-java-dev mailing list > > > Moc...@li... > > > https://lists.sourceforge.net/lists/listinfo/mockobjects-java-dev > > -- > > > > > > _______________________________________________ > > Mockobjects-java-dev mailing list > > Moc...@li... > > https://lists.sourceforge.net/lists/listinfo/mockobjects-java-dev > > > |
From: Jeff M. <je...@mk...> - 2002-04-11 09:12:48
|
Why would I want to compile tests selectively. The only things I might want to do in sections is core then jdk and then j2ee. The way the build should work is, you never attempt to compile the code, you attempt to run the tests. This means compilation is a prerequisite of testing not and end in itself. If you put tests in another directory not just the same package your removing them from direct sight. You can arrange and ide to make it look like it's in the same directory, but you don't have to, so there's a good chance people won't. There's also people like me who don't use an ide. I don't want to give people an option of looking at tests, I want to force them to do it. On Thu, 2002-04-11 at 01:08, Vincent Tence wrote: > Guess I have to learn to use Reply to All correctly :-) > ---- > > From: Vincent Tence <vt...@sy...> > To: rin...@me... > Subject: RE: [MO-java-dev] Location of test source > Date: 10 Apr 2002 08:20:49 -0400 > > I second that. That way tests lie in the same packages as sources and > ant can easily compiles the source selectively. > > Vincent > > > On Wed, 2002-04-10 at 06:55, rin...@me... wrote: > > Hello Jeff, > > > > > I'm currently seperating out the jdk classes from the core mockobject > > > classes hopefully we'll end up with something like this. > > > > > > src/core/ > > > src/jdk/common/ > > > /1.1/ > > > /1.2/ > > > /1.3/ > > > /1.4/ > > > src/j2ee/common > > > /1.2/ > > > /1.3/ > > > > > > > What about appending each of this folders with java and test, like they do > > in a number of Apache projects? e.g: > > > > src/core/java > > src/core/test > > src/jdk/common/java > > src/jdk/common/test > > ... > > > > In Apache style, configuration files are placed in a third subdirectory > > named conf, e.g. > > > > src/core/conf > > src/jdk/common/conf > > ... > > > > Within each of these subdirectories you can take the same package structure. > > Then you don't have to filter on the source files to distinguish between > > production and test code. > > > > Ringg > > > > _______________________________________________ > > Mockobjects-java-dev mailing list > > Moc...@li... > > https://lists.sourceforge.net/lists/listinfo/mockobjects-java-dev > -- |
From: Vincent T. <vt...@sy...> - 2002-04-11 00:09:37
|
Guess I have to learn to use Reply to All correctly :-) |