mockobject-checkins Mailing List for Old mocklib
Brought to you by:
fastdragon
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(47) |
Aug
(28) |
Sep
(290) |
Oct
(16) |
Nov
(4) |
Dec
(8) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(4) |
Feb
|
Mar
(6) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Nobody <fas...@us...> - 2005-03-20 13:45:51
|
Update of /cvsroot/mockobject/mockobject2/input/javasrc/biz/xsoftware/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2628/input/javasrc/biz/xsoftware/test Modified Files: MockOne.java TestMockCreator.java Log Message: force error if they try to expect an invalid method. Index: MockOne.java =================================================================== RCS file: /cvsroot/mockobject/mockobject2/input/javasrc/biz/xsoftware/test/MockOne.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MockOne.java 13 Nov 2004 14:38:16 -0000 1.2 --- MockOne.java 20 Mar 2005 13:45:42 -0000 1.3 *************** *** 17,23 **** public class MockOne extends MockSuperclass implements ListenerOne { ! public static final String FIRST = "firstOne"; ! public static final String SECOND = "secondOne"; ! public static final String EXTRA = "extraOne"; public static final String MULTIPLE_PARAMS = "multipleParams"; --- 17,23 ---- public class MockOne extends MockSuperclass implements ListenerOne { ! public static final String FIRST = "callMeFirst"; ! public static final String SECOND = "callMeSecond"; ! public static final String EXTRA = "callMeExtra"; public static final String MULTIPLE_PARAMS = "multipleParams"; *************** *** 49,51 **** --- 49,57 ---- methodCalled(MULTIPLE_PARAMS, new Object[] { x, i }); } + /* (non-Javadoc) + * @see biz.xsoftware.mock.MockSuperclass#getClasses() + */ + public Class[] getClasses() { + return new Class[] { MockOne.class }; + } } Index: TestMockCreator.java =================================================================== RCS file: /cvsroot/mockobject/mockobject2/input/javasrc/biz/xsoftware/test/TestMockCreator.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TestMockCreator.java 18 Mar 2005 16:00:59 -0000 1.2 --- TestMockCreator.java 20 Mar 2005 13:45:42 -0000 1.3 *************** *** 1,174 **** ! /* ! * Created on Apr 24, 2004 ! * ! * To change the template for this generated file go to ! * Window - Preferences - Java - Code Generation - Code and Comments ! */ ! package biz.xsoftware.test; ! ! import java.io.IOException; ! import java.util.logging.Logger; ! ! import junit.framework.TestCase; ! import junit.framework.TestSuite; ! import junit.textui.TestRunner; ! import biz.xsoftware.mock.CalledMethod; ! import biz.xsoftware.mock.ExpectFailedException; ! import biz.xsoftware.mock.MockObjectFactory; ! import biz.xsoftware.mock.MockObject; ! ! /** ! * @author Dean Hiller ! * ! * To change the template for this generated type comment go to ! * Window - Preferences - Java - Code Generation - Code and Comments ! */ ! public class TestMockCreator extends TestCase { ! ! private final static Logger log = Logger.getLogger(TestMockCreator.class.getName()); ! ! /** ! * @param name ! */ ! public TestMockCreator(String name) { ! super(name); ! } ! ! public void testMockCreator() throws Exception { ! MockObject m = MockObjectFactory.createMock(ListenerOne.class); ! ListenerOne l = (ListenerOne)m; ! String param1 = "some param"; ! l.callMeSecond(param1); ! ! String methodName = "callMeSecond"; ! CalledMethod method = m.expectCall(methodName); ! ! assertEquals("method name should be the same", methodName, method.getMethodName()); ! assertEquals("params should equal", param1, method.getParameter(0)); ! assertEquals("param count should be 1", 1, method.getParameterCount()); ! assertEquals("1st param should be equal", param1, method.getAllParams()[0]); ! } ! ! public void testEqualsAndToString() throws Exception { ! MockObject m = MockObjectFactory.createMock(ListenerOne.class); ! ListenerOne l = (ListenerOne)m; ! ! assertTrue("These should not be equal", !l.equals(new Integer(4))); ! assertTrue("These should be equal", l.equals(l)); ! ! String name = ""+l;//test toString does not throw exception. ! ! } ! ! public void testNoneFailure() throws Exception { ! MockObject m = MockObjectFactory.createMock(ListenerOne.class); ! ListenerOne l = (ListenerOne)m; ! String param1 = "some param"; ! l.callMeSecond(param1); ! ! try { ! m.expectCall(MockObject.NONE); ! fail("Should have failed with ExpectFailedException"); ! } catch(ExpectFailedException e) { ! //gulp ! } ! } ! ! public void testMultipleParams() throws Exception { ! MockObject m = MockObjectFactory.createMock(ListenerOne.class); ! ListenerOne l = (ListenerOne)m; ! String param1 = "someparam2"; ! Integer param2 = new Integer(2345); ! l.multipleParams(param1, param2); ! ! CalledMethod method = m.expectCall("multipleParams"); ! assertEquals("param1 is not correct", param1, method.getParameter(0)); ! assertEquals("param2 is not correct", param2, method.getParameter(1)); ! } ! ! public void testMockCreatorFail() throws Exception { ! MockObject m = MockObjectFactory.createMock(ListenerOne.class); ! ListenerOne l = (ListenerOne)m; ! l.callMeSecond("dummy"); ! try { ! m.expectCall("callMeFirst"); ! fail("should have thrown exception"); ! } catch(ExpectFailedException e) {} ! } ! ! public void testMockCreatorCreatesCar() throws Exception { ! MockObject factory = MockObjectFactory.createMock(FactoryInterface.class); ! MockObject car = MockObjectFactory.createMock(Car.class); ! ! factory.addReturnValue("createCar", (Car)car); ! ! //now we would normally tweak code on the subsystem which ! //would call createcar but we are only unit testing MockCreator ! Car c = ((FactoryInterface)factory).createCar("someid"); ! factory.expectCall("createCar"); ! ! c.openDoor(); ! car.expectCall("openDoor"); ! } ! ! public void testThrowCheckedException() throws Exception { ! MockObject mockList = MockObjectFactory.createMock(ListenerOne.class); ! mockList.addThrowException("callMeSecond", new IOException("test throwing IOException")); ! ! ListenerOne l = (ListenerOne)mockList; ! try { ! l.callMeSecond("dummy"); ! fail("should have thrown IOException"); ! } catch(IOException e) {} ! } ! ! public void testUsingANY() throws Exception { ! MockObject mockList = MockObjectFactory.createMock(ListenerOne.class); ! ListenerOne l = (ListenerOne)mockList; ! ! int expected = 1; ! l.callMeFirst(expected); ! ! CalledMethod m = mockList.expectCall(MockObject.ANY); ! Integer i = (Integer)m.getAllParams()[0]; ! assertEquals("param should be 1", new Integer(expected), i); ! } ! ! public void testMultipleANYs() throws Exception { ! MockObject mockList = MockObjectFactory.createMock(ListenerOne.class); ! ListenerOne l = (ListenerOne)mockList; ! ! int expected = 1; ! l.callMeFirst(1); ! l.callMeSecond("second"); ! ! String[] methods = new String[] { MockObject.ANY, "callMeSecond" }; ! mockList.expectOrderedCalls(methods); ! } ! ! public void testWrongMethod() { ! MockObject mock = MockObjectFactory.createMock(ListenerOne.class); ! ! try { ! mock.expectCall("noSuchMethod"); ! fail("This should throw an exception"); ! } catch(IllegalArgumentException e) { ! } ! } ! ! private void smallTest(String s) { ! s.trim(); ! } ! ! ! public static void main(String[] args) { ! TestSuite suite = new TestSuite(); ! suite.addTest(new TestMockCreator("testWrongMethod")); ! // suite.addTest(new TestMockSuperclass("testMockCreator")); ! // suite.addTest(new TestMockSuperclass("testMockCreatorFail")); ! // suite.addTest(new TestMockSuperclass("testMockCreatorCreatesCar")); ! // suite.addTest(new TestMockSuperclass("testThrowCheckedException")); ! ! TestRunner.run(suite); ! } ! } --- 1,172 ---- ! /* ! * Created on Apr 24, 2004 ! * ! * To change the template for this generated file go to ! * Window - Preferences - Java - Code Generation - Code and Comments ! */ ! package biz.xsoftware.test; ! ! import java.io.IOException; ! import java.util.logging.Logger; ! ! import junit.framework.TestCase; ! import junit.framework.TestSuite; ! import junit.textui.TestRunner; ! import biz.xsoftware.mock.CalledMethod; ! import biz.xsoftware.mock.ExpectFailedException; ! import biz.xsoftware.mock.MockObjectFactory; ! import biz.xsoftware.mock.MockObject; ! ! /** ! * @author Dean Hiller ! * ! * To change the template for this generated type comment go to ! * Window - Preferences - Java - Code Generation - Code and Comments ! */ ! public class TestMockCreator extends TestCase { ! ! private final static Logger log = Logger.getLogger(TestMockCreator.class.getName()); ! ! /** ! * @param name ! */ ! public TestMockCreator(String name) { ! super(name); ! } ! ! public void testMockCreator() throws Exception { ! MockObject m = MockObjectFactory.createMock(ListenerOne.class); ! ListenerOne l = (ListenerOne)m; ! String param1 = "some param"; ! l.callMeSecond(param1); ! ! String methodName = "callMeSecond"; ! CalledMethod method = m.expectCall(methodName); ! ! assertEquals("method name should be the same", methodName, method.getMethodName()); ! assertEquals("params should equal", param1, method.getParameter(0)); ! assertEquals("param count should be 1", 1, method.getParameterCount()); ! assertEquals("1st param should be equal", param1, method.getAllParams()[0]); ! } ! ! public void testEqualsAndToString() throws Exception { ! MockObject m = MockObjectFactory.createMock(ListenerOne.class); ! ListenerOne l = (ListenerOne)m; ! ! assertTrue("These should not be equal", !l.equals(new Integer(4))); ! assertTrue("These should be equal", l.equals(l)); ! ! String name = ""+l;//test toString does not throw exception. ! } ! ! public void testNoneFailure() throws Exception { ! MockObject m = MockObjectFactory.createMock(ListenerOne.class); ! ListenerOne l = (ListenerOne)m; ! String param1 = "some param"; ! l.callMeSecond(param1); ! ! try { ! m.expectCall(MockObject.NONE); ! fail("Should have failed with ExpectFailedException"); ! } catch(ExpectFailedException e) { ! //gulp ! } ! } ! ! public void testMultipleParams() throws Exception { ! MockObject m = MockObjectFactory.createMock(ListenerOne.class); ! ListenerOne l = (ListenerOne)m; ! String param1 = "someparam2"; ! Integer param2 = new Integer(2345); ! l.multipleParams(param1, param2); ! ! CalledMethod method = m.expectCall("multipleParams"); ! assertEquals("param1 is not correct", param1, method.getParameter(0)); ! assertEquals("param2 is not correct", param2, method.getParameter(1)); ! } ! ! public void testMockCreatorFail() throws Exception { ! MockObject m = MockObjectFactory.createMock(ListenerOne.class); ! ListenerOne l = (ListenerOne)m; ! l.callMeSecond("dummy"); ! try { ! m.expectCall("callMeFirst"); ! fail("should have thrown exception"); ! } catch(ExpectFailedException e) {} ! } ! ! public void testMockCreatorCreatesCar() throws Exception { ! MockObject factory = MockObjectFactory.createMock(FactoryInterface.class); ! MockObject car = MockObjectFactory.createMock(Car.class); ! ! factory.addReturnValue("createCar", (Car)car); ! ! //now we would normally tweak code on the subsystem which ! //would call createcar but we are only unit testing MockCreator ! Car c = ((FactoryInterface)factory).createCar("someid"); ! factory.expectCall("createCar"); ! ! c.openDoor(); ! car.expectCall("openDoor"); ! } ! ! public void testThrowCheckedException() throws Exception { ! MockObject mockList = MockObjectFactory.createMock(ListenerOne.class); ! mockList.addThrowException("callMeSecond", new IOException("test throwing IOException")); ! ! ListenerOne l = (ListenerOne)mockList; ! try { ! l.callMeSecond("dummy"); ! fail("should have thrown IOException"); ! } catch(IOException e) {} ! } ! ! public void testUsingANY() throws Exception { ! MockObject mockList = MockObjectFactory.createMock(ListenerOne.class); ! ListenerOne l = (ListenerOne)mockList; ! ! int expected = 1; ! l.callMeFirst(expected); ! ! CalledMethod m = mockList.expectCall(MockObject.ANY); ! Integer i = (Integer)m.getAllParams()[0]; ! assertEquals("param should be 1", new Integer(expected), i); ! } ! ! public void testMultipleANYs() throws Exception { ! MockObject mockList = MockObjectFactory.createMock(ListenerOne.class); ! ListenerOne l = (ListenerOne)mockList; ! ! int expected = 1; ! l.callMeFirst(1); ! l.callMeSecond("second"); ! ! String[] methods = new String[] { MockObject.ANY, "callMeSecond" }; ! mockList.expectOrderedCalls(methods); ! } ! ! public void testWrongMethod() { ! MockObject mock = MockObjectFactory.createMock(ListenerOne.class); ! ! try { ! mock.expectCall("noSuchMethod"); ! fail("This should throw an exception"); ! } catch(IllegalArgumentException e) { ! } ! } ! ! private void smallTest(String s) { ! s.trim(); ! } ! ! public static void main(String[] args) { ! TestSuite suite = new TestSuite(); ! suite.addTest(new TestMockCreator("testWrongMethod")); ! // suite.addTest(new TestMockSuperclass("testMockCreator")); ! // suite.addTest(new TestMockSuperclass("testMockCreatorFail")); ! // suite.addTest(new TestMockSuperclass("testMockCreatorCreatesCar")); ! // suite.addTest(new TestMockSuperclass("testThrowCheckedException")); ! TestRunner.run(suite); ! } ! } ! |
From: Nobody <fas...@us...> - 2005-03-20 13:45:51
|
Update of /cvsroot/mockobject/mockobject2/input/javasrc/biz/xsoftware/mock In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2628/input/javasrc/biz/xsoftware/mock Modified Files: MockObjectFactory.java MockObjectImpl.java MockSuperclass.java Log Message: force error if they try to expect an invalid method. Index: MockSuperclass.java =================================================================== RCS file: /cvsroot/mockobject/mockobject2/input/javasrc/biz/xsoftware/mock/MockSuperclass.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** MockSuperclass.java 18 Mar 2005 16:00:58 -0000 1.10 --- MockSuperclass.java 20 Mar 2005 13:45:42 -0000 1.11 *************** *** 1,531 **** ! package biz.xsoftware.mock; ! ! import java.io.PrintWriter; ! import java.io.StringWriter; ! import java.lang.reflect.Method; ! import java.util.ArrayList; ! import java.util.Arrays; ! import java.util.HashMap; ! import java.util.LinkedList; ! import java.util.List; [...1054 lines suppressed...] ! ! public void setDefaultReturnValue(String method, Object o) { ! methodToDefaultRetVal.put(method, o); ! } ! ! /** ! * Only needs to be overridden if the events are modifiable. ! * If the event is immutable, this does not need to be ! * overridden. To override this function, you just need to ! * copy the object and return a new one. ! * ! * @param o ! * @return ! */ ! protected Object[] clone(Object[] params) { ! return params; ! } ! ! abstract public Class[] getClasses(); ! } Index: MockObjectImpl.java =================================================================== RCS file: /cvsroot/mockobject/mockobject2/input/javasrc/biz/xsoftware/mock/MockObjectImpl.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MockObjectImpl.java 12 Sep 2004 07:14:10 -0000 1.1 --- MockObjectImpl.java 20 Mar 2005 13:45:42 -0000 1.2 *************** *** 24,27 **** --- 24,28 ---- private static Map isMethodInSuper = new HashMap(); + private Class[] classes; static { *************** *** 39,42 **** --- 40,46 ---- } + public MockObjectImpl(Class[] interfaces) { + this.classes = interfaces; + } /* (non-Javadoc) * @see java.lang.reflect.InvocationHandler#invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[]) *************** *** 73,75 **** --- 77,85 ---- } } + /* (non-Javadoc) + * @see biz.xsoftware.mock.MockSuperclass#getClasses() + */ + public Class[] getClasses() { + return classes; + } } Index: MockObjectFactory.java =================================================================== RCS file: /cvsroot/mockobject/mockobject2/input/javasrc/biz/xsoftware/mock/MockObjectFactory.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MockObjectFactory.java 12 Sep 2004 07:14:10 -0000 1.1 --- MockObjectFactory.java 20 Mar 2005 13:45:42 -0000 1.2 *************** *** 63,67 **** ClassLoader cl = MockObjectFactory.class.getClassLoader(); ! Object o = Proxy.newProxyInstance(cl, interfacesPlusMock, new MockObjectImpl()); MockObject m = (MockObject)o; return m; --- 63,68 ---- ClassLoader cl = MockObjectFactory.class.getClassLoader(); ! MockObjectImpl impl = new MockObjectImpl(interfaces); ! Object o = Proxy.newProxyInstance(cl, interfacesPlusMock, impl); MockObject m = (MockObject)o; return m; |
From: Nobody <fas...@us...> - 2005-03-20 13:45:50
|
Update of /cvsroot/mockobject/mockobject2/input/javasrc/biz/xsoftware/examples/timer In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2628/input/javasrc/biz/xsoftware/examples/timer Modified Files: MockTimer.java Log Message: force error if they try to expect an invalid method. Index: MockTimer.java =================================================================== RCS file: /cvsroot/mockobject/mockobject2/input/javasrc/biz/xsoftware/examples/timer/MockTimer.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** MockTimer.java 8 Dec 2004 18:38:13 -0000 1.3 --- MockTimer.java 20 Mar 2005 13:45:42 -0000 1.4 *************** *** 36,39 **** --- 36,46 ---- return super.methodCalled(method, param); } + + /* (non-Javadoc) + * @see biz.xsoftware.mock.MockSuperclass#getClasses() + */ + public Class[] getClasses() { + return new Class[] { MockTimer.class }; + } } |
From: Nobody <fas...@us...> - 2005-03-20 13:45:50
|
Update of /cvsroot/mockobject/mockobject2/input/javasrc/biz/xsoftware/examples/socket In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2628/input/javasrc/biz/xsoftware/examples/socket Modified Files: TCPSocketMock.java Log Message: force error if they try to expect an invalid method. Index: TCPSocketMock.java =================================================================== RCS file: /cvsroot/mockobject/mockobject2/input/javasrc/biz/xsoftware/examples/socket/TCPSocketMock.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TCPSocketMock.java 12 Sep 2004 07:14:09 -0000 1.1 --- TCPSocketMock.java 20 Mar 2005 13:45:42 -0000 1.2 *************** *** 45,48 **** --- 45,55 ---- return socket.read(b); } + + /* (non-Javadoc) + * @see biz.xsoftware.mock.MockSuperclass#getClasses() + */ + public Class[] getClasses() { + return null; + } } |
From: Nobody <fas...@us...> - 2005-03-18 16:01:08
|
Update of /cvsroot/mockobject/mockobject2/input/javasrc/biz/xsoftware/mock In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2922/input/javasrc/biz/xsoftware/mock Modified Files: MockSuperclass.java Log Message: Index: MockSuperclass.java =================================================================== RCS file: /cvsroot/mockobject/mockobject2/input/javasrc/biz/xsoftware/mock/MockSuperclass.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** MockSuperclass.java 18 Dec 2004 17:49:16 -0000 1.9 --- MockSuperclass.java 18 Mar 2005 16:00:58 -0000 1.10 *************** *** 1,512 **** ! package biz.xsoftware.mock; ! ! import java.io.PrintWriter; ! import java.io.StringWriter; ! import java.util.ArrayList; ! import java.util.Arrays; ! import java.util.HashMap; ! import java.util.LinkedList; ! import java.util.List; ! import java.util.Map; [...1014 lines suppressed...] ! l.add(o); ! } ! ! public void setDefaultReturnValue(String method, Object o) { ! methodToDefaultRetVal.put(method, o); ! } ! ! /** ! * Only needs to be overridden if the events are modifiable. ! * If the event is immutable, this does not need to be ! * overridden. To override this function, you just need to ! * copy the object and return a new one. ! * ! * @param o ! * @return ! */ ! protected Object[] clone(Object[] params) { ! return params; ! } ! } |
From: Nobody <fas...@us...> - 2005-03-18 16:01:08
|
Update of /cvsroot/mockobject/mockobject2/input/javasrc/biz/xsoftware/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2922/input/javasrc/biz/xsoftware/test Modified Files: TestMockCreator.java Log Message: Index: TestMockCreator.java =================================================================== RCS file: /cvsroot/mockobject/mockobject2/input/javasrc/biz/xsoftware/test/TestMockCreator.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TestMockCreator.java 12 Sep 2004 07:14:10 -0000 1.1 --- TestMockCreator.java 18 Mar 2005 16:00:59 -0000 1.2 *************** *** 1,161 **** ! /* ! * Created on Apr 24, 2004 ! * ! * To change the template for this generated file go to ! * Window - Preferences - Java - Code Generation - Code and Comments ! */ ! package biz.xsoftware.test; ! ! import java.io.IOException; ! import java.util.logging.Logger; ! ! import junit.framework.TestCase; ! import junit.framework.TestSuite; ! import junit.textui.TestRunner; ! import biz.xsoftware.mock.CalledMethod; ! import biz.xsoftware.mock.ExpectFailedException; ! import biz.xsoftware.mock.MockObjectFactory; ! import biz.xsoftware.mock.MockObject; ! ! /** ! * @author Dean Hiller ! * ! * To change the template for this generated type comment go to ! * Window - Preferences - Java - Code Generation - Code and Comments ! */ ! public class TestMockCreator extends TestCase { ! ! private final static Logger log = Logger.getLogger(TestMockCreator.class.getName()); ! ! /** ! * @param name ! */ ! public TestMockCreator(String name) { ! super(name); ! } ! ! public void testMockCreator() throws Exception { ! MockObject m = MockObjectFactory.createMock(ListenerOne.class); ! ListenerOne l = (ListenerOne)m; ! String param1 = "some param"; ! l.callMeSecond(param1); ! ! String methodName = "callMeSecond"; ! CalledMethod method = m.expectCall(methodName); ! ! assertEquals("method name should be the same", methodName, method.getMethodName()); ! assertEquals("params should equal", param1, method.getParameter(0)); ! assertEquals("param count should be 1", 1, method.getParameterCount()); ! assertEquals("1st param should be equal", param1, method.getAllParams()[0]); ! } ! ! public void testEqualsAndToString() throws Exception { ! MockObject m = MockObjectFactory.createMock(ListenerOne.class); ! ListenerOne l = (ListenerOne)m; ! ! assertTrue("These should not be equal", !l.equals(new Integer(4))); ! assertTrue("These should be equal", l.equals(l)); ! ! String name = ""+l;//test toString does not throw exception. ! ! } ! ! public void testNoneFailure() throws Exception { ! MockObject m = MockObjectFactory.createMock(ListenerOne.class); ! ListenerOne l = (ListenerOne)m; ! String param1 = "some param"; ! l.callMeSecond(param1); ! ! try { ! m.expectCall(MockObject.NONE); ! fail("Should have failed with ExpectFailedException"); ! } catch(ExpectFailedException e) { ! //gulp ! } ! } ! ! public void testMultipleParams() throws Exception { ! MockObject m = MockObjectFactory.createMock(ListenerOne.class); ! ListenerOne l = (ListenerOne)m; ! String param1 = "someparam2"; ! Integer param2 = new Integer(2345); ! l.multipleParams(param1, param2); ! ! CalledMethod method = m.expectCall("multipleParams"); ! assertEquals("param1 is not correct", param1, method.getParameter(0)); ! assertEquals("param2 is not correct", param2, method.getParameter(1)); ! } ! ! public void testMockCreatorFail() throws Exception { ! MockObject m = MockObjectFactory.createMock(ListenerOne.class); ! ListenerOne l = (ListenerOne)m; ! l.callMeSecond("dummy"); ! try { ! m.expectCall("callMeFirst"); ! fail("should have thrown exception"); ! } catch(ExpectFailedException e) {} ! } ! ! public void testMockCreatorCreatesCar() throws Exception { ! MockObject factory = MockObjectFactory.createMock(FactoryInterface.class); ! MockObject car = MockObjectFactory.createMock(Car.class); ! ! factory.addReturnValue("createCar", (Car)car); ! ! //now we would normally tweak code on the subsystem which ! //would call createcar but we are only unit testing MockCreator ! Car c = ((FactoryInterface)factory).createCar("someid"); ! factory.expectCall("createCar"); ! ! c.openDoor(); ! car.expectCall("openDoor"); ! } ! ! public void testThrowCheckedException() throws Exception { ! MockObject mockList = MockObjectFactory.createMock(ListenerOne.class); ! mockList.addThrowException("callMeSecond", new IOException("test throwing IOException")); ! ! ListenerOne l = (ListenerOne)mockList; ! try { ! l.callMeSecond("dummy"); ! fail("should have thrown IOException"); ! } catch(IOException e) {} ! } ! ! public void testUsingANY() throws Exception { ! MockObject mockList = MockObjectFactory.createMock(ListenerOne.class); ! ListenerOne l = (ListenerOne)mockList; ! ! int expected = 1; ! l.callMeFirst(expected); ! ! CalledMethod m = mockList.expectCall(MockObject.ANY); ! Integer i = (Integer)m.getAllParams()[0]; ! assertEquals("param should be 1", new Integer(expected), i); ! } ! ! public void testMultipleANYs() throws Exception { ! MockObject mockList = MockObjectFactory.createMock(ListenerOne.class); ! ListenerOne l = (ListenerOne)mockList; ! ! int expected = 1; ! l.callMeFirst(1); ! l.callMeSecond("second"); ! ! String[] methods = new String[] { MockObject.ANY, "callMeSecond" }; ! mockList.expectOrderedCalls(methods); ! } ! private void smallTest(String s) { ! s.trim(); ! } ! public static void main(String[] args) { ! TestSuite suite = new TestSuite(); ! suite.addTest(new TestMockCreator("testExceptionThrown")); ! // suite.addTest(new TestMockSuperclass("testMockCreator")); ! // suite.addTest(new TestMockSuperclass("testMockCreatorFail")); ! // suite.addTest(new TestMockSuperclass("testMockCreatorCreatesCar")); ! // suite.addTest(new TestMockSuperclass("testThrowCheckedException")); ! ! TestRunner.run(suite); ! } ! } --- 1,174 ---- ! /* ! * Created on Apr 24, 2004 ! * ! * To change the template for this generated file go to ! * Window - Preferences - Java - Code Generation - Code and Comments ! */ ! package biz.xsoftware.test; ! ! import java.io.IOException; ! import java.util.logging.Logger; ! ! import junit.framework.TestCase; ! import junit.framework.TestSuite; ! import junit.textui.TestRunner; ! import biz.xsoftware.mock.CalledMethod; ! import biz.xsoftware.mock.ExpectFailedException; ! import biz.xsoftware.mock.MockObjectFactory; ! import biz.xsoftware.mock.MockObject; ! ! /** ! * @author Dean Hiller ! * ! * To change the template for this generated type comment go to ! * Window - Preferences - Java - Code Generation - Code and Comments ! */ ! public class TestMockCreator extends TestCase { ! ! private final static Logger log = Logger.getLogger(TestMockCreator.class.getName()); ! ! /** ! * @param name ! */ ! public TestMockCreator(String name) { ! super(name); ! } ! ! public void testMockCreator() throws Exception { ! MockObject m = MockObjectFactory.createMock(ListenerOne.class); ! ListenerOne l = (ListenerOne)m; ! String param1 = "some param"; ! l.callMeSecond(param1); ! ! String methodName = "callMeSecond"; ! CalledMethod method = m.expectCall(methodName); ! ! assertEquals("method name should be the same", methodName, method.getMethodName()); ! assertEquals("params should equal", param1, method.getParameter(0)); ! assertEquals("param count should be 1", 1, method.getParameterCount()); ! assertEquals("1st param should be equal", param1, method.getAllParams()[0]); ! } ! ! public void testEqualsAndToString() throws Exception { ! MockObject m = MockObjectFactory.createMock(ListenerOne.class); ! ListenerOne l = (ListenerOne)m; ! ! assertTrue("These should not be equal", !l.equals(new Integer(4))); ! assertTrue("These should be equal", l.equals(l)); ! ! String name = ""+l;//test toString does not throw exception. ! ! } ! ! public void testNoneFailure() throws Exception { ! MockObject m = MockObjectFactory.createMock(ListenerOne.class); ! ListenerOne l = (ListenerOne)m; ! String param1 = "some param"; ! l.callMeSecond(param1); ! ! try { ! m.expectCall(MockObject.NONE); ! fail("Should have failed with ExpectFailedException"); ! } catch(ExpectFailedException e) { ! //gulp ! } ! } ! ! public void testMultipleParams() throws Exception { ! MockObject m = MockObjectFactory.createMock(ListenerOne.class); ! ListenerOne l = (ListenerOne)m; ! String param1 = "someparam2"; ! Integer param2 = new Integer(2345); ! l.multipleParams(param1, param2); ! ! CalledMethod method = m.expectCall("multipleParams"); ! assertEquals("param1 is not correct", param1, method.getParameter(0)); ! assertEquals("param2 is not correct", param2, method.getParameter(1)); ! } ! ! public void testMockCreatorFail() throws Exception { ! MockObject m = MockObjectFactory.createMock(ListenerOne.class); ! ListenerOne l = (ListenerOne)m; ! l.callMeSecond("dummy"); ! try { ! m.expectCall("callMeFirst"); ! fail("should have thrown exception"); ! } catch(ExpectFailedException e) {} ! } ! ! public void testMockCreatorCreatesCar() throws Exception { ! MockObject factory = MockObjectFactory.createMock(FactoryInterface.class); ! MockObject car = MockObjectFactory.createMock(Car.class); ! ! factory.addReturnValue("createCar", (Car)car); ! ! //now we would normally tweak code on the subsystem which ! //would call createcar but we are only unit testing MockCreator ! Car c = ((FactoryInterface)factory).createCar("someid"); ! factory.expectCall("createCar"); ! ! c.openDoor(); ! car.expectCall("openDoor"); ! } ! ! public void testThrowCheckedException() throws Exception { ! MockObject mockList = MockObjectFactory.createMock(ListenerOne.class); ! mockList.addThrowException("callMeSecond", new IOException("test throwing IOException")); ! ! ListenerOne l = (ListenerOne)mockList; ! try { ! l.callMeSecond("dummy"); ! fail("should have thrown IOException"); ! } catch(IOException e) {} ! } ! ! public void testUsingANY() throws Exception { ! MockObject mockList = MockObjectFactory.createMock(ListenerOne.class); ! ListenerOne l = (ListenerOne)mockList; ! ! int expected = 1; ! l.callMeFirst(expected); ! ! CalledMethod m = mockList.expectCall(MockObject.ANY); ! Integer i = (Integer)m.getAllParams()[0]; ! assertEquals("param should be 1", new Integer(expected), i); ! } ! ! public void testMultipleANYs() throws Exception { ! MockObject mockList = MockObjectFactory.createMock(ListenerOne.class); ! ListenerOne l = (ListenerOne)mockList; ! ! int expected = 1; ! l.callMeFirst(1); ! l.callMeSecond("second"); ! ! String[] methods = new String[] { MockObject.ANY, "callMeSecond" }; ! mockList.expectOrderedCalls(methods); ! } ! ! public void testWrongMethod() { ! MockObject mock = MockObjectFactory.createMock(ListenerOne.class); ! ! try { ! mock.expectCall("noSuchMethod"); ! fail("This should throw an exception"); ! } catch(IllegalArgumentException e) { ! } ! } ! ! private void smallTest(String s) { ! s.trim(); ! } ! ! ! public static void main(String[] args) { ! TestSuite suite = new TestSuite(); ! suite.addTest(new TestMockCreator("testWrongMethod")); ! // suite.addTest(new TestMockSuperclass("testMockCreator")); ! // suite.addTest(new TestMockSuperclass("testMockCreatorFail")); ! // suite.addTest(new TestMockSuperclass("testMockCreatorCreatesCar")); ! // suite.addTest(new TestMockSuperclass("testThrowCheckedException")); ! ! TestRunner.run(suite); ! } ! } |
From: Nobody <fas...@us...> - 2005-01-21 21:31:21
|
Update of /cvsroot/mockobject/mockobject2/input/staging/mockobject In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30204/input/staging/mockobject Removed Files: index.html README.html Log Message: moving index.html files to correct location. --- README.html DELETED --- --- index.html DELETED --- |
From: Nobody <fas...@us...> - 2005-01-21 21:31:21
|
Update of /cvsroot/mockobject/mockobject2/input/staging/mocklib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30204/input/staging/mocklib Added Files: index.html README.html Log Message: moving index.html files to correct location. --- NEW FILE: README.html --- <HTML> <h1><a href="index.html">Click here for documentation</a></h1> </HTML> --- NEW FILE: index.html --- <HTML> <TITLE>MockLib</TITLE> <BODY> <h1>MockLib</h1> This is a very small library but powerful enough to create most of your mockobjects for you. The ones it can't create, you can leverage the library to create. <br/><br/> <a href="http://sourceforge.net/projects/mockobject">MockLib</a> <br/><br/> <a href="http://sourceforge.net/project/showfiles.php?group_id=113040&package_id=122340">Download MockLib library plus these web pages</a> <br/> <a href="coverage.html">Test coverage report</a> <br/> <a href="impl/index.html">MockLib Javadoc</a> <br/><br/> <h3>All MockLib Examples</h3> <ol> <li>Basic Examples - Basic Examples to help get started</li> <ul> <li><a href="examples/biz/xsoftware/examples/basic/TestExample.html#testBasicSysUnderTest()">Example code for basic success</a></li> <li><a href="examples/biz/xsoftware/examples/basic/TestExample.html#testFailureOfAuthorization()">Example code for basic failure</a></li> <li><a href="examples/biz/xsoftware/examples/basic/TestExample.html#testFailureOfBuyingGiftCard()">Example code for more advanced failure</a></li> </ul> <li>Listener Example - How to mock listeners and verify events were received under certain conditions</li> <ul> <li><a href="examples/biz/xsoftware/examples/listener/TestExample.html#testBasicListener()">Example code for listener</a></li> </ul> <li>Timer Example - How to mock out the java.util.Timer class which already exists in your code</li> <ul> <li><a href="examples/biz/xsoftware/examples/timer/TestExample.html#testBasicCalendar()">Example code for timer</a></li> </ul> <li>Timer 2 Example - How to use your own Timer interface instead and mock that out</li> <ul> <li><a href="examples/biz/xsoftware/examples/timer2/TestExample.html#testBasicCalendar()">Example code for timer interface</a></li> </ul> <li>Socket Example - How to create bad network conditions and test your systems reaction to them</li> <ul> <li><a href="examples/biz/xsoftware/examples/socket/TestExample.html#testNetworkProblems()">Example code for testing if system behaves when their are network problems</a></li> <li><a href="examples/biz/xsoftware/examples/socket/TestExample.html#testServerClosingSocket()">Example code for testing if system behaves if other end closes the socket</a></li> </ul> <li>Advanced Example - How to mock our a more complicated api, and trigger events from one system and make sure things happen to another system based on those events</li> <ul> <li><a href="examples/biz/xsoftware/examples/advanced/TestExample.html#testSystemInteractionWithSubsytemsAPI()">Example code for complex apis</a></li> </ul> </ol> <a href="examples/index.html">All MockLib Examples</a> <br/><br/><br/><br/> <a href=http://sourceforge.net> <IMG src=http://sourceforge.net/sflogo.php?group_id=113040 width=210 height=62 border=0 alt=SourceForge Logo> </a> </BODY> </HTML> |
From: Nobody <fas...@us...> - 2005-01-21 21:30:56
|
Update of /cvsroot/mockobject/mockobject2/input/staging/mocklib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30023/input/staging/mocklib Log Message: Directory /cvsroot/mockobject/mockobject2/input/staging/mocklib added to the repository |
From: Nobody <fas...@us...> - 2005-01-21 21:26:13
|
Update of /cvsroot/mockobject/mockobject2/bldfiles In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28818/bldfiles Modified Files: release.xml Log Message: just changing user to fastdragon Index: release.xml =================================================================== RCS file: /cvsroot/mockobject/mockobject2/bldfiles/release.xml,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** release.xml 18 Dec 2004 15:35:28 -0000 1.6 --- release.xml 21 Jan 2005 21:26:04 -0000 1.7 *************** *** 10,13 **** --- 10,14 ---- <property name="taglet" value="${tool.dir}/taglet"/> + <property name="user" value="fastdragon"/> <!-- *************** *** 126,130 **** remotedir="incoming" userid="anonymous" ! password="dea...@us..."> <fileset dir="${dist}"> <include name="${name}-${version}.zip"/> --- 127,131 ---- remotedir="incoming" userid="anonymous" ! password="${user}@user.sourceforge.net"> <fileset dir="${dist}"> <include name="${name}-${version}.zip"/> *************** *** 133,152 **** <scp file="${dist}/${name}-${version}.zip" ! todir="dea...@sh...:/home/groups/m/mo/mockobject" password="${pw}"/> <sshexec host="shell.sourceforge.net" ! username="deanhiller" password="${pw}" command="rm -rf /home/groups/m/mo/mockobject/htdocs/*"/> <sshexec host="shell.sourceforge.net" ! username="deanhiller" password="${pw}" command="unzip /home/groups/m/mo/mockobject/${name}-${version}.zip -d /home/groups/m/mo/mockobject/htdocs/"/> <sshexec host="shell.sourceforge.net" ! username="deanhiller" password="${pw}" command="mv /home/groups/m/mo/mockobject/htdocs/${name}/* /home/groups/m/mo/mockobject/htdocs"/> <sshexec host="shell.sourceforge.net" ! username="deanhiller" password="${pw}" command="rm /home/groups/m/mo/mockobject/${name}*.zip"/> --- 134,153 ---- <scp file="${dist}/${name}-${version}.zip" ! todir="${user}@shell.sourceforge.net:/home/groups/m/mo/mockobject" password="${pw}"/> <sshexec host="shell.sourceforge.net" ! username="${user}" password="${pw}" command="rm -rf /home/groups/m/mo/mockobject/htdocs/*"/> <sshexec host="shell.sourceforge.net" ! username="${user}" password="${pw}" command="unzip /home/groups/m/mo/mockobject/${name}-${version}.zip -d /home/groups/m/mo/mockobject/htdocs/"/> <sshexec host="shell.sourceforge.net" ! username="${user}" password="${pw}" command="mv /home/groups/m/mo/mockobject/htdocs/${name}/* /home/groups/m/mo/mockobject/htdocs"/> <sshexec host="shell.sourceforge.net" ! username="${user}" password="${pw}" command="rm /home/groups/m/mo/mockobject/${name}*.zip"/> *************** *** 154,156 **** </target> ! </project> \ No newline at end of file --- 155,157 ---- </target> ! </project> |
From: Dean H. <dea...@us...> - 2004-12-18 17:49:26
|
Update of /cvsroot/mockobject/mockobject2/input/javasrc/biz/xsoftware/mock In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16683/input/javasrc/biz/xsoftware/mock Modified Files: MockSuperclass.java Log Message: add more info when expecting no methods to be called fails. Index: MockSuperclass.java =================================================================== RCS file: /cvsroot/mockobject/mockobject2/input/javasrc/biz/xsoftware/mock/MockSuperclass.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** MockSuperclass.java 18 Dec 2004 15:31:12 -0000 1.8 --- MockSuperclass.java 18 Dec 2004 17:49:16 -0000 1.9 *************** *** 295,299 **** o = expectUnignoredCall(method, ignorables, methodsCalledList); } catch(ExpectFailedException e) { ! throw new ExpectFailedException(e.getMessage(), cleanup(retVal, i), e.getReason()); } if(o == null) { --- 295,303 ---- o = expectUnignoredCall(method, ignorables, methodsCalledList); } catch(ExpectFailedException e) { ! if(!ExpectFailedException.UNEXPECTED_ON_NONE.equals(e.getReason())) { ! throw e; ! } ! CalledMethod[] leftOver = e.getCalledMethods(); ! throw new ExpectFailedException(e.getMessage(), leftOver, e.getReason()); } if(o == null) { *************** *** 324,328 **** private String putTogetherReason(String[] methods, Map ignorables, List methodsCalled, String lastLine) { ! String reason = "Methods you expected...\n"; for(int i = 0; i < methods.length; i++) { reason += "method["+i+"]="+methods[i]+"\n"; --- 328,332 ---- private String putTogetherReason(String[] methods, Map ignorables, List methodsCalled, String lastLine) { ! String reason = "\nMethods you expected...\n"; for(int i = 0; i < methods.length; i++) { reason += "method["+i+"]="+methods[i]+"\n"; *************** *** 365,371 **** log.log(Level.FINE, "method expected="+NONE+" on obj="+this); LeftOverMethods leftOver = getLeftOverMethods(ignorables); ! if(leftOver != null) ! throw new ExpectFailedException("A method that wasn't expected(nor ignored) was\n" ! +"called earlier. method(s)="+leftOver, null, ExpectFailedException.UNEXPECTED_ON_NONE); return new CalledMethod(NONE, null, null); } --- 369,378 ---- log.log(Level.FINE, "method expected="+NONE+" on obj="+this); LeftOverMethods leftOver = getLeftOverMethods(ignorables); ! if(leftOver != null) { ! String reason = "You were expecting no methods to be called, but method(s) not\n" ! +"in the ignore list were called earlier. method(s)="+leftOver; ! reason += getHowMethodWasCalled(leftOver.getMethods()[0]); ! throw new ExpectFailedException(reason, leftOver.getMethods(), ExpectFailedException.UNEXPECTED_ON_NONE); ! } return new CalledMethod(NONE, null, null); } |
From: Dean H. <dea...@us...> - 2004-12-18 15:35:38
|
Update of /cvsroot/mockobject/mockobject2/bldfiles In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21749 Modified Files: release.xml Log Message: fix release.xml file. Index: release.xml =================================================================== RCS file: /cvsroot/mockobject/mockobject2/bldfiles/release.xml,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** release.xml 15 Dec 2004 19:39:21 -0000 1.5 --- release.xml 18 Dec 2004 15:35:28 -0000 1.6 *************** *** 146,150 **** username="deanhiller" password="${pw}" ! command="mv /home/groups/m/mo/mockobject/htdocs/${name}/* /home/groups/m/mo/${name}/htdocs"/> <sshexec host="shell.sourceforge.net" username="deanhiller" --- 146,150 ---- username="deanhiller" password="${pw}" ! command="mv /home/groups/m/mo/mockobject/htdocs/${name}/* /home/groups/m/mo/mockobject/htdocs"/> <sshexec host="shell.sourceforge.net" username="deanhiller" |
From: Dean H. <dea...@us...> - 2004-12-18 15:31:24
|
Update of /cvsroot/mockobject/mockobject2/input/javasrc/biz/xsoftware/mock In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20852/input/javasrc/biz/xsoftware/mock Modified Files: MockSuperclass.java Log Message: added more info when failure occurs. Index: MockSuperclass.java =================================================================== RCS file: /cvsroot/mockobject/mockobject2/input/javasrc/biz/xsoftware/mock/MockSuperclass.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** MockSuperclass.java 8 Dec 2004 18:38:13 -0000 1.7 --- MockSuperclass.java 18 Dec 2004 15:31:12 -0000 1.8 *************** *** 4,7 **** --- 4,8 ---- import java.io.StringWriter; import java.util.ArrayList; + import java.util.Arrays; import java.util.HashMap; import java.util.LinkedList; *************** *** 312,316 **** String reason = putTogetherReason(methods, ignorables, methodsCalledList, "extra method(s)="+leftOver+"\n"); reason += getHowMethodWasCalled(leftOver.getMethods()[0]); ! throw new ExpectFailedException("There was a method called after your expected methods.\n"+reason, cleanup(retVal, i) , ExpectFailedException.UNEXPECTED_CALL_AFTER); } --- 313,320 ---- String reason = putTogetherReason(methods, ignorables, methodsCalledList, "extra method(s)="+leftOver+"\n"); reason += getHowMethodWasCalled(leftOver.getMethods()[0]); ! CalledMethod[] calledOnes = new CalledMethod[retVal.length+1]; ! System.arraycopy(retVal, 0, calledOnes, 0, retVal.length); ! calledOnes[retVal.length] = leftOver.getMethods()[0]; ! throw new ExpectFailedException("There was a method called after your expected methods.\n"+reason, calledOnes , ExpectFailedException.UNEXPECTED_CALL_AFTER); } |
From: Dean H. <dea...@us...> - 2004-12-15 19:39:32
|
Update of /cvsroot/mockobject/mockobject2/bldfiles In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11353 Modified Files: release.xml Log Message: fix release.xml file Index: release.xml =================================================================== RCS file: /cvsroot/mockobject/mockobject2/bldfiles/release.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** release.xml 8 Dec 2004 18:39:35 -0000 1.4 --- release.xml 15 Dec 2004 19:39:21 -0000 1.5 *************** *** 114,118 **** <echo message="***************************************************************"/> <echo message=" Delivering zip=${name}-${version}.zip to"/> ! <echo message=" sourceforge ftp site, and to mocklib website"/> <echo message=" The website will be updated at mockobject.sourceforge.net"/> <echo message=" Please finish this and go to sourceforge.net/projects/mockobject"/> --- 114,118 ---- <echo message="***************************************************************"/> <echo message=" Delivering zip=${name}-${version}.zip to"/> ! <echo message=" sourceforge ftp site, and to ${name} website"/> <echo message=" The website will be updated at mockobject.sourceforge.net"/> <echo message=" Please finish this and go to sourceforge.net/projects/mockobject"/> *************** *** 146,154 **** username="deanhiller" password="${pw}" ! command="mv /home/groups/m/mo/mockobject/htdocs/mockobject/* /home/groups/m/mo/mockobject/htdocs"/> <sshexec host="shell.sourceforge.net" username="deanhiller" password="${pw}" ! command="rm /home/groups/m/mo/mockobject/mocklib*.zip"/> </target> --- 146,154 ---- username="deanhiller" password="${pw}" ! command="mv /home/groups/m/mo/mockobject/htdocs/${name}/* /home/groups/m/mo/${name}/htdocs"/> <sshexec host="shell.sourceforge.net" username="deanhiller" password="${pw}" ! command="rm /home/groups/m/mo/mockobject/${name}*.zip"/> </target> |
From: Dean H. <dea...@us...> - 2004-12-08 18:39:43
|
Update of /cvsroot/mockobject/mockobject2/bldfiles In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18288/bldfiles Modified Files: release.xml Log Message: change refs to mockobject to mocklib Index: release.xml =================================================================== RCS file: /cvsroot/mockobject/mockobject2/bldfiles/release.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** release.xml 21 Sep 2004 04:43:30 -0000 1.3 --- release.xml 8 Dec 2004 18:39:35 -0000 1.4 *************** *** 5,9 **** <property name="misc" value="${input}/misc"/> ! <property name="javadoc.examples.title" value="MockObject Examples"/> <!-- temporary until we fix buildtemplate to not erase every folder in tools --> --- 5,9 ---- <property name="misc" value="${input}/misc"/> ! <property name="javadoc.examples.title" value="MockLib Examples"/> <!-- temporary until we fix buildtemplate to not erase every folder in tools --> *************** *** 114,118 **** <echo message="***************************************************************"/> <echo message=" Delivering zip=${name}-${version}.zip to"/> ! <echo message=" sourceforge ftp site, and to mockobject website"/> <echo message=" The website will be updated at mockobject.sourceforge.net"/> <echo message=" Please finish this and go to sourceforge.net/projects/mockobject"/> --- 114,118 ---- <echo message="***************************************************************"/> <echo message=" Delivering zip=${name}-${version}.zip to"/> ! <echo message=" sourceforge ftp site, and to mocklib website"/> <echo message=" The website will be updated at mockobject.sourceforge.net"/> <echo message=" Please finish this and go to sourceforge.net/projects/mockobject"/> *************** *** 150,154 **** username="deanhiller" password="${pw}" ! command="rm /home/groups/m/mo/mockobject/mockobject*.zip"/> </target> --- 150,154 ---- username="deanhiller" password="${pw}" ! command="rm /home/groups/m/mo/mockobject/mocklib*.zip"/> </target> |
From: Dean H. <dea...@us...> - 2004-12-08 18:38:27
|
Update of /cvsroot/mockobject/mockobject2/input/javasrc/biz/xsoftware/examples/timer In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17916/input/javasrc/biz/xsoftware/examples/timer Modified Files: MockTimer.java Log Message: add more info into ExpectFailedExceptions. Index: MockTimer.java =================================================================== RCS file: /cvsroot/mockobject/mockobject2/input/javasrc/biz/xsoftware/examples/timer/MockTimer.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MockTimer.java 13 Nov 2004 14:36:38 -0000 1.2 --- MockTimer.java 8 Dec 2004 18:38:13 -0000 1.3 *************** *** 101,111 **** /** - * @see biz.xsoftware.mock.MockObject#expectCall(java.lang.String, java.lang.String[]) - */ - public CalledMethod expectCall(String method, String[] ignoredMethods) { - return delegate.expectCall(method, ignoredMethods); - } - - /** * @see biz.xsoftware.mock.MockObject#expectOrderedCalls(java.lang.String[]) */ --- 101,104 ---- *************** *** 115,125 **** /** - * @see biz.xsoftware.mock.MockObject#expectOrderedCalls(java.lang.String[], java.lang.String[]) - */ - public CalledMethod[] expectOrderedCalls(String[] methods, String[] ignoredMethods) { - return delegate.expectOrderedCalls(methods, ignoredMethods); - } - - /** * @see biz.xsoftware.mock.MockObject#expectUnorderedCalls(java.lang.String[]) */ --- 108,111 ---- *************** *** 129,139 **** /** - * @see biz.xsoftware.mock.MockObject#expectUnorderedCalls(java.lang.String[], java.lang.String[]) - */ - public CalledMethod[] expectUnorderedCalls(String[] methods, String[] ignoredMethods) { - return delegate.expectUnorderedCalls(methods, ignoredMethods); - } - - /** * @see biz.xsoftware.mock.MockObject#addThrowException(java.lang.String, java.lang.Throwable) */ --- 115,118 ---- *************** *** 169,171 **** --- 148,157 ---- return delegate.getExpectTimeout(); } + + /** + * @see biz.xsoftware.mock.MockObject#setIgnoredMethods(java.lang.String[]) + */ + public void setIgnoredMethods(String[] methods) { + delegate.setIgnoredMethods(methods); + } } |
From: Dean H. <dea...@us...> - 2004-12-08 18:38:26
|
Update of /cvsroot/mockobject/mockobject2/bldfiles In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17916/bldfiles Modified Files: ant.properties Log Message: add more info into ExpectFailedExceptions. Index: ant.properties =================================================================== RCS file: /cvsroot/mockobject/mockobject2/bldfiles/ant.properties,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ant.properties 25 Sep 2004 04:33:04 -0000 1.3 --- ant.properties 8 Dec 2004 18:38:12 -0000 1.4 *************** *** 3,7 **** #----------------------------------------------------------------------- ! name = mockobject #used as the jar file name(ie. ${name}.jar) #used as zip file name(ie. ${name}-version.jar) --- 3,7 ---- #----------------------------------------------------------------------- ! name = mocklib #used as the jar file name(ie. ${name}.jar) #used as zip file name(ie. ${name}-version.jar) |
From: Dean H. <dea...@us...> - 2004-12-08 18:38:26
|
Update of /cvsroot/mockobject/mockobject2/input/javasrc/biz/xsoftware/mock In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17916/input/javasrc/biz/xsoftware/mock Modified Files: CalledMethod.java ExpectFailedException.java MockObject.java MockSuperclass.java Log Message: add more info into ExpectFailedExceptions. Index: MockSuperclass.java =================================================================== RCS file: /cvsroot/mockobject/mockobject2/input/javasrc/biz/xsoftware/mock/MockSuperclass.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** MockSuperclass.java 13 Nov 2004 15:48:40 -0000 1.6 --- MockSuperclass.java 8 Dec 2004 18:38:13 -0000 1.7 *************** *** 4,8 **** import java.io.StringWriter; import java.util.ArrayList; - import java.util.Arrays; import java.util.HashMap; import java.util.LinkedList; --- 4,7 ---- *************** *** 72,75 **** --- 71,77 ---- */ private Map methodToDefaultRetVal = new HashMap(); + + private String[] ignoredMethods = new String[0]; + /** * Default wait time to wait for a method to be called once expectCall is *************** *** 103,106 **** --- 105,115 ---- return waitTime; } + + public void setIgnoredMethods(String[] methods) { + if(methods == null) + ignoredMethods = new String[0]; + ignoredMethods = methods; + } + /** * Subclasses should call this method when a method on their interface *************** *** 150,154 **** //without cloning the object so it can't be changed. parameters = clone(parameters); ! methodsCalled.add(new MethodAndParam(method, parameters, new Throwable().fillInStackTrace())); this.notifyAll(); --- 159,163 ---- //without cloning the object so it can't be changed. parameters = clone(parameters); ! methodsCalled.add(new CalledMethod(method, parameters, new Throwable().fillInStackTrace())); this.notifyAll(); *************** *** 184,195 **** * @see biz.xsoftware.mock.MockObject#expectUnorderedCalls(java.lang.String[]) */ ! public CalledMethod[] expectUnorderedCalls(String[] methods) { ! return expectUnorderedCalls(methods, null); ! } ! ! /** ! * @see biz.xsoftware.mock.MockObject#expectUnorderedCalls(java.lang.String[], java.lang.String[]) ! */ ! synchronized public CalledMethod[] expectUnorderedCalls(String[] methods, String[] ignorableMethods) { if(methods == null) throw new IllegalArgumentException("methods cannot be null"); --- 193,197 ---- * @see biz.xsoftware.mock.MockObject#expectUnorderedCalls(java.lang.String[]) */ ! synchronized public CalledMethod[] expectUnorderedCalls(String[] methods) { if(methods == null) throw new IllegalArgumentException("methods cannot be null"); *************** *** 206,210 **** } ! Map ignorables = createIgnorableMap(ignorableMethods); CalledMethod[] retVal = new CalledMethod[methods.length]; --- 208,212 ---- } ! Map ignorables = createIgnorableMap(ignoredMethods); CalledMethod[] retVal = new CalledMethod[methods.length]; *************** *** 214,230 **** throw new IllegalArgumentException("The parameter 'methods' in expectUnorderedCalls cannot contain MockSuperclass.ANY(use expectOrderedCalls instead)"); ! MethodAndParam o = expectUnignoredCall(ANY, ignorables, methodsCalledList); if(o == null) { String reason = putTogetherReason(methods, ignorables, methodsCalledList, "timed out on next expected method\n"); ! throw new ExpectFailedException("Timed out waiting for a method call\n"+reason, ExpectFailedException.TIMED_OUT); } ! Integer index = (Integer)expectedMethods.remove(o.getMethod()); if(index == null) { String reason = putTogetherReason(methods, ignorables, methodsCalledList, null); ! throw new ExpectFailedException(reason, ExpectFailedException.UNEXPECTED_CALL_BEFORE); } ! ! retVal[index.intValue()] = new CalledMethod(o.method, o.getParams()); } --- 216,231 ---- throw new IllegalArgumentException("The parameter 'methods' in expectUnorderedCalls cannot contain MockSuperclass.ANY(use expectOrderedCalls instead)"); ! CalledMethod o = expectUnignoredCall(ANY, ignorables, methodsCalledList); if(o == null) { String reason = putTogetherReason(methods, ignorables, methodsCalledList, "timed out on next expected method\n"); ! throw new ExpectFailedException("Timed out waiting for a method call\n"+reason, retVal, ExpectFailedException.TIMED_OUT); } ! Integer index = (Integer)expectedMethods.remove(o.getMethodName()); if(index == null) { String reason = putTogetherReason(methods, ignorables, methodsCalledList, null); ! throw new ExpectFailedException(reason, retVal, ExpectFailedException.UNEXPECTED_CALL_BEFORE); } ! retVal[index.intValue()] = o; } *************** *** 232,236 **** if(leftOver != null) { String reason = putTogetherReason(methods, ignorables, methodsCalledList, "extra method(s)="+leftOver+"\n"); ! throw new ExpectFailedException("There was a method called after your expected methods.\n"+reason , ExpectFailedException.UNEXPECTED_CALL_AFTER); } --- 233,237 ---- if(leftOver != null) { String reason = putTogetherReason(methods, ignorables, methodsCalledList, "extra method(s)="+leftOver+"\n"); ! throw new ExpectFailedException("There was a method called after your expected methods.\n"+reason, retVal , ExpectFailedException.UNEXPECTED_CALL_AFTER); } *************** *** 239,267 **** } ! private String getHowMethodWasCalled(MethodAndParam method) { Throwable t = method.getHowItWasCalled(); ! String retVal = "\nThe last method was="+method.getMethod(); retVal += "\nHere is a stack trace showing "; retVal += "you how it was called...\n"; ! retVal += "--------BEGIN="+method.getMethod()+"---------------\n"; StringWriter s = new StringWriter(); PrintWriter p = new PrintWriter(s); t.printStackTrace(p); retVal += s.toString(); ! retVal += "--------END="+method.getMethod() +"---------------\n"; return retVal; } /** * @see biz.xsoftware.mock.MockObject#expectCall(java.lang.String) */ public CalledMethod expectCall(String method) { ! return expectCall(method, null); ! } ! /** ! * @see biz.xsoftware.mock.MockObject#expectCall(java.lang.String, java.lang.String[]) ! */ ! public CalledMethod expectCall(String method, String[] ignorableMethods) { ! return expectOrderedCalls(new String[] {method}, ignorableMethods)[0]; } --- 240,270 ---- } ! private String getHowMethodWasCalled(CalledMethod method) { Throwable t = method.getHowItWasCalled(); ! String retVal = "\nThe last method was="+method.getMethodName(); retVal += "\nHere is a stack trace showing "; retVal += "you how it was called...\n"; ! retVal += "--------BEGIN="+method.getMethodName()+"---------------\n"; StringWriter s = new StringWriter(); PrintWriter p = new PrintWriter(s); t.printStackTrace(p); retVal += s.toString(); ! retVal += "--------END="+method.getMethodName() +"---------------\n"; return retVal; } + private CalledMethod[] cleanup(CalledMethod[] methods, int size) { + CalledMethod[] retVal = new CalledMethod[size]; + for(int i = 0; i < retVal.length; i++) { + retVal[i] = methods[i]; + } + return retVal; + } + /** * @see biz.xsoftware.mock.MockObject#expectCall(java.lang.String) */ public CalledMethod expectCall(String method) { ! return expectOrderedCalls(new String[] {method})[0]; } *************** *** 269,280 **** * @see biz.xsoftware.mock.MockObject#expectOrderedCalls(java.lang.String[]) */ ! public CalledMethod[] expectOrderedCalls(String[] methods) { ! return expectOrderedCalls(methods, null); ! } ! ! /** ! * @see biz.xsoftware.mock.MockObject#expectOrderedCalls(java.lang.String[], java.lang.String[]) ! */ ! synchronized public CalledMethod[] expectOrderedCalls(String[] methods, String[] ignorableMethods) { if(methods == null) throw new IllegalArgumentException("methods cannot be null"); --- 272,276 ---- * @see biz.xsoftware.mock.MockObject#expectOrderedCalls(java.lang.String[]) */ ! synchronized public CalledMethod[] expectOrderedCalls(String[] methods) { if(methods == null) throw new IllegalArgumentException("methods cannot be null"); *************** *** 286,306 **** } ! Map ignorables = createIgnorableMap(ignorableMethods); List methodsCalledList = new ArrayList(); CalledMethod[] retVal = new CalledMethod[methods.length]; ! for(int i = 0; i < methods.length; i++) { String method = methods[i]; ! MethodAndParam o = expectUnignoredCall(method, ignorables, methodsCalledList); if(o == null) { String reason = putTogetherReason(methods, ignorables, methodsCalledList, "timed out on next expected method\n"); ! throw new ExpectFailedException("Timed out waiting for call="+method+"\n"+reason, ExpectFailedException.TIMED_OUT); } ! retVal[i] = new CalledMethod(o.method, o.getParams()); ! if(!method.equals(o.method) && !ANY.equals(method)) { String reason = putTogetherReason(methods, ignorables, methodsCalledList, null); reason += getHowMethodWasCalled(o); ! throw new ExpectFailedException(reason, null); } } --- 282,308 ---- } ! Map ignorables = createIgnorableMap(ignoredMethods); List methodsCalledList = new ArrayList(); CalledMethod[] retVal = new CalledMethod[methods.length]; ! int i = 0; ! for(; i < methods.length; i++) { String method = methods[i]; ! CalledMethod o = null; ! try { ! o = expectUnignoredCall(method, ignorables, methodsCalledList); ! } catch(ExpectFailedException e) { ! throw new ExpectFailedException(e.getMessage(), cleanup(retVal, i), e.getReason()); ! } if(o == null) { String reason = putTogetherReason(methods, ignorables, methodsCalledList, "timed out on next expected method\n"); ! throw new ExpectFailedException("Timed out waiting for call="+method+"\n"+reason, cleanup(retVal, i), ExpectFailedException.TIMED_OUT); } ! retVal[i] = o; ! if(!method.equals(o.getMethodName()) && !ANY.equals(method)) { String reason = putTogetherReason(methods, ignorables, methodsCalledList, null); reason += getHowMethodWasCalled(o); ! throw new ExpectFailedException(reason, cleanup(retVal, i), null); } } *************** *** 310,314 **** String reason = putTogetherReason(methods, ignorables, methodsCalledList, "extra method(s)="+leftOver+"\n"); reason += getHowMethodWasCalled(leftOver.getMethods()[0]); ! throw new ExpectFailedException("There was a method called after your expected methods.\n"+reason , ExpectFailedException.UNEXPECTED_CALL_AFTER); } --- 312,316 ---- String reason = putTogetherReason(methods, ignorables, methodsCalledList, "extra method(s)="+leftOver+"\n"); reason += getHowMethodWasCalled(leftOver.getMethods()[0]); ! throw new ExpectFailedException("There was a method called after your expected methods.\n"+reason, cleanup(retVal, i) , ExpectFailedException.UNEXPECTED_CALL_AFTER); } *************** *** 346,350 **** } ! synchronized protected MethodAndParam expectUnignoredCall(String method, Map ignorables, List calledMethods) { if(method == null) --- 348,352 ---- } ! synchronized protected CalledMethod expectUnignoredCall(String method, Map ignorables, List calledMethods) { if(method == null) *************** *** 361,366 **** if(leftOver != null) throw new ExpectFailedException("A method that wasn't expected(nor ignored) was\n" ! +"called earlier. method(s)="+leftOver, ExpectFailedException.UNEXPECTED_ON_NONE); ! return new MethodAndParam(NONE, null, null); } --- 363,368 ---- if(leftOver != null) throw new ExpectFailedException("A method that wasn't expected(nor ignored) was\n" ! +"called earlier. method(s)="+leftOver, null, ExpectFailedException.UNEXPECTED_ON_NONE); ! return new CalledMethod(NONE, null, null); } *************** *** 372,376 **** } ! private MethodAndParam waitForUnignoredCall(String logM, Map ignorables, List calledMethods) throws InterruptedException { long waitTime2 = waitTime+50; --- 374,378 ---- } ! private CalledMethod waitForUnignoredCall(String logM, Map ignorables, List calledMethods) throws InterruptedException { long waitTime2 = waitTime+50; *************** *** 382,386 **** currentTime = System.currentTimeMillis(); if (log.isLoggable(Level.FINE)) ! log.fine("method expected(not called yet-waiting)="+logM+" on obj="+this); this.wait(waitTime2); long waitedOnWait = System.currentTimeMillis() - currentTime; --- 384,388 ---- currentTime = System.currentTimeMillis(); if (log.isLoggable(Level.FINE)) ! log.fine("method expected(not called yet-waiting)="+logM+" on obj="+this+" wait="+waitTime2); this.wait(waitTime2); long waitedOnWait = System.currentTimeMillis() - currentTime; *************** *** 391,397 **** //continue while loop. for(int i = 0; i < methodsCalled.size(); i++) { ! MethodAndParam calledMethod = (MethodAndParam)methodsCalled.remove(0); calledMethods.add(calledMethod); ! if(ignorables.get(calledMethod.getMethod()) == null) { if(log.isLoggable(Level.FINE)) log.fine("method expected and was called="+logM); --- 393,399 ---- //continue while loop. for(int i = 0; i < methodsCalled.size(); i++) { ! CalledMethod calledMethod = (CalledMethod)methodsCalled.remove(0); calledMethods.add(calledMethod); ! if(ignorables.get(calledMethod.getMethodName()) == null) { if(log.isLoggable(Level.FINE)) log.fine("method expected and was called="+logM); *************** *** 418,423 **** List leftOver = new ArrayList(); for(int i = 0; i < methodsCalled.size(); i++) { ! MethodAndParam o = (MethodAndParam)methodsCalled.get(i); ! if(ignorables.get(o.getMethod()) == null && o != null) { leftOver.add(o); } --- 420,425 ---- List leftOver = new ArrayList(); for(int i = 0; i < methodsCalled.size(); i++) { ! CalledMethod o = (CalledMethod)methodsCalled.get(i); ! if(ignorables.get(o.getMethodName()) == null && o != null) { leftOver.add(o); } *************** *** 426,431 **** return null; ! MethodAndParam[] m = new MethodAndParam[0]; ! m = (MethodAndParam[])leftOver.toArray(m); return new LeftOverMethods(m); } --- 428,433 ---- return null; ! CalledMethod[] m = new CalledMethod[0]; ! m = (CalledMethod[])leftOver.toArray(m); return new LeftOverMethods(m); } *************** *** 433,438 **** private class LeftOverMethods { ! private MethodAndParam[] leftOver; ! public LeftOverMethods(MethodAndParam[] m) { leftOver = m; } --- 435,440 ---- private class LeftOverMethods { ! private CalledMethod[] leftOver; ! public LeftOverMethods(CalledMethod[] m) { leftOver = m; } *************** *** 440,444 **** * @return */ ! public MethodAndParam[] getMethods() { return leftOver; } --- 442,446 ---- * @return */ ! public CalledMethod[] getMethods() { return leftOver; } *************** *** 455,458 **** --- 457,464 ---- */ synchronized public void addThrowException(String method, Throwable e) { + if(method == null) + throw new IllegalArgumentException("method parameter cannot be null"); + else if(e == null) + throw new IllegalArgumentException("e parameter to this method cannot be null"); List l = (List)methodToException.get(method); if(l == null) { *************** *** 467,470 **** --- 473,478 ---- */ synchronized public void addReturnValue(String method, Object o) { + if(method == null) + throw new IllegalArgumentException("method parameter cannot be null"); List l = (List)methodToReturnVal.get(method); if(l == null) { *************** *** 491,520 **** return params; } - - private class MethodAndParam { - private String method; - private Object[] param; - private Throwable howItWasCalled; - public MethodAndParam(String method, Object[] param, Throwable howItWasCalled) { - this.method = method; - this.param = param; - this.howItWasCalled = howItWasCalled; - } - public String getMethod() { - return method; - } - public Object[] getParams() { - return param; - } - public Throwable getHowItWasCalled() { - return howItWasCalled; - } - public String toString() { - List params = null; - if(param != null) - params = Arrays.asList(param); - - return "[method="+method+" params="+params+"]"; - } - } } --- 499,501 ---- Index: CalledMethod.java =================================================================== RCS file: /cvsroot/mockobject/mockobject2/input/javasrc/biz/xsoftware/mock/CalledMethod.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CalledMethod.java 12 Sep 2004 07:14:10 -0000 1.1 --- CalledMethod.java 8 Dec 2004 18:38:13 -0000 1.2 *************** *** 7,10 **** --- 7,13 ---- package biz.xsoftware.mock; + import java.util.Arrays; + import java.util.List; + /** * @author Dean Hiller *************** *** 17,27 **** private String method; private Object[] params; ! public CalledMethod(String method, Object[] params) { if(params == null) this.params = new Object[0]; else ! this.params = params; ! this.method = method; } --- 20,32 ---- private String method; private Object[] params; + private Throwable howItWasCalled; ! public CalledMethod(String method, Object[] params, Throwable howItWasCalled) { ! this.method = method; if(params == null) this.params = new Object[0]; else ! this.params = params; ! this.howItWasCalled = howItWasCalled; } *************** *** 37,43 **** return params[index]; } ! public Object[] getAllParams() { return params; } } --- 42,62 ---- return params[index]; } ! /** ! * ! * @return ! */ public Object[] getAllParams() { return params; } + + public Throwable getHowItWasCalled() { + return howItWasCalled; + } + public String toString() { + List paramList = null; + if(params != null) + paramList = Arrays.asList(params); + + return "[method="+method+" params="+paramList+"]"; + } } Index: MockObject.java =================================================================== RCS file: /cvsroot/mockobject/mockobject2/input/javasrc/biz/xsoftware/mock/MockObject.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MockObject.java 13 Nov 2004 14:29:41 -0000 1.2 --- MockObject.java 8 Dec 2004 18:38:13 -0000 1.3 *************** *** 25,34 **** public static String ANY = "'Any method'"; ! //public CalledMethod expectCalls(int numberMethodsToBeCalled); ! public void setExpectTimeout(int timeout); ! ! public int getExpectTimeout(); /** --- 25,37 ---- public static String ANY = "'Any method'"; ! //possibly for any.... //public CalledMethod expectCalls(int numberMethodsToBeCalled); ! /** ! * When calling expectCall, the MockObject will ignore the methods ! * in 'methods' variable so if one of the methods in this array is ! * called, it will not result in an exception. ! */ ! public void setIgnoredMethods(String[] methods); /** *************** *** 44,64 **** /** - * Waits for one and only one method to be called. If any methods are - * called before or after this one(after can sometimes be caught by - * the MockObject when the threading is not synchronous), then - * this call will throw an ExpectFailedException. - * <br/><br/> - * If any of the ignoredMethods are called, they will be ignored and not - * verified at all that they were called or not called. They are like the - * toString on object which will be ignored every time so you can write - * a test case that is less brittle. - * - * @param method The expected method. - * @param ignoredMethods methods to ignore(don't throw an exception if one of these accidentally happens) - * @return An array of params that were passed to the methods called - */ - public CalledMethod expectCall(String method, String[] ignoredMethods); - - /** * Waits for all the methods to be called. If any of the methods * are not called or are called out of order, this method throws --- 47,50 ---- *************** *** 72,93 **** */ public CalledMethod[] expectOrderedCalls(String[] methods); - /** - * Waits for all the methods to be called. If any of the methods - * are not called or are called out of order, this method throws - * an exception which will fail the test case. For each method, - * this will wait WAIT_TIME milliseconds for each method to be called. - * If the method is not called within this period, an exception will - * be thrown saying 'method' was not called within timeout period. - * <br/><br/> - * If any of the ignoredMethods are called, they will be ignored and not - * verified at all that they were called or not called. They are like the - * toString on object which will be ignored every time so you can write - * a test case that is less brittle. - * - * @param methods The expected methods in the correct order. - * @param ignoredMethods methods to ignore(don't throw an exception if one of these accidentally happens) - * @return An array of params that were passed to the methods called - */ - public CalledMethod[] expectOrderedCalls(String[] methods, String[] ignoredMethods); /** --- 58,61 ---- *************** *** 100,117 **** */ public CalledMethod[] expectUnorderedCalls(String[] methods); - /** - * Expect many methods to be called irrelevant of the order in which they are - * called. - * <br/><br/> - * If any of the ignoredMethods are called, they will be ignored and not - * verified at all that they were called or not called. They are like the - * toString on object which will be ignored every time so you can write - * a test case that is less brittle. - * - * @param methods The methods to be called in no particular order - * @return An array of params that were passed to the methods called. This - * array lines up with the methods array passed in. - */ - public CalledMethod[] expectUnorderedCalls(String[] methods, String[] ignoredMethods); /** --- 68,71 ---- *************** *** 157,159 **** --- 111,117 ---- */ public void setDefaultReturnValue(String method, Object o); + + public void setExpectTimeout(int timeout); + + public int getExpectTimeout(); } Index: ExpectFailedException.java =================================================================== RCS file: /cvsroot/mockobject/mockobject2/input/javasrc/biz/xsoftware/mock/ExpectFailedException.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ExpectFailedException.java 12 Sep 2004 07:14:10 -0000 1.1 --- ExpectFailedException.java 8 Dec 2004 18:38:13 -0000 1.2 *************** *** 37,41 **** private String reason; ! --- 37,41 ---- private String reason; ! private CalledMethod[] methods; *************** *** 45,57 **** * @param message */ ! public ExpectFailedException(String message, String reason) { super(message); this.reason = reason; } - - // public ExpectFailedException(String message, Throwable e, String reason) { - // super(message, e); - // this.reason = reason; - // } /** --- 45,53 ---- * @param message */ ! public ExpectFailedException(String message, CalledMethod[] methods, String reason) { super(message); this.reason = reason; + this.methods = methods; } /** *************** *** 70,72 **** --- 66,79 ---- return reason; } + + /** + * Gives you back the CalledMethods giving you access to the + * parameters that were passed in and the stack traces of how + * they were called. + * + * @return + */ + public CalledMethod[] getCalledMethods() { + return methods; + } } |
From: Dean H. <dea...@us...> - 2004-11-13 15:48:49
|
Update of /cvsroot/mockobject/mockobject2/input/javasrc/biz/xsoftware/mock In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27630/input/javasrc/biz/xsoftware/mock Modified Files: MockSuperclass.java Log Message: fix small bug Index: MockSuperclass.java =================================================================== RCS file: /cvsroot/mockobject/mockobject2/input/javasrc/biz/xsoftware/mock/MockSuperclass.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** MockSuperclass.java 13 Nov 2004 14:29:41 -0000 1.5 --- MockSuperclass.java 13 Nov 2004 15:48:40 -0000 1.6 *************** *** 98,102 **** public void setExpectTimeout(int delay) { ! this.waitTime = waitTime; } public int getExpectTimeout() { --- 98,102 ---- public void setExpectTimeout(int delay) { ! this.waitTime = delay; } public int getExpectTimeout() { |
From: Dean H. <dea...@us...> - 2004-11-13 14:38:25
|
Update of /cvsroot/mockobject/mockobject2/input/javasrc/biz/xsoftware/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13376/input/javasrc/biz/xsoftware/test Modified Files: MockOne.java Log Message: fix test class Index: MockOne.java =================================================================== RCS file: /cvsroot/mockobject/mockobject2/input/javasrc/biz/xsoftware/test/MockOne.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MockOne.java 12 Sep 2004 07:14:10 -0000 1.1 --- MockOne.java 13 Nov 2004 14:38:16 -0000 1.2 *************** *** 22,26 **** public static final String MULTIPLE_PARAMS = "multipleParams"; ! public MockOne(long delay) { super(delay); } --- 22,26 ---- public static final String MULTIPLE_PARAMS = "multipleParams"; ! public MockOne(int delay) { super(delay); } |
From: Dean H. <dea...@us...> - 2004-11-13 14:36:47
|
Update of /cvsroot/mockobject/mockobject2/input/javasrc/biz/xsoftware/examples/timer In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12972/input/javasrc/biz/xsoftware/examples/timer Modified Files: MockTimer.java Log Message: fix class Index: MockTimer.java =================================================================== RCS file: /cvsroot/mockobject/mockobject2/input/javasrc/biz/xsoftware/examples/timer/MockTimer.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MockTimer.java 12 Sep 2004 07:14:09 -0000 1.1 --- MockTimer.java 13 Nov 2004 14:36:38 -0000 1.2 *************** *** 155,157 **** --- 155,171 ---- delegate.setDefaultReturnValue(method, o); } + + /* (non-Javadoc) + * @see biz.xsoftware.mock.MockObject#setExpectTimeout(int) + */ + public void setExpectTimeout(int timeout) { + delegate.setExpectTimeout(timeout); + } + + /* (non-Javadoc) + * @see biz.xsoftware.mock.MockObject#getExpectTimeout() + */ + public int getExpectTimeout() { + return delegate.getExpectTimeout(); + } } |
From: Dean H. <dea...@us...> - 2004-11-13 14:29:50
|
Update of /cvsroot/mockobject/mockobject2/input/javasrc/biz/xsoftware/mock In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11800/input/javasrc/biz/xsoftware/mock Modified Files: MockObject.java MockSuperclass.java Log Message: no message Index: MockSuperclass.java =================================================================== RCS file: /cvsroot/mockobject/mockobject2/input/javasrc/biz/xsoftware/mock/MockSuperclass.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** MockSuperclass.java 14 Sep 2004 05:22:15 -0000 1.4 --- MockSuperclass.java 13 Nov 2004 14:29:41 -0000 1.5 *************** *** 76,81 **** * called. */ ! public final static long DEFAULT_WAIT_TIME = 10000; ! private long waitTime = DEFAULT_WAIT_TIME; /** --- 76,81 ---- * called. */ ! public final static int DEFAULT_WAIT_TIME = 10000; ! private int waitTime = DEFAULT_WAIT_TIME; /** *************** *** 93,100 **** * called. */ ! public MockSuperclass(long delay) { waitTime = delay; } /** * Subclasses should call this method when a method on their interface --- 93,106 ---- * called. */ ! public MockSuperclass(int delay) { waitTime = delay; } + public void setExpectTimeout(int delay) { + this.waitTime = waitTime; + } + public int getExpectTimeout() { + return waitTime; + } /** * Subclasses should call this method when a method on their interface Index: MockObject.java =================================================================== RCS file: /cvsroot/mockobject/mockobject2/input/javasrc/biz/xsoftware/mock/MockObject.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MockObject.java 12 Sep 2004 07:14:10 -0000 1.1 --- MockObject.java 13 Nov 2004 14:29:41 -0000 1.2 *************** *** 28,31 **** --- 28,35 ---- //public CalledMethod expectCalls(int numberMethodsToBeCalled); + public void setExpectTimeout(int timeout); + + public int getExpectTimeout(); + /** * Waits for one and only one method to be called. If any methods are |
From: Dean H. <dea...@us...> - 2004-10-02 22:00:10
|
Update of /cvsroot/mockobject/scratch/input In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2730/input Log Message: Directory /cvsroot/mockobject/scratch/input added to the repository |
From: Dean H. <dea...@us...> - 2004-10-02 21:59:12
|
Update of /cvsroot/mockobject/scratch/input/javasrc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2730/input/javasrc Log Message: Directory /cvsroot/mockobject/scratch/input/javasrc added to the repository |
From: Dean H. <dea...@us...> - 2004-10-02 21:59:09
|
Update of /cvsroot/mockobject/scratch/input/javasrc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3004/input/javasrc Added Files: overview.html Log Message: add scratch area to mockobject project. --- NEW FILE: overview.html --- <html> <body> </body> </html> |