From: Steve F. <sm...@us...> - 2003-07-06 23:24:14
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic In directory sc8-pr-cvs1:/tmp/cvs-serv19884/src/core/com/mockobjects/dynamic Modified Files: AbstractCallableCollection.java CoreMock.java Callable.java CallableList.java ReturnStub.java CallBag.java VoidStub.java CallOnceExpectation.java CallStub.java CallSequence.java ThrowStub.java CallSignature.java Added Files: Invocation.java Removed Files: ActiveCall.java Log Message: Renamed ActiveCall to Invocation --- NEW FILE: Invocation.java --- /* * Copyright mockobjects.com 05-Jul-2003 */ package com.mockobjects.dynamic; import java.lang.reflect.Method; public class Invocation extends Object { final public String methodName; final public Object[] args; public Invocation(Method method, Object[] args) { this(method.getName(), args == null ? new Object[0] : args); } public Invocation(String methodName, Object[] args) { this.methodName = methodName; this.args = args; } public String getMethodName() { return methodName; } public String toString() { return DynamicUtil.methodToString(getMethodName(), args); } } Index: AbstractCallableCollection.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/AbstractCallableCollection.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- AbstractCallableCollection.java 6 Jul 2003 02:29:40 -0000 1.1 +++ AbstractCallableCollection.java 6 Jul 2003 23:24:09 -0000 1.2 @@ -5,9 +5,9 @@ abstract public class AbstractCallableCollection implements CallableCollection { abstract public String getDescription(); - abstract public Object call(ActiveCall call) throws Throwable; + abstract public Object call(Invocation invocation) throws Throwable; - public boolean matches(ActiveCall activeCall) { + public boolean matches(Invocation invocation) { throw new AssertionFailedError("matches() operation not supported in CallCollection"); } @@ -31,20 +31,20 @@ protected CallableList expectedCalls = new CallableList(); protected CallableList matchingCalls = new CallableList(); - protected AssertionFailedError createUnexpectedCallError(ActiveCall call) { + protected AssertionFailedError createUnexpectedCallError(Invocation invocation) { StringBuffer buf = new StringBuffer(); buf.append("Unexpected call: "); - buf.append(call.toString()); + buf.append(invocation.toString()); buf.append("\n"); buf.append("Expected "); buf.append(getDescription()); return new AssertionFailedError(buf.toString()); } - protected Callable findMatchingCall(ActiveCall call) throws AssertionFailedError { - Callable foundCall = matchingCalls.firstMatchingCall(call); + protected Callable findMatchingCall(Invocation invocation) throws AssertionFailedError { + Callable foundCall = matchingCalls.firstMatchingCall(invocation); if (foundCall == null) { - throw createUnexpectedCallError(call); + throw createUnexpectedCallError(invocation); } return foundCall; } Index: CoreMock.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/CoreMock.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- CoreMock.java 6 Jul 2003 23:06:12 -0000 1.2 +++ CoreMock.java 6 Jul 2003 23:24:09 -0000 1.3 @@ -27,14 +27,14 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { try { - ActiveCall activeCall = new ActiveCall(method, args); + Invocation invocation = new Invocation(method, args); - if (isCheckingEqualityOnProxy(activeCall)) { + if (isCheckingEqualityOnProxy(invocation)) { return new Boolean(args[0] == this.proxy); - } else if (isMockNameGetter(activeCall)) { + } else if (isMockNameGetter(invocation)) { return this.getMockName(); } else { - return invocationMatchers.call(activeCall); + return invocationMatchers.call(invocation); } } catch (AssertionFailedError ex) { throw new AssertionFailedError(name + ": " + ex.getMessage()); @@ -65,13 +65,13 @@ invocationMatchers.addMatch(invocationMatcher); } - protected boolean isCheckingEqualityOnProxy(ActiveCall call) { - return (call.getMethodName().equals("equals")) && (call.args.length == 1) && - (Proxy.isProxyClass(call.args[0].getClass())); + protected boolean isCheckingEqualityOnProxy(Invocation invocation) { + return (invocation.getMethodName().equals("equals")) && (invocation.args.length == 1) && + (Proxy.isProxyClass(invocation.args[0].getClass())); } - protected boolean isMockNameGetter(ActiveCall call) { - return (call.getMethodName().equals("getMockName")) && (call.args.length == 0); + protected boolean isMockNameGetter(Invocation invocation) { + return (invocation.getMethodName().equals("getMockName")) && (invocation.args.length == 0); } public void reset() { Index: Callable.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/Callable.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- Callable.java 5 Jul 2003 15:15:54 -0000 1.4 +++ Callable.java 6 Jul 2003 23:24:09 -0000 1.5 @@ -4,6 +4,6 @@ public interface Callable extends Verifiable { String getDescription(); - Object call( ActiveCall call ) throws Throwable; - boolean matches(ActiveCall activeCall); + Object call(Invocation invocation) throws Throwable; + boolean matches(Invocation invocation); } Index: CallableList.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/CallableList.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- CallableList.java 5 Jul 2003 16:35:51 -0000 1.1 +++ CallableList.java 6 Jul 2003 23:24:09 -0000 1.2 @@ -34,10 +34,10 @@ list.clear(); } - public Callable firstMatchingCall(final ActiveCall call) { + public Callable firstMatchingCall(final Invocation invocation) { return apply(new Handler() { public Callable handle(int index, Callable callable) { - return callable.matches(call) ? callable : null; + return callable.matches(invocation) ? callable : null; } }); } Index: ReturnStub.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/ReturnStub.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- ReturnStub.java 5 Jul 2003 15:15:54 -0000 1.5 +++ ReturnStub.java 6 Jul 2003 23:24:09 -0000 1.6 @@ -12,7 +12,7 @@ this.result = result; } - public Object call(ActiveCall args) throws Throwable { + public Object call(Invocation invocation) throws Throwable { return result; } Index: CallBag.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/CallBag.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- CallBag.java 6 Jul 2003 02:31:37 -0000 1.7 +++ CallBag.java 6 Jul 2003 23:24:09 -0000 1.8 @@ -5,14 +5,14 @@ public class CallBag extends AbstractCallableCollection { - public Object call(ActiveCall call) throws Throwable { + public Object call(Invocation invocation) throws Throwable { - Callable foundCall = expectedCalls.firstMatchingCall(call); + Callable foundCall = expectedCalls.firstMatchingCall(invocation); if (foundCall == null) { - foundCall = findMatchingCall(call); + foundCall = findMatchingCall(invocation); } - return foundCall.call(call); + return foundCall.call(invocation); } public String getDescription() { Index: VoidStub.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/VoidStub.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- VoidStub.java 5 Jul 2003 15:15:54 -0000 1.4 +++ VoidStub.java 6 Jul 2003 23:24:09 -0000 1.5 @@ -10,7 +10,7 @@ return "returns <void>"; } - public Object call(ActiveCall args) throws Throwable { + public Object call(Invocation invocation) throws Throwable { return null; } Index: CallOnceExpectation.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/CallOnceExpectation.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- CallOnceExpectation.java 5 Jul 2003 15:15:54 -0000 1.3 +++ CallOnceExpectation.java 6 Jul 2003 23:24:09 -0000 1.4 @@ -14,13 +14,13 @@ return delegate.getDescription() + " [" + (wasCalled ? "" : "not ") + "called]"; } - public Object call(ActiveCall args) throws Throwable { + public Object call(Invocation invocation) throws Throwable { wasCalled = true; - return delegate.call( args ); + return delegate.call( invocation ); } - public boolean matches(ActiveCall activeCall) { - return (!wasCalled) && delegate.matches( activeCall ); + public boolean matches(Invocation invocation) { + return (!wasCalled) && delegate.matches( invocation ); } public void verify() { Index: CallStub.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/CallStub.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- CallStub.java 5 Jul 2003 15:15:54 -0000 1.4 +++ CallStub.java 6 Jul 2003 23:24:09 -0000 1.5 @@ -6,7 +6,7 @@ public abstract class CallStub implements Callable { - public boolean matches(ActiveCall activeCall) { + public boolean matches(Invocation invocation) { return true; } Index: CallSequence.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/CallSequence.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- CallSequence.java 6 Jul 2003 02:31:37 -0000 1.9 +++ CallSequence.java 6 Jul 2003 23:24:09 -0000 1.10 @@ -6,19 +6,19 @@ int callIndex = 0; - public Object call(ActiveCall activeCall) throws Throwable { + public Object call(Invocation invocation) throws Throwable { if (expectedCalls.isEmpty()) - throw new AssertionFailedError("no methods defined on mock, received: " + activeCall.toString()); + throw new AssertionFailedError("no methods defined on mock, received: " + invocation.toString()); if (callIndex == expectedCalls.size()) - throw new AssertionFailedError("mock called too many times, received: " + activeCall.toString()); + throw new AssertionFailedError("mock called too many times, received: " + invocation.toString()); Callable callable = expectedCalls.get(callIndex++); - if (callable.matches(activeCall)) { + if (callable.matches(invocation)) { //TODO shouldn't callIndex be incremented here? - return callable.call(activeCall); + return callable.call(invocation); } - return findMatchingCall(activeCall).call(activeCall); + return findMatchingCall(invocation).call(invocation); } public String getDescription() { Index: ThrowStub.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/ThrowStub.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- ThrowStub.java 5 Jul 2003 15:15:54 -0000 1.5 +++ ThrowStub.java 6 Jul 2003 23:24:09 -0000 1.6 @@ -12,7 +12,7 @@ this.throwable = throwable; } - public Object call(ActiveCall args) throws Throwable { + public Object call(Invocation invocation) throws Throwable { throw throwable; } Index: CallSignature.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/CallSignature.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- CallSignature.java 6 Jul 2003 02:31:37 -0000 1.4 +++ CallSignature.java 6 Jul 2003 23:24:09 -0000 1.5 @@ -12,18 +12,18 @@ this.delegate = delegate; } - public Object call( ActiveCall args ) + public Object call( Invocation invocation ) throws Throwable { - return delegate.call( args ); + return delegate.call( invocation ); } public void verify() { delegate.verify(); } - public boolean matches(ActiveCall activeCall) { - return this.methodName.equals(activeCall.getMethodName()) && constraints.matches(activeCall.args); + public boolean matches(Invocation invocation) { + return this.methodName.equals(invocation.getMethodName()) && constraints.matches(invocation.args); } public String getDescription() { --- ActiveCall.java DELETED --- |