Update of /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic
In directory sc8-pr-cvs1:/tmp/cvs-serv30075/src/core/test/mockobjects/dynamic
Modified Files:
CallOnceExpectationTest.java CallSignatureTest.java
CallBagTest.java CallableArrayListTest.java
MockCallableFactory.java MockCallableList.java StubTest.java
CoreMockTest.java MockCallableCollection.java
MockCallFactory.java MockConstraintMatcher.java
CallSequenceTest.java MockCallable.java
Removed Files:
CTest.java
Log Message:
First move towards Invokable-based refactoring
Index: CallOnceExpectationTest.java
===================================================================
RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/CallOnceExpectationTest.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- CallOnceExpectationTest.java 9 Jul 2003 02:13:59 -0000 1.6
+++ CallOnceExpectationTest.java 20 Aug 2003 21:51:27 -0000 1.7
@@ -10,10 +10,12 @@
final String RESULT = "result!";
final String METHOD_NAME = "methodName";
- final Object[] ARGS = { "arg1", "arg2" };
- final Invocation INVOCATION = new Invocation(METHOD_NAME, ARGS) ;
+ final Object[] ARG_VALUES = { "arg1", "arg2" };
+ final Class[] ARG_TYPES = { ARG_VALUES[0].getClass(), ARG_VALUES[1].getClass() };
+ final Class RETURN_TYPE = void.class;
+ final Invocation INVOCATION = new Invocation(METHOD_NAME, ARG_TYPES, RETURN_TYPE, ARG_VALUES) ;
- final String DECORATED_DESCRIPTION = DynamicUtil.methodToString( METHOD_NAME, ARGS );
+ final String DECORATED_DESCRIPTION = DynamicUtil.methodToString( METHOD_NAME, ARG_VALUES );
Mock ignoredMock = null;
MockCallable mockCallable = new MockCallable(DECORATED_DESCRIPTION);
@@ -47,14 +49,14 @@
mockCallable.setupCallReturn( RESULT );
mockCallable.setExpectedVerifyCalls(1);
- call.call( INVOCATION );
+ call.invoke( INVOCATION );
call.verify();
mockCallable.verifyExpectations();
}
public void testMatchesDelegated() throws Throwable {
- mockCallable.setExpectedMatches( METHOD_NAME, ARGS );
+ mockCallable.setExpectedMatches( METHOD_NAME, ARG_VALUES );
mockCallable.matches = true;
assertTrue( "returns matches to be true", call.matches( INVOCATION ) );
mockCallable.verifyExpectations();
@@ -64,7 +66,7 @@
mockCallable.callInvocation.setExpected(INVOCATION);
mockCallable.setupCallReturn(RESULT);
- call.call( INVOCATION );
+ call.invoke( INVOCATION );
mockCallable.verifyExpectations();
}
@@ -74,7 +76,7 @@
mockCallable.setupCallReturn(RESULT);
assertTrue( "First time should match", call.matches( INVOCATION ));
- call.call( INVOCATION );
+ call.invoke( INVOCATION );
assertFalse( "Second time should not match", call.matches( INVOCATION ));
}
@@ -82,7 +84,7 @@
mockCallable.setupCallReturn(RESULT);
assertSame( "should return decorated's result",
- RESULT, call.call( INVOCATION ) );
+ RESULT, call.invoke( INVOCATION ) );
mockCallable.verifyExpectations();
}
@@ -93,7 +95,7 @@
mockCallable.setupCallThrow(exception);
try {
- call.call( INVOCATION );
+ call.invoke( 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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- CallSignatureTest.java 9 Jul 2003 02:14:00 -0000 1.3
+++ CallSignatureTest.java 20 Aug 2003 21:51:27 -0000 1.4
@@ -11,7 +11,9 @@
public class CallSignatureTest extends TestCase {
final String METHOD_NAME = "methodName";
final Object[] IGNORED_ARGS = new Object[0];
- final Invocation INVOCATION = new Invocation(METHOD_NAME, IGNORED_ARGS);
+ final Class[] IGNORED_ARG_TYPES = new Class[0];
+ final Class IGNORED_RETURN_TYPE = void.class;
+ final Invocation INVOCATION = new Invocation(METHOD_NAME, IGNORED_ARG_TYPES, IGNORED_RETURN_TYPE, IGNORED_ARGS);
Mock mock = new Mock(DummyInterface.class, "mock");
MockCallable mockCallable = new MockCallable("mock callable");
@@ -29,7 +31,7 @@
mockCallable.callInvocation.setExpected(INVOCATION);
mockCallable.setupCallReturn(result);
- callSignature.call(INVOCATION);
+ callSignature.invoke(INVOCATION);
mockCallable.verifyExpectations();
}
@@ -46,7 +48,7 @@
mockCallable.setExpectedVerifyCalls(1);
mockCallable.setupCallReturn("result");
- callSignature.call(INVOCATION);
+ callSignature.invoke(INVOCATION);
callSignature.verify();
mockCallable.verifyExpectations();
@@ -55,8 +57,8 @@
public void testMultipleCallsSucceed() throws Throwable {
mockCallable.setupCallReturn("result");
- callSignature.call(INVOCATION);
- callSignature.call(INVOCATION);
+ callSignature.invoke(INVOCATION);
+ callSignature.invoke(INVOCATION);
mockCallable.verifyExpectations();
}
@@ -66,7 +68,8 @@
}
public void testCallDoesNotMatchWhenWrongName() throws Throwable {
- assertFalse("call does not match", callSignature.matches(new Invocation("anotherName", IGNORED_ARGS)));
+ assertFalse("call does not match", callSignature.matches(
+ new Invocation("anotherName", IGNORED_ARG_TYPES, IGNORED_RETURN_TYPE, IGNORED_ARGS)));
mockCallable.verifyExpectations();
}
@@ -76,22 +79,26 @@
mockConstraintMatcher.setupMatches(true);
- callSignature.call(INVOCATION);
+ callSignature.invoke(INVOCATION);
assertTrue("matches after first call", callSignature.matches( INVOCATION ));
- callSignature.call(INVOCATION);
+ callSignature.invoke(INVOCATION);
assertTrue("matches after further calls", callSignature.matches( INVOCATION ));
mockCallable.verifyExpectations();
}
- public void testMatchesDelegatesToContraintMatcher()
- throws Throwable {
+ public void testMatchesDelegatesToConstraintMatcher()
+ throws Throwable
+ {
final String[] args = new String[] { "a1", "a2" };
-
+ final Class[] argTypes = new Class[] { String.class, String.class };
+ final Class returnType = void.class;
+
mockConstraintMatcher.addExpectedMatches(args);
mockConstraintMatcher.setupMatches(true);
- assertTrue("matches delegated to constraint matcher", callSignature.matches(new Invocation(METHOD_NAME, args)));
+ assertTrue("matches delegated to constraint matcher", callSignature.matches(
+ new Invocation(METHOD_NAME, argTypes, returnType, args)));
mockConstraintMatcher.verify();
}
Index: CallBagTest.java
===================================================================
RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/CallBagTest.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- CallBagTest.java 9 Aug 2003 13:18:45 -0000 1.11
+++ CallBagTest.java 20 Aug 2003 21:51:27 -0000 1.12
@@ -18,7 +18,7 @@
private MockCallable mockCallable = new MockCallable("mock callable");
private MockCallableList mockExpected = new MockCallableList();
private MockCallableList mockStubs = new MockCallableList();
- private Invocation dummyInvocation = new Invocation("missingMethod", new Object[0]);
+ private Invocation dummyInvocation = new Invocation("missingMethod", new Class[0], void.class, new Object[0]);
private CallBag callBag = new CallBag(mockExpected, mockStubs);
@@ -58,7 +58,7 @@
mockStubs.lastMatchingCallInvocation.setExpected(dummyInvocation);
try {
- callBag.call(dummyInvocation);
+ callBag.invoke(dummyInvocation);
} catch (AssertionFailedError ex) {
AssertMo.assertIncludes("reports empty list", "no methods", ex.getMessage());
verifyAll();
@@ -76,7 +76,7 @@
mockStubs.lastMatchingCallInvocation.setExpected(dummyInvocation);
try {
- callBag.call(dummyInvocation);
+ callBag.invoke(dummyInvocation);
} catch (AssertionFailedError ex) {
AssertMo.assertIncludes("reports missing method", mockCallable.getDescription(), ex.getMessage());
verifyAll();
@@ -94,7 +94,7 @@
mockStubs.lastMatchingCallInvocation.setExpectNothing();
mockCallable.callInvocation.setExpected(dummyInvocation);
- assertEquals("Call should return", "call result", callBag.call(dummyInvocation));
+ assertEquals("Call should return", "call result", callBag.invoke(dummyInvocation));
verifyAll();
}
@@ -108,7 +108,7 @@
mockStubs.lastMatchingCallInvocation.setExpected(dummyInvocation);
mockCallable.callInvocation.setExpected(dummyInvocation);
- assertEquals("Call should return", "call result", callBag.call(dummyInvocation));
+ assertEquals("Call should return", "call result", callBag.invoke(dummyInvocation));
verifyAll();
}
@@ -119,7 +119,7 @@
mockCallable.setupCallThrow(throwable);
try {
- callBag.call(dummyInvocation);
+ callBag.invoke(dummyInvocation);
} catch (Throwable ex) {
Assert.assertEquals("Should have caught throwable", throwable, ex);
return;
Index: CallableArrayListTest.java
===================================================================
RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/CallableArrayListTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- CallableArrayListTest.java 9 Jul 2003 02:13:59 -0000 1.1
+++ CallableArrayListTest.java 20 Aug 2003 21:51:27 -0000 1.2
@@ -3,7 +3,7 @@
*/
package test.mockobjects.dynamic;
-import com.mockobjects.dynamic.Callable;
+import com.mockobjects.dynamic.Invokable;
import com.mockobjects.dynamic.CallableArrayList;
import com.mockobjects.dynamic.CallableList;
import com.mockobjects.dynamic.Invocation;
@@ -11,7 +11,7 @@
import junit.framework.TestCase;
public class CallableArrayListTest extends TestCase {
- private Invocation dummyInvocation = new Invocation("dummy", new Object[0]);
+ private Invocation dummyInvocation = new Invocation("dummy", new Class[0], void.class, new Object[0]);
public CallableArrayListTest(String name) {
super(name);
@@ -66,7 +66,7 @@
allElements.addExpected(otherCallable);
list.apply(new CallableList.Handler() {
- public Callable handle(int index, Callable callable) {
+ public Invokable handle(int index, Invokable callable) {
allElements.addActual(callable);
return null;
}
Index: MockCallableFactory.java
===================================================================
RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/MockCallableFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MockCallableFactory.java 7 Jul 2003 02:24:26 -0000 1.1
+++ MockCallableFactory.java 20 Aug 2003 21:51:27 -0000 1.2
@@ -2,7 +2,7 @@
import com.mockobjects.*;
import com.mockobjects.dynamic.CallableFactory;
-import com.mockobjects.dynamic.Callable;
+import com.mockobjects.dynamic.Invokable;
import com.mockobjects.dynamic.ConstraintMatcher;
public class MockCallableFactory implements CallableFactory{
@@ -28,24 +28,24 @@
myCreateCallExpectationCalls.setExpected(calls);
}
- public void addExpectedCreateCallExpectation(Callable arg0){
+ public void addExpectedCreateCallExpectation(Invokable arg0){
myCreateCallExpectationParameter0Values.addExpected(arg0);
}
- public Callable createCallExpectation(Callable arg0){
+ public Invokable createCallExpectation(Invokable arg0){
myCreateCallExpectationCalls.inc();
myCreateCallExpectationParameter0Values.addActual(arg0);
Object nextReturnValue = myActualCreateCallExpectationReturnValues.getNext();
if (nextReturnValue instanceof ExceptionalReturnValue && ((ExceptionalReturnValue)nextReturnValue).getException() instanceof RuntimeException)
throw (RuntimeException)((ExceptionalReturnValue)nextReturnValue).getException();
- return (Callable) nextReturnValue;
+ return (Invokable) nextReturnValue;
}
public void setupExceptionCreateCallExpectation(Throwable arg){
myActualCreateCallExpectationReturnValues.add(new ExceptionalReturnValue(arg));
}
- public void setupCreateCallExpectation(Callable arg){
+ public void setupCreateCallExpectation(Invokable arg){
myActualCreateCallExpectationReturnValues.add(arg);
}
@@ -59,7 +59,7 @@
myCreateReturnCallableParameter2Values.addExpected(arg2);
}
- public Callable createReturnCallable(String arg0, ConstraintMatcher arg1, Object arg2){
+ public Invokable createReturnCallable(String arg0, ConstraintMatcher arg1, Object arg2){
myCreateReturnCallableCalls.inc();
myCreateReturnCallableParameter0Values.addActual(arg0);
myCreateReturnCallableParameter1Values.addActual(arg1);
@@ -67,14 +67,14 @@
Object nextReturnValue = myActualCreateReturnCallableReturnValues.getNext();
if (nextReturnValue instanceof ExceptionalReturnValue && ((ExceptionalReturnValue)nextReturnValue).getException() instanceof RuntimeException)
throw (RuntimeException)((ExceptionalReturnValue)nextReturnValue).getException();
- return (Callable) nextReturnValue;
+ return (Invokable) nextReturnValue;
}
public void setupExceptionCreateReturnCallable(Throwable arg){
myActualCreateReturnCallableReturnValues.add(new ExceptionalReturnValue(arg));
}
- public void setupCreateReturnCallable(Callable arg){
+ public void setupCreateReturnCallable(Invokable arg){
myActualCreateReturnCallableReturnValues.add(arg);
}
@@ -88,7 +88,7 @@
myCreateThrowableCallableParameter2Values.addExpected(arg2);
}
- public Callable createThrowableCallable(String arg0, ConstraintMatcher arg1, Throwable arg2){
+ public Invokable createThrowableCallable(String arg0, ConstraintMatcher arg1, Throwable arg2){
myCreateThrowableCallableCalls.inc();
myCreateThrowableCallableParameter0Values.addActual(arg0);
myCreateThrowableCallableParameter1Values.addActual(arg1);
@@ -96,14 +96,14 @@
Object nextReturnValue = myActualCreateThrowableCallableReturnValues.getNext();
if (nextReturnValue instanceof ExceptionalReturnValue && ((ExceptionalReturnValue)nextReturnValue).getException() instanceof RuntimeException)
throw (RuntimeException)((ExceptionalReturnValue)nextReturnValue).getException();
- return (Callable) nextReturnValue;
+ return (Invokable) nextReturnValue;
}
public void setupExceptionCreateThrowableCallable(Throwable arg){
myActualCreateThrowableCallableReturnValues.add(new ExceptionalReturnValue(arg));
}
- public void setupCreateThrowableCallable(Callable arg){
+ public void setupCreateThrowableCallable(Invokable arg){
myActualCreateThrowableCallableReturnValues.add(arg);
}
@@ -116,21 +116,21 @@
myCreateVoidCallableParameter1Values.addExpected(arg1);
}
- public Callable createVoidCallable(String arg0, ConstraintMatcher arg1){
+ public Invokable createVoidCallable(String arg0, ConstraintMatcher arg1){
myCreateVoidCallableCalls.inc();
myCreateVoidCallableParameter0Values.addActual(arg0);
myCreateVoidCallableParameter1Values.addActual(arg1);
Object nextReturnValue = myActualCreateVoidCallableReturnValues.getNext();
if (nextReturnValue instanceof ExceptionalReturnValue && ((ExceptionalReturnValue)nextReturnValue).getException() instanceof RuntimeException)
throw (RuntimeException)((ExceptionalReturnValue)nextReturnValue).getException();
- return (Callable) nextReturnValue;
+ return (Invokable) nextReturnValue;
}
public void setupExceptionCreateVoidCallable(Throwable arg){
myActualCreateVoidCallableReturnValues.add(new ExceptionalReturnValue(arg));
}
- public void setupCreateVoidCallable(Callable arg){
+ public void setupCreateVoidCallable(Invokable arg){
myActualCreateVoidCallableReturnValues.add(arg);
}
Index: MockCallableList.java
===================================================================
RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/MockCallableList.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MockCallableList.java 9 Jul 2003 02:14:00 -0000 1.1
+++ MockCallableList.java 20 Aug 2003 21:51:27 -0000 1.2
@@ -3,7 +3,7 @@
import com.mockobjects.ExpectationCounter;
import com.mockobjects.ExpectationValue;
import com.mockobjects.ExpectationList;
-import com.mockobjects.dynamic.Callable;
+import com.mockobjects.dynamic.Invokable;
import com.mockobjects.dynamic.CallableList;
import com.mockobjects.dynamic.Invocation;
import com.mockobjects.util.Verifier;
@@ -16,12 +16,12 @@
public ExpectationList addedCallables = new ExpectationList("added callables");
public ExpectationCounter clearCalls = new ExpectationCounter("clear calls");
public ExpectationCounter verifyCalls = new ExpectationCounter("verify calls");
- public Callable lastMatchingCall;
- public Callable applied;
- public Callable apply;
+ public Invokable lastMatchingCall;
+ public Invokable applied;
+ public Invokable apply;
public boolean isEmpty;
- public void add(Callable callable) {
+ public void add(Invokable callable) {
addedCallables.addActual(callable);
}
@@ -29,7 +29,7 @@
return isEmpty;
}
- public Callable get(int index) {
+ public Invokable get(int index) {
return null;
}
@@ -41,16 +41,16 @@
clearCalls.inc();
}
- public Callable firstMatchingCall(Invocation invocation) {
+ public Invokable firstMatchingCall(Invocation invocation) {
return null;
}
- public Callable lastMatchingCall(Invocation invocation) {
+ public Invokable lastMatchingCall(Invocation invocation) {
lastMatchingCallInvocation.setActual(invocation);
return lastMatchingCall;
}
- public Callable apply(CallableList.Handler handler) {
+ public Invokable apply(CallableList.Handler handler) {
handler.handle(0, applied);
return null;
}
Index: StubTest.java
===================================================================
RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/StubTest.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- StubTest.java 6 Jul 2003 23:24:09 -0000 1.5
+++ StubTest.java 20 Aug 2003 21:51:27 -0000 1.6
@@ -15,19 +15,19 @@
super(name);
}
- Invocation invocation = new Invocation("ignoredName", new Object[0]);
+ Invocation invocation = new Invocation("ignoredName", new Class[0], void.class, new Object[0]);
public void testReturnStub() throws Throwable {
final String RESULT = "result";
- assertSame( "Should be the same result object", RESULT, new ReturnStub(RESULT).call( invocation) );
+ assertSame( "Should be the same result object", RESULT, new ReturnStub(RESULT).invoke( invocation) );
}
public void testThrowStub() {
final Throwable throwable = new DummyThrowable();
try {
- new ThrowStub(throwable).call( invocation );
+ new ThrowStub(throwable).invoke( invocation );
}
catch( Throwable t ) {
assertSame( "Should be the same throwable", throwable, t );
Index: CoreMockTest.java
===================================================================
RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/CoreMockTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- CoreMockTest.java 11 Aug 2003 21:25:07 -0000 1.3
+++ CoreMockTest.java 20 Aug 2003 21:51:27 -0000 1.4
@@ -138,11 +138,11 @@
Verifier.verifyObject(this);
}
- public void testMockNameFromClass() throws Exception {
+ public void testGeneratesMockNameFromInterfaceNameIfNoNameSpecified() throws Exception {
assertEquals("mockString", CoreMock.mockNameFromClass(String.class));
}
- public void testMockToStringContainsName() {
+ public void testResultOfToStringContainsName() {
AssertMo.assertIncludes("result of toString() should include name", MOCK_NAME, coreMock.toString());
}
Index: MockCallableCollection.java
===================================================================
RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/MockCallableCollection.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- MockCallableCollection.java 9 Aug 2003 13:19:25 -0000 1.6
+++ MockCallableCollection.java 20 Aug 2003 21:51:27 -0000 1.7
@@ -2,7 +2,7 @@
import com.mockobjects.*;
import com.mockobjects.dynamic.Invocation;
-import com.mockobjects.dynamic.Callable;
+import com.mockobjects.dynamic.Invokable;
import com.mockobjects.dynamic.CallableCollection;
import com.mockobjects.util.Verifier;
import junit.framework.AssertionFailedError;
@@ -31,19 +31,19 @@
resetCalls.inc();
}
- public void addStub(Callable callable) {
+ public void addStub(Invokable callable) {
matchedCallables.addActual(callable);
}
- public void addExpectedMatch(Callable callable) {
+ public void addExpectedMatch(Invokable callable) {
matchedCallables.addExpected(callable);
}
- public void addExpect(Callable callable) {
+ public void addExpect(Invokable callable) {
expectedCallables.addActual(callable);
}
- public void addExpectedExpect(Callable callable) {
+ public void addExpectedExpect(Invokable callable) {
expectedCallables.addExpected(callable);
}
@@ -59,7 +59,7 @@
public boolean matches(Invocation invocation) {
myMatchesCalls.inc();
myMatchesParameter0Values.addActual(invocation.getMethodName());
- myMatchesParameter1Values.addActual(invocation.args);
+ myMatchesParameter1Values.addActual(invocation.getParameterValues().toArray());
Object nextReturnValue = myActualMatchesReturnValues.getNext();
@@ -95,10 +95,10 @@
myCallArguments.addExpectedMany(args);
}
- public Object call(Invocation invocation) throws Throwable {
+ public Object invoke(Invocation invocation) throws Throwable {
myCallCalls.inc();
myCallMethodNames.addActual(invocation.getMethodName());
- myCallArguments.addActualMany(invocation.args);
+ myCallArguments.addActualMany(invocation.getParameterValues().toArray());
if (callException != null) throw callException;
return callResult;
Index: MockCallFactory.java
===================================================================
RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/MockCallFactory.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- MockCallFactory.java 6 Jul 2003 02:31:37 -0000 1.5
+++ MockCallFactory.java 20 Aug 2003 21:51:27 -0000 1.6
@@ -2,7 +2,7 @@
import com.mockobjects.*;
import com.mockobjects.dynamic.CallableFactory;
-import com.mockobjects.dynamic.Callable;
+import com.mockobjects.dynamic.Invokable;
import com.mockobjects.dynamic.ConstraintMatcher;
import com.mockobjects.util.Verifier;
@@ -22,31 +22,31 @@
private ExpectationList myCreateCallSignatureParameter1Values = new ExpectationList("MockCallFactory.createCallMatch(String, ConstraintMatcher, Callable) com.mockobjects.dynamic.ConstraintMatcher");
private ExpectationList myCreateCallSignatureParameter2Values = new ExpectationList("MockCallFactory.createCallMatch(String, ConstraintMatcher, Callable) com.mockobjects.dynamic.Callable");
- private Callable createReturnStub(Object arg0){
+ private Invokable createReturnStub(Object arg0){
createReturnStub.setActual(arg0);
Object nextReturnValue = myActualCreateReturnStubReturnValues.getNext();
if (nextReturnValue instanceof ExceptionalReturnValue && ((ExceptionalReturnValue)nextReturnValue).getException() instanceof RuntimeException)
throw (RuntimeException)((ExceptionalReturnValue)nextReturnValue).getException();
- return (Callable) nextReturnValue;
+ return (Invokable) nextReturnValue;
}
- public void setupCreateReturnStub(Callable arg){
+ public void setupCreateReturnStub(Invokable arg){
myActualCreateReturnStubReturnValues.add(arg);
}
- private Callable createThrowStub(Throwable arg0){
+ private Invokable createThrowStub(Throwable arg0){
createThrowStub.setActual(arg0);
Object nextReturnValue = myActualCreateThrowStubReturnValues.getNext();
if (nextReturnValue instanceof ExceptionalReturnValue && ((ExceptionalReturnValue)nextReturnValue).getException() instanceof RuntimeException)
throw (RuntimeException)((ExceptionalReturnValue)nextReturnValue).getException();
- return (Callable) nextReturnValue;
+ return (Invokable) nextReturnValue;
}
public void setupExceptionCreateThrowStub(Throwable arg){
myActualCreateThrowStubReturnValues.add(new ExceptionalReturnValue(arg));
}
- public void setupCreateThrowStub(Callable arg){
+ public void setupCreateThrowStub(Invokable arg){
myActualCreateThrowStubReturnValues.add(arg);
}
@@ -54,19 +54,19 @@
myCreateVoidStubCalls.setExpected(calls);
}
- private Callable createVoidStub(){
+ private Invokable createVoidStub(){
myCreateVoidStubCalls.inc();
Object nextReturnValue = myActualCreateVoidStubReturnValues.getNext();
if (nextReturnValue instanceof ExceptionalReturnValue && ((ExceptionalReturnValue)nextReturnValue).getException() instanceof RuntimeException)
throw (RuntimeException)((ExceptionalReturnValue)nextReturnValue).getException();
- return (Callable) nextReturnValue;
+ return (Invokable) nextReturnValue;
}
public void setupExceptionCreateVoidStub(Throwable arg){
myActualCreateVoidStubReturnValues.add(new ExceptionalReturnValue(arg));
}
- public void setupCreateVoidStub(Callable arg){
+ public void setupCreateVoidStub(Invokable arg){
myActualCreateVoidStubReturnValues.add(arg);
}
@@ -74,24 +74,24 @@
myCreateCallExpectationCalls.setExpected(calls);
}
- public void addExpectedCreateCallExpectation(Callable arg0){
+ public void addExpectedCreateCallExpectation(Invokable arg0){
myCreateCallExpectationParameter0Values.addExpected(arg0);
}
- public Callable createCallExpectation(Callable arg0){
+ public Invokable createCallExpectation(Invokable arg0){
myCreateCallExpectationCalls.inc();
myCreateCallExpectationParameter0Values.addActual(arg0);
Object nextReturnValue = myActualCreateCallExpectationReturnValues.getNext();
if (nextReturnValue instanceof ExceptionalReturnValue && ((ExceptionalReturnValue)nextReturnValue).getException() instanceof RuntimeException)
throw (RuntimeException)((ExceptionalReturnValue)nextReturnValue).getException();
- return (Callable) nextReturnValue;
+ return (Invokable) nextReturnValue;
}
public void setupExceptionCreateCallExpectation(Throwable arg){
myActualCreateCallExpectationReturnValues.add(new ExceptionalReturnValue(arg));
}
- public void setupCreateCallExpectation(Callable arg){
+ public void setupCreateCallExpectation(Invokable arg){
myActualCreateCallExpectationReturnValues.add(arg);
}
@@ -99,13 +99,13 @@
myCreateCallSignatureCalls.setExpected(calls);
}
- public void addExpectedCreateCallSignature(String arg0, ConstraintMatcher arg1, Callable arg2){
+ public void addExpectedCreateCallSignature(String arg0, ConstraintMatcher arg1, Invokable arg2){
myCreateCallSignatureParameter0Values.addExpected(arg0);
myCreateCallSignatureParameter1Values.addExpectedMany(arg1.getConstraints());
myCreateCallSignatureParameter2Values.addExpected(arg2);
}
- private Callable createCallSignature(String arg0, ConstraintMatcher arg1, Callable arg2){
+ private Invokable createCallSignature(String arg0, ConstraintMatcher arg1, Invokable arg2){
myCreateCallSignatureCalls.inc();
myCreateCallSignatureParameter0Values.addActual(arg0);
myCreateCallSignatureParameter1Values.addActualMany(arg1.getConstraints());
@@ -113,27 +113,27 @@
Object nextReturnValue = myActualCreateCallSignatureReturnValues.getNext();
if (nextReturnValue instanceof ExceptionalReturnValue && ((ExceptionalReturnValue)nextReturnValue).getException() instanceof RuntimeException)
throw (RuntimeException)((ExceptionalReturnValue)nextReturnValue).getException();
- return (Callable) nextReturnValue;
+ return (Invokable) nextReturnValue;
}
public void setupExceptionCreateCallSignature(Throwable arg){
myActualCreateCallSignatureReturnValues.add(new ExceptionalReturnValue(arg));
}
- public void setupCreateCallSignature(Callable arg){
+ public void setupCreateCallSignature(Invokable arg){
myActualCreateCallSignatureReturnValues.add(arg);
}
- public Callable createReturnCallable(String methodName, ConstraintMatcher constraints, Object result) {
+ public Invokable createReturnCallable(String methodName, ConstraintMatcher constraints, Object result) {
return createCallSignature(methodName, constraints, createReturnStub(result));
}
- public Callable createThrowableCallable(String methodName, ConstraintMatcher constraints, Throwable throwable) {
+ public Invokable createThrowableCallable(String methodName, ConstraintMatcher constraints, Throwable throwable) {
return createCallSignature(methodName, constraints, createThrowStub(throwable));
}
- public Callable createVoidCallable(String methodName, ConstraintMatcher constraints) {
+ public Invokable createVoidCallable(String methodName, ConstraintMatcher constraints) {
return createCallSignature(methodName, constraints, createVoidStub());
}
Index: MockConstraintMatcher.java
===================================================================
RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/MockConstraintMatcher.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- MockConstraintMatcher.java 18 May 2003 20:59:39 -0000 1.2
+++ MockConstraintMatcher.java 20 Aug 2003 21:51:27 -0000 1.3
@@ -15,12 +15,12 @@
}
public void addExpectedMatches(Object[] arg0){
- myMatchesParameter0Values.addExpected(arg0);
+ myMatchesParameter0Values.addExpectedMany(arg0);
}
public boolean matches(Object[] arg0){
myMatchesCalls.inc();
- myMatchesParameter0Values.addActual(arg0);
+ myMatchesParameter0Values.addActualMany(arg0);
Object nextReturnValue = myActualMatchesReturnValues.getNext();
if (nextReturnValue instanceof ExceptionalReturnValue && ((ExceptionalReturnValue)nextReturnValue).getException() instanceof RuntimeException)
throw (RuntimeException)((ExceptionalReturnValue)nextReturnValue).getException();
Index: CallSequenceTest.java
===================================================================
RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/CallSequenceTest.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- CallSequenceTest.java 9 Aug 2003 13:19:25 -0000 1.14
+++ CallSequenceTest.java 20 Aug 2003 21:51:27 -0000 1.15
@@ -7,7 +7,7 @@
import com.mockobjects.dynamic.C;
import com.mockobjects.dynamic.CallSignature;
import com.mockobjects.dynamic.CallSequence;
-import com.mockobjects.dynamic.Callable;
+import com.mockobjects.dynamic.Invokable;
import com.mockobjects.dynamic.CallOnceExpectation;
import com.mockobjects.dynamic.ReturnStub;
@@ -24,11 +24,13 @@
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 Invocation METHOD_A_INVOCATION = new Invocation(METHOD_A_NAME, METHOD_A_ARGS);
+ final Class[] METHOD_A_ARG_TYPES = new Class[] { String.class, String.class };
+ final Invocation METHOD_A_INVOCATION = new Invocation(METHOD_A_NAME, METHOD_A_ARG_TYPES, void.class, 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 Invocation METHOD_B_INVOCATION = new Invocation(METHOD_B_NAME, METHOD_B_ARGS);
+ final Class[] METHOD_B_ARG_TYPES = new Class[] { String.class, String.class };
+ final Invocation METHOD_B_INVOCATION = new Invocation(METHOD_B_NAME, METHOD_B_ARG_TYPES, void.class, METHOD_B_ARGS);
private CallSequence callSequence = new CallSequence();
private MockCallable methodA = new MockCallable("method a");
@@ -48,7 +50,7 @@
callSequence.addExpect(mockCallable);
try {
- callSequence.call(new Invocation("hello", new String[0]));
+ callSequence.invoke(new Invocation("hello", new Class[0], void.class, new String[0]));
} catch (Throwable ex) {
assertSame("exception is caught by mock", throwable, ex);
}
@@ -56,7 +58,7 @@
public void testCallFailsOnEmptyList() throws Throwable {
try {
- callSequence.call(new Invocation("missingMethod", new Object[0]));
+ callSequence.invoke(new Invocation("missingMethod", new Class[0], void.class, new Object[0]));
} catch (AssertionFailedError ex) {
AssertMo.assertIncludes("reports empty set in error message", "no methods", ex.getMessage());
@@ -70,10 +72,10 @@
mockCallable.matches = true;
mockCallable.setupCallReturn(METHOD_A_RESULT);
callSequence.addExpect(mockCallable);
- callSequence.call(new Invocation("willdefinitelyMatch", new Object[0]));
+ callSequence.invoke(new Invocation("willdefinitelyMatch", new Class[0], void.class, new Object[0]));
try {
- callSequence.call(new Invocation("oneMethodTooMany", new Object[0]));
+ callSequence.invoke(new Invocation("oneMethodTooMany", new Class[0], void.class, new Object[0]));
} catch (AssertionFailedError ex) {
AssertMo.assertIncludes("reports one method call too many", "too many", ex.getMessage());
@@ -94,7 +96,7 @@
callSequence.addExpect(methodA);
callSequence.addExpect(methodB);
- assertSame("expected result from method A", METHOD_A_RESULT, callSequence.call(METHOD_A_INVOCATION));
+ assertSame("expected result from method A", METHOD_A_RESULT, callSequence.invoke(METHOD_A_INVOCATION));
methodA.verifyExpectations();
methodB.verifyExpectations();
@@ -108,7 +110,7 @@
callSequence.addExpect(methodB);
try {
- assertSame("expected result from method B", METHOD_B_RESULT, callSequence.call(METHOD_B_INVOCATION));
+ assertSame("expected result from method B", METHOD_B_RESULT, callSequence.invoke(METHOD_B_INVOCATION));
} catch (AssertionFailedError ex) {
String message = ex.getMessage();
AssertMo.assertIncludes("Should have expected error message", "Unexpected call: methodB", message);
@@ -134,7 +136,7 @@
callSequence.addExpect(mockCallable);
- assertSame("result is returned by mock", result, callSequence.call(new Invocation("method", new Object[0])));
+ assertSame("result is returned by mock", result, callSequence.invoke(new Invocation("method", new Class[0], void.class, new Object[0])));
}
public void testEmptySetVerifies() throws Exception {
@@ -144,7 +146,9 @@
public void testFailureIfNoElementMatches() throws Throwable {
final String methodCName = "methodC";
final String[] methodCArgs = { "c1", "c2" };
- final Invocation methodCInvocation = new Invocation(methodCName, methodCArgs);
+ final Class[] methodCArgTypes = { String.class, String.class };
+ final Class methodCReturnType = void.class;
+ final Invocation methodCInvocation = new Invocation(methodCName, methodCArgTypes, methodCReturnType, methodCArgs);
methodA.setExpectedMatches(methodCName, methodCArgs);
methodA.matches = false;
@@ -157,7 +161,7 @@
callSequence.addExpect(methodB);
try {
- callSequence.call(methodCInvocation);
+ callSequence.invoke(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());
@@ -204,13 +208,13 @@
public void testExpectOverridesMatch() throws Throwable {
- Callable methodASignature = new CallSignature(METHOD_A_NAME,METHOD_A_CONSTRAINTS, new ReturnStub("result1"));
- Callable anotherMethodASignature = new CallSignature(METHOD_A_NAME,METHOD_A_CONSTRAINTS, new ReturnStub("result2"));
+ Invokable methodASignature = new CallSignature(METHOD_A_NAME,METHOD_A_CONSTRAINTS, new ReturnStub("result1"));
+ Invokable anotherMethodASignature = new CallSignature(METHOD_A_NAME,METHOD_A_CONSTRAINTS, new ReturnStub("result2"));
callSequence.addStub(methodASignature);
callSequence.addExpect(new CallOnceExpectation(anotherMethodASignature));
assertSame("expected result from method B, as expect has precendence over match", "result2",
- callSequence.call(METHOD_A_INVOCATION));
+ callSequence.invoke(METHOD_A_INVOCATION));
}
}
Index: MockCallable.java
===================================================================
RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/MockCallable.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- MockCallable.java 9 Jul 2003 02:14:00 -0000 1.7
+++ MockCallable.java 20 Aug 2003 21:51:27 -0000 1.8
@@ -7,10 +7,10 @@
import com.mockobjects.ExpectationValue;
import com.mockobjects.ReturnValue;
import com.mockobjects.dynamic.Invocation;
-import com.mockobjects.dynamic.Callable;
+import com.mockobjects.dynamic.Invokable;
import com.mockobjects.util.Verifier;
-public class MockCallable implements Callable {
+public class MockCallable implements Invokable {
final public String name;
@@ -39,7 +39,7 @@
callThrow = thrown;
}
- public Object call(Invocation anInvocation) throws Throwable {
+ public Object invoke(Invocation anInvocation) throws Throwable {
callInvocation.setActual(anInvocation);
if( callThrow != null ) {
@@ -60,7 +60,7 @@
public boolean matches(Invocation invocation) {
matchesMethodName.setActual(invocation.getMethodName());
- matchesArgs.addActualMany(invocation.args);
+ matchesArgs.addActualMany(invocation.getParameterValues().toArray());
matchesCount.inc();
return matches;
}
--- CTest.java DELETED ---
|