From: Steve F. <sm...@us...> - 2003-07-06 23:24:13
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic In directory sc8-pr-cvs1:/tmp/cvs-serv19884/src/core/test/mockobjects/dynamic Modified Files: CallOnceExpectationTest.java CallSignatureTest.java StubTest.java CallBagTest.java MockCallableCollection.java CallSequenceTest.java MockCallable.java Log Message: Renamed ActiveCall to Invocation Index: CallOnceExpectationTest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/CallOnceExpectationTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- CallOnceExpectationTest.java 5 Jul 2003 16:35:20 -0000 1.4 +++ CallOnceExpectationTest.java 6 Jul 2003 23:24:09 -0000 1.5 @@ -11,7 +11,7 @@ final String RESULT = "result!"; final String METHOD_NAME = "methodName"; final Object[] ARGS = { "arg1", "arg2" }; - final ActiveCall CALL = new ActiveCall(METHOD_NAME, ARGS) ; + final Invocation INVOCATION = new Invocation(METHOD_NAME, ARGS) ; final String DECORATED_DESCRIPTION = DynamicUtil.methodToString( METHOD_NAME, ARGS ); @@ -51,7 +51,7 @@ mockCallable.setupCallReturn( RESULT ); mockCallable.setExpectedVerifyCalls(1); - call.call( CALL ); + call.call( INVOCATION ); call.verify(); mockCallable.verifyExpectations(); @@ -60,15 +60,15 @@ public void testMatchesDelegated() throws Throwable { mockCallable.setExpectedMatches( METHOD_NAME, ARGS ); mockCallable.setupAlwaysMatchActiveCall(true); - assertTrue( "returns matches to be true", call.matches( CALL ) ); + assertTrue( "returns matches to be true", call.matches( INVOCATION ) ); mockCallable.verifyExpectations(); } public void testCallArgumentsPassedThrough() throws Throwable { - mockCallable.activeCall.setExpected(CALL); + mockCallable.invocation.setExpected(INVOCATION); mockCallable.setupCallReturn(RESULT); - call.call( CALL ); + call.call( INVOCATION ); mockCallable.verifyExpectations(); } @@ -77,16 +77,16 @@ mockCallable.setupAlwaysMatchActiveCall(true); mockCallable.setupCallReturn(RESULT); - assertTrue( "First time should match", call.matches( CALL )); - call.call( CALL ); - assertFalse( "Second time should not match", call.matches( CALL )); + assertTrue( "First time should match", call.matches( INVOCATION )); + call.call( INVOCATION ); + assertFalse( "Second time should not match", call.matches( INVOCATION )); } public void testDecoratedResultPassedThrough() throws Throwable { mockCallable.setupCallReturn(RESULT); assertSame( "should return decorated's result", - RESULT, call.call( CALL ) ); + RESULT, call.call( INVOCATION ) ); mockCallable.verifyExpectations(); } @@ -97,7 +97,7 @@ mockCallable.setupCallThrow(exception); try { - call.call( CALL ); + call.call( INVOCATION ); fail("expected decorated's throwable to be thrown"); } catch( DummyThrowable ex ) { Index: CallSignatureTest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/CallSignatureTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- CallSignatureTest.java 6 Jul 2003 02:31:37 -0000 1.1 +++ CallSignatureTest.java 6 Jul 2003 23:24:09 -0000 1.2 @@ -11,7 +11,7 @@ public class CallSignatureTest extends TestCase { final String METHOD_NAME = "methodName"; final Object[] IGNORED_ARGS = new Object[0]; - final ActiveCall CALL = new ActiveCall(METHOD_NAME, IGNORED_ARGS); + final Invocation INVOCATION = new Invocation(METHOD_NAME, IGNORED_ARGS); Mock mock = new Mock(DummyInterface.class, "mock"); MockCallable mockCallable = new MockCallable("mock callable"); @@ -26,10 +26,10 @@ throws Throwable { final String result = "result"; - mockCallable.activeCall.setExpected(CALL); + mockCallable.invocation.setExpected(INVOCATION); mockCallable.setupCallReturn(result); - callSignature.call(CALL); + callSignature.call(INVOCATION); mockCallable.verifyExpectations(); } @@ -46,7 +46,7 @@ mockCallable.setExpectedVerifyCalls(1); mockCallable.setupCallReturn("result"); - callSignature.call(CALL); + callSignature.call(INVOCATION); callSignature.verify(); mockCallable.verifyExpectations(); @@ -55,8 +55,8 @@ public void testMultipleCallsSucceed() throws Throwable { mockCallable.setupCallReturn("result"); - callSignature.call(CALL); - callSignature.call(CALL); + callSignature.call(INVOCATION); + callSignature.call(INVOCATION); mockCallable.verifyExpectations(); } @@ -66,7 +66,7 @@ } public void testCallDoesNotMatchWhenWrongName() throws Throwable { - assertFalse("call does not match", callSignature.matches(new ActiveCall("anotherName", IGNORED_ARGS))); + assertFalse("call does not match", callSignature.matches(new Invocation("anotherName", IGNORED_ARGS))); mockCallable.verifyExpectations(); } @@ -76,10 +76,10 @@ mockConstraintMatcher.setupMatches(true); - callSignature.call(CALL); - assertTrue("matches after first call", callSignature.matches( CALL )); - callSignature.call(CALL); - assertTrue("matches after further calls", callSignature.matches( CALL )); + callSignature.call(INVOCATION); + assertTrue("matches after first call", callSignature.matches( INVOCATION )); + callSignature.call(INVOCATION); + assertTrue("matches after further calls", callSignature.matches( INVOCATION )); mockCallable.verifyExpectations(); } @@ -91,13 +91,13 @@ mockConstraintMatcher.addExpectedMatches(args); mockConstraintMatcher.setupMatches(true); - assertTrue("matches delegated to constraint matcher", callSignature.matches(new ActiveCall(METHOD_NAME, args))); + assertTrue("matches delegated to constraint matcher", callSignature.matches(new Invocation(METHOD_NAME, args))); mockConstraintMatcher.verify(); } public void testMatchesFailure() throws Throwable { mockConstraintMatcher.setupMatches(false); - assertFalse("Should not match if constraint matcher doesn't", callSignature.matches(CALL)); + assertFalse("Should not match if constraint matcher doesn't", callSignature.matches(INVOCATION)); } } Index: StubTest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/StubTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- StubTest.java 5 Jul 2003 15:15:54 -0000 1.4 +++ StubTest.java 6 Jul 2003 23:24:09 -0000 1.5 @@ -5,7 +5,7 @@ import junit.framework.TestCase; -import com.mockobjects.dynamic.ActiveCall; +import com.mockobjects.dynamic.Invocation; import com.mockobjects.dynamic.ReturnStub; import com.mockobjects.dynamic.ThrowStub; @@ -15,19 +15,19 @@ super(name); } - ActiveCall stubCall = new ActiveCall("ignoredName", new Object[0]); + Invocation invocation = new Invocation("ignoredName", new Object[0]); public void testReturnStub() throws Throwable { final String RESULT = "result"; - assertSame( "Should be the same result object", RESULT, new ReturnStub(RESULT).call( stubCall) ); + assertSame( "Should be the same result object", RESULT, new ReturnStub(RESULT).call( invocation) ); } public void testThrowStub() { final Throwable throwable = new DummyThrowable(); try { - new ThrowStub(throwable).call( stubCall ); + new ThrowStub(throwable).call( invocation ); } catch( Throwable t ) { assertSame( "Should be the same throwable", throwable, t ); Index: CallBagTest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/CallBagTest.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- CallBagTest.java 5 Jul 2003 16:34:14 -0000 1.7 +++ CallBagTest.java 6 Jul 2003 23:24:09 -0000 1.8 @@ -13,11 +13,11 @@ final Throwable METHOD_A_EXCEPTION = new DummyThrowable("Configured test throwable"); final String[] METHOD_A_ARGS = new String[] { "a1", "a2" }; - final ActiveCall METHOD_A_CALL = new ActiveCall(METHOD_A_NAME, METHOD_A_ARGS); + final Invocation METHOD_A_INVOCATION = new Invocation(METHOD_A_NAME, METHOD_A_ARGS); final ConstraintMatcher METHOD_A_CONSTRAINTS = C.args(C.eq("a1"), C.eq("a2")); final String[] METHOD_B_ARGS = new String[] { "b1", "b2" }; - final ActiveCall METHOD_B_CALL = new ActiveCall(METHOD_B_NAME, METHOD_B_ARGS); + final Invocation METHOD_B_INVOCATION = new Invocation(METHOD_B_NAME, METHOD_B_ARGS); private CallBag callBag = new CallBag(); @@ -32,7 +32,7 @@ public void testCallFailsOnEmptySet() throws Throwable { try { - callBag.call(new ActiveCall("missingMethod", new Object[0])); + callBag.call(new Invocation("missingMethod", new Object[0])); } catch (AssertionFailedError ex) { AssertMo.assertIncludes("reports empty set in error message", "no methods", ex.getMessage()); @@ -45,15 +45,15 @@ public void testCallPassedToContainedElements() throws Throwable { methodA.setExpectedMatches(METHOD_A_NAME, METHOD_A_ARGS); methodA.setupAlwaysMatchActiveCall(true); - methodA.activeCall.setExpected(METHOD_A_CALL); + methodA.invocation.setExpected(METHOD_A_INVOCATION); methodA.setupCallReturn(METHOD_A_RESULT); - methodB.activeCall.setExpectNothing(); + methodB.invocation.setExpectNothing(); callBag.addExpect(methodA); callBag.addExpect(methodB); - assertSame("expected result from method A", METHOD_A_RESULT, callBag.call(METHOD_A_CALL)); + assertSame("expected result from method A", METHOD_A_RESULT, callBag.call(METHOD_A_INVOCATION)); methodA.verifyExpectations(); methodB.verifyExpectations(); @@ -68,15 +68,15 @@ callBag.addExpect(new CallOnceExpectation(anotherMethodASignature)); assertSame("expected result from method B, as expect has precendence over match", "result2", - callBag.call(METHOD_A_CALL)); + callBag.call(METHOD_A_INVOCATION)); } public void testCallPassedToContainedElementsOtherOrder() throws Throwable { methodA.setExpectedMatches(METHOD_B_NAME, METHOD_B_ARGS); methodA.setupAlwaysMatchActiveCall(false); - methodA.activeCall.setExpectNothing(); - methodB.activeCall.setExpected(METHOD_B_CALL); + methodA.invocation.setExpectNothing(); + methodB.invocation.setExpected(METHOD_B_INVOCATION); methodB.setupCallReturn(METHOD_B_RESULT); methodB.setExpectedMatches(METHOD_B_NAME, METHOD_B_ARGS); @@ -86,7 +86,7 @@ callBag.addExpect(methodB); assertSame("expected result from method B", METHOD_B_RESULT, - callBag.call(METHOD_B_CALL)); + callBag.call(METHOD_B_INVOCATION)); methodA.verifyExpectations(); methodB.verifyExpectations(); @@ -100,7 +100,7 @@ callBag.addExpect(mockCallable); - assertSame("result is returned by mock", result, callBag.call(new ActiveCall("method", new Object[0]))); + assertSame("result is returned by mock", result, callBag.call(new Invocation("method", new Object[0]))); } public void testCallableThrowableThrown() @@ -113,7 +113,7 @@ callBag.addExpect(mockCallable); try { - callBag.call(new ActiveCall("anyMethod", new String[0])); + callBag.call(new Invocation("anyMethod", new String[0])); } catch (Throwable ex) { assertSame("exception was thrown by mock", throwable, ex); } @@ -126,22 +126,22 @@ public void testFailureIfNoElementMatches() throws Throwable { final String methodCName = "methodC"; final String[] methodCArgs = { "c1", "c2" }; - final ActiveCall methodCCall = new ActiveCall(methodCName, methodCArgs); + final Invocation methodCInvocation = new Invocation(methodCName, methodCArgs); methodA.setExpectedMatches(methodCName, methodCArgs); methodA.setupAlwaysMatchActiveCall(false); - methodA.activeCall.setExpectNothing(); + methodA.invocation.setExpectNothing(); methodA.setupGetDescription("***methodA-description****"); - methodB.activeCall.setExpected(methodCCall); + methodB.invocation.setExpected(methodCInvocation); methodB.setupAlwaysMatchActiveCall(false); - methodB.activeCall.setExpectNothing(); + methodB.invocation.setExpectNothing(); methodB.setupGetDescription("***methodB-description****"); callBag.addExpect(methodA); callBag.addExpect(methodB); try { - callBag.call(methodCCall); + callBag.call(methodCInvocation); } catch (AssertionFailedError ex) { AssertMo.assertIncludes("method name is in error message", "methodC", ex.getMessage()); AssertMo.assertIncludes("argument is in error message (1)", methodCArgs[0], ex.getMessage()); Index: MockCallableCollection.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/MockCallableCollection.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- MockCallableCollection.java 6 Jul 2003 02:31:36 -0000 1.1 +++ MockCallableCollection.java 6 Jul 2003 23:24:09 -0000 1.2 @@ -4,7 +4,7 @@ import com.mockobjects.ExpectationList; import com.mockobjects.MockObject; import com.mockobjects.ReturnValues; -import com.mockobjects.dynamic.ActiveCall; +import com.mockobjects.dynamic.Invocation; import com.mockobjects.dynamic.Callable; import com.mockobjects.dynamic.CallableCollection; import com.mockobjects.util.NotImplementedException; @@ -47,10 +47,10 @@ myMatchesParameter1Values.addExpected(arg1); } - public boolean matches(ActiveCall call) { + public boolean matches(Invocation invocation) { myMatchesCalls.inc(); - myMatchesParameter0Values.addActual(call.getMethodName()); - myMatchesParameter1Values.addActual(call.args); + myMatchesParameter0Values.addActual(invocation.getMethodName()); + myMatchesParameter1Values.addActual(invocation.args); Object nextReturnValue = myActualMatchesReturnValues.getNext(); @@ -86,11 +86,11 @@ myCallArguments.addExpectedMany(args); } - public Object call(ActiveCall call) + public Object call(Invocation invocation) throws Throwable { myCallCalls.inc(); - myCallMethodNames.addActual(call.getMethodName()); - myCallArguments.addActualMany(call.args); + myCallMethodNames.addActual(invocation.getMethodName()); + myCallArguments.addActualMany(invocation.args); Object nextReturnValue = myActualCallReturnValues.getNext(); Index: CallSequenceTest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/CallSequenceTest.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- CallSequenceTest.java 5 Jul 2003 16:35:20 -0000 1.11 +++ CallSequenceTest.java 6 Jul 2003 23:24:09 -0000 1.12 @@ -24,11 +24,11 @@ final String METHOD_B_RESULT = "resultB"; final Throwable METHOD_A_EXCEPTION = new DummyThrowable("Configured test throwable"); final String[] METHOD_A_ARGS = new String[] { "a1", "a2" }; - final ActiveCall METHOD_A_CALL = new ActiveCall(METHOD_A_NAME, METHOD_A_ARGS); + final Invocation METHOD_A_INVOCATION = new Invocation(METHOD_A_NAME, METHOD_A_ARGS); final ConstraintMatcher METHOD_A_CONSTRAINTS = C.args(C.eq("a1"), C.eq("a2")); final String[] METHOD_B_ARGS = new String[] { "b1", "b2" }; - final ActiveCall METHOD_B_CALL = new ActiveCall(METHOD_B_NAME, METHOD_B_ARGS); + final Invocation METHOD_B_INVOCATION = new Invocation(METHOD_B_NAME, METHOD_B_ARGS); private CallSequence callSequence = new CallSequence(); private MockCallable methodA = new MockCallable("method a"); @@ -48,7 +48,7 @@ callSequence.addExpect(mockCallable); try { - callSequence.call(new ActiveCall("hello", new String[0])); + callSequence.call(new Invocation("hello", new String[0])); } catch (Throwable ex) { assertSame("exception is caught by mock", throwable, ex); } @@ -56,7 +56,7 @@ public void testCallFailsOnEmptyList() throws Throwable { try { - callSequence.call(new ActiveCall("missingMethod", new Object[0])); + callSequence.call(new Invocation("missingMethod", new Object[0])); } catch (AssertionFailedError ex) { AssertMo.assertIncludes("reports empty set in error message", "no methods", ex.getMessage()); @@ -70,10 +70,10 @@ mockCallable.setupAlwaysMatchActiveCall(true); mockCallable.setupCallReturn(METHOD_A_RESULT); callSequence.addExpect(mockCallable); - callSequence.call(new ActiveCall("willdefinitelyMatch", new Object[0])); + callSequence.call(new Invocation("willdefinitelyMatch", new Object[0])); try { - callSequence.call(new ActiveCall("oneMethodTooMany", new Object[0])); + callSequence.call(new Invocation("oneMethodTooMany", new Object[0])); } catch (AssertionFailedError ex) { AssertMo.assertIncludes("reports one method call too many", "too many", ex.getMessage()); @@ -86,15 +86,15 @@ public void testCallPassedToContainedElements() throws Throwable { methodA.setExpectedMatches(METHOD_A_NAME, METHOD_A_ARGS); methodA.setupAlwaysMatchActiveCall(true); - methodA.activeCall.setExpected(METHOD_A_CALL); + methodA.invocation.setExpected(METHOD_A_INVOCATION); methodA.setupCallReturn(METHOD_A_RESULT); - methodB.activeCall.setExpectNothing(); + methodB.invocation.setExpectNothing(); callSequence.addExpect(methodA); callSequence.addExpect(methodB); - assertSame("expected result from method A", METHOD_A_RESULT, callSequence.call(METHOD_A_CALL)); + assertSame("expected result from method A", METHOD_A_RESULT, callSequence.call(METHOD_A_INVOCATION)); methodA.verifyExpectations(); methodB.verifyExpectations(); @@ -111,7 +111,7 @@ callSequence.addExpect(methodB); try { - assertSame("expected result from method B", METHOD_B_RESULT, callSequence.call(METHOD_B_CALL)); + assertSame("expected result from method B", METHOD_B_RESULT, callSequence.call(METHOD_B_INVOCATION)); } catch (AssertionFailedError ex) { String message = ex.getMessage(); AssertMo.assertIncludes("Should have expected error message", "Unexpected call: methodB", message); @@ -137,7 +137,7 @@ callSequence.addExpect(mockCallable); - assertSame("result is returned by mock", result, callSequence.call(new ActiveCall("method", new Object[0]))); + assertSame("result is returned by mock", result, callSequence.call(new Invocation("method", new Object[0]))); } public void testEmptySetVerifies() throws Exception { @@ -147,22 +147,22 @@ public void testFailureIfNoElementMatches() throws Throwable { final String methodCName = "methodC"; final String[] methodCArgs = { "c1", "c2" }; - final ActiveCall methodCCall = new ActiveCall(methodCName, methodCArgs); + final Invocation methodCInvocation = new Invocation(methodCName, methodCArgs); methodA.setExpectedMatches(methodCName, methodCArgs); methodA.setupAlwaysMatchActiveCall(false); - methodA.activeCall.setExpectNothing(); + methodA.invocation.setExpectNothing(); methodA.setupGetDescription("***methodA-description****"); - methodB.activeCall.setExpected(methodCCall); + methodB.invocation.setExpected(methodCInvocation); methodB.setupAlwaysMatchActiveCall(false); - methodB.activeCall.setExpectNothing(); + methodB.invocation.setExpectNothing(); methodB.setupGetDescription("***methodB-description****"); callSequence.addExpect(methodA); callSequence.addExpect(methodB); try { - callSequence.call(methodCCall); + callSequence.call(methodCInvocation); } catch (AssertionFailedError ex) { AssertMo.assertIncludes("method name is in error message", "methodC", ex.getMessage()); AssertMo.assertIncludes("argument is in error message (1)", methodCArgs[0], ex.getMessage()); @@ -216,6 +216,6 @@ callSequence.addExpect(new CallOnceExpectation(anotherMethodASignature)); assertSame("expected result from method B, as expect has precendence over match", "result2", - callSequence.call(METHOD_A_CALL)); + callSequence.call(METHOD_A_INVOCATION)); } } Index: MockCallable.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/MockCallable.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- MockCallable.java 5 Jul 2003 16:35:20 -0000 1.5 +++ MockCallable.java 6 Jul 2003 23:24:09 -0000 1.6 @@ -6,7 +6,7 @@ import com.mockobjects.ExpectationList; import com.mockobjects.ExpectationValue; import com.mockobjects.ReturnValue; -import com.mockobjects.dynamic.ActiveCall; +import com.mockobjects.dynamic.Invocation; import com.mockobjects.dynamic.Callable; import com.mockobjects.util.Verifier; @@ -14,7 +14,7 @@ final public String name; - public ExpectationValue activeCall = new ExpectationValue("call") ; + public ExpectationValue invocation = new ExpectationValue("call") ; private ReturnValue callResult = new ReturnValue("call.return"); private Throwable callThrow = null; @@ -41,8 +41,8 @@ callThrow = thrown; } - public Object call(ActiveCall anActiveCall) throws Throwable { - activeCall.setActual(anActiveCall); + public Object call(Invocation anInvocation) throws Throwable { + invocation.setActual(anInvocation); if( callThrow != null ) { throw callThrow; @@ -64,9 +64,9 @@ matchesResult.setValue(result); } - public boolean matches(ActiveCall call) { - matchesMethodName.setActual(call.getMethodName()); - matchesArgs.addActualMany(call.args); + public boolean matches(Invocation invocation) { + matchesMethodName.setActual(invocation.getMethodName()); + matchesArgs.addActualMany(invocation.args); matchesCount.inc(); return matchesResult.getBooleanValue(); } |