|
From: Tim M. <ma...@us...> - 2003-05-20 00:05:27
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic
In directory sc8-pr-cvs1:/tmp/cvs-serv10050/core/test/mockobjects/dynamic
Modified Files:
CallBagTest.java CallSequenceTest.java
Added Files:
CallOnceExpectationTest.java
Removed Files:
ExpectedCallTest.java
Log Message:
Internal class rename - ExpectedCall to more specific
CallOnceExpectation
--- NEW FILE: CallOnceExpectationTest.java ---
package test.mockobjects.dynamic;
import com.mockobjects.dynamic.*;
import com.mockobjects.util.*;
import junit.framework.*;
public class CallOnceExpectationTest extends TestCase {
final String RESULT = "result!";
final String METHOD_NAME = "methodName";
final Object[] ARGS = { "arg1", "arg2" };
final String DECORATED_DESCRIPTION = DynamicUtil.methodToString( METHOD_NAME, ARGS );
Mock ignoredMock = null;
MockCallable mockCallable = new MockCallable();
CallOnceExpectation call = new CallOnceExpectation( mockCallable );
public CallOnceExpectationTest(String name) {
super(name);
}
public void setUp() {
mockCallable.setupGetDescription(DECORATED_DESCRIPTION);
}
public void testDescription() {
AssertMo.assertIncludes( "should contain decorated's description",
DECORATED_DESCRIPTION, call.getDescription() );
AssertMo.assertIncludes( "should say that decorated call has called status",
"called", call.getDescription() );
}
public void testDoesNotVerifyIfNotCalled() {
try {
call.verify();
}
catch( AssertionFailedError ex ) {
AssertMo.assertIncludes( "should include description of expected call",
DECORATED_DESCRIPTION, ex.getMessage() );
return;
}
fail( "verify did not fail when expected call not called");
}
public void testVerifiesIfCalled() throws Throwable {
mockCallable.setupCallReturn( RESULT );
mockCallable.setExpectedVerifyCalls(1);
call.call( ignoredMock, METHOD_NAME, ARGS );
call.verify();
mockCallable.verifyExpectations();
}
public void testMatchesDelegated() throws Throwable {
mockCallable.setExpectedMatches( METHOD_NAME, ARGS );
mockCallable.setupMatchesReturn(true);
assertTrue( "returns matches to be true", call.matches( METHOD_NAME, ARGS ) );
mockCallable.verifyExpectations();
}
public void testCallArgumentsPassedThrough() throws Throwable {
mockCallable.setExpectedCall(ignoredMock, METHOD_NAME, ARGS);
mockCallable.setupCallReturn(RESULT);
call.call( ignoredMock, METHOD_NAME, ARGS );
mockCallable.verifyExpectations();
}
public void testDoesNotMatchAfterMethodCalled() throws Throwable
{
mockCallable.setupMatchesReturn(true);
mockCallable.setupCallReturn(RESULT);
assertTrue( "First time should match", call.matches(METHOD_NAME, ARGS));
call.call(ignoredMock, METHOD_NAME, ARGS);
assertFalse( "Second time should not match", call.matches(METHOD_NAME, ARGS));
}
public void testDecoratedResultPassedThrough() throws Throwable {
mockCallable.setupCallReturn(RESULT);
assertSame( "should return decorated's result",
RESULT, call.call( ignoredMock, METHOD_NAME, ARGS ) );
mockCallable.verifyExpectations();
}
public void testDecoratedExceptionPassedThrough() throws Throwable {
final Throwable exception = new DummyThrowable();
mockCallable.setupCallThrow(exception);
try {
call.call( ignoredMock, METHOD_NAME, ARGS );
fail("expected decorated's throwable to be thrown");
}
catch( DummyThrowable ex ) {
// expected
}
mockCallable.verifyExpectations();
}
}
Index: CallBagTest.java
===================================================================
RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/CallBagTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- CallBagTest.java 19 May 2003 23:37:49 -0000 1.3
+++ CallBagTest.java 20 May 2003 00:05:24 -0000 1.4
@@ -63,7 +63,7 @@
Callable anotherMethodASignature = new CallSignature(METHOD_A_NAME,METHOD_A_CONSTRAINTS, new ReturnStub("result2"));
callSet.addMatch(methodASignature);
- callSet.addExpect(new ExpectedCall(anotherMethodASignature));
+ callSet.addExpect(new CallOnceExpectation(anotherMethodASignature));
assertSame("expected result from method B, as expect has precendence over match", "result2",
callSet.call(unusedMock, METHOD_A_NAME, METHOD_A_ARGS));
Index: CallSequenceTest.java
===================================================================
RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/CallSequenceTest.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- CallSequenceTest.java 19 May 2003 23:37:49 -0000 1.7
+++ CallSequenceTest.java 20 May 2003 00:05:24 -0000 1.8
@@ -8,7 +8,7 @@
import com.mockobjects.dynamic.CallSignature;
import com.mockobjects.dynamic.CallSequence;
import com.mockobjects.dynamic.Callable;
-import com.mockobjects.dynamic.ExpectedCall;
+import com.mockobjects.dynamic.CallOnceExpectation;
import com.mockobjects.dynamic.Mock;
import com.mockobjects.dynamic.ReturnStub;
@@ -210,7 +210,7 @@
Callable anotherMethodASignature = new CallSignature(METHOD_A_NAME,METHOD_A_CONSTRAINTS, new ReturnStub("result2"));
callSequence.addMatch(methodASignature);
- callSequence.addExpect(new ExpectedCall(anotherMethodASignature));
+ callSequence.addExpect(new CallOnceExpectation(anotherMethodASignature));
assertSame("expected result from method B, as expect has precendence over match", "result2",
callSequence.call(unusedMock, METHOD_A_NAME, METHOD_A_ARGS));
--- ExpectedCallTest.java DELETED ---
|