Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic In directory sc8-pr-cvs1:/tmp/cvs-serv925/src/core/com/mockobjects/dynamic Modified Files: ReturnStub.java ArgumentsMatcher.java FullArgumentsMatcher.java C.java ThrowStub.java DefaultInvokableFactory.java Log Message: Converted Mock.matches() to use InvocationMocker. Added more functional tests Index: ReturnStub.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/ReturnStub.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- ReturnStub.java 20 Aug 2003 21:51:27 -0000 1.7 +++ ReturnStub.java 5 Oct 2003 09:28:15 -0000 1.8 @@ -5,6 +5,7 @@ public class ReturnStub extends CallStub + implements Stub { private Object result; Index: ArgumentsMatcher.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/ArgumentsMatcher.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ArgumentsMatcher.java 4 Oct 2003 22:56:45 -0000 1.1 +++ ArgumentsMatcher.java 5 Oct 2003 09:28:16 -0000 1.2 @@ -3,7 +3,9 @@ */ package com.mockobjects.dynamic; +import com.mockobjects.constraint.Constraint; + public interface ArgumentsMatcher { boolean matches(Object[] args); - Object[] getConstraints(); + Constraint[] getConstraints(); } Index: FullArgumentsMatcher.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/FullArgumentsMatcher.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- FullArgumentsMatcher.java 4 Oct 2003 22:56:45 -0000 1.1 +++ FullArgumentsMatcher.java 5 Oct 2003 09:28:16 -0000 1.2 @@ -36,7 +36,7 @@ return true; } - public Object[] getConstraints() { + public Constraint[] getConstraints() { return constraints; } Index: C.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/C.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- C.java 4 Oct 2003 22:56:45 -0000 1.5 +++ C.java 5 Oct 2003 09:28:16 -0000 1.6 @@ -22,8 +22,13 @@ public static final ArgumentsMatcher NO_ARGS = new FullArgumentsMatcher(new Constraint[0]); public static final ArgumentsMatcher ANY_ARGS = new ArgumentsMatcher() { + final Constraint anyArguments = new IsAnything() { + public String toString() { + return "Any Arguments"; + } + }; public boolean matches(Object[] args) { return true; } - public Object[] getConstraints() { return new String[] {"ANY"};} + public Constraint[] getConstraints() { return new Constraint[] {anyArguments};} }; public static Constraint same( Object o ) { Index: ThrowStub.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/ThrowStub.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- ThrowStub.java 20 Aug 2003 21:51:27 -0000 1.7 +++ ThrowStub.java 5 Oct 2003 09:28:16 -0000 1.8 @@ -5,6 +5,7 @@ public class ThrowStub extends CallStub + implements Stub { private Throwable throwable; Index: DefaultInvokableFactory.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/DefaultInvokableFactory.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- DefaultInvokableFactory.java 4 Oct 2003 22:56:45 -0000 1.6 +++ DefaultInvokableFactory.java 5 Oct 2003 09:28:16 -0000 1.7 @@ -2,22 +2,28 @@ public class DefaultInvokableFactory implements InvokableFactory { - public Invokable createReturnStub(String methodName, ArgumentsMatcher constraints, Object result) { - return createCallSignature(methodName, constraints, new ReturnStub(result)); + public Invokable createReturnStub(String methodName, ArgumentsMatcher arguments, Object result) { + return new InvocationMocker(methodName, + new InvocationMatcher.Arguments(arguments.getConstraints()), + new ReturnStub(result)); } public Invokable createReturnExpectation(String methodName, ArgumentsMatcher constraints, Object result) { return createCallExpectation(createCallSignature(methodName, constraints, new ReturnStub(result))); } - public Invokable createThrowableStub(String methodName, ArgumentsMatcher constraints, Throwable throwable) { - return createCallSignature(methodName, constraints, new ThrowStub(throwable)); + public Invokable createThrowableStub(String methodName, ArgumentsMatcher arguments, Throwable throwable) { + return new InvocationMocker(methodName, + new InvocationMatcher.Arguments(arguments.getConstraints()), + new ThrowStub(throwable)); } public Invokable createThrowableExpectation(String methodName, ArgumentsMatcher constraints, Throwable throwable) { return createCallExpectation(createCallSignature(methodName, constraints, new ThrowStub(throwable))); } - public Invokable createVoidStub(String methodName, ArgumentsMatcher constraints) { - return createCallSignature(methodName, constraints, new VoidStub()); + public Invokable createVoidStub(String methodName, ArgumentsMatcher arguments) { + return new InvocationMocker(methodName, + new InvocationMatcher.Arguments(arguments.getConstraints()), + new VoidStub()); } public Invokable createVoidExpectation(String methodName, ArgumentsMatcher constraints) { return createCallExpectation(createCallSignature(methodName, constraints, new VoidStub())); |