Update of /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic
In directory sc8-pr-cvs1:/tmp/cvs-serv345/src/core/test/mockobjects/dynamic
Modified Files:
InvocationTest.java InvocationMockerTest.java StubTest.java
CoreMockTest.java
Removed Files:
DynamicMockErrorTest.java
Log Message:
Added better error reporting. Shows invocation and invokables.
Index: InvocationTest.java
===================================================================
RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/InvocationTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- InvocationTest.java 29 Oct 2003 22:11:35 -0000 1.2
+++ InvocationTest.java 18 Nov 2003 23:12:52 -0000 1.3
@@ -19,6 +19,7 @@
return "hello, world";
}
+ final Class DECLARING_CLASS = Void.class;
final String METHOD_NAME = "exampleMethod";
final Class[] ARG_TYPES = { int.class, boolean.class };
final Class RETURN_TYPE = String.class;
@@ -30,7 +31,7 @@
}
public void testCanBeConstructedWithExplicitCallDetails() {
- Invocation call = new Invocation( METHOD_NAME, ARG_TYPES,
+ Invocation call = new Invocation( DECLARING_CLASS, METHOD_NAME, ARG_TYPES,
RETURN_TYPE, ARG_VALUES );
assertEquals( "name", METHOD_NAME, call.getMethodName() );
@@ -58,7 +59,7 @@
}
public void testConstructorInterpretsNullParameterValueArrayAsZeroArguments() {
- Invocation call = new Invocation( METHOD_NAME, new Class[0],
+ Invocation call = new Invocation( DECLARING_CLASS, METHOD_NAME, new Class[0],
RETURN_TYPE, null );
assertEquals( "expected no parameters values",
@@ -66,22 +67,22 @@
}
public void testTestsForEqualityOnMethodSignatureAndArguments() {
- Invocation call1 = new Invocation(
+ Invocation call1 = new Invocation(DECLARING_CLASS,
METHOD_NAME, ARG_TYPES, RETURN_TYPE,
ARG_VALUES );
- Invocation call2 = new Invocation(
+ Invocation call2 = new Invocation( DECLARING_CLASS,
METHOD_NAME, ARG_TYPES, RETURN_TYPE,
ARG_VALUES );
- Invocation differentName = new Invocation(
+ Invocation differentName = new Invocation( DECLARING_CLASS,
"other" + METHOD_NAME, ARG_TYPES, RETURN_TYPE,
ARG_VALUES );
- Invocation differentReturnType = new Invocation(
+ Invocation differentReturnType = new Invocation( DECLARING_CLASS,
"other" + METHOD_NAME, ARG_TYPES, int.class,
ARG_VALUES );
- Invocation differentArgTypes = new Invocation(
+ Invocation differentArgTypes = new Invocation( DECLARING_CLASS,
"other" + METHOD_NAME, new Class[]{double.class}, RETURN_TYPE,
ARG_VALUES );
- Invocation differentArgValues = new Invocation(
+ Invocation differentArgValues = new Invocation( DECLARING_CLASS,
"other" + METHOD_NAME, ARG_TYPES, RETURN_TYPE,
new Object[] { new Integer(1), Boolean.FALSE } );
@@ -102,10 +103,10 @@
}
public void testFollowsEqualsHashcodeProtocol() {
- Invocation call1 = new Invocation(
+ Invocation call1 = new Invocation( DECLARING_CLASS,
METHOD_NAME, ARG_TYPES, RETURN_TYPE,
ARG_VALUES );
- Invocation call2 = new Invocation(
+ Invocation call2 = new Invocation( DECLARING_CLASS,
METHOD_NAME, ARG_TYPES, RETURN_TYPE,
ARG_VALUES );
@@ -115,7 +116,7 @@
public void testToStringWithTwoArguments() throws Exception {
Invocation invocation =
- new Invocation("methodName", new Class[] { String.class, String.class} , void.class,
+ new Invocation(DECLARING_CLASS, "methodName", new Class[] { String.class, String.class} , void.class,
new Object[] { "arg1", "arg2" } );
String result = invocation.toString();
@@ -126,7 +127,7 @@
public void testToStringWithStringArray() throws Exception {
Invocation invocation =
- new Invocation("methodName", new Class[] { String[].class} , void.class,
+ new Invocation(DECLARING_CLASS, "methodName", new Class[] { String[].class} , void.class,
new Object[] { new String[] { "arg1", "arg2" } } );
String result = invocation.toString();
@@ -136,7 +137,7 @@
public void testToStringWithPrimitiveArray() throws Exception {
Invocation invocation =
- new Invocation("methodName", new Class[] { long[].class} , void.class,
+ new Invocation(DECLARING_CLASS, "methodName", new Class[] { long[].class} , void.class,
new Object[] { new long[] { 1, 2 } } );
String result = invocation.toString();
@@ -148,7 +149,7 @@
Mock mockDummyInterface = new Mock(DummyInterface.class, "DummyMock");
Invocation invocation =
- new Invocation("methodName", new Class[] { String.class, DummyInterface.class} , void.class,
+ new Invocation(DECLARING_CLASS, "methodName", new Class[] { String.class, DummyInterface.class} , void.class,
new Object[] { "arg1", mockDummyInterface.proxy() } );
String result = invocation.toString();
@@ -159,7 +160,7 @@
public void testMethodToStringWithNullArg() throws Exception {
Invocation invocation =
- new Invocation("methodName", new Class[] { String.class }, void.class,
+ new Invocation(DECLARING_CLASS, "methodName", new Class[] { String.class }, void.class,
new Object[] { null });
String result = invocation.toString();
Index: InvocationMockerTest.java
===================================================================
RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/InvocationMockerTest.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- InvocationMockerTest.java 11 Nov 2003 06:47:07 -0000 1.7
+++ InvocationMockerTest.java 18 Nov 2003 23:12:52 -0000 1.8
@@ -18,11 +18,11 @@
public boolean matches(Invocation invocation) {
return true;
}
+ public StringBuffer writeTo(StringBuffer buffer) { return buffer.append("match all"); }
};
private InvocationMatcher matchNone = new StatelessInvocationMatcher() {
- public boolean matches(Invocation invocation) {
- return false;
- }
+ public boolean matches(Invocation invocation) { return false; }
+ public StringBuffer writeTo(StringBuffer buffer) { return buffer.append("match none"); }
};
public class MockInvocationMatcher implements InvocationMatcher {
@@ -37,6 +37,8 @@
public void invoked(Invocation invocation) {
this.invocation.setActual(invocation);
}
+
+ public StringBuffer writeTo(StringBuffer buffer) { return buffer.append("Mock matcher"); }
public void verify() {
verifyCalls.inc();
@@ -54,10 +56,14 @@
public String getDescription() {
return "MockStub";
}
+
+ public StringBuffer writeTo(StringBuffer buffer) {
+ throw new AssertionError("should implement writeTo");
+ }
};
private Invocation exampleInvocation =
- new Invocation("example", new Class[] { String.class, String.class }, Void.class,
+ new Invocation(Void.class, "example", new Class[] { String.class, String.class }, Void.class,
new Object[] { "arg1", "arg2"} );
Index: StubTest.java
===================================================================
RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/StubTest.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- StubTest.java 29 Oct 2003 22:11:36 -0000 1.8
+++ StubTest.java 18 Nov 2003 23:12:52 -0000 1.9
@@ -15,7 +15,7 @@
super(name);
}
- Invocation invocation = new Invocation("ignoredName", new Class[0], void.class, new Object[0]);
+ Invocation invocation = new Invocation(Void.class, "ignoredName", new Class[0], void.class, new Object[0]);
public void testReturnStub() throws Throwable {
final String RESULT = "result";
Index: CoreMockTest.java
===================================================================
RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/CoreMockTest.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- CoreMockTest.java 2 Oct 2003 22:55:32 -0000 1.9
+++ CoreMockTest.java 18 Nov 2003 23:12:52 -0000 1.10
@@ -94,7 +94,7 @@
mockDispatcher.dispatchResult = new Boolean(false);
mockDispatcher.dispatchInvocation.setExpected(
- new Invocation("equals", new Class[] { Object.class }, boolean.class,
+ new Invocation(Void.class, "equals", new Class[] { Object.class }, boolean.class,
new Object[] { "not a proxy" }));
assertFalse("Should handle proxy inequality by calling through", proxy.equals("not a proxy"));
@@ -104,7 +104,7 @@
public void testProxyEqualityWithNull() throws Exception {
mockDispatcher.dispatchResult = new Boolean(true);
mockDispatcher.dispatchInvocation.setExpected(
- new Invocation("equals", new Class[] { Object.class }, boolean.class,
+ new Invocation(Void.class, "equals", new Class[] { Object.class }, boolean.class,
new Object[] { null }));
assertTrue("Proxy should handle null equality", proxy.equals(null));
--- DynamicMockErrorTest.java DELETED ---
|