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-12-08 12:59:24
|
---------------------------------------------------- This email is autogenerated from the output from: <http://cvs.apache.org/builds/gump/2002-12-08/mockobjects.html> ---------------------------------------------------- Buildfile: build.xml project-properties: deliverable-names: useful-file-patterns: source-locations: check-availabilities: [available] DEPRECATED - <available> used to override an existing property. [available] Build file should not reuse the same property name for different values. [available] DEPRECATED - <available> used to override an existing property. [available] Build file should not reuse the same property name for different values. call-me-first: [echo] --------- Mock Objects 20021208 --------- [echo] java.class.path = /home/rubys/jakarta/xml-xerces2/java/build/xmlParserAPIs.jar:/home/rubys/jakarta/xml-xerces2/java/build/xercesImpl.jar:.:/usr/java/j2sdk1.4.1_01/lib/tools.jar:/usr/java/j2sdk1.4.1_01/jre/lib/rt.jar:/usr/java/j2sdk1.4.1_01/lib/tools.jar:/home/rubys/jakarta/jakarta-ant/dist/lib/ant.jar:/home/rubys/jakarta/jakarta-ant/dist/lib/nodeps.jar:/home/rubys/jakarta/jakarta-ant/dist/lib/ant-junit.jar:/home/rubys/jakarta/jakarta-ant/dist/lib/ant-stylebook.jar:/home/rubys/jakarta/jakarta-ant/dist/lib/ant-swing.jar:/home/rubys/jakarta/jakarta-ant/dist/lib/ant-trax.jar:/home/rubys/jakarta/jakarta-ant/dist/lib/ant-xalan2.jar:/home/rubys/jakarta/dist/junit/junit.jar:/home/rubys/jakarta/mockobjects/out/core/classes:/home/rubys/jakarta/mockobjects/out/jdk/classes [echo] java.home = /usr/java/j2sdk1.4.1_01/jre [echo] user.home = /home/rubys [echo] ant.home = ${ant.home} compile-core: [javac] Compiling 67 source files to /home/rubys/jakarta/mockobjects/out/core/classes compile-jdk: [javac] Compiling 42 source files to /home/rubys/jakarta/mockobjects/out/jdk/classes [javac] /home/rubys/jakarta/mockobjects/src/jdk/common/com/mockobjects/sql/CommonMockMultiRowResultSet.java:30: cannot resolve symbol [javac] symbol : constructor MockResultSet (java.lang.String) [javac] location: class com.mockobjects.sql.MockResultSet [javac] super(name); [javac] ^ [javac] Note: Some input files use or override a deprecated API. [javac] Note: Recompile with -deprecation for details. [javac] 1 error BUILD FAILED file:///home/rubys/jakarta/mockobjects/build.xml:143: Compile failed; see the compiler error output for details. Total time: 6 seconds |
From: Jeff M. <je...@cu...> - 2002-12-07 12:55:16
|
---------------------------------------------------- This email is autogenerated from the output from: <http://cvs.apache.org/builds/gump/2002-12-07/mockobjects.html> ---------------------------------------------------- Buildfile: build.xml project-properties: deliverable-names: useful-file-patterns: source-locations: check-availabilities: [available] DEPRECATED - <available> used to override an existing property. [available] Build file should not reuse the same property name for different values. [available] DEPRECATED - <available> used to override an existing property. [available] Build file should not reuse the same property name for different values. call-me-first: [echo] --------- Mock Objects 20021207 --------- [echo] java.class.path = /home/rubys/jakarta/xml-xerces2/java/build/xmlParserAPIs.jar:/home/rubys/jakarta/xml-xerces2/java/build/xercesImpl.jar:.:/usr/java/j2sdk1.4.1_01/lib/tools.jar:/usr/java/j2sdk1.4.1_01/jre/lib/rt.jar:/usr/java/j2sdk1.4.1_01/lib/tools.jar:/home/rubys/jakarta/jakarta-ant/dist/lib/ant.jar:/home/rubys/jakarta/jakarta-ant/dist/lib/nodeps.jar:/home/rubys/jakarta/jakarta-ant/dist/lib/ant-junit.jar:/home/rubys/jakarta/jakarta-ant/dist/lib/ant-stylebook.jar:/home/rubys/jakarta/jakarta-ant/dist/lib/ant-swing.jar:/home/rubys/jakarta/jakarta-ant/dist/lib/ant-trax.jar:/home/rubys/jakarta/jakarta-ant/dist/lib/ant-xalan2.jar:/home/rubys/jakarta/dist/junit/junit.jar:/home/rubys/jakarta/mockobjects/out/core/classes:/home/rubys/jakarta/mockobjects/out/jdk/classes [echo] java.home = /usr/java/j2sdk1.4.1_01/jre [echo] user.home = /home/rubys [echo] ant.home = ${ant.home} compile-core: [javac] Compiling 67 source files to /home/rubys/jakarta/mockobjects/out/core/classes compile-jdk: [javac] Compiling 42 source files to /home/rubys/jakarta/mockobjects/out/jdk/classes [javac] /home/rubys/jakarta/mockobjects/src/jdk/common/com/mockobjects/sql/CommonMockMultiRowResultSet.java:30: cannot resolve symbol [javac] symbol : constructor MockResultSet (java.lang.String) [javac] location: class com.mockobjects.sql.MockResultSet [javac] super(name); [javac] ^ [javac] Note: Some input files use or override a deprecated API. [javac] Note: Recompile with -deprecation for details. [javac] 1 error BUILD FAILED file:///home/rubys/jakarta/mockobjects/build.xml:143: Compile failed; see the compiler error output for details. Total time: 5 seconds |
From: Jeff M. <je...@cu...> - 2002-12-04 12:54:00
|
Just added a new class (ant test) called ReturnObjectBag. This builds on the ReturnObjectList by mapping ReturnObjectList to key values. This allows you to fill a map style object (set/getAttribute) with the lists of the values you want returned for each key. So you can have the strictness of the ReturnObjectList (You have to use all the objects within it, in the predefined order) with the unordereness of a map. I've started to use this within a MockConnection code where you can now specify the PreparedStatement to return for a piece of sql, whilst make sure your not making unnecessary calls to prepareStatement. Since this changes the behavior of MockConnection I've created a new version called MockConnection2 and deprecated MockConnection eventually we should be able to move MockConnection2 back to MockConnection once people have got used to the idea. I'll also gradually look at some of the other Mocks which have been bugging me like the servlet mocks which use attributes all over the shop. Give me a shout if I've botched anything ;o) p.s. Is ReturnObjectBag the right name for something like this? -- Jeff Martin Memetic Engineer http://www.custommonkey.org/ |
From: Jeff M. <cus...@us...> - 2002-12-04 12:39:27
|
Update of /cvsroot/mockobjects/mockobjects-java/src/jdk/1.3/com/mockobjects/sql In directory sc8-pr-cvs1:/tmp/cvs-serv26378/src/jdk/1.3/com/mockobjects/sql Modified Files: MockMultiRowResultSet.java MockConnection.java Added Files: MockConnection2.java Log Message: Added a new implementation of MockConnection called MockConnection2 which starts to make use of ReturnObjectBag Added new constructor to MockMultiRowResultSet to provide better naming of mocks when raising errors --- NEW FILE: MockConnection2.java --- package com.mockobjects.sql; /** * MockConnection2 is a tempary replacement for the MockConnection. * It differs from the MockConnection in the way in which preparedstatements * are handled. The changes are significant enough to break compatiblity with * exsising testcases so MockConnection2 provides a migration path to the new * system of handling preparedstatements. * This calls will eventually be merged back into MockConnection when it is felt * systems using the classes have been provided with enough time to migrate. */ public class MockConnection2 extends CommonMockConnection2{ public MockConnection2() { } public MockConnection2(String name) { super(name); } } Index: MockMultiRowResultSet.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/jdk/1.3/com/mockobjects/sql/MockMultiRowResultSet.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- MockMultiRowResultSet.java 28 Jun 2002 17:35:39 -0000 1.1 +++ MockMultiRowResultSet.java 4 Dec 2002 12:39:24 -0000 1.2 @@ -1,4 +1,10 @@ package com.mockobjects.sql; public class MockMultiRowResultSet extends CommonMockMultiRowResultSet{ + public MockMultiRowResultSet() { + } + + public MockMultiRowResultSet(String name) { + super(name); + } } Index: MockConnection.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/jdk/1.3/com/mockobjects/sql/MockConnection.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- MockConnection.java 28 Jun 2002 17:35:39 -0000 1.1 +++ MockConnection.java 4 Dec 2002 12:39:24 -0000 1.2 @@ -1,4 +1,8 @@ package com.mockobjects.sql; +/** + * @deprecated Use temporary class MockConnection2 + * @see MockConnection2 + */ public class MockConnection extends CommonMockConnection{ } |
From: Jeff M. <cus...@us...> - 2002-12-04 12:39:26
|
Update of /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com/mockobjects/sql In directory sc8-pr-cvs1:/tmp/cvs-serv26378/src/jdk/common/com/mockobjects/sql Modified Files: CommonMockConnection.java CommonMockMultiRowResultSet.java Added Files: CommonMockConnection2.java Log Message: Added a new implementation of MockConnection called MockConnection2 which starts to make use of ReturnObjectBag Added new constructor to MockMultiRowResultSet to provide better naming of mocks when raising errors --- NEW FILE: CommonMockConnection2.java --- /* * * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact ap...@ap.... * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * */ // ------------------------------------------------------------------------ 78 /** * Abstract Connection for use with mock testing. * Can verify the expected SQL strings with PreparedStatement or Statement * instances (mock versions can be used). * Can verify the state of closed and autoCommit. * Can verify the number of calls to close, commit, createStatement, and * rollBack. * Exceptions to throw can be registered for calling createStatement, * preparedStatement, or close. * Several less-often-used methods are not implemented. * If a notImplemented method is are needed for your project, please submit * a patch. * @see <a href="http://java.sun.com/j2se/1.3/docs/api/java/sql/Connection.html">javax.sql.Connection</a> * @author * @author Jeff Martin * @author Ted Husted * @version $Revision: 1.1 $ $Date: 2002/12/04 12:39:23 $ */ package com.mockobjects.sql; import com.mockobjects.ReturnObjectBag; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; public abstract class CommonMockConnection2 extends CommonMockConnection implements Connection { private final ReturnObjectBag myPreparedStatements; public CommonMockConnection2() { this(CommonMockConnection2.class.getName()); } public CommonMockConnection2(String name) { super(name); myPreparedStatements = new ReturnObjectBag(name+".preparedStatements"); } /** * Adds a PreparedStatement to be return by prepareStatement */ public void setupAddPreparedStatement(String sql, PreparedStatement prepared) { myPreparedStatements.putObjectToReturn(sql, prepared); } /** * Throws a statement exception if one has been registered * (@see throwStatementExceptionIfAny) * or returns the next PreparedStatement instance passed to * setupAddPreparedStatement. */ public PreparedStatement prepareStatement(String sql) throws SQLException { throwStatementExceptionIfAny(); return (PreparedStatement) myPreparedStatements.getNextReturnObject(sql); } } Index: CommonMockConnection.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com/mockobjects/sql/CommonMockConnection.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- CommonMockConnection.java 10 Nov 2002 10:56:57 -0000 1.4 +++ CommonMockConnection.java 4 Dec 2002 12:39:23 -0000 1.5 @@ -78,18 +78,9 @@ */ package com.mockobjects.sql; -import com.mockobjects.ExpectationCollection; -import com.mockobjects.ExpectationCounter; -import com.mockobjects.ExpectationList; -import com.mockobjects.MockObject; -import com.mockobjects.ReturnObjectList; -import java.sql.CallableStatement; -import java.sql.Connection; -import java.sql.DatabaseMetaData; -import java.sql.PreparedStatement; -import java.sql.Statement; -import java.sql.SQLException; -import java.sql.SQLWarning; +import com.mockobjects.*; + +import java.sql.*; import java.util.Map; public abstract class CommonMockConnection extends MockObject implements Connection { @@ -98,17 +89,10 @@ private boolean autoCommit = false; - private ExpectationList myAutoCommit = - new ExpectationList("CommonMockConnection.setAutoCommit"); - - private ExpectationCounter myCloseCalls = - new ExpectationCounter("CommonMockConnection.close"); - - private ExpectationCounter myCommitCalls = - new ExpectationCounter("CommonMockConnection.commit"); - - private ExpectationCounter myCreateStatementCalls = - new ExpectationCounter("CommonMockConnection.createStatement"); + private final ExpectationList myAutoCommit; + private final ExpectationCounter myCloseCalls; + private final ExpectationCounter myCommitCalls; + private final ExpectationCounter myCreateStatementCalls; private boolean myIsClosed; @@ -118,35 +102,46 @@ private DatabaseMetaData myMetaData; - private ReturnObjectList myPreparedStatements = - new ReturnObjectList("CommonMockConnection.PreparedStatements"); + /** + * @deprecated + * @see CommonMockConnection2 + */ + private final ReturnObjectList myPreparedStatements; - private ExpectationCollection myPreparedStatementStrings = - new ExpectationList("CommonMockConnection.preparedStatementString"); + /** + * @deprecated use myPreparedStatementsBag + * @see CommonMockConnection2 + */ + private final ExpectationCollection myPreparedStatementStrings; - private ExpectationCounter myRollbackCalls = - new ExpectationCounter("CommonMockConnection.rollback"); + private final ExpectationCounter myRollbackCalls; private Statement myStatement; private SQLException myStatementException = null; -// --------------------------------------------------------------- addExpected + public CommonMockConnection() { + this(CommonMockConnection.class.getName()); + } + + public CommonMockConnection(String name) { + myAutoCommit = new ExpectationList(name + ".setAutoCommit"); + myCloseCalls = new ExpectationCounter(name + ".close"); + myCommitCalls = new ExpectationCounter(name + ".commit"); + myCreateStatementCalls = new ExpectationCounter(name + ".createStatement"); + myPreparedStatements = new ReturnObjectList(name + ".PreparedStatements"); + myPreparedStatementStrings = new ExpectationList(name + ".preparedStatementString"); + myRollbackCalls = new ExpectationCounter(name + ".rollback"); + } /** + * @deprecated * Add an SQL string to use with a prepared staement. */ public void addExpectedPreparedStatementString(String sql) { myPreparedStatementStrings.addExpected(sql); } - /** - * Add a PreparedStatement instance for use with tests. - */ - public void addExpectedPreparedStatement(PreparedStatement prepared) { - myPreparedStatements.addObjectToReturn(prepared); - } - // --------------------------------------------------------------- setExpected /** @@ -196,7 +191,9 @@ // --------------------------------------------------------------------- setup /** - * @deprecated Use addExpectedPreparedStatement. + * @deprecated + * Adds a PreparedStatement to be return by prepareStatement + * @see CommonMockConnection2 */ public void setupAddPreparedStatement(PreparedStatement prepared) { myPreparedStatements.addObjectToReturn(prepared); @@ -265,8 +262,8 @@ * Throw the Statement instance passed to * setupThrowExceptionOnPrepareOrCreate, if any. */ - private void throwStatementExceptionIfAny() throws SQLException { - if(null != myStatementException) { + void throwStatementExceptionIfAny() throws SQLException { + if (null != myStatementException) { throw myStatementException; } } @@ -278,7 +275,7 @@ * or otherwise increment the number or close calls. */ public void close() throws SQLException { - if(myCloseException != null) { + if (myCloseException != null) { throw myCloseException; } myCloseCalls.inc(); @@ -316,7 +313,7 @@ * or otherwise return the value passed to setupIsClosed. */ public boolean isClosed() throws SQLException { - if(myIsClosedException != null) { + if (myIsClosedException != null) { throw myIsClosedException; } return myIsClosed; @@ -484,4 +481,51 @@ notImplemented(); } -} // end CommonMockConnection + public void setHoldability(int holdability) throws SQLException { + notImplemented(); + } + + public int getHoldability() throws SQLException { + notImplemented(); + return 0; + } + + public Statement createStatement(int resultSetType, int resultSetConcurrency, + int resultSetHoldability) throws SQLException { + notImplemented(); + return null; + } + + public PreparedStatement prepareStatement(String sql, int resultSetType, + int resultSetConcurrency, int resultSetHoldability) + throws SQLException { + notImplemented(); + return null; + } + + public CallableStatement prepareCall(String sql, int resultSetType, + int resultSetConcurrency, + int resultSetHoldability) throws SQLException { + notImplemented(); + return null; + } + + public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) + throws SQLException { + notImplemented(); + return null; + } + + public PreparedStatement prepareStatement(String sql, int columnIndexes[]) + throws SQLException { + notImplemented(); + return null; + } + + public PreparedStatement prepareStatement(String sql, String columnNames[]) + throws SQLException { + notImplemented(); + return null; + } + +} Index: CommonMockMultiRowResultSet.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com/mockobjects/sql/CommonMockMultiRowResultSet.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- CommonMockMultiRowResultSet.java 28 Jun 2002 17:35:39 -0000 1.1 +++ CommonMockMultiRowResultSet.java 4 Dec 2002 12:39:23 -0000 1.2 @@ -26,6 +26,10 @@ super(); } + public CommonMockMultiRowResultSet(String name) { + super(name); + } + public void setupColumnNames(String[] columnNames) { myColumnNames = columnNames; } |
From: Jeff M. <cus...@us...> - 2002-12-04 12:39:26
|
Update of /cvsroot/mockobjects/mockobjects-java/src/jdk/1.4/com/mockobjects/sql In directory sc8-pr-cvs1:/tmp/cvs-serv26378/src/jdk/1.4/com/mockobjects/sql Modified Files: MockConnection.java Added Files: MockConnection2.java Log Message: Added a new implementation of MockConnection called MockConnection2 which starts to make use of ReturnObjectBag Added new constructor to MockMultiRowResultSet to provide better naming of mocks when raising errors --- NEW FILE: MockConnection2.java --- package com.mockobjects.sql; import java.sql.Savepoint; import java.sql.SQLException; /** * MockConnection2 is a tempary replacement for the MockConnection. * It differs from the MockConnection in the way in which preparedstatements * are handled. The changes are significant enough to break compatiblity with * exsising testcases so MockConnection2 provides a migration path to the new * system of handling preparedstatements. * This calls will eventually be merged back into MockConnection when it is felt * systems using the classes have been provided with enough time to migrate. */ public class MockConnection2 extends CommonMockConnection2{ private final MockConnection connection = new MockConnection(); public MockConnection2() { } public MockConnection2(String name) { super(name); } public void releaseSavepoint(Savepoint savepoint) throws SQLException { connection.releaseSavepoint(savepoint); } public void rollback(Savepoint savepoint) throws SQLException { connection.rollback(savepoint); } public Savepoint setSavepoint() throws SQLException { return connection.setSavepoint(); } public Savepoint setSavepoint(String name) throws SQLException { return connection.setSavepoint(); } } Index: MockConnection.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/jdk/1.4/com/mockobjects/sql/MockConnection.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- MockConnection.java 28 Jun 2002 17:35:39 -0000 1.1 +++ MockConnection.java 4 Dec 2002 12:39:23 -0000 1.2 @@ -2,68 +2,26 @@ import java.sql.*; +/** + * @deprecated Use temporary class MockConnection2 + * @see MockConnection2 + */ public class MockConnection extends CommonMockConnection{ - public void setHoldability(int holdability) throws SQLException { - notImplemented(); - } - - public int getHoldability() throws SQLException { - notImplemented(); - return 0; - } - - public Savepoint setSavepoint() throws SQLException { - notImplemented(); - return null; - } - - public Savepoint setSavepoint(String name) throws SQLException { - notImplemented(); - return null; - } - - public void rollback(Savepoint savepoint) throws SQLException { - notImplemented(); - } public void releaseSavepoint(Savepoint savepoint) throws SQLException { notImplemented(); } - public Statement createStatement(int resultSetType, int resultSetConcurrency, - int resultSetHoldability) throws SQLException { - notImplemented(); - return null; - } - - public PreparedStatement prepareStatement(String sql, int resultSetType, - int resultSetConcurrency, int resultSetHoldability) - throws SQLException { - notImplemented(); - return null; - } - - public CallableStatement prepareCall(String sql, int resultSetType, - int resultSetConcurrency, - int resultSetHoldability) throws SQLException { - notImplemented(); - return null; - } - - public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) - throws SQLException { + public void rollback(Savepoint savepoint) throws SQLException { notImplemented(); - return null; } - public PreparedStatement prepareStatement(String sql, int columnIndexes[]) - throws SQLException { + public Savepoint setSavepoint() throws SQLException { notImplemented(); return null; } - public PreparedStatement prepareStatement(String sql, String columnNames[]) - throws SQLException { + public Savepoint setSavepoint(String name) throws SQLException { notImplemented(); return null; } |
From: Jeff M. <cus...@us...> - 2002-12-04 12:36:41
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects In directory sc8-pr-cvs1:/tmp/cvs-serv24401/src/core/test/mockobjects Added Files: TestReturnObjectBag.java Log Message: Added new Mock Object container to help handle maps --- NEW FILE: TestReturnObjectBag.java --- package test.mockobjects; import com.mockobjects.util.TestCaseMo; import com.mockobjects.ReturnObjectBag; import junit.framework.AssertionFailedError; public class TestReturnObjectBag extends TestCaseMo { private final ReturnObjectBag bag = new ReturnObjectBag(getName()); private static final String KEY1 = "key1"; private static final String KEY2 = "key2"; public TestReturnObjectBag(String name) { super(name); } public static void main(String[] args) { start(new String[] { TestReturnObjectBag.class.getName()}); } public void testLeftoverObjectFails() { bag.putObjectToReturn(KEY1, "one"); assertVerifyFails(bag); } public void testEmptyList() { bag.verify(); } public void testReturnSucceeds() { bag.putObjectToReturn(KEY1, "one"); bag.putObjectToReturn(KEY2, "two"); assertEquals("Should be first result", "one", bag.getNextReturnObject(KEY1)); assertEquals("Should be second result", "two", bag.getNextReturnObject(KEY2)); bag.verify(); } public void testNoListForKey(){ try { bag.getNextReturnObject(KEY1); fail("AssertionFiledError not thrown"); } catch (AssertionFailedError e) { assertEquals(getName() + " does not contain key1", e.getMessage()); } } public void testTooManyReturns() { bag.putObjectToReturn(KEY1, "one"); bag.getNextReturnObject(KEY1); try { bag.getNextReturnObject(KEY1); fail("AssertionFiledError not thrown"); } catch (AssertionFailedError e) { assertEquals(getName() + ".key1 has run out of objects.", e.getMessage()); } } } |
From: Jeff M. <cus...@us...> - 2002-12-04 12:36:41
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects In directory sc8-pr-cvs1:/tmp/cvs-serv24401/src/core/com/mockobjects Added Files: ReturnObjectBag.java Log Message: Added new Mock Object container to help handle maps --- NEW FILE: ReturnObjectBag.java --- package com.mockobjects; import com.mockobjects.ReturnObjectList; import com.mockobjects.Verifiable; import com.mockobjects.util.AssertMo; import java.util.HashMap; import java.util.Iterator; /** * The ReturnObjectBag is a map containing instances of ReturnObjectList. * A single instance is held for each mapkey. Every time a call to putObjectToReturn or * getNextReturnObject is made an object is added or removed from the ReturnObjectList for * the given key. * This allows the ReturnObjectBag to be used to return an ordered list of objects for each key * regardless of the order in which the key requests are made. * @see ReturnObjectList * @author Jeff Martin * @version $Revision: 1.1 $ */ public class ReturnObjectBag implements Verifiable { private final HashMap returnObjectLists = new HashMap(); private final String name; /** * @param name Name used to describe an instance of ReturnObjectBag in error messages */ public ReturnObjectBag(String name) { this.name = name; } /** * Places an object into the list of return objects for a particular key * @param key the key against which the object will be stored * @param value the value to be added to the list for that key * @see ReturnObjectList#addObjectToReturn */ public void putObjectToReturn(Object key, Object value) { ReturnObjectList returnObjectList = (ReturnObjectList)returnObjectLists.get(key); if(returnObjectList==null){ returnObjectList = new ReturnObjectList(name+"."+key.toString()); returnObjectLists.put(key, returnObjectList); } returnObjectList.addObjectToReturn(value); } /** * Checks each the list for each key to verify that all no objects remain * in the list for that key. * @see ReturnObjectList#verify */ public void verify() { for(Iterator it = returnObjectLists.values().iterator();it.hasNext();){ ((ReturnObjectList)it.next()).verify(); } } /** * Returns the next object in the ReturnObjectList for a given key. * The call will throw an AssertFailError if the requested key is * not present within this ReturnObjectBag. * @param key The key for which the next object should be returned. * @return The next object from the ReturnObjectList stored against the given key. * @see ReturnObjectList#nextReturnObject */ public Object getNextReturnObject(Object key) { ReturnObjectList returnObjectList = (ReturnObjectList)returnObjectLists.get(key); AssertMo.assertNotNull(name + " does not contain " + key.toString(), returnObjectList); return returnObjectList.nextReturnObject(); } } |
From: Jeff M. <cus...@us...> - 2002-11-29 09:20:12
|
Update of /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com/mockobjects/io In directory sc8-pr-cvs1:/tmp/cvs-serv4000/src/jdk/common/com/mockobjects/io Modified Files: MockFile.java Log Message: Added setupGetName Index: MockFile.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com/mockobjects/io/MockFile.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- MockFile.java 19 Jun 2002 15:26:24 -0000 1.2 +++ MockFile.java 29 Nov 2002 09:20:08 -0000 1.3 @@ -16,18 +16,22 @@ private final ExpectationValue myFilenameFilter = new ExpectationValue("filename filter"); private String myParent; + private String fileName; private File[] myFilesToReturn; private java.io.File file; private String myPath; + public void setupGetName(final String name){ + this.fileName = name; + } + public String getName() { - notImplemented(); - return null; + return fileName; } - public void setupGetParent(String aParent){ + public void setupGetParent(final String aParent){ myParent = aParent; } |
From: Jeff M. <cus...@us...> - 2002-11-25 12:37:25
|
Update of /cvsroot/mockobjects/mockobjects-java/src/j2ee/1.3/com/mockobjects/helpers In directory sc8-pr-cvs1:/tmp/cvs-serv20051/src/j2ee/1.3/com/mockobjects/helpers Modified Files: AbstractServletTestHelper.java Log Message: Added servlet context to the session Index: AbstractServletTestHelper.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/j2ee/1.3/com/mockobjects/helpers/AbstractServletTestHelper.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- AbstractServletTestHelper.java 14 Oct 2002 22:58:28 -0000 1.1 +++ AbstractServletTestHelper.java 25 Nov 2002 12:37:22 -0000 1.2 @@ -16,6 +16,7 @@ public AbstractServletTestHelper() { request.setSession(httpSession); servletContext.setupGetRequestDispatcher(requestDispatcher); + httpSession.setupServletContext(servletContext); } public MockHttpServletRequest getRequest() { |
From: Steve F. <st...@m3...> - 2002-11-25 00:22:00
|
Barry Kaplan wrote: > Seems that the dynamic mocksobjects handle this quite nicely. Here's > what I did: The class I needed to test was an abstract class, so I could > not use Mock or MockObject directly. Instead I mocked just the abstract > hook methods required to the test the template methods. In the case of > the 'getQuantity' hook method, I did: > > private CallSet expectedGetQuantity1 = new CallSet(); > > // Just to provide an easier setup mechansim than having the test use > the CallSet directly > public void expectGetQuantity(Foo foo, Bar bar, Integer returnValue) { > expectedGetQuantity1.expectReturn( > new Constraint[]{P.eq(foo), P.eq(bar)}, returnValue); > } > > public int getQuantity(Foo foo, Bar bar) { > try > return ((Integer) expectedGetQuantity1.call(new Object[]{foo, > bar})).intValue(); > } catch (Throwable t) { > // It kinda sucks that call() declares Throwable. Its really > unecessary, since reflection will > // throw the exception of the reflected. If the reflected > method declares an exception > // the mock method can pass it thru (or extract it from the > exception the method.invoke() throws). > throw new RuntimeException(t); > } > } > > public void verify() throws AssertionFailedError { > expectedGetQuantity1.verify(); > ... > } For an equality test, I would have done something like: ExpectationValue foo = new ExpectationValue("foo"); ExpectationValue bar = new ExpectationValue("bar"); int quantity; public int getQuantity(Foo aFoo, Bar aBar) { foo.setActual(aFoo); bar.setActual(aBar); return quantity; } public void verify() { Verifier.verifyObject(this); } which I find more obvious. I might take shortcuts, like using an ExpectationList for all the parameters and, these days, I tend not to make the mock fields private and just call setExpected() on them directly. If you get the names right, it's pretty readable. S. |
From: Steve F. <st...@m3...> - 2002-11-25 00:15:44
|
Barry Kaplan wrote: > One of the big problem we ran into with mockobjects was the ability to > get back the values passed into mocks (vs. just having the mock assert > the values). For example, when testing a class that registers as a > listener [with some mock], we often want to get hold of that listener > instance (which may be the CUT or an inner of class of the CUT) and > invoke methods on the listener so as to test the listening behavior. > Implementations of Expectation all maintain the expected values as > private and provide no accessors, making this type of usage impossible. We probably should open up the instance variables, but we tend to use those forces to push the way we code. I don't really understand your example, could you post a snippet? > Back then I never really dug into the mockobjects code. Now, after > having done so, I see that the mockobjects implementation is clean and > simple, and most of limitations [for us] can easiliy be removed. We used > easymock for a while, but had same issues as with mockobjects. If you have time, could you describe them? > Thanks for the help Steve. my pleasure. > (I notice that all your responses post to both user and dev. Should that > be the normal practice?) not sure who's interested in this, so I'm resorting to a scattergun. Anyone prefer me not to? S. |
Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/constraint In directory sc8-pr-cvs1:/tmp/cvs-serv6139/src/core/com/mockobjects/constraint Modified Files: Or.java IsNot.java IsEqual.java IsSame.java IsLessThan.java And.java IsEventFrom.java IsGreaterThan.java Log Message: Removed toString()'s from Constraint reporting because it's built into the language Index: Or.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/constraint/Or.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Or.java 12 Nov 2002 17:42:38 -0000 1.1 +++ Or.java 24 Nov 2002 11:20:19 -0000 1.2 @@ -23,6 +23,6 @@ } public String toString() { - return "(" + _p1.toString() + " or " + _p2.toString() + ")"; + return "(" + _p1 + " or " + _p2 + ")"; } } Index: IsNot.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/constraint/IsNot.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- IsNot.java 12 Nov 2002 17:42:37 -0000 1.1 +++ IsNot.java 24 Nov 2002 11:20:19 -0000 1.2 @@ -20,6 +20,6 @@ } public String toString() { - return "not " + _predicate.toString(); + return "not " + _predicate; } } Index: IsEqual.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/constraint/IsEqual.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- IsEqual.java 12 Nov 2002 17:42:37 -0000 1.1 +++ IsEqual.java 24 Nov 2002 11:20:19 -0000 1.2 @@ -23,6 +23,6 @@ } public String toString() { - return "a value equal to <" + _object.toString() + ">"; + return "a value equal to <" + _object + ">"; } } Index: IsSame.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/constraint/IsSame.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- IsSame.java 12 Nov 2002 17:42:37 -0000 1.1 +++ IsSame.java 24 Nov 2002 11:20:19 -0000 1.2 @@ -26,6 +26,6 @@ } public String toString() { - return "the same object as <" + _object.toString() + ">"; + return "the same object as <" + _object + ">"; } } Index: IsLessThan.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/constraint/IsLessThan.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- IsLessThan.java 12 Nov 2002 17:42:37 -0000 1.1 +++ IsLessThan.java 24 Nov 2002 11:20:19 -0000 1.2 @@ -22,6 +22,6 @@ } public String toString() { - return "a value less than <" + _object.toString() + ">"; + return "a value less than <" + _object + ">"; } } Index: And.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/constraint/And.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- And.java 12 Nov 2002 17:42:37 -0000 1.1 +++ And.java 24 Nov 2002 11:20:19 -0000 1.2 @@ -23,6 +23,6 @@ } public String toString() { - return "(" + _p1.toString() + " and " + _p2.toString() + ")"; + return "(" + _p1 + " and " + _p2 + ")"; } } Index: IsEventFrom.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/constraint/IsEventFrom.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- IsEventFrom.java 12 Nov 2002 17:42:38 -0000 1.1 +++ IsEventFrom.java 24 Nov 2002 11:20:19 -0000 1.2 @@ -43,6 +43,6 @@ public String toString() { return "an event of type " + _event_class.getName() + - " from " + _source.toString(); + " from " + _source; } } Index: IsGreaterThan.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/constraint/IsGreaterThan.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- IsGreaterThan.java 12 Nov 2002 17:42:38 -0000 1.1 +++ IsGreaterThan.java 24 Nov 2002 11:20:19 -0000 1.2 @@ -22,6 +22,6 @@ } public String toString() { - return "a value greater than <" + _object.toString() + ">"; + return "a value greater than <" + _object + ">"; } } |
From: Steve F. <sm...@us...> - 2002-11-24 11:11:42
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects In directory sc8-pr-cvs1:/tmp/cvs-serv624/src/core/com/mockobjects Modified Files: ExpectationDoubleValue.java MockObject.java ExpectationValue.java Log Message: Tidied up imports Index: ExpectationDoubleValue.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/ExpectationDoubleValue.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ExpectationDoubleValue.java 23 Aug 2002 16:23:42 -0000 1.1 +++ ExpectationDoubleValue.java 24 Nov 2002 11:11:40 -0000 1.2 @@ -1,8 +1,6 @@ package com.mockobjects; import com.mockobjects.util.AssertMo; -import com.mockobjects.util.Null; -import junit.framework.Assert; public class ExpectationDoubleValue extends AbstractExpectation { Index: MockObject.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/MockObject.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- MockObject.java 22 Apr 2002 16:59:49 -0000 1.3 +++ MockObject.java 24 Nov 2002 11:11:40 -0000 1.4 @@ -1,8 +1,7 @@ package com.mockobjects; -import java.lang.reflect.Field; -import junit.framework.*; -import com.mockobjects.util.*; +import com.mockobjects.util.AssertMo; +import com.mockobjects.util.Verifier; public abstract class MockObject implements Verifiable { Index: ExpectationValue.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/ExpectationValue.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ExpectationValue.java 23 Aug 2002 14:43:32 -0000 1.2 +++ ExpectationValue.java 24 Nov 2002 11:11:40 -0000 1.3 @@ -1,7 +1,6 @@ package com.mockobjects; import com.mockobjects.util.Null; -import junit.framework.Assert; public class ExpectationValue extends AbstractExpectation { private Object myExpectedValue; |
From: Steve F. <sm...@us...> - 2002-11-24 11:11:42
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects In directory sc8-pr-cvs1:/tmp/cvs-serv624/src/core/test/mockobjects Modified Files: TestExpectationMap.java TestExpectationList.java TestExpectationSet.java TestReturnObjectList.java TestNull.java TestExpectationSegment.java Log Message: Tidied up imports Index: TestExpectationMap.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/TestExpectationMap.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- TestExpectationMap.java 21 Oct 2002 22:52:38 -0000 1.1 +++ TestExpectationMap.java 24 Nov 2002 11:11:40 -0000 1.2 @@ -1,5 +1,6 @@ package test.mockobjects; +import junit.awtui.TestRunner; import junit.framework.*; import com.mockobjects.*; import com.mockobjects.util.*; @@ -16,7 +17,7 @@ } public static void main(String[] args) { - new junit.awtui.TestRunner().run(THIS); + TestRunner.run(THIS); } public void testExpectMissingEntry() { Index: TestExpectationList.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/TestExpectationList.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- TestExpectationList.java 21 Oct 2002 22:52:38 -0000 1.1 +++ TestExpectationList.java 24 Nov 2002 11:11:40 -0000 1.2 @@ -1,9 +1,9 @@ package test.mockobjects; -import java.util.*; -import junit.framework.*; -import com.mockobjects.*; -import test.mockobjects.TestExpectationCollection; +import junit.framework.Test; +import junit.framework.TestSuite; + +import com.mockobjects.ExpectationList; public class TestExpectationList extends TestExpectationCollection { private static final Class THIS = TestExpectationList.class; Index: TestExpectationSet.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/TestExpectationSet.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- TestExpectationSet.java 21 Oct 2002 22:52:38 -0000 1.1 +++ TestExpectationSet.java 24 Nov 2002 11:11:40 -0000 1.2 @@ -1,9 +1,9 @@ package test.mockobjects; -import java.util.*; -import junit.framework.*; -import com.mockobjects.*; -import test.mockobjects.TestExpectationCollection; +import junit.framework.Test; +import junit.framework.TestSuite; + +import com.mockobjects.ExpectationSet; public class TestExpectationSet extends TestExpectationCollection { private static final Class THIS = TestExpectationSet.class; Index: TestReturnObjectList.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/TestReturnObjectList.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- TestReturnObjectList.java 21 Oct 2002 22:52:38 -0000 1.1 +++ TestReturnObjectList.java 24 Nov 2002 11:11:40 -0000 1.2 @@ -1,9 +1,9 @@ package test.mockobjects; -import java.util.*; -import junit.framework.*; -import com.mockobjects.*; -import com.mockobjects.util.*; +import junit.framework.AssertionFailedError; + +import com.mockobjects.ReturnObjectList; +import com.mockobjects.util.TestCaseMo; public class TestReturnObjectList extends TestCaseMo { private ReturnObjectList list = new ReturnObjectList("test"); Index: TestNull.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/TestNull.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- TestNull.java 21 Oct 2002 22:52:38 -0000 1.1 +++ TestNull.java 24 Nov 2002 11:11:40 -0000 1.2 @@ -1,9 +1,10 @@ package test.mockobjects; -import java.util.*; -import junit.framework.*; -import com.mockobjects.*; -import com.mockobjects.util.*; +import junit.framework.Test; +import junit.framework.TestSuite; + +import com.mockobjects.util.Null; +import com.mockobjects.util.TestCaseMo; /** * JUnit test case for TestMapEntry Index: TestExpectationSegment.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/TestExpectationSegment.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- TestExpectationSegment.java 21 Oct 2002 22:52:38 -0000 1.1 +++ TestExpectationSegment.java 24 Nov 2002 11:11:40 -0000 1.2 @@ -1,11 +1,11 @@ package test.mockobjects; -import java.io.*; -import java.util.*; +import junit.framework.AssertionFailedError; +import junit.framework.Test; +import junit.framework.TestSuite; -import junit.framework.*; -import com.mockobjects.*; -import com.mockobjects.util.*; +import com.mockobjects.ExpectationSegment; +import com.mockobjects.util.TestCaseMo; public class TestExpectationSegment extends TestCaseMo { private static final Class THIS = TestExpectationSegment.class; |
From: Steve F. <sm...@us...> - 2002-11-24 11:03:31
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic In directory sc8-pr-cvs1:/tmp/cvs-serv28513/src/core/com/mockobjects/dynamic Modified Files: MethodExpectation.java Log Message: Improved error reporting. Index: MethodExpectation.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/MethodExpectation.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- MethodExpectation.java 6 Nov 2002 15:54:35 -0000 1.4 +++ MethodExpectation.java 24 Nov 2002 11:03:28 -0000 1.5 @@ -9,7 +9,7 @@ import com.mockobjects.Verifiable; public class MethodExpectation -implements Verifiable + implements Verifiable { final public String name; @@ -24,7 +24,7 @@ public void expectCall(MockCall aCall) { mockCall = aCall; - wasCalled.setExpected(true); + wasCalled.setExpected("was called"); } public void setupCall(MockCall aCall) { @@ -51,7 +51,7 @@ } public void startCall() { - wasCalled.setActual(true); + wasCalled.setActual("was called"); prerequisites.verify(); } @@ -60,7 +60,7 @@ } private void initializeWasCalled() { - wasCalled = new ExpectationValue(name + " was called"); + wasCalled = new ExpectationValue(name); } private void checkResultType(Method method, Object result) { |
From: Steve F. <sm...@us...> - 2002-11-24 11:02:40
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic In directory sc8-pr-cvs1:/tmp/cvs-serv27982/src/core/com/mockobjects/dynamic Modified Files: CallSequence.java Log Message: Changed P to C Tweaked list handling Index: CallSequence.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/CallSequence.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- CallSequence.java 12 Nov 2002 17:42:37 -0000 1.2 +++ CallSequence.java 24 Nov 2002 11:02:38 -0000 1.3 @@ -20,7 +20,6 @@ implements MockCall, Verifiable { List _expected_calls = new ArrayList(); - int _next_index = 0; public CallSequence() { super(); @@ -59,7 +58,7 @@ * before being returned to the caller of the method. */ public void expectReturn( Object arg, Object result ) { - expectReturn( P.args(P.eq(arg) ), result); + expectReturn( C.args(C.eq(arg) ), result); } /** Expect a method call with no parameters and return a result when it is called. @@ -92,7 +91,7 @@ * An single object that will be compared with predicate eq() */ public void expectVoid( Object arg ) { - expectVoid( P.args(P.eq(arg)) ); + expectVoid( C.args(C.eq(arg)) ); } /** Expect a call to a method with a void return type and no parameters @@ -122,7 +121,7 @@ * The exception or error that will be thrown as a result of this call. */ public void expectThrow( Object arg, Throwable exception ) { - expectThrow( P.args(P.eq(arg)), exception ); + expectThrow( C.args(C.eq(arg)), exception ); } /** Expect a method call with no parameters and throw an exception or error when it is called. @@ -136,18 +135,13 @@ public Object call(Object[] args) throws Throwable { - if( _next_index >= _expected_calls.size() ) { - fail("too many calls"); - } + assertTrue("Too many calls", 0 != _expected_calls.size()); - MockCall call = (MockCall)_expected_calls.get(_next_index); - _next_index++; + MockCall call = (MockCall)_expected_calls.remove(0); return call.call( args ); } public void verify() { - if( _next_index < _expected_calls.size() ) { - fail("too few calls"); - } + assertEquals("Too few calls", 0, _expected_calls.size()); } } |
From: Steve F. <sm...@us...> - 2002-11-24 11:01:57
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic In directory sc8-pr-cvs1:/tmp/cvs-serv27555/src/core/com/mockobjects/dynamic Modified Files: CallCounter.java Log Message: retrofitted ExpectationCounter Index: CallCounter.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/CallCounter.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- CallCounter.java 31 Oct 2002 17:03:45 -0000 1.1 +++ CallCounter.java 24 Nov 2002 11:01:55 -0000 1.2 @@ -3,6 +3,7 @@ */ package com.mockobjects.dynamic; +import com.mockobjects.ExpectationCounter; import com.mockobjects.Verifiable; import com.mockobjects.util.AssertMo; @@ -12,25 +13,19 @@ implements MockCall, Verifiable { private MockCall _call; - private int _expected_calls; + private ExpectationCounter _callCount = new ExpectationCounter("call count"); public CallCounter( int expected_calls, MockCall call ) { _call = call; - _expected_calls = expected_calls; + _callCount.setExpected(expected_calls); } public Object call(Object[] args) throws Throwable { - if( _expected_calls == 0 ) { - fail( "too many calls" ); - } - - _expected_calls--; + _callCount.inc(); return _call.call(args); } public void verify() { - if( _expected_calls != 0 ) { - fail("expected " + _expected_calls + " additional call(s)" ); - } + _callCount.verify(); } } |
From: Steve F. <sm...@us...> - 2002-11-24 11:01:31
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic In directory sc8-pr-cvs1:/tmp/cvs-serv27285/src/core/com/mockobjects/dynamic Modified Files: AbstractMockCall.java Log Message: Minor tidies. Made ANT_ARGS public Index: AbstractMockCall.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/AbstractMockCall.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- AbstractMockCall.java 12 Nov 2002 17:42:37 -0000 1.4 +++ AbstractMockCall.java 24 Nov 2002 11:01:29 -0000 1.5 @@ -4,6 +4,8 @@ */ package com.mockobjects.dynamic; +import junit.framework.Assert; + import com.mockobjects.constraint.*; @@ -12,14 +14,14 @@ * thrown exception or side effect) to derived classes. */ public abstract class AbstractMockCall - extends junit.framework.Assert + extends Assert implements MockCall { /** A constant that indicates that the mocked call accepts * any arguments, that is, that the call does not check the arguments * passed to it. */ - static final Constraint[] ANY_ARGS = null; + public static final Constraint[] ANY_ARGS = null; private Constraint[] _expected_args; |
From: Steve F. <sm...@us...> - 2002-11-24 11:01:09
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic In directory sc8-pr-cvs1:/tmp/cvs-serv26960/src/core/com/mockobjects/dynamic Modified Files: Mock.java Log Message: Renamed P to C for consistency Index: Mock.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/Mock.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- Mock.java 12 Nov 2002 17:42:37 -0000 1.15 +++ Mock.java 24 Nov 2002 11:01:00 -0000 1.16 @@ -8,7 +8,6 @@ import com.mockobjects.constraint.*; import junit.framework.Assert; -import junit.framework.AssertionFailedError; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; @@ -220,7 +219,7 @@ * Mock object. */ public void expectAndReturn( String method, Object arg, Object result ) { - expectAndReturn( method, P.args(P.eq(arg) ), result); + expectAndReturn( method, C.args(C.eq(arg) ), result); } /** Expect a method call with no parameters and return a result when it is called. @@ -268,7 +267,7 @@ * Mock object. */ public void expectVoid(String method, Object arg) { - expectVoid( method, P.args(P.eq(arg)) ); + expectVoid( method, C.args(C.eq(arg)) ); } /** @@ -315,7 +314,7 @@ * Mock object. */ public void expectAndThrow( String method, Object arg, Throwable exception ) { - expectAndThrow( method, P.args(P.eq(arg)), exception ); + expectAndThrow( method, C.args(C.eq(arg)), exception ); } /** Expect a method call with no parameters and throw an exception or error when it is called. |
From: Steve F. <sm...@us...> - 2002-11-24 11:00:02
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic In directory sc8-pr-cvs1:/tmp/cvs-serv26322/src/core/test/mockobjects/dynamic Modified Files: CallCounterTest.java CallSequenceTest.java Log Message: Renamed P to C for consistency Index: CallCounterTest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/CallCounterTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- CallCounterTest.java 7 Nov 2002 17:45:04 -0000 1.3 +++ CallCounterTest.java 24 Nov 2002 10:59:59 -0000 1.4 @@ -8,7 +8,7 @@ import com.mockobjects.dynamic.CallCounter; import com.mockobjects.dynamic.Mock; import com.mockobjects.dynamic.MockCall; -import com.mockobjects.dynamic.P; +import com.mockobjects.dynamic.C; import com.mockobjects.util.TestCaseMo; @@ -44,7 +44,7 @@ 1, (MockCall)mock_call.proxy() ); final Object RESULT = new Object(); - mock_call.expectAndThrow( "call", P.ANY_ARGS, new ExampleException() ); + mock_call.expectAndThrow( "call", C.ANY_ARGS, new ExampleException() ); try { counter.call( new Object[0] ); Index: CallSequenceTest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/CallSequenceTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- CallSequenceTest.java 7 Nov 2002 17:45:04 -0000 1.3 +++ CallSequenceTest.java 24 Nov 2002 10:59:59 -0000 1.4 @@ -8,7 +8,7 @@ import com.mockobjects.dynamic.CallSequence; import com.mockobjects.dynamic.Mock; import com.mockobjects.dynamic.MockCall; -import com.mockobjects.dynamic.P; +import com.mockobjects.dynamic.C; import com.mockobjects.util.TestCaseMo; public class CallSequenceTest @@ -75,11 +75,11 @@ final ExampleException EXCEPTION_1 = new ExampleException(); final ExampleException EXCEPTION_2 = new ExampleException(); - mock_call_1.expectAndThrow( "call", P.args(P.same(ARGS_1)), EXCEPTION_1 ); + mock_call_1.expectAndThrow( "call", C.args(C.same(ARGS_1)), EXCEPTION_1 ); call_list.expect( (MockCall)mock_call_1.proxy() ); - mock_call_2.expectAndThrow( "call", P.args(P.eq(ARGS_2)), EXCEPTION_2 ); + mock_call_2.expectAndThrow( "call", C.args(C.eq(ARGS_2)), EXCEPTION_2 ); call_list.expect( (MockCall)mock_call_2.proxy() ); try { |
From: Steve F. <sm...@us...> - 2002-11-24 10:59:33
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic In directory sc8-pr-cvs1:/tmp/cvs-serv26025/src/core/com/mockobjects/dynamic Added Files: C.java Removed Files: P.java Log Message: Renamed P to C for consistency --- NEW FILE: C.java --- /* Copyright (c) 2002 Nat Pryce. All rights reserved. * * Created on February 14, 2002, 4:02 PM */ package com.mockobjects.dynamic; import com.mockobjects.constraint.*; /** Convenient factory functions and constants for building predicates. */ public abstract class C { public static final IsAnything IS_ANYTHING = new IsAnything(); public static final IsNull IS_NULL = new IsNull(); public static final Constraint IS_NOT_NULL = not(IS_NULL); public static final Constraint IS_TRUE = eq(new Boolean(true)); public static final Constraint IS_FALSE = eq(new Boolean(false)); public static final Constraint IS_ZERO = eq(new Integer(0)); public static final Constraint IS_NOT_ZERO = not(IS_ZERO); public static final Constraint[] ANY_ARGS = MockVoidCall.ANY_ARGS; public static Constraint same( Object o ) { return new IsSame(o); } public static Constraint eq( Object o ) { return new IsEqual(o); } public static Constraint eq( int n ) { return new IsEqual( new Integer(n) ); } public static Constraint eq( long l ) { return new IsEqual( new Long(l) ); } public static Constraint eq( double d ) { return new IsEqual( new Double(d) ); } public static Constraint gt( int n ) { return new IsGreaterThan( new Integer(n) ); } public static Constraint gt( long l ) { return new IsGreaterThan( new Long(l) ); } public static Constraint gt( double d ) { return new IsGreaterThan( new Double(d) ); } public static Constraint gt( char c ) { return new IsGreaterThan( new Character(c) ); } public static Constraint lt( int n ) { return new IsLessThan( new Integer(n) ); } public static Constraint lt( long l ) { return new IsLessThan( new Long(l) ); } public static Constraint lt( double d ) { return new IsLessThan( new Double(d) ); } public static Constraint lt( char c ) { return new IsLessThan( new Character(c) ); } public static Constraint not( Constraint p ) { return new IsNot(p); } public static Constraint and( Constraint p1, Constraint p2 ) { return new And(p1,p2); } public static Constraint or( Constraint p1, Constraint p2 ) { return new Or(p1,p2); } public static Constraint isA( Class c ) { return new IsInstanceOf(c); } /* Helper methods for succinctly constructing Constraint arrays */ public static Constraint[] args() { return Mock.NO_ARGS; } public static Constraint[] args(Constraint p) { return new Constraint[] {p}; } public static Constraint[] args(Constraint p1, Constraint p2) { return new Constraint[] {p1, p2}; } public static Constraint[] args(Constraint p1, Constraint p2, Constraint p3) { return new Constraint[] {p1, p2, p3}; } } --- P.java DELETED --- |
From: Steve F. <st...@m3...> - 2002-11-24 10:52:35
|
If we're going this route, then we should make MockCall a Verifiable and verify everything, even if it doesn't do anything. I'm concerned about the duplication of overloaded methods between Mock and CallSequence. It feels like we haven't teased out all the concepts. One solution may be to make them both derive from some kind of template class. I'm not sure that Mock should extend Assert, it's usually the test case that does that. I've done some tweaking and I'll rename dynamic.P to C for consistency, should it be in the constraint package? S. Barry Kaplan wrote: > Nat Pryce wrote: > >> If you use decorators around MockCall (e.g. CallSequence or a CallCount) >> you have to explcitly verify those objects yourself. >> >> Hmm... perhaps the Mock class should test to see if the MockCall is >> Verifiable and then automatically verify it if it is. What do people >> think? |
From: Barry K. <bk...@in...> - 2002-11-21 20:17:48
|
Nat Pryce wrote: >If you use decorators around MockCall (e.g. CallSequence or a CallCount) >you have to explcitly verify those objects yourself. > >Hmm... perhaps the Mock class should test to see if the MockCall is >Verifiable and then automatically verify it if it is. What do people >think? > > > +1 |
From: Nat P. <nat...@b1...> - 2002-11-21 19:04:22
|
If you use decorators around MockCall (e.g. CallSequence or a CallCount) you have to explcitly verify those objects yourself. Hmm... perhaps the Mock class should test to see if the MockCall is Verifiable and then automatically verify it if it is. What do people think? Cheers, Nat. On Thu, 2002-11-21 at 17:14, Barry Kaplan wrote: > I have the following test snippet: > > Mock mockConnection = new Mock(Connection.class); > Mock mockSelectStatement = new Mock(PreparedStatement.class); > Mock mockUpdateStatement = new Mock(PreparedStatement.class); > CallSequence prepareStatementCalls = new CallSequence(); > > > prepareStatementCalls.expectReturn(HighLowIdentityGenerator.SELECT_NEXT_BLOCK_STATEMENT, > mockSelectStatement.proxy()); > > prepareStatementCalls.expectReturn(HighLowIdentityGenerator.UPDATE_NEXT_BLOCK_STATEMENT, > mockUpdateStatement.proxy()); > mockConnection.expect("prepareStatement", prepareStatementCalls); > mockSelectStatement.expectAndReturn("executeQuery", null); > mockUpdateStatement.expectVoid("execute"); > > generator.setIdentity(mockDatabaseContext, object); > > mockConnection.verify(); // This succeeds, I would > expect it fail > prepareStatementCalls.verify(); // This fails, as I expect > assertEquals(1, object.getId()); > > It seems that the MethodMap only checks that the method of the name was > invoked, but does not take into account that the MockCall for that > method was a CallSequence. Should MethodMap be delegating to MockCall > for [part of?] its verify? > > -bk > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > Mockobjects-java-dev mailing list > Moc...@li... > https://lists.sourceforge.net/lists/listinfo/mockobjects-java-dev -- Nat Pryce <nat...@b1...> B13media |