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-10-01 16:05:17
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic In directory sc8-pr-cvs1:/tmp/cvs-serv13114/src/core/test/mockobjects/dynamic Modified Files: MockTest.java Log Message: Index: MockTest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/MockTest.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- MockTest.java 23 Sep 2003 23:04:33 -0000 1.20 +++ MockTest.java 1 Oct 2003 16:05:12 -0000 1.21 @@ -5,9 +5,10 @@ import com.mockobjects.constraint.Constraint; import com.mockobjects.constraint.IsEqual; -import com.mockobjects.dynamic.C; -import com.mockobjects.dynamic.ConstraintMatcher; -import com.mockobjects.dynamic.Mock; +import com.mockobjects.dynamic.*; +import com.mockobjects.util.*; + +import junit.framework.*; public class MockTest extends TestCase { @@ -17,10 +18,11 @@ final ConstraintMatcher METHOD_ONEARG_CONSTRAINTS = C.args(C.eq("oneP1")); final ConstraintMatcher METHOD_TWOARG_CONSTRAINTS = C.args(C.eq("twoP1"), C.eq("twoP2")); - private MockInvokableFactory mockCallableFactory = new MockInvokableFactory(); - private MockInvocationDispatcher mockDispatcher = new MockInvocationDispatcher(); - private MockInvokable mockInvokable = new MockInvokable(); + private MockCallableFactory mockCallableFactory = new MockCallableFactory(); + private MockCallableCollection mockCallables = new MockCallableCollection(); + private MockCallable mockCall = new MockCallable("call match"); + private DummyInterface proxy; private Mock mock; public MockTest(String name) throws Exception { @@ -28,227 +30,220 @@ } public void setUp() { - mock = new Mock(mockCallableFactory, mockDispatcher, DummyInterface.class, MOCK_NAME); - mockCallableFactory.createCallExpectationResult = mockInvokable; + mock = new Mock(mockCallableFactory, mockCallables, DummyInterface.class, MOCK_NAME); + proxy = (DummyInterface)mock.proxy(); + mockCallableFactory.setupCreateCallExpectation(mockCall); } public void testExpectManyAndVoid() throws Throwable { - mockCallableFactory.createVoidCallableResult = mockInvokable; - - mockCallableFactory.expectCreateVoidCallable(DummyInterface.METHOD_TWOARG_NAME, METHOD_TWOARG_CONSTRAINTS); - mockCallableFactory.createCallExpectation.setExpected(mockInvokable); - - mockDispatcher.addInvokable.setExpected(mockInvokable); + mockCallableFactory.addExpectedCreateVoidCallable(DummyInterface.METHOD_TWOARG_NAME, METHOD_TWOARG_CONSTRAINTS); + mockCallableFactory.setupCreateVoidCallable(mockCall); + mockCallableFactory.addExpectedCreateCallExpectation(mockCall); + mockCallables.addExpectedExpect(mockCall); mock.expect(DummyInterface.METHOD_TWOARG_NAME, METHOD_TWOARG_CONSTRAINTS); - verifyThis(); + Verifier.verifyObject(this); } - private void verifyThis() { - mockCallableFactory.verify(); - mockDispatcher.verifyExpectations(); - mockInvokable.verifyExpectations(); - } - - public void testExpectNoneAndReturn() throws Throwable { - mockCallableFactory.expectCreateReturnCallable(DummyInterface.METHOD_NOARG_NAME, C.NO_ARGS, DummyInterface.METHOD_NOARG_RESULT); - mockCallableFactory.createReturnCallableResult = mockInvokable; - mockCallableFactory.createCallExpectation.setExpected(mockInvokable); - mockDispatcher.addInvokable.setExpected(mockInvokable); + public void testExpectNoneAndReturn() throws Throwable { + mockCallableFactory.addExpectedCreateReturnCallable(DummyInterface.METHOD_NOARG_NAME, C.NO_ARGS, DummyInterface.METHOD_NOARG_RESULT); + mockCallableFactory.setupCreateReturnCallable(mockCall); + mockCallableFactory.addExpectedCreateCallExpectation(mockCall); + mockCallables.addExpectedExpect(mockCall); mock.expectAndReturn(DummyInterface.METHOD_NOARG_NAME, DummyInterface.METHOD_NOARG_RESULT); - verifyThis(); + Verifier.verifyObject(this); } public void testExpectNoneAndThrow() throws Throwable { - mockCallableFactory.expectCreateThrowableCallable(DummyInterface.METHOD_NOARG_NAME, C.NO_ARGS, METHOD_EXCEPTION); - mockCallableFactory.createThrowableCallableResult = mockInvokable; - mockCallableFactory.createCallExpectation.setExpected(mockInvokable); - mockDispatcher.addInvokable.setExpected(mockInvokable); + mockCallableFactory.addExpectedCreateThrowableCallable(DummyInterface.METHOD_NOARG_NAME, C.NO_ARGS, METHOD_EXCEPTION); + mockCallableFactory.setupCreateThrowableCallable(mockCall); + mockCallableFactory.addExpectedCreateCallExpectation(mockCall); + mockCallables.addExpectedExpect(mockCall); mock.expectAndThrow(DummyInterface.METHOD_NOARG_NAME, METHOD_EXCEPTION); - verifyThis(); + Verifier.verifyObject(this); } public void testExpectOneAndThrow() throws Throwable { - mockCallableFactory.expectCreateThrowableCallable(DummyInterface.METHOD_ONEARG_NAME, METHOD_ONEARG_CONSTRAINTS, METHOD_EXCEPTION); - mockCallableFactory.createThrowableCallableResult = mockInvokable; - mockCallableFactory.createCallExpectation.setExpected(mockInvokable); - mockDispatcher.addInvokable.setExpected(mockInvokable); + mockCallableFactory.addExpectedCreateThrowableCallable(DummyInterface.METHOD_ONEARG_NAME, METHOD_ONEARG_CONSTRAINTS, METHOD_EXCEPTION); + mockCallableFactory.setupCreateThrowableCallable(mockCall); + mockCallableFactory.addExpectedCreateCallExpectation(mockCall); + mockCallables.addExpectedExpect(mockCall); mock.expectAndThrow(DummyInterface.METHOD_ONEARG_NAME, DummyInterface.METHOD_ONEARG_ARGS[0], METHOD_EXCEPTION); - verifyThis(); + Verifier.verifyObject(this); } public void testExpectNoneAndVoid() throws Throwable { - mockCallableFactory.expectCreateVoidCallable(DummyInterface.METHOD_NOARG_NAME, C.NO_ARGS); - mockCallableFactory.createVoidCallableResult = mockInvokable; - mockCallableFactory.createCallExpectation.setExpected(mockInvokable); - mockDispatcher.addInvokable.setExpected(mockInvokable); + mockCallableFactory.addExpectedCreateVoidCallable(DummyInterface.METHOD_NOARG_NAME, C.NO_ARGS); + mockCallableFactory.setupCreateVoidCallable(mockCall); + mockCallableFactory.addExpectedCreateCallExpectation(mockCall); + mockCallables.addExpectedExpect(mockCall); mock.expect(DummyInterface.METHOD_NOARG_NAME); - verifyThis(); + Verifier.verifyObject(this); } public void testExpectOneAndVoid() throws Throwable { - mockCallableFactory.expectCreateVoidCallable(DummyInterface.METHOD_ONEARG_NAME, METHOD_ONEARG_CONSTRAINTS); - mockCallableFactory.createVoidCallableResult = mockInvokable; - mockCallableFactory.createCallExpectation.setExpected(mockInvokable); - mockDispatcher.addInvokable.setExpected(mockInvokable); + mockCallableFactory.addExpectedCreateVoidCallable(DummyInterface.METHOD_ONEARG_NAME, METHOD_ONEARG_CONSTRAINTS); + mockCallableFactory.setupCreateVoidCallable(mockCall); + mockCallableFactory.addExpectedCreateCallExpectation(mockCall); + mockCallables.addExpectedExpect(mockCall); mock.expect(DummyInterface.METHOD_ONEARG_NAME, DummyInterface.METHOD_ONEARG_ARGS[0]); - verifyThis(); + Verifier.verifyObject(this); } public void testExpectManyAndReturn() throws Throwable { - mockCallableFactory.expectCreateReturnCallable(DummyInterface.METHOD_TWOARG_NAME, METHOD_TWOARG_CONSTRAINTS, DummyInterface.METHOD_TWOARG_RESULT); - mockCallableFactory.createReturnCallableResult = mockInvokable; - mockCallableFactory.createCallExpectation.setExpected(mockInvokable); - mockDispatcher.addInvokable.setExpected(mockInvokable); + mockCallableFactory.addExpectedCreateReturnCallable(DummyInterface.METHOD_TWOARG_NAME, METHOD_TWOARG_CONSTRAINTS, DummyInterface.METHOD_TWOARG_RESULT); + mockCallableFactory.setupCreateReturnCallable(mockCall); + mockCallableFactory.addExpectedCreateCallExpectation(mockCall); + mockCallables.addExpectedExpect(mockCall); mock.expectAndReturn(DummyInterface.METHOD_TWOARG_NAME, METHOD_TWOARG_CONSTRAINTS, DummyInterface.METHOD_TWOARG_RESULT); - verifyThis(); + Verifier.verifyObject(this); } public void testExpectManyAndThrow() throws Throwable { - mockCallableFactory.expectCreateThrowableCallable(DummyInterface.METHOD_TWOARG_NAME, METHOD_TWOARG_CONSTRAINTS, METHOD_EXCEPTION); - mockCallableFactory.createThrowableCallableResult = mockInvokable; - mockCallableFactory.createCallExpectation.setExpected(mockInvokable); - mockDispatcher.addInvokable.setExpected(mockInvokable); + mockCallableFactory.addExpectedCreateThrowableCallable(DummyInterface.METHOD_TWOARG_NAME, METHOD_TWOARG_CONSTRAINTS, METHOD_EXCEPTION); + mockCallableFactory.setupCreateThrowableCallable(mockCall); + mockCallableFactory.addExpectedCreateCallExpectation(mockCall); + mockCallables.addExpectedExpect(mockCall); mock.expectAndThrow(DummyInterface.METHOD_TWOARG_NAME, METHOD_TWOARG_CONSTRAINTS, METHOD_EXCEPTION); - verifyThis(); + Verifier.verifyObject(this); } public void testExpectOneAndReturn() throws Throwable { - mockCallableFactory.expectCreateReturnCallable(DummyInterface.METHOD_ONEARG_NAME, METHOD_ONEARG_CONSTRAINTS, DummyInterface.METHOD_ONEARG_RESULT); - mockCallableFactory.createReturnCallableResult = mockInvokable; - mockCallableFactory.createCallExpectation.setExpected(mockInvokable); - mockDispatcher.addInvokable.setExpected(mockInvokable); + mockCallableFactory.addExpectedCreateReturnCallable(DummyInterface.METHOD_ONEARG_NAME, METHOD_ONEARG_CONSTRAINTS, DummyInterface.METHOD_ONEARG_RESULT); + mockCallableFactory.setupCreateReturnCallable(mockCall); + mockCallableFactory.addExpectedCreateCallExpectation(mockCall); + mockCallables.addExpectedExpect(mockCall); mock.expectAndReturn(DummyInterface.METHOD_ONEARG_NAME, DummyInterface.METHOD_ONEARG_ARGS[0], DummyInterface.METHOD_ONEARG_RESULT); - verifyThis(); + Verifier.verifyObject(this); } public void testMatchNoneAndVoid() throws Throwable { - mockCallableFactory.expectCreateVoidCallable(DummyInterface.METHOD_NOARG_NAME, C.NO_ARGS); - mockCallableFactory.createVoidCallableResult = mockInvokable; - mockDispatcher.addInvokable.setExpected(mockInvokable); + mockCallableFactory.addExpectedCreateVoidCallable(DummyInterface.METHOD_NOARG_NAME, C.NO_ARGS); + mockCallableFactory.setupCreateVoidCallable(mockCall); + mockCallables.addExpectedMatch(mockCall); mock.match(DummyInterface.METHOD_NOARG_NAME); - verifyThis(); + Verifier.verifyObject(this); } public void testMatchNoneAndReturn() throws Throwable { - mockCallableFactory.expectCreateReturnCallable(DummyInterface.METHOD_NOARG_NAME, C.NO_ARGS, DummyInterface.METHOD_NOARG_RESULT); - mockCallableFactory.createReturnCallableResult = mockInvokable; - mockDispatcher.addInvokable.setExpected(mockInvokable); + mockCallableFactory.addExpectedCreateReturnCallable(DummyInterface.METHOD_NOARG_NAME, C.NO_ARGS, DummyInterface.METHOD_NOARG_RESULT); + mockCallableFactory.setupCreateReturnCallable(mockCall); + mockCallables.addExpectedMatch(mockCall); mock.matchAndReturn(DummyInterface.METHOD_NOARG_NAME, DummyInterface.METHOD_NOARG_RESULT); - verifyThis(); + Verifier.verifyObject(this); } public void testMatchNoneAndThrow() throws Throwable { - mockCallableFactory.expectCreateThrowableCallable(DummyInterface.METHOD_NOARG_NAME, C.NO_ARGS, METHOD_EXCEPTION); - mockCallableFactory.createThrowableCallableResult = mockInvokable; - mockDispatcher.addInvokable.setExpected(mockInvokable); + mockCallableFactory.addExpectedCreateThrowableCallable(DummyInterface.METHOD_NOARG_NAME, C.NO_ARGS, METHOD_EXCEPTION); + mockCallableFactory.setupCreateThrowableCallable(mockCall); + mockCallables.addExpectedMatch(mockCall); mock.matchAndThrow(DummyInterface.METHOD_NOARG_NAME, METHOD_EXCEPTION); - verifyThis(); + Verifier.verifyObject(this); } public void testMatchOneAndVoid() throws Throwable { - mockCallableFactory.expectCreateVoidCallable(DummyInterface.METHOD_ONEARG_NAME, METHOD_ONEARG_CONSTRAINTS); - mockCallableFactory.createVoidCallableResult = mockInvokable; - mockDispatcher.addInvokable.setExpected(mockInvokable); + mockCallableFactory.addExpectedCreateVoidCallable(DummyInterface.METHOD_ONEARG_NAME, METHOD_ONEARG_CONSTRAINTS); + mockCallableFactory.setupCreateVoidCallable(mockCall); + mockCallables.addExpectedMatch(mockCall); mock.match(DummyInterface.METHOD_ONEARG_NAME, DummyInterface.METHOD_ONEARG_ARGS[0]); - verifyThis(); + Verifier.verifyObject(this); } public void testMatchOneAndReturn() throws Throwable { - mockCallableFactory.expectCreateReturnCallable(DummyInterface.METHOD_ONEARG_NAME, METHOD_ONEARG_CONSTRAINTS, DummyInterface.METHOD_ONEARG_RESULT); - mockCallableFactory.createReturnCallableResult = mockInvokable; - mockDispatcher.addInvokable.setExpected(mockInvokable); + mockCallableFactory.addExpectedCreateReturnCallable(DummyInterface.METHOD_ONEARG_NAME, METHOD_ONEARG_CONSTRAINTS, DummyInterface.METHOD_ONEARG_RESULT); + mockCallableFactory.setupCreateReturnCallable(mockCall); + mockCallables.addExpectedMatch(mockCall); mock.matchAndReturn(DummyInterface.METHOD_ONEARG_NAME, DummyInterface.METHOD_ONEARG_ARGS[0], DummyInterface.METHOD_ONEARG_RESULT); - verifyThis(); + Verifier.verifyObject(this); } public void testMatchOneAndThrow() throws Throwable { - mockCallableFactory.expectCreateThrowableCallable(DummyInterface.METHOD_ONEARG_NAME, METHOD_ONEARG_CONSTRAINTS, METHOD_EXCEPTION); - mockCallableFactory.createThrowableCallableResult = mockInvokable; - mockDispatcher.addInvokable.setExpected(mockInvokable); + mockCallableFactory.addExpectedCreateThrowableCallable(DummyInterface.METHOD_ONEARG_NAME, METHOD_ONEARG_CONSTRAINTS, METHOD_EXCEPTION); + mockCallableFactory.setupCreateThrowableCallable(mockCall); + mockCallables.addExpectedMatch(mockCall); mock.matchAndThrow(DummyInterface.METHOD_ONEARG_NAME, DummyInterface.METHOD_ONEARG_ARGS[0], METHOD_EXCEPTION); - verifyThis(); + Verifier.verifyObject(this); } public void testMatchManyAndVoid() throws Throwable { - mockCallableFactory.expectCreateVoidCallable(DummyInterface.METHOD_TWOARG_NAME, METHOD_TWOARG_CONSTRAINTS); - mockCallableFactory.createVoidCallableResult = mockInvokable; - mockDispatcher.addInvokable.setExpected(mockInvokable); + mockCallableFactory.addExpectedCreateVoidCallable(DummyInterface.METHOD_TWOARG_NAME, METHOD_TWOARG_CONSTRAINTS); + mockCallableFactory.setupCreateVoidCallable(mockCall); + mockCallables.addExpectedMatch(mockCall); mock.match(DummyInterface.METHOD_TWOARG_NAME, METHOD_TWOARG_CONSTRAINTS); - verifyThis(); + Verifier.verifyObject(this); } public void testMatchManyAndReturn() throws Throwable { - mockCallableFactory.expectCreateReturnCallable(DummyInterface.METHOD_TWOARG_NAME, METHOD_TWOARG_CONSTRAINTS, DummyInterface.METHOD_TWOARG_RESULT); - mockCallableFactory.createReturnCallableResult = mockInvokable; - mockDispatcher.addInvokable.setExpected(mockInvokable); + mockCallableFactory.addExpectedCreateReturnCallable(DummyInterface.METHOD_TWOARG_NAME, METHOD_TWOARG_CONSTRAINTS, DummyInterface.METHOD_TWOARG_RESULT); + mockCallableFactory.setupCreateReturnCallable(mockCall); + mockCallables.addExpectedMatch(mockCall); mock.matchAndReturn(DummyInterface.METHOD_TWOARG_NAME, METHOD_TWOARG_CONSTRAINTS, DummyInterface.METHOD_TWOARG_RESULT); - verifyThis(); + Verifier.verifyObject(this); } public void testMatchManyAndThrow() throws Throwable { - mockCallableFactory.expectCreateThrowableCallable(DummyInterface.METHOD_TWOARG_NAME, METHOD_TWOARG_CONSTRAINTS, METHOD_EXCEPTION); - mockCallableFactory.createThrowableCallableResult = mockInvokable; - mockDispatcher.addInvokable.setExpected(mockInvokable); + mockCallableFactory.addExpectedCreateThrowableCallable(DummyInterface.METHOD_TWOARG_NAME, METHOD_TWOARG_CONSTRAINTS, METHOD_EXCEPTION); + mockCallableFactory.setupCreateThrowableCallable(mockCall); + mockCallables.addExpectedMatch(mockCall); mock.matchAndThrow(DummyInterface.METHOD_TWOARG_NAME, METHOD_TWOARG_CONSTRAINTS, METHOD_EXCEPTION); - verifyThis(); + Verifier.verifyObject(this); } public void testExpectWithConstraint() throws Throwable { - mockCallableFactory.expectCreateVoidCallable(DummyInterface.METHOD_ONEARG_NAME, METHOD_ONEARG_CONSTRAINTS); - mockCallableFactory.createVoidCallableResult = mockInvokable; - mockCallableFactory.createCallExpectation.setExpected(mockInvokable); - mockDispatcher.addInvokable.setExpected(mockInvokable); + mockCallableFactory.addExpectedCreateVoidCallable(DummyInterface.METHOD_ONEARG_NAME, METHOD_ONEARG_CONSTRAINTS); + mockCallableFactory.setupCreateVoidCallable(mockCall); + mockCallableFactory.addExpectedCreateCallExpectation(mockCall); + mockCallables.addExpectedExpect(mockCall); mock.expect(DummyInterface.METHOD_ONEARG_NAME, new IsEqual(DummyInterface.METHOD_ONEARG_ARGS[0])); - verifyThis(); + Verifier.verifyObject(this); } public void testExpectWithConstraintArray() throws Throwable { - mockCallableFactory.expectCreateVoidCallable(DummyInterface.METHOD_ONEARG_NAME, METHOD_ONEARG_CONSTRAINTS); - mockCallableFactory.createVoidCallableResult = mockInvokable; - mockCallableFactory.createCallExpectation.setExpected(mockInvokable); - mockDispatcher.addInvokable.setExpected(mockInvokable); + mockCallableFactory.addExpectedCreateVoidCallable(DummyInterface.METHOD_ONEARG_NAME, METHOD_ONEARG_CONSTRAINTS); + mockCallableFactory.setupCreateVoidCallable(mockCall); + mockCallableFactory.addExpectedCreateCallExpectation(mockCall); + mockCallables.addExpectedExpect(mockCall); mock.expect(DummyInterface.METHOD_ONEARG_NAME, new Constraint[] { new IsEqual(DummyInterface.METHOD_ONEARG_ARGS[0])}); - verifyThis(); - mockDispatcher.verifyExpectations(); + Verifier.verifyObject(this); + mockCallables.verifyExpectations(); } } |
From: Steve F. <sm...@us...> - 2003-10-01 16:04:37
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic In directory sc8-pr-cvs1:/tmp/cvs-serv12967/src/core/test/mockobjects/dynamic Added Files: InvocationDispatcherTest.java Log Message: |
From: Steve F. <sm...@us...> - 2003-10-01 16:04:25
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic In directory sc8-pr-cvs1:/tmp/cvs-serv12892/src/core/test/mockobjects/dynamic Modified Files: CoreMockTest.java Log Message: Index: CoreMockTest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/CoreMockTest.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- CoreMockTest.java 23 Sep 2003 23:04:33 -0000 1.6 +++ CoreMockTest.java 1 Oct 2003 16:04:19 -0000 1.7 @@ -4,13 +4,18 @@ package test.mockobjects.dynamic; import test.mockobjects.dynamic.support.*; + +import test.mockobjects.dynamic.support.*; import junit.framework.AssertionFailedError; import junit.framework.TestCase; import com.mockobjects.dynamic.CoreMock; import com.mockobjects.dynamic.DynamicUtil; -import com.mockobjects.dynamic.Invocation; import com.mockobjects.util.AssertMo; +import com.mockobjects.util.Verifier; + +import junit.framework.AssertionFailedError; +import junit.framework.TestCase; public class CoreMockTest extends TestCase { @@ -18,15 +23,15 @@ private DummyInterface proxy; private CoreMock coreMock; - private MockInvocationDispatcher mockDispatcher = new MockInvocationDispatcher(); - private MockInvokable mockInvokable = new MockInvokable(); + private MockCallableCollection mockCallables = new MockCallableCollection(); + private MockCallable mockCallable = new MockCallable("coreMock mockCallable"); public CoreMockTest(String name) { super(name); } public void setUp() { - coreMock = new CoreMock(DummyInterface.class, MOCK_NAME, mockDispatcher); + coreMock = new CoreMock(DummyInterface.class, MOCK_NAME, mockCallables); try { proxy = (DummyInterface)coreMock.proxy(); @@ -40,7 +45,7 @@ final String originalMessage = "original message"; Object arg = new AssertionFailedError(originalMessage); - mockDispatcher.dispatchResult = arg; + mockCallables.callResult = arg; try { proxy.noArgVoidMethod(); @@ -53,15 +58,36 @@ public void testProxyReturnsConfiguredResult() throws Throwable { final String RESULT = "configured result"; - mockDispatcher.dispatchResult = RESULT; + mockCallables.callResult = RESULT; assertSame("result is returned by coreMock", RESULT, proxy.oneArgMethod("arg")); } + public void testProxySendsAllArgument() throws Throwable { + mockCallables.addExpectedCall(DummyInterface.METHOD_TWOARG_NAME, DummyInterface.METHOD_TWOARG_ARGS); + + proxy.twoArgMethod(DummyInterface.METHOD_TWOARG_ARGS[0], DummyInterface.METHOD_TWOARG_ARGS[1]); + + // Can't use Verifier as we are verifying "verify" + mockCallables.verifyExpectations(); + } + + public void testProxySendsEmptyArrayWhenNoArguments() throws Throwable { + mockCallables.callResult = "result ignored"; + + mockCallables.addExpectedCall(DummyInterface.METHOD_NOARGVOID_NAME, DummyInterface.METHOD_NOARGVOID_ARGS); + + proxy.noArgVoidMethod(); + + Verifier.verifyObject(this); + // Can't use Verifier as we are verifying "verify" + mockCallables.verifyExpectations(); + } + public void testExceptionsPropagatedThroughProxy() throws Throwable { final Throwable throwable = new DummyThrowable(); - mockDispatcher.dispatchThrowable = throwable; + mockCallables.callException = throwable; try { proxy.noArgVoidMethod(); @@ -73,50 +99,49 @@ } public void testMockVerifies() throws Exception { - mockDispatcher.verifyCalls.setExpected(1); + mockCallables.setExpectedVerifyCalls(1); coreMock.verify(); // Can't use Verifier as we are verifying "verify" - mockDispatcher.verifyExpectations(); + mockCallables.verifyExpectations(); } public void testProxyEquality() throws Exception { - mockDispatcher.dispatchResult = new Boolean(false); + mockCallables.callResult = new Boolean(false); - mockDispatcher.dispatchInvocation.setExpectNothing(); + mockCallables.setExpectedCallCalls(0); assertTrue("Proxy equality is implemented directly", proxy.equals(proxy)); - mockDispatcher.verifyExpectations(); + + Verifier.verifyObject(this); } public void testProxyInequality() throws Exception { - mockDispatcher.dispatchResult = new Boolean(false); + mockCallables.callResult = new Boolean(false); - mockDispatcher.dispatchInvocation.setExpected( - new Invocation("equals", new Class[] { Object.class }, boolean.class, - new Object[] { "not a proxy" })); + mockCallables.addExpectedCall("equals", new Object[] {"not a proxy"}); assertFalse("Should handle proxy inequality by calling through", proxy.equals("not a proxy")); - mockDispatcher.verifyExpectations(); + + Verifier.verifyObject(this); } public void testProxyEqualityWithNull() throws Exception { - mockDispatcher.dispatchResult = new Boolean(true); - mockDispatcher.dispatchInvocation.setExpected( - new Invocation("equals", new Class[] { Object.class }, boolean.class, - new Object[] { null })); + mockCallables.callResult = new Boolean(true); + mockCallables.addExpectedCall("equals", new Object[] {null}); assertTrue("Proxy should handle null equality", proxy.equals(null)); - mockDispatcher.verifyExpectations(); + + Verifier.verifyObject(this); } public void testCallingGetMockNameOnProxyReturnsNameOfUnderlyingMock() { - mockDispatcher.dispatchInvocation.setExpectNothing(); + mockCallables.setExpectedCallCalls(0); assertEquals("proxy.getMockName() returns name of underlying mock", MOCK_NAME, proxy.getMockName()); - mockDispatcher.verifyExpectations(); + Verifier.verifyObject(this); } public void testGeneratesMockNameFromInterfaceNameIfNoNameSpecified() throws Exception { @@ -132,33 +157,40 @@ coreMock.verify(); // should not fail on a proxyToString call } - public void testAddAnInvokable() { - mockDispatcher.addInvokable.setExpected(mockInvokable); + public void testAddAnExpectation() { + mockCallables.addExpectedExpect(mockCallable); - coreMock.expect(mockInvokable); + coreMock.expect(mockCallable); - mockDispatcher.verifyExpectations(); + mockCallables.verifyExpectations(); } + public void testAddAStub() { + mockCallables.addExpectedMatch(mockCallable); + + coreMock.stub(mockCallable); + + mockCallables.verifyExpectations(); + } public void testReset() { - mockDispatcher.clearCalls.setExpected(1); + mockCallables.resetCalls.setExpected(1); coreMock.reset(); - mockDispatcher.verifyExpectations(); + mockCallables.verifyExpectations(); } public void testVerifyFailuresIncludeMockName() { - mockDispatcher.verifyFailure = new AssertionFailedError("verify failure"); + mockCallables.verifyFailure = new AssertionFailedError("verify failure"); - mockDispatcher.verifyCalls.setExpected(1); + mockCallables.setExpectedVerifyCalls(1); try { coreMock.verify(); } catch (AssertionFailedError expected) { AssertMo.assertIncludes("Should include mock name", MOCK_NAME, expected.getMessage()); - mockDispatcher.verifyExpectations(); + mockCallables.verifyExpectations(); return; } fail("Should have thrown exception"); |
From: Steve F. <sm...@us...> - 2003-10-01 15:59:53
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/functional/test/mockobjects/dynamic In directory sc8-pr-cvs1:/tmp/cvs-serv11815/src/core/functional/test/mockobjects/dynamic Added Files: DynamicMockExample.java Log Message: Added example for Dynamic Mocks --- NEW FILE: DynamicMockExample.java --- /* * Copyright mockobjects.com 23-Sep-2003 */ package functional.test.mockobjects.dynamic; import junit.framework.TestCase; import com.mockobjects.dynamic.*; public class DynamicMockExample extends TestCase { public interface Market { } public class Agent { public Agent(Market market) { } public void buyLowestPriceStock(int cost) { // TODO Auto-generated method stub } } public void xtestExample() { Mock mockMarket = new Mock(Market.class); Agent agent = new Agent((Market)mockMarket.proxy()); // // // mockMarket.method("buyStock", "MSFT", new Integer(10)).returns(true) // .expectOnce(); // //.expectNever(); // //.addMatcher(new MyExpectation()); // // mockMarket.method("listStocks").alwaysReturns(new Vector("MSFT", "ORCL")); // mockMarket.method("getPrice", "MSFT").alwaysReturns(10); // mockMarket.method("getPrice", "ORCL").alwaysReturns(50); // // mockMarket.method(C.equal("buyStock"), C.eq(1)). // // mockMarket.methodName("listStocks").noParams() // .alwaysReturns("MSFT"); // // InvocationHandler listInvocation = mockMarket.methodName("listStocks").noParams() // .returns("MSFT") // .returns("ORCL") // .throwsException(new ....); // // mockMarket.methodName("buyStock").params("MSFT", 10).returns(900) // .calledOnce() // .before(listInvocation); // mockMarket.methodName("buyStock").params("ORCL", 2).returns(100) // .calledOnce() // .before(listInvocation); // // mockMarket.newInvocationHandler().addMatcher( new NameMatcher(new IsEqual("buyStock")) // .addMatcher( new ActualParameterMatcher( new Constraint[] { new IsEqual("MSFT"), new IsEqual(new Integer(10)}))) // .addStub( new ReturnStub( new Integer(900) ))); // // agent.buyLowestPriceStock(1000); } } |
From: Steve F. <sm...@us...> - 2003-10-01 15:59:42
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/functional In directory sc8-pr-cvs1:/tmp/cvs-serv11731/src/core/functional Log Message: Directory /cvsroot/mockobjects/mockobjects-java/src/core/functional added to the repository |
From: Steve F. <sm...@us...> - 2003-10-01 15:59:42
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/functional/test/mockobjects/dynamic In directory sc8-pr-cvs1:/tmp/cvs-serv11731/src/core/functional/test/mockobjects/dynamic Log Message: Directory /cvsroot/mockobjects/mockobjects-java/src/core/functional/test/mockobjects/dynamic added to the repository |
From: Steve F. <sm...@us...> - 2003-10-01 15:59:42
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/functional/test In directory sc8-pr-cvs1:/tmp/cvs-serv11731/src/core/functional/test Log Message: Directory /cvsroot/mockobjects/mockobjects-java/src/core/functional/test added to the repository |
From: Steve F. <sm...@us...> - 2003-10-01 15:59:42
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/functional/test/mockobjects In directory sc8-pr-cvs1:/tmp/cvs-serv11731/src/core/functional/test/mockobjects Log Message: Directory /cvsroot/mockobjects/mockobjects-java/src/core/functional/test/mockobjects added to the repository |
From: Nat P. <nat...@b1...> - 2003-09-24 11:17:13
|
The Callable interface only defines three methods. It's very easy to implement. More details are on the Wiki. Cheers, Nat. _______________________ Dr. Nathaniel Pryce B13media Ltd. http://www.b13media.com +44 (0)7712 526 661 ----- Original Message ----- From: "veny" <ve...@p2...> To: "MockObject users (E-mail)" <moc...@li...>; "MockObjects devs (E-mail)" <moc...@li...> Sent: Wednesday, September 24, 2003 3:42 AM Subject: [MO-java-users] Re: A kind of "don't care" Mock? > > Hi, > > I am having the same problem. Any easier way than writing a custom Callable > objects? > or how to easily write a Callable object that fulfils what is required. > > Thanks. > > Veny > > From: Nat Pryce <nat@b1...> > Re: A kind of "don't care" Mock? > 2003-09-23 14:17 > With the dynamic mocks you can write your own Callable objects to match > against any method or in some other custom manner. > > Cheers, > Nat. > > _______________________ > Dr. Nathaniel Pryce > B13media Ltd. > http://www.b13media.com > +44 (0)7712 526 661 > > ----- Original Message ----- > From: "Frederic Donckels" <frederic.donckels@ac...> > To: <mockobjects-java-users@li...> > Sent: Tuesday, September 23, 2003 11:11 AM > Subject: [MO-java-users] A kind of "don't care" Mock? > > > > Hi all, > > > > I must confess I haven't thoroughly searched through either Wiki, > > the lists or the source code (Flame disclaimer :) ) > > > > Is there a way to create a mock with a default 'I don't care' > > behaviour for most of the methods? > > What I mean is that, for some tests, there might be a bunch of > > methods called, for which I don't want to set expectations (because > > sometimes I don't know which methods will be called, how many times, > > ..., or if the mock-proxy is temporarily handled to an outside object > > for which I don''t have the source code, or I just don't care to > > provide an 'implementation' (hashcode, toString, ..)). > > For those methods, I'd just like to set a global default behaviour: > > - match any call, with any args (or no args) > > - return a default value (true or false for boolean, 0 for numeric > > values, null for objects) (with this default value that could be > > changed). > > > > but still to be able to set expectations on methods I care. > > > > In the same way, is there a way to say "this method will be called, > > I don't care how many times, just return always this value" ? > > > > Thanks!! > > > > Regards > > > > Frederic > > |
From: Steve F. <sm...@us...> - 2003-09-23 23:04:37
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/support In directory sc8-pr-cvs1:/tmp/cvs-serv3211/src/core/test/mockobjects/dynamic/support Added Files: MockInvokableFactory.java MockConstraint.java MockInvokable.java MockConstraintMatcher.java MockCallable.java MockInvocationDispatcher.java Log Message: Moved mocks to support testing of dynamic mock into support package for clarity. --- NEW FILE: MockInvokableFactory.java --- /* * Copyright mockobjects.com 11-Sep-2003 * */ package test.mockobjects.dynamic.support; import com.mockobjects.ExpectationList; import com.mockobjects.ExpectationValue; import com.mockobjects.MockObject; import com.mockobjects.dynamic.InvokableFactory; import com.mockobjects.dynamic.ConstraintMatcher; import com.mockobjects.dynamic.Invokable; public class MockInvokableFactory extends MockObject implements InvokableFactory { public Invokable createCallExpectationResult; public Invokable createReturnCallableResult; public Invokable createThrowableCallableResult; public Invokable createVoidCallableResult; public ExpectationValue createCallExpectation = new ExpectationValue("createCallExpectation"); public ExpectationList parameters = new ExpectationList("parameters"); public Invokable createCallExpectation(Invokable invokable) { createCallExpectation.setActual(invokable); return createCallExpectationResult; } public void expectCreateReturnCallable( String methodName, ConstraintMatcher constraints, Object result) { parameters.addExpectedMany( new Object[] { "createReturnCallable", methodName, constraints, result }); } public Invokable createReturnCallable( String methodName, ConstraintMatcher constraints, Object result) { parameters.addActualMany( new Object[] { "createReturnCallable", methodName, constraints, result }); return createReturnCallableResult; } public void expectCreateThrowableCallable( String methodName, ConstraintMatcher constraints, Throwable throwable) { parameters.addExpectedMany( new Object[] { "createThrowableCallable", methodName, constraints, throwable }); } public Invokable createThrowableCallable( String methodName, ConstraintMatcher constraints, Throwable throwable) { parameters.addActualMany( new Object[] { "createThrowableCallable", methodName, constraints, throwable }); return createThrowableCallableResult; } public void expectCreateVoidCallable( String methodName, ConstraintMatcher constraints) { parameters.addExpectedMany( new Object[] { "createVoidCallable", methodName, constraints }); } public Invokable createVoidCallable( String methodName, ConstraintMatcher constraints) { parameters.addActualMany( new Object[] { "createVoidCallable", methodName, constraints }); return createVoidCallableResult; } } --- NEW FILE: MockConstraint.java --- /* * Created on 04-Apr-2003 */ package test.mockobjects.dynamic.support; import junit.framework.*; import com.mockobjects.*; import com.mockobjects.constraint.*; /** * @author dev */ public class MockConstraint extends Assert implements Constraint, Verifiable { private String description; private Object expectedArg; private boolean result; private boolean wasChecked = false; public MockConstraint( String description, Object expectedArg, boolean result ) { this.description = description; this.expectedArg = expectedArg; this.result = result; } public String toString() { return description; } public boolean eval( Object arg ) { assertSame( "Should be expected argument", expectedArg, arg ); wasChecked = true; return result; } public void verify() { assertTrue( description + " should have been checked", wasChecked ); } } --- NEW FILE: MockInvokable.java --- /* * Created on 20-Aug-2003 * Copyright mockobjects.com */ package test.mockobjects.dynamic.support; import com.mockobjects.ExpectationCounter; import com.mockobjects.ExpectationValue; import com.mockobjects.dynamic.Invocation; import com.mockobjects.dynamic.Invokable; import com.mockobjects.util.Verifier; public class MockInvokable implements Invokable { public boolean matchesResult; public ExpectationValue matchesInvocation = new ExpectationValue("matches.invocation"); public Object invokeResult; public ExpectationValue invokeInvocation = new ExpectationValue("invoke.invocation"); public Throwable invokeThrow; public ExpectationCounter verifyCalls = new ExpectationCounter("verify.calls"); public String getDescription() { return null; } public boolean matches(Invocation invocation) { matchesInvocation.setActual(invocation); return matchesResult; } public Object invoke(Invocation invocation) throws Throwable { invokeInvocation.setActual(invocation); if (invokeThrow != null) { throw invokeThrow; } return invokeResult; } public void verify() { verifyCalls.inc(); } public void verifyExpectations() { Verifier.verifyObject(this); } } --- NEW FILE: MockConstraintMatcher.java --- package test.mockobjects.dynamic.support; import com.mockobjects.*; import com.mockobjects.dynamic.ConstraintMatcher; public class MockConstraintMatcher implements ConstraintMatcher{ private ExpectationCounter myMatchesCalls = new ExpectationCounter("MockConstraintMatcher.matches(Object[])"); private ReturnValues myActualMatchesReturnValues = new ReturnValues("MockConstraintMatcher.matches(Object[])", true); private ExpectationList myMatchesParameter0Values = new ExpectationList("MockConstraintMatcher.matches(Object[]) java.lang.Object"); private ExpectationCounter myGetConstraintsCalls = new ExpectationCounter("MockConstraintMatcher.getConstraints()"); private ReturnValues myActualGetConstraintsReturnValues = new ReturnValues("MockConstraintMatcher.getConstraints()", true); public void setExpectedMatchesCalls(int calls){ myMatchesCalls.setExpected(calls); } public void addExpectedMatches(Object[] arg0){ myMatchesParameter0Values.addExpectedMany(arg0); } public boolean matches(Object[] arg0){ myMatchesCalls.inc(); myMatchesParameter0Values.addActualMany(arg0); Object nextReturnValue = myActualMatchesReturnValues.getNext(); if (nextReturnValue instanceof ExceptionalReturnValue && ((ExceptionalReturnValue)nextReturnValue).getException() instanceof RuntimeException) throw (RuntimeException)((ExceptionalReturnValue)nextReturnValue).getException(); return ((Boolean) nextReturnValue).booleanValue(); } public void setupExceptionMatches(Throwable arg){ myActualMatchesReturnValues.add(new ExceptionalReturnValue(arg)); } public void setupMatches(boolean arg){ myActualMatchesReturnValues.add(new Boolean(arg)); } public void setExpectedGetConstraintsCalls(int calls){ myGetConstraintsCalls.setExpected(calls); } public Object[] getConstraints(){ myGetConstraintsCalls.inc(); Object nextReturnValue = myActualGetConstraintsReturnValues.getNext(); if (nextReturnValue instanceof ExceptionalReturnValue && ((ExceptionalReturnValue)nextReturnValue).getException() instanceof RuntimeException) throw (RuntimeException)((ExceptionalReturnValue)nextReturnValue).getException(); return (Object[]) nextReturnValue; } public void setupExceptionGetConstraints(Throwable arg){ myActualGetConstraintsReturnValues.add(new ExceptionalReturnValue(arg)); } public void setupGetConstraints(Object[] arg){ myActualGetConstraintsReturnValues.add(arg); } public void verify(){ myMatchesCalls.verify(); myMatchesParameter0Values.verify(); myGetConstraintsCalls.verify(); } } --- NEW FILE: MockCallable.java --- package test.mockobjects.dynamic.support; import junit.framework.AssertionFailedError; import com.mockobjects.ExpectationCounter; import com.mockobjects.ExpectationList; import com.mockobjects.ExpectationValue; import com.mockobjects.ReturnValue; import com.mockobjects.dynamic.Invocation; import com.mockobjects.dynamic.Invokable; import com.mockobjects.util.Verifier; public class MockCallable implements Invokable { final public String name; public ExpectationValue callInvocation = new ExpectationValue("call") ; private ReturnValue callResult = new ReturnValue("call.return"); private Throwable callThrow = null; private ExpectationValue matchesMethodName = new ExpectationValue("matches.methodName"); private ExpectationList matchesArgs = new ExpectationList("matches.args"); public boolean matches = false; private ExpectationCounter matchesCount = new ExpectationCounter("matches.count"); private ExpectationCounter verifyCount = new ExpectationCounter("verify.count"); private AssertionFailedError verifyError = null; public MockCallable(String name) { this.name = name; } public void setupCallReturn( Object result ) { callResult.setValue(result); } public void setupCallThrow( Throwable thrown ) { callThrow = thrown; } public Object invoke(Invocation anInvocation) throws Throwable { callInvocation.setActual(anInvocation); if( callThrow != null ) { throw callThrow; } else { return callResult.getValue(); } } public void setExpectedMatches( String methodName, Object[] args ) { matchesMethodName.setExpected(methodName); matchesArgs.addExpectedMany(args); } public void setExpectedMatchesCount(int count) { matchesCount.setExpected(count); } public boolean matches(Invocation invocation) { matchesMethodName.setActual(invocation.getMethodName()); matchesArgs.addActualMany(invocation.getParameterValues().toArray()); matchesCount.inc(); return matches; } public void setExpectedVerifyCalls( int count ) { verifyCount.setExpected(count); } public void setupVerifyThrow( AssertionFailedError err ) { verifyError = err; } /** @deprecated to avoid calling verify instead of verifyExpectations */ public void verify() { verifyCount.inc(); if( verifyError != null ) throw verifyError; } /** We have to rename 'verify' because we want to mock the behaviour of the * verify method itself. */ public void verifyExpectations() { Verifier.verifyObject(this); } public String getDescription() { return name; } public String toString() { return "MockCallable " + name; } } --- NEW FILE: MockInvocationDispatcher.java --- /* * 11-Sep-2003 * Copyright mockobjects.com */ package test.mockobjects.dynamic.support; import junit.framework.AssertionFailedError; import com.mockobjects.ExpectationCounter; import com.mockobjects.ExpectationValue; import com.mockobjects.MockObject; import com.mockobjects.dynamic.Invocation; import com.mockobjects.dynamic.InvocationDispatcher; import com.mockobjects.dynamic.Invokable; public class MockInvocationDispatcher extends MockObject implements InvocationDispatcher { public ExpectationValue dispatchInvocation = new ExpectationValue("dispatchInvocation"); public Object dispatchResult; public Throwable dispatchThrowable; public ExpectationValue addInvokable = new ExpectationValue("addInvokable"); public ExpectationCounter clearCalls = new ExpectationCounter("clear calls"); public ExpectationCounter verifyCalls = new ExpectationCounter("verify calls"); public AssertionFailedError verifyFailure; public void add(Invokable invokable) { addInvokable.setActual(invokable); } public void clear() { clearCalls.inc(); } public Object dispatch(Invocation invocation) throws Throwable { dispatchInvocation.setActual(invocation); if (null != dispatchThrowable) { throw dispatchThrowable; } return dispatchResult; } /** * @deprecated Use verifyExpectations to verify this object */ public void verify() { verifyCalls.inc(); if (null != verifyFailure) { throw verifyFailure; } } public void verifyExpectations() { super.verify(); } } |
Update of /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic In directory sc8-pr-cvs1:/tmp/cvs-serv3211/src/core/test/mockobjects/dynamic Modified Files: CallOnceExpectationTest.java ConstraintMatcherTest.java CallSignatureTest.java MockTest.java CoreMockTest.java CallableArrayListTest.java CallSequenceTest.java LIFOInvocationDispatcherTest.java Removed Files: MockConstraint.java MockConstraintMatcher.java MockInvocationDispatcher.java MockCallable.java MockInvokable.java MockInvokableFactory.java Log Message: Moved mocks to support testing of dynamic mock into support package for clarity. Index: CallOnceExpectationTest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/CallOnceExpectationTest.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- CallOnceExpectationTest.java 20 Aug 2003 21:51:27 -0000 1.7 +++ CallOnceExpectationTest.java 23 Sep 2003 23:04:33 -0000 1.8 @@ -1,5 +1,7 @@ package test.mockobjects.dynamic; +import test.mockobjects.dynamic.support.*; + import com.mockobjects.dynamic.*; import com.mockobjects.util.*; Index: ConstraintMatcherTest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/ConstraintMatcherTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ConstraintMatcherTest.java 18 May 2003 20:59:37 -0000 1.2 +++ ConstraintMatcherTest.java 23 Sep 2003 23:04:33 -0000 1.3 @@ -1,5 +1,7 @@ package test.mockobjects.dynamic; +import test.mockobjects.dynamic.support.*; + import com.mockobjects.dynamic.*; import com.mockobjects.dynamic.ConstraintMatcher; Index: CallSignatureTest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/CallSignatureTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- CallSignatureTest.java 20 Aug 2003 21:51:27 -0000 1.4 +++ CallSignatureTest.java 23 Sep 2003 23:04:33 -0000 1.5 @@ -3,6 +3,7 @@ */ package test.mockobjects.dynamic; +import test.mockobjects.dynamic.support.*; import junit.framework.TestCase; import com.mockobjects.dynamic.*; Index: MockTest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/MockTest.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- MockTest.java 11 Sep 2003 21:39:01 -0000 1.19 +++ MockTest.java 23 Sep 2003 23:04:33 -0000 1.20 @@ -1,5 +1,6 @@ package test.mockobjects.dynamic; +import test.mockobjects.dynamic.support.*; import junit.framework.TestCase; import com.mockobjects.constraint.Constraint; Index: CoreMockTest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/CoreMockTest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- CoreMockTest.java 11 Sep 2003 21:39:01 -0000 1.5 +++ CoreMockTest.java 23 Sep 2003 23:04:33 -0000 1.6 @@ -3,6 +3,7 @@ */ package test.mockobjects.dynamic; +import test.mockobjects.dynamic.support.*; import junit.framework.AssertionFailedError; import junit.framework.TestCase; Index: CallableArrayListTest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/CallableArrayListTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- CallableArrayListTest.java 20 Aug 2003 21:51:27 -0000 1.2 +++ CallableArrayListTest.java 23 Sep 2003 23:04:33 -0000 1.3 @@ -3,6 +3,8 @@ */ package test.mockobjects.dynamic; +import test.mockobjects.dynamic.support.*; + import com.mockobjects.dynamic.Invokable; import com.mockobjects.dynamic.CallableArrayList; import com.mockobjects.dynamic.CallableList; Index: CallSequenceTest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/CallSequenceTest.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- CallSequenceTest.java 20 Aug 2003 21:51:27 -0000 1.15 +++ CallSequenceTest.java 23 Sep 2003 23:04:33 -0000 1.16 @@ -3,6 +3,8 @@ */ package test.mockobjects.dynamic; +import test.mockobjects.dynamic.support.*; + import com.mockobjects.dynamic.*; import com.mockobjects.dynamic.C; import com.mockobjects.dynamic.CallSignature; Index: LIFOInvocationDispatcherTest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/LIFOInvocationDispatcherTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- LIFOInvocationDispatcherTest.java 11 Sep 2003 21:39:01 -0000 1.1 +++ LIFOInvocationDispatcherTest.java 23 Sep 2003 23:04:33 -0000 1.2 @@ -6,6 +6,8 @@ import java.lang.reflect.Method; +import test.mockobjects.dynamic.support.*; + import junit.framework.TestCase; import com.mockobjects.dynamic.DynamicMockError; --- MockConstraint.java DELETED --- --- MockConstraintMatcher.java DELETED --- --- MockInvocationDispatcher.java DELETED --- --- MockCallable.java DELETED --- --- MockInvokable.java DELETED --- --- MockInvokableFactory.java DELETED --- |
From: Steve F. <sm...@us...> - 2003-09-23 23:04:25
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/support In directory sc8-pr-cvs1:/tmp/cvs-serv3133/src/core/test/mockobjects/dynamic/support Log Message: Directory /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/support added to the repository |
From: Jeff M. <je...@cu...> - 2003-09-23 08:37:38
|
> Is there any near-term plans to fix these methods? If not, would > anyone mind if I helped out? Personally, I've implemented as much of the JMS mocks as I use so have no plans to implement anything else for the time being. Feel free to implement anything you feel you need and I'll look at adding it to HEAD -- Jeff Martin Memetic Engineer http://www.custommonkey.org/ |
From: <Vin...@ge...> - 2003-09-22 22:25:23
|
Hi Brent, The rule is that methods are implemented as the community needs them. Hence the status ;-) I suggest you consider using the dynamic mocks instead of the mock jms package, since most (all?) of the JMS API uses interfaces. It'll save you a lot of time, since you're not forced to write mocks any more - they're generated for you. But you can only mock interfaces. If you're not familiar with dynamic mocks, look at the wiki www.mockobjects.com. Cheers, Vincent > -----Original Message----- > From: moc...@li... > [mailto:moc...@li...]On Behalf Of > br...@wo... > Sent: Monday, September 22, 2003 6:05 PM > To: moc...@li... > Subject: [MO-java-dev] JMS mockobjects > > > I was wondering what the current development status was for the JMS > portion of mockobjects. I was planning to use mockobjects to add some > JMS test cases to geronimo but found some of the mock jms methods I > needed throw unsupported operation exceptions. > > The one that comes to mind is MockTopicSession.createTemporaryTopic > > Is there any near-term plans to fix these methods? If not, would > anyone mind if I helped out? > > > Brent Worden > http://www.brent.worden.org/ > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > Mockobjects-java-dev mailing list > Moc...@li... > https://lists.sourceforge.net/lists/listinfo/mockobjects-java-dev > > -----Original Message----- > From: moc...@li... > [mailto:moc...@li...]On Behalf Of > br...@wo... > Sent: Monday, September 22, 2003 6:05 PM > To: moc...@li... > Subject: [MO-java-dev] JMS mockobjects > > > I was wondering what the current development status was for the JMS > portion of mockobjects. I was planning to use mockobjects to add some > JMS test cases to geronimo but found some of the mock jms methods I > needed throw unsupported operation exceptions. > > The one that comes to mind is MockTopicSession.createTemporaryTopic > > Is there any near-term plans to fix these methods? If not, would > anyone mind if I helped out? > > > Brent Worden > http://www.brent.worden.org/ > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > Mockobjects-java-dev mailing list > Moc...@li... > https://lists.sourceforge.net/lists/listinfo/mockobjects-java-dev > |
From: <br...@wo...> - 2003-09-22 22:04:50
|
I was wondering what the current development status was for the JMS portion of mockobjects. I was planning to use mockobjects to add some JMS test cases to geronimo but found some of the mock jms methods I needed throw unsupported operation exceptions. The one that comes to mind is MockTopicSession.createTemporaryTopic Is there any near-term plans to fix these methods? If not, would anyone mind if I helped out? Brent Worden http://www.brent.worden.org/ |
From: Nat P. <nat...@b1...> - 2003-09-22 12:40:45
|
Create an Constraint[] array with constraint objects in it. e.g. new Constraint[] { C.eq(1), C.eq(2), C.eq(3), C.eq(4) } Cheers, Nat. _______________________ Dr. Nathaniel Pryce B13media Ltd. http://www.b13media.com +44 (0)7712 526 661 ----- Original Message ----- From: "veny" <ve...@p2...> To: "MockObject users (E-mail)" <moc...@li...>; "MockObjects devs (E-mail)" <moc...@li...> Sent: Monday, September 22, 2003 12:28 PM Subject: [MO-java-dev] ConstraintsMatcher for more than 3 input arguments? C.args()? > Hi all, > > How to use ConstraintsMatcher to verify method that has 4 input parameters? > Or is there any other way to do that? > By the way, how to use C.args(), C.args(Constraints, Constraints), > C.args(Constraints, Constraints, Constraints) methods? > > Thanks. > > Veny > > ____________________________________________ > P2H > 136 Telok Ayer St. > Singapore. 068601 > www.p2h.com.sg > > > Veny Handoko > Software Developer > > Tel : +65 6372 2473 > > Fax : +65 6225 1023 > > Mobile : +65 9681 8617 > ve...@p2... > > > -------------------------------------------------------------------------- -- > ---- > > Email disclaimer > The email, its content and any files transmitted with it are intended solely > for the addressee(s) and may be legally privileged and/or confidential. > Access by any other party is unauthorised without the express written > permission of the sender. If you received this email in error,you may not > copy or use the contents, attachments or information in any way. Please > destroy it and contact the sender on the number printed above or via email > return. Internet communications are not secure unless protected using strong > cryptography. This email has been prepared using information believed by the > author to be reliable and accurate, but P2H Pte Ltd makes no warranty as to > accuracy or completeness. In particular P2H Pte Ltd does not accept > responsibility for changes made to this email after it was sent. Any > opinions expressed in this document are those of the author and do not > necessarily reflect the opinions of P2H Pte Ltd or its affiliates. > |
From: veny <ve...@p2...> - 2003-09-22 11:28:25
|
Hi all, How to use ConstraintsMatcher to verify method that has 4 input parameters? Or is there any other way to do that? By the way, how to use C.args(), C.args(Constraints, Constraints), C.args(Constraints, Constraints, Constraints) methods? Thanks. Veny ____________________________________________ P2H 136 Telok Ayer St. Singapore. 068601 www.p2h.com.sg Veny Handoko Software Developer Tel : +65 6372 2473 Fax : +65 6225 1023 Mobile : +65 9681 8617 ve...@p2... ---------------------------------------------------------------------------- ---- Email disclaimer The email, its content and any files transmitted with it are intended solely for the addressee(s) and may be legally privileged and/or confidential. Access by any other party is unauthorised without the express written permission of the sender. If you received this email in error,you may not copy or use the contents, attachments or information in any way. Please destroy it and contact the sender on the number printed above or via email return. Internet communications are not secure unless protected using strong cryptography. This email has been prepared using information believed by the author to be reliable and accurate, but P2H Pte Ltd makes no warranty as to accuracy or completeness. In particular P2H Pte Ltd does not accept responsibility for changes made to this email after it was sent. Any opinions expressed in this document are those of the author and do not necessarily reflect the opinions of P2H Pte Ltd or its affiliates. |
From: Jeff M. <cus...@us...> - 2003-09-17 13:17:13
|
Update of /cvsroot/mockobjects/mockobjects-java/src/j2ee/1.3/com/mockobjects/servlet In directory sc8-pr-cvs1:/tmp/cvs-serv10283/src/j2ee/1.3/com/mockobjects/servlet Modified Files: MockFilterChain.java Log Message: Added counter for MockFilterChange.doFilter Index: MockFilterChain.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/j2ee/1.3/com/mockobjects/servlet/MockFilterChain.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- MockFilterChain.java 23 Feb 2002 18:50:35 -0000 1.1 +++ MockFilterChain.java 17 Sep 2003 13:17:01 -0000 1.2 @@ -1,12 +1,23 @@ package com.mockobjects.servlet; -import com.mockobjects.*; -import javax.servlet.*; +import com.mockobjects.ExpectationCounter; +import com.mockobjects.MockObject; + +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; import java.io.IOException; public class MockFilterChain extends MockObject implements FilterChain { + private final ExpectationCounter doFilterCounter = new ExpectationCounter("do filter"); public void doFilter(ServletRequest request, ServletResponse response) - throws IOException, ServletException{ + throws IOException, ServletException { + doFilterCounter.inc(); + } + + public void setExpectedDoFilterCount(int count) { + doFilterCounter.setExpected(count); } } |
From: Steve F. <st...@m3...> - 2003-09-17 07:21:42
|
At that point you might as well write your mocks by hand -- the expectation library will help you do this. We have some ideas about dynmically mocking classes, but haven't had the time to patch them in. S. veny wrote: > What i actually meant was that i want my mock class to take in expectation > of a method being called and verify whether the method has been called at > the end (i.e. when .verify() method is called). I understand > dynamic.Mock.expect(String methodName) does that. I cant use dynamic.Mock as > the dynamic.Mock can only mock an interface, but i need to mock a class > implementation. > > So my issue is how to write my mock class that so that it can perform a > function like dynamic.Mock.expect(String methodName)? Any idea? |
From: veny <ve...@p2...> - 2003-09-17 02:24:55
|
Hi Steve, Thanks for your reply. What i actually meant was that i want my mock class to take in expectation of a method being called and verify whether the method has been called at the end (i.e. when .verify() method is called). I understand dynamic.Mock.expect(String methodName) does that. I cant use dynamic.Mock as the dynamic.Mock can only mock an interface, but i need to mock a class implementation. So my issue is how to write my mock class that so that it can perform a function like dynamic.Mock.expect(String methodName)? Any idea? Thanks lots. Veny -----Original Message----- From: Steve Freeman [mailto:st...@m3...] Sent: Tuesday, September 16, 2003 3:09 PM To: ve...@p2... Cc: 'Francois Beausoleil'; MockObject users (E-mail); MockObjects devs (E-mail) Subject: Re: [MO-java-users] RE: [MO-java-dev] creating a dynamic mock error - com.packagename.classname is not an interface. veny wrote: > I have another question thought. How should i write the equivalent of > methods 'dynamic.Mock.expect(String methodName)' and > 'dynamic.Mock.expectAndReturn(String methodName, java.lang.Object obj)' in > own Mock object? If you mean when writing a mock object using the dynamic libraries, then no. The Dynamic Mock will do the work. If you mean, when writing your own mock objects from scratch, then you should write some kind of expectation, but how you write that is up to you. S. |
From: Steve F. <st...@m3...> - 2003-09-16 07:10:11
|
veny wrote: > I have another question thought. How should i write the equivalent of > methods 'dynamic.Mock.expect(String methodName)' and > 'dynamic.Mock.expectAndReturn(String methodName, java.lang.Object obj)' in > own Mock object? If you mean when writing a mock object using the dynamic libraries, then no. The Dynamic Mock will do the work. If you mean, when writing your own mock objects from scratch, then you should write some kind of expectation, but how you write that is up to you. S. |
From: veny <ve...@p2...> - 2003-09-16 06:37:23
|
Hi Francois, Thanks for your explanation. I have another question thought. How should i write the equivalent of methods 'dynamic.Mock.expect(String methodName)' and 'dynamic.Mock.expectAndReturn(String methodName, java.lang.Object obj)' in own Mock object? Is there any sample available? Thanks lots. Veny -----Original Message----- From: Francois Beausoleil [mailto:fb...@us...] Sent: Tuesday, September 16, 2003 11:43 AM To: ve...@p2... Subject: Re: [MO-java-dev] creating a dynamic mock error - com.packagename.classname is not an interface. As you have noticed, you cannot mock classes. For your information, java.util.List is an interface, not a class. ArrayList and LinkedList are actual implementations of the List interface. To mock concrete classes, you have to resort to the old way: public class ObjectUnderTest { public void method(Object arg) { // Do something } } public class MockObjectUnderTest extends ObjectUnderTest implements Verifiable { private ExpectationValue expectedArg = new ExpectationValue("arg"); public void setExpectedArg(Object arg) { expectedArg.setExpected(arg); } public void method(Object arg) { expectedArg.setActual(arg); // Might call into super class to execute the code for real, or not, // depending on your needs. } public void verify() { // This asserts that all Verifiable objects in this class have their // verify() methods called, and any exceptions thrown up the // call stack Verifier.verifyObject(this); } } That is why most programmers and designers recommend coding against interfaces. This helps because you can then send in a mock implementation. DynaMocks are simpler to setup than old-style Mocks. I sure hope that helps ! If you have other questions, do not hesitate ! François On Tue, 16 Sep 2003 10:06:14 +0800, "veny" <ve...@p2...> said: > Hi all, > > I've been using DynaMock to create mock class from interfaces. It works > great. However, when i tried to mock my classes, there's always this > error: > "com.packagename.classname is not an interface". I've tried to mock java > class (e.g. java.util.List), it works. But why creating of mock of my > custom > class doesn't? Any idea? > > Thanks. > > Veny Developer of Java Gui Builder http://jgb.sourceforge.net/ |
From: veny <ve...@p2...> - 2003-09-16 02:06:57
|
Hi all, I've been using DynaMock to create mock class from interfaces. It works great. However, when i tried to mock my classes, there's always this error: "com.packagename.classname is not an interface". I've tried to mock java class (e.g. java.util.List), it works. But why creating of mock of my custom class doesn't? Any idea? Thanks. Veny |
From: Francois B. <fb...@us...> - 2003-09-12 02:22:46
|
Hello Veny, Here is a bit of information for you: expectAndReturn() Expect a call to the named method using the specified argument or arguments, and return the specified value. It is possible to also throw an Exception instead by using expectAndThrow(). As you have guessed, expectAndReturn() will fail the verification if the method has not been called. matchAndReturn() Stub out a method call. This would be useful in the case where you will be calling a method, but do not care if the method is called once, twice or no time at all. ConstraintMatcher It is possible to specify constraints on the parameters that are received. Let's say you are mocking a List. Lists have a method named Object get(int index). It is possible to ask the expectAndReturn method to assert that the method is called with an appropriate parameter. An example will help: Mock mockList =3D new Mock(List.class); List list =3D (List)mockList.proxy(); mockList.expectAndReturn("get", C.eq(3), "returned object"); // This is where the domain methods call upon the mock classUnderTest.method(list); mockList.verify(); Given the above, the following implementation will fail: public void method(List list) { int index =3D 4; this.object =3D list.get(index); } It will fail because the expectAndReturn() method expected a single parameter, and it must have been equal to 3 (C.eq stands for ConstraintMatcher Shortcuts.equals(3)). Given the above too, this implementation will fail the verify() stage: public void method(List list) { } The Mock expected the get() method to be called with 3 as an argument, but did not receive it. Finally, if you overload your methods, the same principles as Java apply: interface User { addBilling(double x); addBilling(long x); } Mock mockUser =3D new Mock(User.class); User user =3D (User)mockUser.proxy(); user.expect("addBilling", C.eq(new Double(13.2d))); user.expect("addBilling", C.eq(new Long(17l))); classUnderTest.do(user); public void do(User user) { user.addBilling(17); // Passes. Java calls addBilling(long) user.addBilling(13.2f); // Passes. Java calls addBilling(double) } As for your last question, if the method that you expect a call upon accepts a single parameter, and you want to assert equality, Mock implementations allow a shortcut. Instead of this: user.expect("addBilling", C.eq(new Double(13.2d))); You can do this instead: user.expect("addBilling", new Double(13.2d)); Notice that the C.eq() was removed. We are expecting equality, and this will assert it just fine. For documentation, you can try http://www.mockobjects.org/. This will bring you to the MockObjects Wiki. There is information on the wiki about the framework. Not everything is documented, but a good bit of it is available. Have a nice day ! Fran=E7ois On Fri, 12 Sep 2003 09:39:18 +0800, "veny" <ve...@p2...> said: > Hi all, >=20 > I am new to mockobject and looking through the DynaMock class. > Could somebody give me some idea, what does the following methods in > com.mockobjects.dynamic.Mock class do? >=20 > expectAndReturn(java.lang.String methodName, ConstraintMatcher args, > java.lang.Object result) > expectAndReturn(java.lang.String methodName, java.lang.Object > singleEqualArg, boolean result) >=20 > I understand the above methods is setting the return value for the named > method. But some questions: > - How does ConstraintMatcher works? > - For the second method, what is the use of parameter singleEqualArg? > - These methods are name expectAndReturn, does it implies that if the > named > method is not called, it will throw an error? - How bout if the codes > have > methods overloading, how does expectAndReturn know which method i am > referring to? >=20 > matchAndReturn(java.lang.String methodName, java.lang.Object result) > How is this different from expectAndReturn? >=20 > The javadoc has rather limited explanation, any recommendation to sites > that > have sample or more detailed explanation? >=20 > Thanks lots. >=20 > Veny Developer of Java Gui Builder http://jgb.sourceforge.net/ |
From: veny <ve...@p2...> - 2003-09-12 01:39:24
|
Hi all, I am new to mockobject and looking through the DynaMock class. Could somebody give me some idea, what does the following methods in com.mockobjects.dynamic.Mock class do? expectAndReturn(java.lang.String methodName, ConstraintMatcher args, java.lang.Object result) expectAndReturn(java.lang.String methodName, java.lang.Object singleEqualArg, boolean result) I understand the above methods is setting the return value for the named method. But some questions: - How does ConstraintMatcher works? - For the second method, what is the use of parameter singleEqualArg? - These methods are name expectAndReturn, does it implies that if the named method is not called, it will throw an error? - How bout if the codes have methods overloading, how does expectAndReturn know which method i am referring to? matchAndReturn(java.lang.String methodName, java.lang.Object result) How is this different from expectAndReturn? The javadoc has rather limited explanation, any recommendation to sites that have sample or more detailed explanation? Thanks lots. Veny |