Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic
In directory sc8-pr-cvs1:/tmp/cvs-serv1162/src/core/com/mockobjects/dynamic
Modified Files:
AbstractCallableCollection.java CallableCollection.java
CoreMock.java CallSignature.java
Log Message:
renamed match to stub
Index: AbstractCallableCollection.java
===================================================================
RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/AbstractCallableCollection.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- AbstractCallableCollection.java 9 Jul 2003 02:14:00 -0000 1.4
+++ AbstractCallableCollection.java 9 Aug 2003 13:18:30 -0000 1.5
@@ -32,7 +32,7 @@
expectedCalls.add(call);
}
- public void addMatch(Callable call) {
+ public void addStub(Callable call) {
stubCalls.add(call);
}
Index: CallableCollection.java
===================================================================
RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/CallableCollection.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- CallableCollection.java 6 Jul 2003 02:28:51 -0000 1.1
+++ CallableCollection.java 9 Aug 2003 13:18:30 -0000 1.2
@@ -2,7 +2,7 @@
public interface CallableCollection extends Callable {
void addExpect(Callable call);
- void addMatch(Callable call);
+ void addStub(Callable call);
/**
* Resets all expected calls and expected matches.
Index: CoreMock.java
===================================================================
RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/CoreMock.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- CoreMock.java 9 Jul 2003 23:54:20 -0000 1.6
+++ CoreMock.java 9 Aug 2003 13:18:30 -0000 1.7
@@ -15,6 +15,8 @@
this.proxy = Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] { mockedClass }, this);
this.name = name;
this.invocationMatchers = callables;
+
+ // callables.addStub(new ProxyIsEqual(this.proxy));
}
public Object proxy() {
@@ -59,7 +61,7 @@
}
public void stub(Callable invocationMatcher) {
- invocationMatchers.addMatch(invocationMatcher);
+ invocationMatchers.addStub(invocationMatcher);
}
private boolean isCheckingEqualityOnProxy(Invocation invocation) {
@@ -89,5 +91,28 @@
return name;
}
}
+
+ public static class ProxyIsEqual implements Callable {
+ final Object proxy;
+
+ public ProxyIsEqual(Object proxy) {
+ this.proxy = proxy;
+ }
+
+ public String getDescription() {
+ return "Proxy is equal";
+ }
+
+ public Object call(Invocation invocation) throws Throwable {
+ return new Boolean(invocation.args[0] == proxy);
+ }
+
+ public boolean matches(Invocation invocation) {
+ return (invocation.getMethodName().equals("equals")) && (invocation.args.length == 1) &&
+ (Proxy.isProxyClass(invocation.args[0].getClass()));
+ }
+
+ public void verify() { /* no op */ }
+ }
}
Index: CallSignature.java
===================================================================
RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/CallSignature.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- CallSignature.java 7 Jul 2003 01:17:57 -0000 1.6
+++ CallSignature.java 9 Aug 2003 13:18:30 -0000 1.7
@@ -4,22 +4,22 @@
{
private String methodName;
private ConstraintMatcher constraints;
- private Callable delegate;
+ private Callable delegateCall;
- public CallSignature( String methodName, ConstraintMatcher constraints, Callable delegate ) {
+ public CallSignature( String methodName, ConstraintMatcher constraints, Callable delegateCall ) {
this.methodName = methodName;
this.constraints = constraints;
- this.delegate = delegate;
+ this.delegateCall = delegateCall;
}
public Object call( Invocation invocation )
throws Throwable
{
- return delegate.call( invocation );
+ return delegateCall.call( invocation );
}
public void verify() {
- delegate.verify();
+ delegateCall.verify();
}
public boolean matches(Invocation invocation) {
@@ -32,6 +32,6 @@
// Implemented to aid visualisation in an IDE debugger
public String toString() {
- return CoreMock.className(this.getClass()) + "(" + this.getDescription() + ")";
+ return CoreMock.className(getClass()) + "(" + getDescription() + ")";
}
}
|