You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(13) |
Aug
(151) |
Sep
(21) |
Oct
(6) |
Nov
(70) |
Dec
(8) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(47) |
Feb
(66) |
Mar
(23) |
Apr
(115) |
May
(24) |
Jun
(53) |
Jul
(10) |
Aug
(279) |
Sep
(84) |
Oct
(149) |
Nov
(138) |
Dec
(52) |
2003 |
Jan
(22) |
Feb
(20) |
Mar
(29) |
Apr
(106) |
May
(170) |
Jun
(122) |
Jul
(70) |
Aug
(64) |
Sep
(27) |
Oct
(71) |
Nov
(49) |
Dec
(9) |
2004 |
Jan
(7) |
Feb
(38) |
Mar
(3) |
Apr
(9) |
May
(22) |
Jun
(4) |
Jul
(1) |
Aug
(2) |
Sep
(2) |
Oct
|
Nov
(15) |
Dec
(2) |
2005 |
Jan
(1) |
Feb
(1) |
Mar
|
Apr
(1) |
May
(28) |
Jun
(3) |
Jul
(11) |
Aug
(5) |
Sep
(1) |
Oct
(5) |
Nov
(2) |
Dec
(3) |
2006 |
Jan
(8) |
Feb
(3) |
Mar
(8) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Steve F. <sm...@us...> - 2003-11-12 21:16:02
|
Update of /cvsroot/mockobjects/mockobjects_education/talks/fruitshop/doc In directory sc8-pr-cvs1:/tmp/cvs-serv9018/talks/fruitshop/doc Added Files: Mock Objects.ppt Log Message: --- NEW FILE: Mock Objects.ppt --- ÐÏࡱá ð ð ð ð ð ð ð ð ð @ Ð ð ð ð ð ð ð ` à ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð @ ð ð ð ð ð ð ð ð ¦ ð ¸` ð ð ð ð ð ð @. ð ð ð ð ð ð ð ð ð @ ð ð ð ð ¦ ð ¸` ð ð ð ð ð ð @ ð ð ð ð ¦ ð ¸` ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð \ ð ð ð ð ð ð ð ð ð ð ð ð ð d ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð l ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð GZ ð ð ð ð GZ ð ð ð ð GZ ð ð ð ð @ Ð ð I ÙQ¨ôwZ¨ôw ÂQ¨ôwZ¨ôw ¦ ãQ¨ôwZ¨ôw ä ä ä ä ä ä ä ä ÌQ¨ôwZ¨ôw W; æQ¨ôwZ¨ôw ×H |
From: Steve F. <sm...@us...> - 2003-11-12 21:16:02
|
Update of /cvsroot/mockobjects/mockobjects_education In directory sc8-pr-cvs1:/tmp/cvs-serv9018 Added Files: .project .classpath Log Message: --- NEW FILE: .project --- <?xml version="1.0" encoding="UTF-8"?> <projectDescription> <name>mockobjects_education</name> <comment></comment> <projects> <project>mockobjects-java-head</project> <project>org.junit</project> </projects> <buildSpec> <buildCommand> <name>org.eclipse.jdt.core.javabuilder</name> <arguments> </arguments> </buildCommand> </buildSpec> <natures> <nature>org.eclipse.jdt.core.javanature</nature> </natures> </projectDescription> --- NEW FILE: .classpath --- <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="talks/fruitshop/src"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="src" path="/org.junit"/> <classpathentry kind="src" path="/mockobjects-java-head"/> <classpathentry kind="output" path="talks/fruitshop/build"/> </classpath> |
From: Steve F. <sm...@us...> - 2003-11-12 21:16:01
|
Update of /cvsroot/mockobjects/mockobjects_education/talks/fruitshop In directory sc8-pr-cvs1:/tmp/cvs-serv9018/talks/fruitshop Added Files: .cvsignore Log Message: --- NEW FILE: .cvsignore --- build |
From: Steve F. <sm...@us...> - 2003-11-12 21:15:44
|
Update of /cvsroot/mockobjects/mockobjects_education/talks/fruitshop/src In directory sc8-pr-cvs1:/tmp/cvs-serv8856/talks/fruitshop/src Log Message: Directory /cvsroot/mockobjects/mockobjects_education/talks/fruitshop/src added to the repository |
From: Steve F. <sm...@us...> - 2003-11-12 21:15:44
|
Update of /cvsroot/mockobjects/mockobjects_education/talks/fruitshop In directory sc8-pr-cvs1:/tmp/cvs-serv8856/talks/fruitshop Log Message: Directory /cvsroot/mockobjects/mockobjects_education/talks/fruitshop added to the repository |
From: Steve F. <sm...@us...> - 2003-11-12 21:15:44
|
Update of /cvsroot/mockobjects/mockobjects_education/talks/fruitshop/lib In directory sc8-pr-cvs1:/tmp/cvs-serv8856/talks/fruitshop/lib Log Message: Directory /cvsroot/mockobjects/mockobjects_education/talks/fruitshop/lib added to the repository |
From: Steve F. <sm...@us...> - 2003-11-12 21:15:44
|
Update of /cvsroot/mockobjects/mockobjects_education/talks/fruitshop/doc In directory sc8-pr-cvs1:/tmp/cvs-serv8856/talks/fruitshop/doc Log Message: Directory /cvsroot/mockobjects/mockobjects_education/talks/fruitshop/doc added to the repository |
From: Steve F. <sm...@us...> - 2003-11-12 21:15:44
|
Update of /cvsroot/mockobjects/mockobjects_education/talks In directory sc8-pr-cvs1:/tmp/cvs-serv8856/talks Log Message: Directory /cvsroot/mockobjects/mockobjects_education/talks added to the repository |
From: Steve F. <sm...@us...> - 2003-11-12 21:15:23
|
Update of /cvsroot/mockobjects/mockobjects_education In directory sc8-pr-cvs1:/tmp/cvs-serv8742 Log Message: Initial import Status: Vendor Tag: vendor Release Tags: start No conflicts created by this import ***** Bogus filespec: - Imported sources |
From: Steve F. <sm...@us...> - 2003-11-12 20:38:50
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic In directory sc8-pr-cvs1:/tmp/cvs-serv32672/src/core/com/mockobjects/dynamic Modified Files: DynaMock.java Log Message: Bit more progress on DynaMock Index: DynaMock.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/DynaMock.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- DynaMock.java 17 Oct 2003 23:05:01 -0000 1.2 +++ DynaMock.java 12 Nov 2003 20:38:47 -0000 1.3 @@ -11,6 +11,7 @@ DynamicMock coreMock; public DynaMock(Class mockedType) { + this(new CoreMock(mockedType, CoreMock.mockNameFromClass(mockedType), new LIFOInvocationDispatcher())); } public DynaMock(DynamicMock coreMock) { this.coreMock = coreMock; @@ -28,7 +29,7 @@ } public MethodExpectation method(String methodName, Object arg1, Object arg2) { - InvocationMocker mocker = new InvocationMocker(methodName, C.eq(arg1, arg2), null); + InvocationMocker mocker = new InvocationMocker(methodName, C.eq(arg1, arg2), new VoidStub()); coreMock.add(mocker); return new MethodExpectation(mocker); } |
From: Steve F. <sm...@us...> - 2003-11-12 20:38:50
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/functional/test/mockobjects/dynamic In directory sc8-pr-cvs1:/tmp/cvs-serv32672/src/core/functional/test/mockobjects/dynamic Modified Files: DynamicMockExample.java Log Message: Bit more progress on DynaMock Index: DynamicMockExample.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/functional/test/mockobjects/dynamic/DynamicMockExample.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- DynamicMockExample.java 29 Oct 2003 22:11:35 -0000 1.5 +++ DynamicMockExample.java 12 Nov 2003 20:38:47 -0000 1.6 @@ -20,7 +20,7 @@ } - public void xtestWorkingExample() { + public void testWorkingExample() { DynaMock mockMarket = new DynaMock(Market.class); Agent agent = new Agent((Market)mockMarket.proxy()); |
From: Steve F. <sm...@us...> - 2003-11-11 06:47:10
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic In directory sc8-pr-cvs1:/tmp/cvs-serv20692/src/core/test/mockobjects/dynamic Modified Files: InvocationMockerTest.java Log Message: Test tidy up Added test for adding matchers Index: InvocationMockerTest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/InvocationMockerTest.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- InvocationMockerTest.java 29 Oct 2003 22:11:36 -0000 1.6 +++ InvocationMockerTest.java 11 Nov 2003 06:47:07 -0000 1.7 @@ -27,9 +27,11 @@ public class MockInvocationMatcher implements InvocationMatcher { public ExpectationValue invocation = new ExpectationValue("MockInvocationMatcher.invoked"); + public ExpectationValue match = new ExpectationValue("MockInvocationMatcher.matches"); public ExpectationCounter verifyCalls = new ExpectationCounter("Verify calls"); public boolean matches(Invocation invocation) { + match.setActual(invocation); return true; } public void invoked(Invocation invocation) { @@ -54,7 +56,7 @@ } }; - private Invocation invocation = + private Invocation exampleInvocation = new Invocation("example", new Class[] { String.class, String.class }, Void.class, new Object[] { "arg1", "arg2"} ); @@ -67,46 +69,46 @@ InvocationMocker invocationMocker = new InvocationMocker(new InvocationMatcher[] { matchAll, matchAll}, null); - assertTrue("Should have matched", invocationMocker.matches(invocation)); + assertTrue("Should have matched", invocationMocker.matches(exampleInvocation)); } public void testDoesNotMatchIfEverythingMatches() { InvocationMocker invocationMocker = new InvocationMocker(new InvocationMatcher[] { matchAll, matchNone}, null); - assertFalse("Should not have matched", invocationMocker.matches(invocation)); + assertFalse("Should not have matched", invocationMocker.matches(exampleInvocation)); } - public void testExampleInvocationMatches() { + public void testMatchesInvocationWithParameters() { InvocationMocker invocationMocker = new InvocationMocker( new InvocationMatcher[] { new MethodNameMatcher("example"), new ArgumentsMatcher( new Constraint[] {C.eq("arg1"), C.eq("arg2")})}, null); - assertTrue("Should have matched", invocationMocker.matches(invocation)); + assertTrue("Should have matched", invocationMocker.matches(exampleInvocation)); } - public void testExampleInvocationDoesNotMatch() { + public void testDoesNotMatchWithDifferentParameter() { InvocationMocker invocationMocker = new InvocationMocker( new InvocationMatcher[] { new MethodNameMatcher("example"), new ArgumentsMatcher( new Constraint[] {C.eq("arg1"), C.eq("not arg2")})}, null); - assertFalse("Should not have matched", invocationMocker.matches(invocation)); + assertFalse("Should not have matched", invocationMocker.matches(exampleInvocation)); } - public void testCallsInvokedOnInvocationMatchersBeforeStub() throws Throwable { + public void testMatchesInvocationBeforeCallingStub() throws Throwable { MockInvocationMatcher mockInvocationMatcher = new MockInvocationMatcher(); InvocationMocker mocker = new InvocationMocker(new InvocationMatcher[] {mockInvocationMatcher}, new VoidStub()); - mockInvocationMatcher.invocation.setExpected(invocation); + mockInvocationMatcher.invocation.setExpected(exampleInvocation); - mocker.invoke(invocation); + mocker.invoke(exampleInvocation); Verifier.verifyObject(mockInvocationMatcher); } - public void testDelegatesVerifyCallToInvocationMatchers() throws Throwable { + public void testDelegatesVerifyToInvocationMatchers() throws Throwable { MockInvocationMatcher mockInvocationMatcher = new MockInvocationMatcher(); InvocationMocker mocker = new InvocationMocker(new InvocationMatcher[] {mockInvocationMatcher}, new VoidStub()); @@ -118,17 +120,30 @@ } - public void testInvokeDelegatesToStubObject() throws Throwable { + public void testDelegatesInvocationToStubObject() throws Throwable { MockStub mockStub = new MockStub(); InvocationMocker mocker = new InvocationMocker(new InvocationMatcher[0], mockStub); - mockStub.stubInvocation.setExpected(invocation); + mockStub.stubInvocation.setExpected(exampleInvocation); - assertEquals("Should be invoke result", "stub result", mocker.invoke(invocation)); + assertEquals("Should be invoke result", "stub result", mocker.invoke(exampleInvocation)); Verifier.verifyObject(mockStub); } - //TODO addMatcher test + public void testCanAddExtraMatchers() throws Throwable + { + MockInvocationMatcher mockInvocationMatcher = new MockInvocationMatcher(); + + InvocationMocker mocker = new InvocationMocker(new InvocationMatcher[0], new VoidStub()); + mockInvocationMatcher.match.setExpected(exampleInvocation); + mockInvocationMatcher.invocation.setExpected(exampleInvocation); + + mocker.addMatcher(mockInvocationMatcher); + mocker.matches(exampleInvocation); + mocker.invoke(exampleInvocation); + + Verifier.verifyObject(mockInvocationMatcher); + } } |
From: Konstantin S. <k8...@tu...> - 2003-10-29 22:18:30
|
From: Steve F. <sm...@us...> - 2003-10-29 22:11:39
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic In directory sc8-pr-cvs1:/tmp/cvs-serv8912/src/core/test/mockobjects/dynamic Modified Files: InvocationTest.java InvocationMockerTest.java StubTest.java MethodExpectationTest.java Removed Files: DynamicUtilTest.java InvocationMatcherTest.java Log Message: Added support for state to InvocationMatchers Added CallOnceMatcher Removed CallOnceStub Moved matchers into separate package Index: InvocationTest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/InvocationTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- InvocationTest.java 20 Aug 2003 21:48:24 -0000 1.1 +++ InvocationTest.java 29 Oct 2003 22:11:35 -0000 1.2 @@ -8,7 +8,9 @@ import junit.framework.TestCase; +import com.mockobjects.dynamic.Mock; import com.mockobjects.dynamic.Invocation; +import com.mockobjects.util.AssertMo; public class InvocationTest extends TestCase @@ -110,4 +112,59 @@ assertEquals( "should have equal hash codes", call1.hashCode(), call2.hashCode() ); } + + public void testToStringWithTwoArguments() throws Exception { + Invocation invocation = + new Invocation("methodName", new Class[] { String.class, String.class} , void.class, + new Object[] { "arg1", "arg2" } ); + String result = invocation.toString(); + + AssertMo.assertIncludes("Should contain method name", "methodName", result); + AssertMo.assertIncludes("Should contain firstArg", "arg1", result); + AssertMo.assertIncludes("Should contain second Arg", "arg2", result); + } + + public void testToStringWithStringArray() throws Exception { + Invocation invocation = + new Invocation("methodName", new Class[] { String[].class} , void.class, + new Object[] { new String[] { "arg1", "arg2" } } ); + String result = invocation.toString(); + + AssertMo.assertIncludes("Should contain method name", "methodName", result); + AssertMo.assertIncludes("Should contain args as an array", "[<arg1>, <arg2>]", result); + } + + public void testToStringWithPrimitiveArray() throws Exception { + Invocation invocation = + new Invocation("methodName", new Class[] { long[].class} , void.class, + new Object[] { new long[] { 1, 2 } } ); + String result = invocation.toString(); + + AssertMo.assertIncludes("Should contain method name", "methodName", result); + AssertMo.assertIncludes("Should contain args as an array", "[<1>, <2>]", result); + } + + public void testMethodToStringWithProxyArg() throws Exception { + Mock mockDummyInterface = new Mock(DummyInterface.class, "DummyMock"); + + Invocation invocation = + new Invocation("methodName", new Class[] { String.class, DummyInterface.class} , void.class, + new Object[] { "arg1", mockDummyInterface.proxy() } ); + String result = invocation.toString(); + + AssertMo.assertIncludes("Should contain method name", "methodName", result); + AssertMo.assertIncludes("Should contain firstArg", "arg1", result); + AssertMo.assertIncludes("Should contain second Arg", "DummyMock", result); + } + + public void testMethodToStringWithNullArg() throws Exception { + Invocation invocation = + new Invocation("methodName", new Class[] { String.class }, void.class, + new Object[] { null }); + String result = invocation.toString(); + + AssertMo.assertIncludes("Should contain method name", "methodName", result); + AssertMo.assertIncludes("Should contain firstArg", "<null>", result); + } + } Index: InvocationMockerTest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/InvocationMockerTest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- InvocationMockerTest.java 8 Oct 2003 23:47:14 -0000 1.5 +++ InvocationMockerTest.java 29 Oct 2003 22:11:36 -0000 1.6 @@ -7,36 +7,47 @@ import com.mockobjects.ExpectationValue; import com.mockobjects.constraint.Constraint; import com.mockobjects.dynamic.*; -import com.mockobjects.dynamic.C; -import com.mockobjects.dynamic.Invocation; -import com.mockobjects.dynamic.InvocationMatcher; -import com.mockobjects.dynamic.InvocationMocker; +import com.mockobjects.dynamic.matchers.ArgumentsMatcher; +import com.mockobjects.dynamic.matchers.MethodNameMatcher; +import com.mockobjects.dynamic.matchers.StatelessInvocationMatcher; import com.mockobjects.util.TestCaseMo; import com.mockobjects.util.Verifier; public class InvocationMockerTest extends TestCaseMo { - private InvocationMatcher matchAll = new InvocationMatcher() { + private InvocationMatcher matchAll = new StatelessInvocationMatcher() { public boolean matches(Invocation invocation) { return true; } }; - private InvocationMatcher matchNone = new InvocationMatcher() { + private InvocationMatcher matchNone = new StatelessInvocationMatcher() { public boolean matches(Invocation invocation) { return false; } }; + public class MockInvocationMatcher implements InvocationMatcher { + public ExpectationValue invocation = new ExpectationValue("MockInvocationMatcher.invoked"); + public ExpectationCounter verifyCalls = new ExpectationCounter("Verify calls"); + + public boolean matches(Invocation invocation) { + return true; + } + public void invoked(Invocation invocation) { + this.invocation.setActual(invocation); + } + + public void verify() { + verifyCalls.inc(); + } + } + public class MockStub implements Stub { public ExpectationValue stubInvocation = new ExpectationValue("Stub invocation"); - public ExpectationCounter verifyCalls = new ExpectationCounter("Verify calls"); public Object invoke( Invocation invocation ) throws Throwable { stubInvocation.setActual(invocation); return "stub result"; } - public void verify() { - verifyCalls.inc(); - } public String getDescription() { return "MockStub"; @@ -69,8 +80,8 @@ public void testExampleInvocationMatches() { InvocationMocker invocationMocker = new InvocationMocker( new InvocationMatcher[] { - new InvocationMatcher.MethodName("example"), - new InvocationMatcher.Arguments( new Constraint[] {C.eq("arg1"), C.eq("arg2")})}, null); + new MethodNameMatcher("example"), + new ArgumentsMatcher( new Constraint[] {C.eq("arg1"), C.eq("arg2")})}, null); assertTrue("Should have matched", invocationMocker.matches(invocation)); } @@ -78,23 +89,46 @@ public void testExampleInvocationDoesNotMatch() { InvocationMocker invocationMocker = new InvocationMocker( new InvocationMatcher[] { - new InvocationMatcher.MethodName("example"), - new InvocationMatcher.Arguments( new Constraint[] {C.eq("arg1"), C.eq("not arg2")})}, null); + new MethodNameMatcher("example"), + new ArgumentsMatcher( new Constraint[] {C.eq("arg1"), C.eq("not arg2")})}, null); assertFalse("Should not have matched", invocationMocker.matches(invocation)); } + public void testCallsInvokedOnInvocationMatchersBeforeStub() throws Throwable { + MockInvocationMatcher mockInvocationMatcher = new MockInvocationMatcher(); + + InvocationMocker mocker = new InvocationMocker(new InvocationMatcher[] {mockInvocationMatcher}, new VoidStub()); + mockInvocationMatcher.invocation.setExpected(invocation); + + mocker.invoke(invocation); + + Verifier.verifyObject(mockInvocationMatcher); + } + + public void testDelegatesVerifyCallToInvocationMatchers() throws Throwable { + MockInvocationMatcher mockInvocationMatcher = new MockInvocationMatcher(); + + InvocationMocker mocker = new InvocationMocker(new InvocationMatcher[] {mockInvocationMatcher}, new VoidStub()); + mockInvocationMatcher.verifyCalls.setExpected(1); + + mocker.verify(); + + Verifier.verifyObject(mockInvocationMatcher); + } + + public void testInvokeDelegatesToStubObject() throws Throwable { MockStub mockStub = new MockStub(); InvocationMocker mocker = new InvocationMocker(new InvocationMatcher[0], mockStub); mockStub.stubInvocation.setExpected(invocation); - mockStub.verifyCalls.setExpected(1); assertEquals("Should be invoke result", "stub result", mocker.invoke(invocation)); - mocker.verify(); Verifier.verifyObject(mockStub); } + + //TODO addMatcher test } Index: StubTest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/StubTest.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- StubTest.java 8 Oct 2003 23:47:14 -0000 1.7 +++ StubTest.java 29 Oct 2003 22:11:36 -0000 1.8 @@ -3,14 +3,11 @@ */ package test.mockobjects.dynamic; -import junit.framework.AssertionFailedError; import junit.framework.TestCase; -import com.mockobjects.dynamic.*; import com.mockobjects.dynamic.Invocation; import com.mockobjects.dynamic.ReturnStub; import com.mockobjects.dynamic.ThrowStub; -import com.mockobjects.dynamic.VoidStub; public class StubTest extends TestCase { @@ -35,33 +32,6 @@ catch( Throwable t ) { assertSame( "Should be the same throwable", throwable, t ); } - } - - public void testCallOnceStubVerifyFailsIfNotCalled() throws Throwable { - try { - new CallOnceStub(new VoidStub()).verify(); - } catch (AssertionFailedError unused ) { - return; - } - fail("Should have thrown assertion"); - } - - public void testCallOnceStubFailsIfCalledTwice() throws Throwable { - CallOnceStub stub = new CallOnceStub(new VoidStub()); - stub.invoke(invocation); - - try { - stub.invoke(invocation); - } catch (AssertionFailedError unused ) { - return; - } - fail("Should have thrown assertion"); - } - - public void testCallOnceStubVerifiesIfCalledOne() throws Throwable { - CallOnceStub stub = new CallOnceStub(new VoidStub()); - stub.invoke(invocation); - stub.verify(); } } Index: MethodExpectationTest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/MethodExpectationTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- MethodExpectationTest.java 17 Oct 2003 23:05:01 -0000 1.1 +++ MethodExpectationTest.java 29 Oct 2003 22:11:36 -0000 1.2 @@ -4,6 +4,7 @@ package test.mockobjects.dynamic; import com.mockobjects.ExpectationCounter; +import com.mockobjects.dynamic.*; import com.mockobjects.dynamic.InvocationMatcher; import com.mockobjects.dynamic.InvocationMocker; import com.mockobjects.dynamic.MethodExpectation; @@ -13,8 +14,8 @@ public class MethodExpectationTest extends TestCaseMo { public class MockInvocationMocker extends InvocationMocker { - public MockInvocationMocker(InvocationMatcher[] matchers, Stub stub) { - super(matchers, stub); + public MockInvocationMocker() { + super(new InvocationMatcher[0], new VoidStub()); } public ExpectationCounter addStubCalls = new ExpectationCounter("add stub"); @@ -26,16 +27,16 @@ Verifier.verifyObject(this); } } + public MethodExpectationTest(String name) { super(name); } - - public void testVoidAddsVoidStub() { - MockInvocationMocker mocker = new MockInvocationMocker(null, null); + + public void xtestVoidAddsVoidStub() { // TODO + MockInvocationMocker mocker = new MockInvocationMocker(); MethodExpectation expectation = new MethodExpectation(mocker); mocker.addStubCalls.setExpected(1); - expectation.Void(); mocker.verifyExpectations(); } --- DynamicUtilTest.java DELETED --- --- InvocationMatcherTest.java DELETED --- |
From: Steve F. <sm...@us...> - 2003-10-29 22:11:39
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic In directory sc8-pr-cvs1:/tmp/cvs-serv8912/src/core/com/mockobjects/dynamic Modified Files: Mock.java C.java CoreMock.java MethodExpectation.java InvocationMatcher.java InvocationMocker.java Stub.java InvokableFactory.java Removed Files: CallOnceStub.java Log Message: Added support for state to InvocationMatchers Added CallOnceMatcher Removed CallOnceStub Moved matchers into separate package Index: Mock.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/Mock.java,v retrieving revision 1.43 retrieving revision 1.44 diff -u -r1.43 -r1.44 --- Mock.java 15 Oct 2003 08:20:54 -0000 1.43 +++ Mock.java 29 Oct 2003 22:11:35 -0000 1.44 @@ -2,6 +2,7 @@ import com.mockobjects.Verifiable; import com.mockobjects.constraint.Constraint; +import com.mockobjects.dynamic.matchers.*; public class Mock implements Verifiable { private InvokableFactory invokableFactory; @@ -31,7 +32,7 @@ if (constraintArg instanceof Constraint[]) { // to support possible legacy usage of new Contraint[] {...} - return new InvocationMatcher.Arguments((Constraint[])constraintArg); + return new ArgumentsMatcher((Constraint[])constraintArg); } else if (constraintArg instanceof Constraint) { // to support usage of C.lt(5) type constraints return C.args((Constraint)constraintArg); Index: C.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/C.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- C.java 14 Oct 2003 20:26:03 -0000 1.7 +++ C.java 29 Oct 2003 22:11:35 -0000 1.8 @@ -5,6 +5,7 @@ package com.mockobjects.dynamic; import com.mockobjects.constraint.*; +import com.mockobjects.dynamic.matchers.*; /** Convenient factory functions and constants for building predicates. @@ -20,12 +21,12 @@ public static final Constraint IS_NOT_ZERO = not(IS_ZERO); public static final InvocationMatcher NO_ARGS = - new InvocationMatcher() { - public boolean matches(Invocation invocation) { return invocation.getParameterValues().isEmpty();} + new StatelessInvocationMatcher() { + public boolean matches(Invocation invocation) { return invocation.getParameterValues().isEmpty();} }; public static final InvocationMatcher ANY_ARGS = - new InvocationMatcher() { + new StatelessInvocationMatcher() { public boolean matches(Invocation invocation) { return true;} }; @@ -119,19 +120,19 @@ } public static InvocationMatcher args(Constraint p) { - return new InvocationMatcher.Arguments(new Constraint[]{p}); + return new ArgumentsMatcher(new Constraint[]{p}); } public static InvocationMatcher args(Constraint p1, Constraint p2) { - return new InvocationMatcher.Arguments(new Constraint[]{p1, p2}); + return new ArgumentsMatcher(new Constraint[]{p1, p2}); } public static InvocationMatcher args(Constraint p1, Constraint p2, Constraint p3) { - return new InvocationMatcher.Arguments(new Constraint[]{p1, p2, p3}); + return new ArgumentsMatcher(new Constraint[]{p1, p2, p3}); } public static InvocationMatcher args(Constraint p1, Constraint p2, Constraint p3, Constraint p4) { - return new InvocationMatcher.Arguments(new Constraint[]{p1, p2, p3, p4}); + return new ArgumentsMatcher(new Constraint[]{p1, p2, p3, p4}); } public static InvocationMatcher anyArgs( int argCount) { @@ -140,6 +141,6 @@ constraints[i] = new IsAnything(); } - return new InvocationMatcher.Arguments(constraints); + return new ArgumentsMatcher(constraints); } } Index: CoreMock.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/CoreMock.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- CoreMock.java 14 Oct 2003 20:26:03 -0000 1.13 +++ CoreMock.java 29 Oct 2003 22:11:35 -0000 1.14 @@ -24,10 +24,10 @@ } public Object invoke(Object proxy, Method method, Object[] args) - throws Throwable { + throws Throwable + { + Invocation invocation = new Invocation(method, args); try { - Invocation invocation = new Invocation(method, args); - if (invocation.isCheckingEqualityOnProxy()) { return new Boolean(args[0] == this.proxy); } else if (invocation.isMockNameGetter()) { @@ -36,7 +36,9 @@ return invocationDispatcher.dispatch(invocation); } } catch (AssertionFailedError ex) { - throw new AssertionFailedError(name + ": " + ex.getMessage()); + DynamicMockError error = new DynamicMockError(invocation, name + ": " + ex.getMessage()); + error.fillInStackTrace(); + throw error; } } Index: MethodExpectation.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/MethodExpectation.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- MethodExpectation.java 17 Oct 2003 23:05:01 -0000 1.8 +++ MethodExpectation.java 29 Oct 2003 22:11:35 -0000 1.9 @@ -5,13 +5,9 @@ package com.mockobjects.dynamic; public class MethodExpectation { - private InvocationMocker mocker; + private InvocationMocker mocker; //TODO in progress public MethodExpectation(InvocationMocker mocker) { this.mocker = mocker; - } - - public void Void() { - mocker.addStub(new VoidStub()); } } Index: InvocationMatcher.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/InvocationMatcher.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- InvocationMatcher.java 14 Oct 2003 20:26:03 -0000 1.3 +++ InvocationMatcher.java 29 Oct 2003 22:11:35 -0000 1.4 @@ -3,69 +3,12 @@ */ package com.mockobjects.dynamic; -import java.util.List; +import com.mockobjects.Verifiable; -import com.mockobjects.constraint.Constraint; -import com.mockobjects.constraint.IsEqual; - -public interface InvocationMatcher { +public interface InvocationMatcher + extends Verifiable +{ boolean matches(Invocation invocation); - - - public class MethodName implements InvocationMatcher { - private Constraint constraint; - - public MethodName(Constraint constraint) { - this.constraint = constraint; - } - public MethodName(String methodName) { - this(new IsEqual(methodName)); - } - public boolean matches(Invocation invocation) { - return constraint.eval(invocation.getMethodName()); - } - } - - public class Arguments - implements InvocationMatcher - { - private Constraint[] constraints; - - public Arguments(Constraint[] constraints) { - Arguments.this.constraints = constraints; - } - - public boolean matches(Invocation invocation) { - return constraints.length == invocation.getParameterValues().size() - && matchesValues(invocation.getParameterValues()); - } - - private boolean matchesValues(List list) { - for (int i = 0; i < constraints.length; ++i) { - if (!constraints[i].eval(list.get(i))) { - return false; - } - } - return true; - } - - public Constraint[] getConstraints() { - return constraints; - } - - public String toString() { - StringBuffer result = new StringBuffer(); - result.append("ArgumentMatcher: "); - for (int i = 0; i < constraints.length; ++i) { - result.append(constraints[i]).append(", "); - } - return result.toString(); - } - - public boolean equals(Object other) { - return other != null && toString().equals(other.toString()); - } - } - + void invoked(Invocation invocation); } Index: InvocationMocker.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/InvocationMocker.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- InvocationMocker.java 17 Oct 2003 23:05:01 -0000 1.6 +++ InvocationMocker.java 29 Oct 2003 22:11:35 -0000 1.7 @@ -3,27 +3,40 @@ */ package com.mockobjects.dynamic; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import com.mockobjects.dynamic.matchers.MethodNameMatcher; + public class InvocationMocker implements Invokable { - private InvocationMatcher[] matchers; + private List matchers = new ArrayList(); private Stub stub; - + public InvocationMocker(String methodName, InvocationMatcher arguments, Stub stub) { - this(new InvocationMatcher[] {new InvocationMatcher.MethodName(methodName), arguments}, - stub); + this(stub); + addMatcher(new MethodNameMatcher(methodName)); + addMatcher(arguments); } public InvocationMocker(InvocationMatcher[] matchers, Stub stub) { - this.matchers = matchers; + this(stub); + for( int i = 0; i < matchers.length; i++ ) addMatcher( matchers[i] ); + } + + public InvocationMocker(Stub stub) { this.stub = stub; } + public String getDescription() { return null; // TODO } public boolean matches(Invocation invocation) { - for (int i = 0; i < matchers.length; ++i) { - if (! matchers[i].matches(invocation)) { + Iterator i = matchers.iterator(); + while( i.hasNext() ) { + if( !((InvocationMatcher)i.next()).matches(invocation) ) { return false; } } @@ -31,14 +44,22 @@ } public Object invoke(Invocation invocation) throws Throwable { + Iterator i = matchers.iterator(); + while( i.hasNext() ) { + ((InvocationMatcher)i.next()).invoked(invocation); + } return stub.invoke(invocation); } public void verify() { - stub.verify(); + Iterator i = matchers.iterator(); + while( i.hasNext() ) { + ((InvocationMatcher)i.next()).verify(); + } } - public void addStub(Stub stub) { - // TODO + public InvocationMocker addMatcher(InvocationMatcher matcher) { + matchers.add(matcher); + return this; } } Index: Stub.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/Stub.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- Stub.java 8 Oct 2003 23:47:14 -0000 1.6 +++ Stub.java 29 Oct 2003 22:11:35 -0000 1.7 @@ -4,13 +4,12 @@ */ package com.mockobjects.dynamic; -import com.mockobjects.Verifiable; /** * An object that stubs the behaviour of a method invocation on behalf of an * {@link Invokable} object. */ -public interface Stub extends Verifiable +public interface Stub { /** * Processes the invocation. Index: InvokableFactory.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/InvokableFactory.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- InvokableFactory.java 15 Oct 2003 08:20:54 -0000 1.8 +++ InvokableFactory.java 29 Oct 2003 22:11:35 -0000 1.9 @@ -1,25 +1,32 @@ package com.mockobjects.dynamic; +import com.mockobjects.dynamic.matchers.CallOnceMatcher; + public class InvokableFactory { public Invokable createReturnStub(String methodName, InvocationMatcher arguments, Object result) { return new InvocationMocker(methodName, arguments, new ReturnStub(result)); } public Invokable createReturnExpectation(String methodName, InvocationMatcher arguments, Object result) { - return new InvocationMocker(methodName, arguments, new CallOnceStub(new ReturnStub(result))); + return callOnce(new InvocationMocker(methodName, arguments, new ReturnStub(result))); } public Invokable createThrowableStub(String methodName, InvocationMatcher arguments, Throwable throwable) { return new InvocationMocker(methodName, arguments, new ThrowStub(throwable)); } public Invokable createThrowableExpectation(String methodName, InvocationMatcher arguments, Throwable throwable) { - return new InvocationMocker(methodName, arguments,new CallOnceStub(new ThrowStub(throwable))); + return callOnce(new InvocationMocker(methodName, arguments, new ThrowStub(throwable))); } public Invokable createVoidStub(String methodName, InvocationMatcher arguments) { return new InvocationMocker(methodName, arguments, new VoidStub()); } + public Invokable createVoidExpectation(String methodName, InvocationMatcher arguments) { - return new InvocationMocker(methodName, arguments, new CallOnceStub(new VoidStub())); + return callOnce(new InvocationMocker(methodName, arguments, new VoidStub())); + } + + private Invokable callOnce(InvocationMocker mocker) { + return mocker.addMatcher(new CallOnceMatcher()); } } --- CallOnceStub.java DELETED --- |
From: Steve F. <sm...@us...> - 2003-10-29 22:11:39
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/matchers In directory sc8-pr-cvs1:/tmp/cvs-serv8912/src/core/test/mockobjects/dynamic/matchers Added Files: InvocationMatcherTest.java CallOnceMatcherTest.java Log Message: Added support for state to InvocationMatchers Added CallOnceMatcher Removed CallOnceStub Moved matchers into separate package --- NEW FILE: InvocationMatcherTest.java --- /* * Copyright mockobjects.com 04-Oct-2003 */ package test.mockobjects.dynamic.matchers; import com.mockobjects.constraint.Constraint; import com.mockobjects.dynamic.C; import com.mockobjects.dynamic.Invocation; import com.mockobjects.dynamic.matchers.ArgumentsMatcher; import com.mockobjects.dynamic.matchers.MethodNameMatcher; import com.mockobjects.util.TestCaseMo; public class InvocationMatcherTest extends TestCaseMo { private Invocation emptyInvocation = new Invocation("example", new Class[0], Void.class, new Object[0] ); private Invocation exampleInvocation = new Invocation("example", new Class[] { String.class }, Void.class, new Object[] { "arg1", "arg2" } ); public InvocationMatcherTest(String name) { super(name); } public void testNameMatchesWhenConstraintIsAnything() { MethodNameMatcher matcher = new MethodNameMatcher(C.IS_ANYTHING); assertTrue("Should match name", matcher.matches(exampleInvocation)); } public void testNameMatchesWhenConstraintIsNothing() { MethodNameMatcher matcher = new MethodNameMatcher(C.not(C.IS_ANYTHING)); assertFalse("Should not match name", matcher.matches(exampleInvocation)); } public void testNameMatchesGivenString() { MethodNameMatcher matcher = new MethodNameMatcher("example"); assertTrue("Should match name", matcher.matches(exampleInvocation)); } public void testNameDoesNotMatchIncorrectString() { MethodNameMatcher matcher = new MethodNameMatcher("not an example"); assertFalse("Should not match name", matcher.matches(exampleInvocation)); } public void testMatchWhenNoArgumentsOrConstraints() throws Throwable { ArgumentsMatcher matcher = new ArgumentsMatcher(new Constraint[0]); assertTrue("No arguments", matcher.matches(emptyInvocation)); } public void testNoMatchWhenTooManyArguments() throws Throwable { ArgumentsMatcher matcher = new ArgumentsMatcher(new Constraint[0]); assertFalse("Too many arguments", matcher.matches(exampleInvocation)); } public void testNoMatchWhenTooFewArguments() throws Throwable { ArgumentsMatcher matcher = new ArgumentsMatcher( new Constraint[] { C.IS_ANYTHING, C.IS_ANYTHING, C.IS_ANYTHING} ); assertFalse("Too many arguments", matcher.matches(exampleInvocation)); } public void testNoMatchWhenAnyArgumentDoNotConform() throws Throwable { ArgumentsMatcher matcher = new ArgumentsMatcher( new Constraint[] { C.IS_ANYTHING, C.eq("wrong")} ); assertFalse("Incorrect argument", matcher.matches(exampleInvocation)); } public void testArgumentsMatchWhenAllValuesMatch() throws Throwable { ArgumentsMatcher matcher = new ArgumentsMatcher( new Constraint[] { C.IS_ANYTHING, C.eq("arg2")} ); assertTrue("Arguments match", matcher.matches(exampleInvocation)); } } --- NEW FILE: CallOnceMatcherTest.java --- /* * Copyright mockobjects.com 29-Oct-2003 */ package test.mockobjects.dynamic.matchers; import junit.framework.AssertionFailedError; import junit.framework.TestCase; import com.mockobjects.dynamic.Invocation; import com.mockobjects.dynamic.matchers.CallOnceMatcher; public class CallOnceMatcherTest extends TestCase { private Invocation emptyInvocation = new Invocation("example", new Class[0], Void.class, new Object[0] ); private CallOnceMatcher matcher = new CallOnceMatcher(); public void testWillMatchIfNotYetInvoked() { assertTrue("Should match", matcher.matches(emptyInvocation)); } public void testVerifyFailsIfNotYetInvoked() { try { matcher.verify(); } catch (AssertionFailedError expected) { return; } fail("Should have thrown exception"); } public void testWillNotMatchAfterInvocation() { matcher.invoked(emptyInvocation); assertFalse("Should not match", matcher.matches(emptyInvocation)); } public void testVerifyPassesAfterInvocation() { matcher.invoked(emptyInvocation); matcher.verify(); } } |
Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/matchers In directory sc8-pr-cvs1:/tmp/cvs-serv8912/src/core/com/mockobjects/dynamic/matchers Added Files: StatelessInvocationMatcher.java CallOnceMatcher.java MethodNameMatcher.java ArgumentsMatcher.java Log Message: Added support for state to InvocationMatchers Added CallOnceMatcher Removed CallOnceStub Moved matchers into separate package --- NEW FILE: StatelessInvocationMatcher.java --- /* * Copyright Mockobjects.com 29-Oct-2003 */ package com.mockobjects.dynamic.matchers; import com.mockobjects.dynamic.Invocation; import com.mockobjects.dynamic.InvocationMatcher; public abstract class StatelessInvocationMatcher implements InvocationMatcher { public void invoked(Invocation invocation) { // Do nothing because state cannot change } public void verify() { // Nothing to verify because state cannot change } } --- NEW FILE: CallOnceMatcher.java --- /* * Copyright mockobjects.com 29-Oct-2003 */ package com.mockobjects.dynamic.matchers; import junit.framework.Assert; import com.mockobjects.dynamic.Invocation; import com.mockobjects.dynamic.InvocationMatcher; public class CallOnceMatcher implements InvocationMatcher { private boolean wasInvoked = false; public boolean matches(Invocation invocation) { return ! wasInvoked; } public void invoked(Invocation invocation) { wasInvoked = true; } public void verify() { Assert.assertTrue("Should have been invoked", wasInvoked); } } --- NEW FILE: MethodNameMatcher.java --- /* * Copyright Mockobjects.com 29-Oct-2003 */ package com.mockobjects.dynamic.matchers; import com.mockobjects.constraint.Constraint; import com.mockobjects.constraint.IsEqual; import com.mockobjects.dynamic.Invocation; public class MethodNameMatcher extends StatelessInvocationMatcher { private Constraint constraint; public MethodNameMatcher(Constraint constraint) { this.constraint = constraint; } public MethodNameMatcher(String methodName) { this(new IsEqual(methodName)); } public boolean matches(Invocation invocation) { return constraint.eval(invocation.getMethodName()); } } --- NEW FILE: ArgumentsMatcher.java --- /* * Copyright mockobjects.com 29-Oct-2003 * */ package com.mockobjects.dynamic.matchers; import java.util.List; import com.mockobjects.constraint.Constraint; import com.mockobjects.dynamic.Invocation; public class ArgumentsMatcher extends StatelessInvocationMatcher { private Constraint[] constraints; public ArgumentsMatcher(Constraint[] constraints) { ArgumentsMatcher.this.constraints = constraints; } public boolean matches(Invocation invocation) { return constraints.length == invocation.getParameterValues().size() && matchesValues(invocation.getParameterValues()); } private boolean matchesValues(List list) { for (int i = 0; i < constraints.length; ++i) { if (!constraints[i].eval(list.get(i))) { return false; } } return true; } public Constraint[] getConstraints() { return constraints; } public String toString() { StringBuffer result = new StringBuffer(); result.append("ArgumentMatcher: "); for (int i = 0; i < constraints.length; ++i) { result.append(constraints[i]).append(", "); } return result.toString(); } public boolean equals(Object other) { return other != null && toString().equals(other.toString()); } } |
From: Steve F. <sm...@us...> - 2003-10-29 22:11:38
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/functional/test/mockobjects/dynamic In directory sc8-pr-cvs1:/tmp/cvs-serv8912/src/core/functional/test/mockobjects/dynamic Modified Files: DynamicMockExample.java MockTest.java Log Message: Added support for state to InvocationMatchers Added CallOnceMatcher Removed CallOnceStub Moved matchers into separate package Index: DynamicMockExample.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/functional/test/mockobjects/dynamic/DynamicMockExample.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- DynamicMockExample.java 17 Oct 2003 23:05:01 -0000 1.4 +++ DynamicMockExample.java 29 Oct 2003 22:11:35 -0000 1.5 @@ -24,7 +24,7 @@ DynaMock mockMarket = new DynaMock(Market.class); Agent agent = new Agent((Market)mockMarket.proxy()); - mockMarket.method("buyStock", "IBM", new Integer(10)).Void(); + mockMarket.method("buyStock", "IBM", new Integer(10)); agent.buyLowestPriceStock(20); Index: MockTest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/functional/test/mockobjects/dynamic/MockTest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- MockTest.java 15 Oct 2003 08:20:54 -0000 1.5 +++ MockTest.java 29 Oct 2003 22:11:35 -0000 1.6 @@ -39,7 +39,7 @@ } public void testFailsIfMockedMethodCalledTwice() { - actions. expectNoParams(); + actions.expectNoParams(); actions.callNoParams(); try { actions.callNoParams(); |
From: Steve F. <sm...@us...> - 2003-10-29 22:11:27
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/matchers In directory sc8-pr-cvs1:/tmp/cvs-serv8853/src/core/com/mockobjects/dynamic/matchers Log Message: Directory /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/matchers added to the repository |
From: Steve F. <sm...@us...> - 2003-10-29 22:11:27
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/matchers In directory sc8-pr-cvs1:/tmp/cvs-serv8853/src/core/test/mockobjects/dynamic/matchers Log Message: Directory /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/matchers added to the repository |
From: Steve F. <sm...@us...> - 2003-10-17 23:08:24
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic In directory sc8-pr-cvs1:/tmp/cvs-serv30164/src/core/com/mockobjects/dynamic Modified Files: InvocationMocker.java DynaMock.java Added Files: MethodExpectation.java Log Message: A bt more of the new dynamic mocks Added MethodExpectation Index: InvocationMocker.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/InvocationMocker.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- InvocationMocker.java 17 Oct 2003 08:37:47 -0000 1.5 +++ InvocationMocker.java 17 Oct 2003 23:05:01 -0000 1.6 @@ -37,4 +37,8 @@ public void verify() { stub.verify(); } + + public void addStub(Stub stub) { + // TODO + } } Index: DynaMock.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/DynaMock.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- DynaMock.java 17 Oct 2003 08:38:32 -0000 1.1 +++ DynaMock.java 17 Oct 2003 23:05:01 -0000 1.2 @@ -26,4 +26,10 @@ public void verify() { coreMock.verify(); } + + public MethodExpectation method(String methodName, Object arg1, Object arg2) { + InvocationMocker mocker = new InvocationMocker(methodName, C.eq(arg1, arg2), null); + coreMock.add(mocker); + return new MethodExpectation(mocker); + } } |
From: Steve F. <sm...@us...> - 2003-10-17 23:06:12
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/functional/test/mockobjects/dynamic In directory sc8-pr-cvs1:/tmp/cvs-serv30164/src/core/functional/test/mockobjects/dynamic Modified Files: DynamicMockExample.java Log Message: A bt more of the new dynamic mocks Added MethodExpectation Index: DynamicMockExample.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/functional/test/mockobjects/dynamic/DynamicMockExample.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- DynamicMockExample.java 17 Oct 2003 08:38:31 -0000 1.3 +++ DynamicMockExample.java 17 Oct 2003 23:05:01 -0000 1.4 @@ -24,7 +24,11 @@ DynaMock mockMarket = new DynaMock(Market.class); Agent agent = new Agent((Market)mockMarket.proxy()); - // mockMarket.method("buyStock", "IBM", new Integer(10)); + mockMarket.method("buyStock", "IBM", new Integer(10)).Void(); + + agent.buyLowestPriceStock(20); + + mockMarket.verify(); } public void xtestExample() { Mock mockMarket = new Mock(Market.class); |
From: Steve F. <sm...@us...> - 2003-10-17 23:06:12
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/support In directory sc8-pr-cvs1:/tmp/cvs-serv30164/src/core/test/mockobjects/dynamic/support Modified Files: MockDynamicMock.java Log Message: A bt more of the new dynamic mocks Added MethodExpectation Index: MockDynamicMock.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/support/MockDynamicMock.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- MockDynamicMock.java 17 Oct 2003 08:38:32 -0000 1.1 +++ MockDynamicMock.java 17 Oct 2003 23:05:01 -0000 1.2 @@ -5,12 +5,20 @@ import java.lang.reflect.Method; +import com.mockobjects.util.Verifier; +import com.mockobjects.ExpectationCounter; import com.mockobjects.dynamic.DynamicMock; import com.mockobjects.dynamic.Invokable; +import com.mockobjects.util.AssertMo; -public class MockDynamicMock implements DynamicMock { - +public class MockDynamicMock + extends AssertMo + implements DynamicMock +{ + public ExpectationCounter addCalls = new ExpectationCounter("add calls"); public void add(Invokable invokable) { + assertNotNull("invokable", invokable); + addCalls.inc(); } public Object proxy() { @@ -20,7 +28,9 @@ public void reset() { } + public ExpectationCounter verifyCalls = new ExpectationCounter("verify"); public void verify() { + verifyCalls.inc(); } public Object invoke(Object arg0, Method arg1, Object[] arg2) @@ -31,5 +41,9 @@ public String toStringResult; public String toString() { return toStringResult; + } + + public void verifyExpectations() { + Verifier.verifyObject(this); } } |
From: Steve F. <sm...@us...> - 2003-10-17 23:05:45
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic In directory sc8-pr-cvs1:/tmp/cvs-serv30164/src/core/test/mockobjects/dynamic Modified Files: DynaMockTest.java Added Files: MethodExpectationTest.java Log Message: A bt more of the new dynamic mocks Added MethodExpectation --- NEW FILE: MethodExpectationTest.java --- /* * Copyright mockobjects.com 17-Oct-2003 */ package test.mockobjects.dynamic; import com.mockobjects.ExpectationCounter; import com.mockobjects.dynamic.InvocationMatcher; import com.mockobjects.dynamic.InvocationMocker; import com.mockobjects.dynamic.MethodExpectation; import com.mockobjects.dynamic.Stub; import com.mockobjects.util.*; public class MethodExpectationTest extends TestCaseMo { public class MockInvocationMocker extends InvocationMocker { public MockInvocationMocker(InvocationMatcher[] matchers, Stub stub) { super(matchers, stub); } public ExpectationCounter addStubCalls = new ExpectationCounter("add stub"); public void addStub(Stub stub) { addStubCalls.inc(); } public void verifyExpectations() { Verifier.verifyObject(this); } } public MethodExpectationTest(String name) { super(name); } public void testVoidAddsVoidStub() { MockInvocationMocker mocker = new MockInvocationMocker(null, null); MethodExpectation expectation = new MethodExpectation(mocker); mocker.addStubCalls.setExpected(1); expectation.Void(); mocker.verifyExpectations(); } } Index: DynaMockTest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/DynaMockTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- DynaMockTest.java 17 Oct 2003 08:38:32 -0000 1.1 +++ DynaMockTest.java 17 Oct 2003 23:05:01 -0000 1.2 @@ -20,5 +20,18 @@ assertEquals("Should be same string", "some string here", mock.toString()); } - // public void testMethodAddsInvocationMockerAndReturns + public void testMethodAddsInvocationMockerAndReturnsMethodExpectation() { + mockCoreMock.addCalls.setExpected(1); + + assertNotNull("Should be method expectation", mock.method("methodname", "param1", "param2")); + mockCoreMock.verifyExpectations(); + } + + public void testVerifyCallsUnderlyingMock() { + mockCoreMock.verifyCalls.setExpected(1); + + mock.verify(); + + mockCoreMock.verifyExpectations(); + } } |
From: Steve F. <sm...@us...> - 2003-10-17 09:05:19
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic In directory sc8-pr-cvs1:/tmp/cvs-serv15764/src/core/com/mockobjects/dynamic Modified Files: InvocationMocker.java Log Message: Marked unfinished method with TODO Index: InvocationMocker.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/InvocationMocker.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- InvocationMocker.java 14 Oct 2003 20:26:03 -0000 1.4 +++ InvocationMocker.java 17 Oct 2003 08:37:47 -0000 1.5 @@ -18,7 +18,7 @@ this.stub = stub; } public String getDescription() { - return null; + return null; // TODO } public boolean matches(Invocation invocation) { |