Update of /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic In directory sc8-pr-cvs1:/tmp/cvs-serv6154/core/test/mockobjects/dynamic Modified Files: Tag: DynamicMockExperiment MockTest.java ExpectedCallTest.java CallMatchTest.java Added Files: Tag: DynamicMockExperiment DynamicUtilTest.java Log Message: Fixed proxy error reporting when used as an expectation --- NEW FILE: DynamicUtilTest.java --- /* * Created on 16-Apr-2003 */ package test.mockobjects.dynamic; import com.mockobjects.dynamic.DynamicUtil; import com.mockobjects.dynamic.Mock; import com.mockobjects.util.AssertMo; import junit.framework.TestCase; /** * @author e2x */ public class DynamicUtilTest extends TestCase { public DynamicUtilTest(String name) { super(name); } public void testMethodToStringWithoutProxyArg() throws Exception { String[] args = new String[] {"arg1", "arg2" }; String result = DynamicUtil.methodToString("methodName", args); AssertMo.assertIncludes("Should contain method name", "methodName", result); AssertMo.assertIncludes("Should contain firstArg", "arg1", result); AssertMo.assertIncludes("Should contain second Arg", "arg2", result); } public void testMethodToStringWithProxyArg() throws Exception { Mock mockDummyInterface = new Mock(DummyInterface.class, "DummyMock"); Object[] args = new Object[] {"arg1", mockDummyInterface.proxy()}; String result = DynamicUtil.methodToString("methodName", args); AssertMo.assertIncludes("Should contain method name", "methodName", result); AssertMo.assertIncludes("Should contain firstArg", "arg1", result); AssertMo.assertIncludes("Should contain second Arg", "DummyMock", result); } } Index: MockTest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/MockTest.java,v retrieving revision 1.8.2.6 retrieving revision 1.8.2.7 diff -u -r1.8.2.6 -r1.8.2.7 --- MockTest.java 15 Apr 2003 22:22:56 -0000 1.8.2.6 +++ MockTest.java 16 Apr 2003 16:31:46 -0000 1.8.2.7 @@ -367,12 +367,17 @@ boolean IGNORED_RESULT = true; CallStub ret = new ReturnStub(new Boolean(IGNORED_RESULT)); mockCallFactory.setupCreateReturnStub(ret); - mockCallFactory.setupCreateCallMatch(new CallMatch("call",C.ANY_ARGS,ret)); + mockCallFactory.setupCreateCallMatch(new CallMatch("call",C.anyArgs(1),ret)); mockCallableAddable.setupCallReturn(new Boolean(false)); - mock.matchAndReturn("call", C.ANY_ARGS, IGNORED_RESULT); + mock.matchAndReturn("call", C.anyArgs(1), IGNORED_RESULT); assertFalse("Should handle proxy inequality by calling through", proxy.equals("not a proxy")); Verifier.verifyObject(this); } + + public void testProxygetMockName() throws Exception { + assertEquals("Should get a mock name without touching the underlying mock", MOCK_NAME, DynamicUtil.getProxyName(proxy)); + mock.verify(); // should not fail on a getMockName call + } } Index: ExpectedCallTest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/Attic/ExpectedCallTest.java,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -u -r1.1.2.4 -r1.1.2.5 --- ExpectedCallTest.java 15 Apr 2003 22:22:55 -0000 1.1.2.4 +++ ExpectedCallTest.java 16 Apr 2003 16:31:47 -0000 1.1.2.5 @@ -16,7 +16,7 @@ final String RESULT = "result!"; final String METHOD_NAME = "methodName"; final Object[] ARGS = { "arg1", "arg2" }; - final String DECORATED_DESCRIPTION = AssertMo.methodToString( METHOD_NAME, ARGS ); + final String DECORATED_DESCRIPTION = DynamicUtil.methodToString( METHOD_NAME, ARGS ); Mock ignoredMock = null; MockCallable mockCallable = new MockCallable(); Index: CallMatchTest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/Attic/CallMatchTest.java,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -u -r1.1.2.3 -r1.1.2.4 --- CallMatchTest.java 15 Apr 2003 22:22:56 -0000 1.1.2.3 +++ CallMatchTest.java 16 Apr 2003 16:31:47 -0000 1.1.2.4 @@ -125,9 +125,9 @@ AssertMo.assertIncludes("Should show index of failed argument", "1", ex.getMessage() ); AssertMo.assertIncludes("Should show expected arguments", - AssertMo.join(constraints), ex.getMessage()); + DynamicUtil.join(constraints), ex.getMessage()); AssertMo.assertIncludes("Should show actual arguments", - AssertMo.join(args), ex.getMessage()); + DynamicUtil.join(args), ex.getMessage()); } assertTrue("Should fail is call doesn't give an exception", passed); @@ -161,7 +161,20 @@ CallMatch call = new CallMatch( METHOD_NAME, (Constraint[])constraints, mockCallable ); - assertTrue( "call should matche", call.matches( METHOD_NAME, args) ); + assertTrue( "call should match", call.matches( METHOD_NAME, args) ); + mockCallable.verifyExpectations(); + } + + public void testCallMatchesWithAnyArguments() throws Throwable { + String[] args = new String[] {"anyArg" }; + MockConstraint[] constraints = new MockConstraint[0]; + + mockCallable.setExpectedMatches( METHOD_NAME, args ); + mockCallable.setupMatchesReturn(true); + + CallMatch call = new CallMatch( METHOD_NAME, C.anyArgs(1), mockCallable ); + + assertTrue( "call should match", call.matches( METHOD_NAME, args) ); mockCallable.verifyExpectations(); } |