mocklib-checkins Mailing List for mocklib (Page 25)
Brought to you by:
bittwidler,
fastdragon
You can subscribe to this list here.
| 2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(6) |
Jul
(1) |
Aug
(5) |
Sep
(3) |
Oct
|
Nov
|
Dec
(46) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2006 |
Jan
(54) |
Feb
(120) |
Mar
(31) |
Apr
(11) |
May
(8) |
Jun
(5) |
Jul
|
Aug
(22) |
Sep
(295) |
Oct
(6) |
Nov
(10) |
Dec
|
| 2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(9) |
Jun
|
Jul
(2) |
Aug
(2) |
Sep
|
Oct
|
Nov
(2) |
Dec
(8) |
| 2008 |
Jan
|
Feb
(1) |
Mar
|
Apr
(8) |
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
|
| 2009 |
Jan
|
Feb
(17) |
Mar
|
Apr
|
May
(3) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Nobody <fas...@us...> - 2006-01-07 15:13:49
|
Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18515/javasrc/biz/xsoftware/mock2 Modified Files: MockObject.java Log Message: whoops, fix the api I checked in. They were supposed to be varargs. Index: MockObject.java =================================================================== RCS file: /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2/MockObject.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MockObject.java 23 Dec 2005 01:33:05 -0000 1.1 --- MockObject.java 7 Jan 2006 15:13:39 -0000 1.2 *************** *** 18,22 **** * is called */ ! public CalledMethod expect(String methodName, Class[] vargs); /** --- 18,22 ---- * is called */ ! public CalledMethod expect(String methodName, Class... vargs); /** *************** *** 34,38 **** */ public CalledMethod expect(Object returnValue, String methodName, ! Class[] vargs); /** --- 34,38 ---- */ public CalledMethod expect(Object returnValue, String methodName, ! Class... vargs); /** *************** *** 50,54 **** */ public CalledMethod expect(String methodName, Throwable throwable, ! Class[] vargs); /** --- 50,54 ---- */ public CalledMethod expect(String methodName, Throwable throwable, ! Class... vargs); /** *************** *** 66,70 **** */ public CalledMethod expect(String methodName, Behavior behavior, ! Class[] params); /*************************************************************************** --- 66,70 ---- */ public CalledMethod expect(String methodName, Behavior behavior, ! Class... params); /*************************************************************************** *************** *** 84,88 **** * is called */ ! public CalledMethod expect(String methodName, long timeout, Class[] vargs); /** --- 84,88 ---- * is called */ ! public CalledMethod expect(String methodName, long timeout, Class... vargs); /** *************** *** 101,105 **** */ public CalledMethod expect(Object returnValue, String methodName, ! long timeout, Class[] vargs); /** --- 101,105 ---- */ public CalledMethod expect(Object returnValue, String methodName, ! long timeout, Class... vargs); /** *************** *** 119,123 **** */ public CalledMethod expect(String methodName, Throwable throwable, ! long timeout, Class[] vargs); /** --- 119,123 ---- */ public CalledMethod expect(String methodName, Throwable throwable, ! long timeout, Class... vargs); /** *************** *** 137,141 **** */ public CalledMethod expect(String methodName, Behavior behavior, ! long timeout, Class[] params); /** --- 137,141 ---- */ public CalledMethod expect(String methodName, Behavior behavior, ! long timeout, Class... params); /** *************** *** 152,156 **** * the optional parameter types of the method call */ ! public void addIgnoreMethod(String methodName, Class[] vargs); /** --- 152,156 ---- * the optional parameter types of the method call */ ! public void addIgnoreMethod(String methodName, Class... vargs); /** *************** *** 162,166 **** * the optinal parameter types of the method call */ ! public void removeIgnoreMethod(String methodName, Class[] vargs); /** --- 162,166 ---- * the optinal parameter types of the method call */ ! public void removeIgnoreMethod(String methodName, Class... vargs); /** *************** *** 176,180 **** */ public void setDefaultReturnValue(Object returnValue, String methodName, ! Class[] vargs); /** --- 176,180 ---- */ public void setDefaultReturnValue(Object returnValue, String methodName, ! Class... vargs); /** |
|
From: Jay <ja...@us...> - 2006-01-05 15:10:10
|
Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2/impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9248/input/javasrc/biz/xsoftware/mock2/impl Modified Files: MockObjectSuperImpl.java Log Message: Index: MockObjectSuperImpl.java =================================================================== RCS file: /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2/impl/MockObjectSuperImpl.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MockObjectSuperImpl.java 3 Jan 2006 15:33:49 -0000 1.1 --- MockObjectSuperImpl.java 5 Jan 2006 15:09:59 -0000 1.2 *************** *** 1,4 **** --- 1,6 ---- package biz.xsoftware.mock2.impl; + import java.util.logging.Logger; + import biz.xsoftware.mock2.Behavior; import biz.xsoftware.mock2.CalledMethod; *************** *** 6,32 **** public abstract class MockObjectSuperImpl implements MockObject{ public CalledMethod expect(String methodName, Class[] vargs) { ! // TODO Auto-generated method stub ! return null; } public CalledMethod expect(Object returnValue, String methodName, Class[] vargs) { ! // TODO Auto-generated method stub ! return null; } public CalledMethod expect(String methodName, Throwable throwable, Class[] vargs) { ! // TODO Auto-generated method stub ! return null; } public CalledMethod expect(String methodName, Behavior behavior, Class[] params) { ! // TODO Auto-generated method stub ! return null; } public CalledMethod expect(String methodName, long timeout, Class[] vargs) { ! // TODO Auto-generated method stub return null; } --- 8,35 ---- public abstract class MockObjectSuperImpl implements MockObject{ + + private static final Logger logger=Logger.getLogger(MockObjectSuperImpl.class.getName()); + private static final long NO_TIME_OUT=0; public CalledMethod expect(String methodName, Class[] vargs) { ! return expect(methodName,NO_TIME_OUT,vargs); } public CalledMethod expect(Object returnValue, String methodName, Class[] vargs) { ! return expect(returnValue,methodName,NO_TIME_OUT,vargs); } public CalledMethod expect(String methodName, Throwable throwable, Class[] vargs) { ! ! return expect(methodName,throwable,NO_TIME_OUT,vargs); } public CalledMethod expect(String methodName, Behavior behavior, Class[] params) { ! ! return expect(methodName,behavior,NO_TIME_OUT,params); } public CalledMethod expect(String methodName, long timeout, Class[] vargs) { ! return null; } |
|
From: Jay <ja...@us...> - 2006-01-03 15:37:46
|
Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9257/input/javasrc/biz/xsoftware/mock2 Added Files: MockObjectImpl.java Log Message: check in to implements at office :) --- NEW FILE: MockObjectImpl.java --- package biz.xsoftware.mock2; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import biz.xsoftware.mock2.impl.MockObjectSuperImpl; public class MockObjectImpl extends MockObjectSuperImpl implements InvocationHandler { public MockObjectImpl(Class[] interfacesToMock) { // TODO Auto-generated constructor stub } public MockObjectImpl(Class interfaceToMock, Object realObject) { // TODO Auto-generated constructor stub } public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { // TODO Auto-generated method stub return null; } } |
|
From: Jay <ja...@us...> - 2006-01-03 15:36:52
|
Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9110/input/javasrc/biz/xsoftware/mock2 Modified Files: MockObjectFactory.java Log Message: mockObjectFactory to create different kind of mock objects Index: MockObjectFactory.java =================================================================== RCS file: /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2/MockObjectFactory.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MockObjectFactory.java 23 Dec 2005 01:33:05 -0000 1.1 --- MockObjectFactory.java 3 Jan 2006 15:36:45 -0000 1.2 *************** *** 1,4 **** --- 1,9 ---- package biz.xsoftware.mock2; + import java.lang.reflect.Proxy; + + import biz.xsoftware.mock2.MockObject; + import biz.xsoftware.mock2.MockObjectImpl; + /** * The factory class that creates MockObjects *************** *** 9,14 **** public abstract class MockObjectFactory { public static MockObject createMock(Class[] interfacesToMock) { ! // TODO: Implement me! ! return null; } --- 14,28 ---- public abstract class MockObjectFactory { public static MockObject createMock(Class[] interfacesToMock) { ! Class[] interfacesPlusMock = new Class[interfacesToMock.length + 1]; ! interfacesPlusMock[0] = MockObject.class; ! for (int i = 1; i < interfacesPlusMock.length; i++) { ! interfacesPlusMock[i] = interfacesToMock[i - 1]; ! } ! ! ClassLoader cl = MockObjectFactory.class.getClassLoader(); ! MockObjectImpl impl = new MockObjectImpl(interfacesToMock); ! Object o = Proxy.newProxyInstance(cl, interfacesPlusMock, impl); ! MockObject m = (MockObject) o; ! return m; } *************** *** 19,23 **** public static MockObject createMock(Class interfaceToMock, Object realObject) { // TODO: Implement me! ! return null; } } --- 33,44 ---- public static MockObject createMock(Class interfaceToMock, Object realObject) { // TODO: Implement me! ! Class[] interfacePlusMock = new Class[1]; ! interfacePlusMock[0] = MockObject.class; ! ! ClassLoader cl = MockObjectFactory.class.getClassLoader(); ! MockObjectImpl impl = new MockObjectImpl(interfaceToMock, realObject); ! Object o = Proxy.newProxyInstance(cl, interfacePlusMock, impl); ! MockObject m = (MockObject) o; ! return m; } } |
|
From: Jay <ja...@us...> - 2006-01-03 15:33:58
|
Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2/impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8500/input/javasrc/biz/xsoftware/mock2/impl Added Files: MockObjectSuperImpl.java Log Message: mockObjectFactory to create different kind of mock objects --- NEW FILE: MockObjectSuperImpl.java --- package biz.xsoftware.mock2.impl; import biz.xsoftware.mock2.Behavior; import biz.xsoftware.mock2.CalledMethod; import biz.xsoftware.mock2.MockObject; public abstract class MockObjectSuperImpl implements MockObject{ public CalledMethod expect(String methodName, Class[] vargs) { // TODO Auto-generated method stub return null; } public CalledMethod expect(Object returnValue, String methodName, Class[] vargs) { // TODO Auto-generated method stub return null; } public CalledMethod expect(String methodName, Throwable throwable, Class[] vargs) { // TODO Auto-generated method stub return null; } public CalledMethod expect(String methodName, Behavior behavior, Class[] params) { // TODO Auto-generated method stub return null; } public CalledMethod expect(String methodName, long timeout, Class[] vargs) { // TODO Auto-generated method stub return null; } public CalledMethod expect(Object returnValue, String methodName, long timeout, Class[] vargs) { // TODO Auto-generated method stub return null; } public CalledMethod expect(String methodName, Throwable throwable, long timeout, Class[] vargs) { // TODO Auto-generated method stub return null; } public CalledMethod expect(String methodName, Behavior behavior, long timeout, Class[] params) { // TODO Auto-generated method stub return null; } public void verify() { // TODO Auto-generated method stub } public void addIgnoreMethod(String methodName, Class[] vargs) { // TODO Auto-generated method stub } public void removeIgnoreMethod(String methodName, Class[] vargs) { // TODO Auto-generated method stub } public void setDefaultReturnValue(Object returnValue, String methodName, Class[] vargs) { // TODO Auto-generated method stub } public Object instance() { // TODO Auto-generated method stub return null; } } |
|
From: Jay <ja...@us...> - 2006-01-03 13:30:06
|
Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2/impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10329/input/javasrc/biz/xsoftware/mock2/impl Added Files: CalledMethodImpl.java Log Message: CalledMethod bean impl --- NEW FILE: CalledMethodImpl.java --- package biz.xsoftware.mock2.impl; import biz.xsoftware.mock2.CalledMethod; public class CalledMethodImpl implements CalledMethod{ private String methodName; private Object[] parameters; private String stackTrace; public void setMethodName(String methodName) { this.methodName = methodName; } public void setParameters(Object[] parameters) { this.parameters = parameters; } public void setStackTrace(String stackTrace) { this.stackTrace = stackTrace; } public String getMethodName() { // TODO Auto-generated method stub return methodName; } public Object[] getParameters() { // TODO Auto-generated method stub return parameters; } public String getStackTrace() { // TODO Auto-generated method stub return stackTrace; } } |
|
From: Jay <ja...@us...> - 2006-01-03 13:29:49
|
Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2/impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10272/input/javasrc/biz/xsoftware/mock2/impl Log Message: Directory /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2/impl added to the repository |
|
From: Nobody <fas...@us...> - 2006-01-01 00:36:06
|
Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/test/mock In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23654/input/javasrc/biz/xsoftware/test/mock Added Files: Car.java FactoryInterface.java ListenerOne.java MockOne.java TestMockCreator.java TestOrderedCalls.java TestUnorderedCalls.java Log Message: get code coverage back up to 80% by eliminating unfinished examples and running the example tests. --- NEW FILE: TestUnorderedCalls.java --- /* * 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.mock; import junit.framework.TestCase; import junit.framework.TestSuite; import junit.textui.TestRunner; import biz.xsoftware.mock.ExpectFailedException; /** * @author Dean Hiller * * To change the template for this generated type comment go to * Window - Preferences - Java - Code Generation - Code and Comments */ public class TestUnorderedCalls extends TestCase { //private final static Logger log = Logger.getLogger(TestUnorderedCalls.class.getName()); /** * @param name */ public TestUnorderedCalls(String name) { super(name); } public void testUnorderedWorks() { MockOne one = new MockOne(10); one.callMeSecond("dummy"); one.callMeFirst(324); String[] evts = new String[] { MockOne.FIRST, MockOne.SECOND }; one.expectUnorderedCalls(evts); } public void testExtraInUnorderedExpect() { MockOne one = new MockOne(3000); one.callMeSecond("dummy"); one.callMeExtra(); one.callMeFirst(5544); String[] evts = new String[] { MockOne.FIRST, MockOne.SECOND }; try { one.expectUnorderedCalls(evts); fail("Should have failed this test case"); } catch(ExpectFailedException e) { /*gulp*/ } } public void testExtraAfterUnorderedExpect() { MockOne one = new MockOne(10); one.callMeSecond("dummy"); one.callMeFirst(322); one.callMeExtra(); String[] evts = new String[] { MockOne.FIRST, MockOne.SECOND }; try { one.expectUnorderedCalls(evts); fail("Should have failed this test case"); } catch(ExpectFailedException e) { /*gulp*/ } } public void testTimeout() { MockOne one = new MockOne(10); one.callMeSecond("dummy"); try { String[] evts = new String[] { MockOne.FIRST, MockOne.SECOND }; one.expectUnorderedCalls(evts); } catch(ExpectFailedException e) { assertEquals("reason must be correct", ExpectFailedException.TIMED_OUT, e.getReason()); } } public static void main(String[] args) { TestSuite suite = new TestSuite(); // suite.addTest(new TestUnorderedCalls("testExceptionThrown")); // suite.addTest(new TestUnorderedCalls("testMockCreator")); // suite.addTest(new TestUnorderedCalls("testMockCreatorFail")); // suite.addTest(new TestUnorderedCalls("testMockCreatorCreatesCar")); suite.addTest(new TestUnorderedCalls("testTimeout")); TestRunner.run(suite); } } --- NEW FILE: TestMockCreator.java --- /* * 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.mock; import java.io.IOException; 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)); } 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; 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) { } } 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); } } --- NEW FILE: ListenerOne.java --- /* * 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.mock; import java.io.IOException; /** * @author Dean Hiller * * To change the template for this generated type comment go to * Window - Preferences - Java - Code Generation - Code and Comments */ public interface ListenerOne { public void callMeFirst(int s); public void callMeSecond(String s) throws IOException; public void multipleParams(String x, Integer i); } --- NEW FILE: MockOne.java --- /* * 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.mock; import biz.xsoftware.mock.MockSuperclass; /** * @author Dean Hiller * * To change the template for this generated type comment go to * Window - Preferences - Java - Code Generation - Code and Comments */ 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"; public MockOne(int delay) { super(delay); } /* (non-Javadoc) * @see test.biz.xsoftware.testlib.test.ListenerOne#callMeFirst() */ public void callMeFirst(int s) { methodCalled(FIRST, new Integer(s)); } /* (non-Javadoc) * @see test.biz.xsoftware.testlib.test.ListenerOne#callMeSecond() */ public void callMeSecond(String s) { methodCalled(SECOND, s); } public void callMeExtra() { methodCalled(EXTRA, null); } /* (non-Javadoc) * @see biz.xsoftware.test.ListenerOne#multipleParams(java.lang.String, java.lang.Integer) */ public void multipleParams(String x, Integer i) { methodCalled(MULTIPLE_PARAMS, new Object[] { x, i }); } /* (non-Javadoc) * @see biz.xsoftware.mock.MockSuperclass#getClasses() */ public Class[] getClasses() { return new Class[] { MockOne.class }; } public Object inst() { // TODO Auto-generated method stub return null; } } --- NEW FILE: FactoryInterface.java --- /* * Created on Jun 8, 2004 * * To change the template for this generated file go to * Window - Preferences - Java - Code Generation - Code and Comments */ package biz.xsoftware.test.mock; /** * @author Dean Hiller * * To change the template for this generated type comment go to * Window - Preferences - Java - Code Generation - Code and Comments */ public interface FactoryInterface { public Car createCar(String id); } --- NEW FILE: Car.java --- /* * Created on Jun 8, 2004 * * To change the template for this generated file go to * Window - Preferences - Java - Code Generation - Code and Comments */ package biz.xsoftware.test.mock; /** * @author Dean Hiller * * To change the template for this generated type comment go to * Window - Preferences - Java - Code Generation - Code and Comments */ public interface Car { public void openDoor(); public void closeDoor(); } --- NEW FILE: TestOrderedCalls.java --- /* * 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.mock; import junit.framework.TestCase; import junit.framework.TestSuite; import junit.textui.TestRunner; import biz.xsoftware.mock.ExpectFailedException; /** * @author Dean Hiller * * To change the template for this generated type comment go to * Window - Preferences - Java - Code Generation - Code and Comments */ public class TestOrderedCalls extends TestCase { //private final static Logger log = Logger.getLogger(TestOrderedCalls.class.getName()); /** * @param name */ public TestOrderedCalls(String name) { super(name); } public void testBasicEventBeforeExpect() { MockOne one = new MockOne(3000); one.callMeFirst(4); one.expectCall(MockOne.FIRST); } public void testBasicExpectBeforeEvent() { final MockOne one = new MockOne(3000); Thread r = new Thread() { public void run() { delay(1000); one.callMeFirst(4); } }; r.start(); one.expectCall(MockOne.FIRST); } public void testOrderAfter() { MockOne one = new MockOne(3000); one.callMeFirst(4); one.callMeSecond("dummy"); String[] evts = new String[] { MockOne.FIRST, MockOne.SECOND }; one.expectOrderedCalls(evts); } public void testOrderBefore() { final MockOne one = new MockOne(3000); Thread r = new Thread() { public void run() { delay(1000); one.callMeFirst(4); one.callMeSecond("dummy"); } }; r.start(); String[] evts = new String[] { MockOne.FIRST, MockOne.SECOND }; one.expectOrderedCalls(evts); } public void testOrderAfterFails() { MockOne one = new MockOne(3000); one.callMeFirst(7); one.callMeSecond("dummy"); String[] evts = new String[] { MockOne.SECOND, MockOne.FIRST }; try { one.expectOrderedCalls(evts); fail("Should have failed this test case"); } catch(ExpectFailedException e) { /*gulp*/ } } public void testOrderBeforeFails() { final MockOne one = new MockOne(3000); Thread r = new Thread() { public void run() { delay(1000); one.callMeFirst(14); one.callMeSecond("dummy"); } }; String[] evts = new String[] { MockOne.SECOND, MockOne.FIRST }; try { r.run(); one.expectOrderedCalls(evts); fail("Should have failed this test case"); } catch(ExpectFailedException e) { /*gulp*/ } } public void testLeftOverEventFails() { MockOne one = new MockOne(3000); one.callMeFirst(234); one.callMeSecond("dummy"); one.callMeFirst(43); String[] evts = new String[] { MockOne.FIRST, MockOne.SECOND }; try { one.expectOrderedCalls(evts); fail("Should have failed this test case"); } catch(ExpectFailedException e) { /*gulp*/ } } public void testExceptionThrown() { MockOne one = new MockOne(3000); RuntimeException e = new IllegalStateException("Test for robustness"); one.addThrowException(MockOne.FIRST, e); try { one.callMeFirst(324); fail("Should have thrown exception"); } catch(IllegalStateException e2) {} one.callMeSecond("dummy"); String[] methods = new String[] {MockOne.FIRST, MockOne.SECOND }; one.expectOrderedCalls(methods); } private void delay(int time) { try { Thread.sleep(time); } catch (InterruptedException e) { throw new RuntimeException("Sleep ended abrubtly"); } } public static void main(String[] args) { TestSuite suite = new TestSuite(); suite.addTest(new TestOrderedCalls("testExceptionThrown")); // 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...> - 2006-01-01 00:36:05
|
Update of /cvsroot/mocklib/mocklib2/bldfiles In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23654/bldfiles Modified Files: design.xml Log Message: get code coverage back up to 80% by eliminating unfinished examples and running the example tests. Index: design.xml =================================================================== RCS file: /cvsroot/mocklib/mocklib2/bldfiles/design.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** design.xml 27 Jun 2005 03:40:32 -0000 1.1 --- design.xml 1 Jan 2006 00:35:56 -0000 1.2 *************** *** 18,27 **** <depends>junit</depends> </package> ! <package name="testapi" package="biz.xsoftware.test" subpackages="include"> <depends>impl</depends> <depends>junit</depends> </package> ! <package name="impl2" package="biz.xsoftware.mock2" subpackages="include"> <!-- is depending on junit a good idea???? it makes it easier to prevent people from forgetting to call verify but also locks us to use junit more --- 18,31 ---- <depends>junit</depends> </package> ! <package name="testapi" package="biz.xsoftware.test.mock" subpackages="include"> ! <depends>impl</depends> ! <depends>junit</depends> ! </package> ! <package name="examples" package="biz.xsoftware.examples" subpackages="include"> <depends>impl</depends> <depends>junit</depends> </package> ! <package name="impl2" package="biz.xsoftware.mock2"> <!-- is depending on junit a good idea???? it makes it easier to prevent people from forgetting to call verify but also locks us to use junit more *************** *** 29,42 **** <depends>junit</depends> </package> ! <package name="testapi2" package="biz.xsoftware.test2" subpackages="include"> <depends>impl2</depends> <depends>junit</depends> </package> ! ! <package name="examples" package="biz.xsoftware.examples" subpackages="include"> ! <depends>impl</depends> <depends>junit</depends> </package> </design> \ No newline at end of file --- 33,46 ---- <depends>junit</depends> </package> ! <package name="testapi2" package="biz.xsoftware.test.mock2" subpackages="include"> <depends>impl2</depends> <depends>junit</depends> </package> ! <package name="examples2" package="biz.xsoftware.examples2" subpackages="include"> ! <depends>impl2</depends> <depends>junit</depends> </package> + </design> \ No newline at end of file |
|
From: Nobody <fas...@us...> - 2006-01-01 00:36:05
|
Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/test/mock2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23654/input/javasrc/biz/xsoftware/test/mock2 Added Files: ListenerOne.java Log Message: get code coverage back up to 80% by eliminating unfinished examples and running the example tests. --- NEW FILE: ListenerOne.java --- /* * 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.mock2; import java.io.IOException; import java.util.Map; /** * @author Dean Hiller * * To change the template for this generated type comment go to * Window - Preferences - Java - Code Generation - Code and Comments */ public interface ListenerOne { public void callMeFirst(int s); public void callMeSecond(String s) throws IOException; public void multipleParams(String x, Integer i); public int respondTo(Map map); public boolean responsd(); public void noParams(); } |
|
From: Nobody <fas...@us...> - 2006-01-01 00:36:05
|
Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/test2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23654/input/javasrc/biz/xsoftware/test2 Removed Files: ListenerOne.java Log Message: get code coverage back up to 80% by eliminating unfinished examples and running the example tests. --- ListenerOne.java DELETED --- |
|
From: Nobody <fas...@us...> - 2006-01-01 00:36:05
|
Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23654/input/javasrc/biz/xsoftware/test Removed Files: Car.java FactoryInterface.java ListenerOne.java MockOne.java TestMockCreator.java TestOrderedCalls.java TestUnorderedCalls.java Log Message: get code coverage back up to 80% by eliminating unfinished examples and running the example tests. --- TestUnorderedCalls.java DELETED --- --- TestMockCreator.java DELETED --- --- ListenerOne.java DELETED --- --- MockOne.java DELETED --- --- FactoryInterface.java DELETED --- --- Car.java DELETED --- --- TestOrderedCalls.java DELETED --- |
|
From: Nobody <fas...@us...> - 2006-01-01 00:34:47
|
Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/test/mock2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23381/input/javasrc/biz/xsoftware/test/mock2 Log Message: Directory /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/test/mock2 added to the repository |
|
From: Nobody <fas...@us...> - 2006-01-01 00:34:46
|
Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/test/mock In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23381/input/javasrc/biz/xsoftware/test/mock Log Message: Directory /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/test/mock added to the repository |
Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/examples/timer In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20241/javasrc/biz/xsoftware/examples/timer Added Files: MockTimer.java.bak SysUnderTest.java.bak TestExample.java.bak Removed Files: MockTimer.java SysUnderTest.java TestExample.java Log Message: get code coverage to be 80% or higher. --- NEW FILE: MockTimer.java.bak --- /* * Created on Jul 12, 2004 * * To change the template for this generated file go to * Window - Preferences - Java - Code Generation - Code and Comments */ package biz.xsoftware.examples.timer; import java.util.Date; import java.util.Timer; import java.util.TimerTask; import biz.xsoftware.mock.CalledMethod; import biz.xsoftware.mock.Cloner; import biz.xsoftware.mock.MockObject; import biz.xsoftware.mock.MockSuperclass; /** * A mock of Timer. This class is a bit more complicated that it would * be if an interface was used instead. * * @author Dean Hiller */ public class MockTimer extends Timer implements MockObject { public final static String CANCEL = "cancel"; public final static String SCHEDULE = "schedule"; public final static String SCHEDULE_FIXED_RATE = "scheduleAtFixedRate"; private Delegate delegate = new Delegate(); private class Delegate extends MockSuperclass { /** * @see biz.xsoftware.mock.MockSuperclass#methodCalled(java.lang.String, java.lang.Object) */ public Object methodCalled(String method, Object param) { return super.methodCalled(method, param); } /* (non-Javadoc) * @see biz.xsoftware.mock.MockSuperclass#getClasses() */ public Class[] getClasses() { return new Class[] { MockTimer.class }; } public Object inst() { // TODO Auto-generated method stub return null; } } /** * @see java.util.Timer#cancel() */ public void cancel() { delegate.methodCalled(CANCEL, null); } /** * @see java.util.Timer#schedule(java.util.TimerTask, java.util.Date, long) */ public void schedule(TimerTask task, Date firstTime, long period) { Object[] obj = new Object[] {task, firstTime, new Long(period)}; delegate.methodCalled(SCHEDULE, obj); } /** * @see java.util.Timer#schedule(java.util.TimerTask, java.util.Date) */ public void schedule(TimerTask task, Date time) { Object[] obj = new Object[] {task, time}; delegate.methodCalled(SCHEDULE, obj); } /** * @see java.util.Timer#schedule(java.util.TimerTask, long, long) */ public void schedule(TimerTask task, long delay, long period) { Object[] obj = new Object[] {task, new Long(delay), new Long(period)}; delegate.methodCalled(SCHEDULE, obj); } /** * @see java.util.Timer#schedule(java.util.TimerTask, long) */ public void schedule(TimerTask task, long delay) { Object[] obj = new Object[] {task, new Long(delay)}; delegate.methodCalled(SCHEDULE, obj); } /** * @see java.util.Timer#scheduleAtFixedRate(java.util.TimerTask, java.util.Date, long) */ public void scheduleAtFixedRate(TimerTask task, Date firstTime, long period) { Object[] obj = new Object[] {task, firstTime, new Long(period)}; delegate.methodCalled(SCHEDULE_FIXED_RATE, obj); } /** * @see java.util.Timer#scheduleAtFixedRate(java.util.TimerTask, long, long) */ public void scheduleAtFixedRate(TimerTask task, long delay, long period) { Object[] obj = new Object[] {task, new Long(delay), new Long(period)}; delegate.methodCalled(SCHEDULE_FIXED_RATE, obj); } /** * @see biz.xsoftware.mock.MockObject#expectCall(java.lang.String) */ public CalledMethod expectCall(String method) { return delegate.expectCall(method); } /** * @see biz.xsoftware.mock.MockObject#expectOrderedCalls(java.lang.String[]) */ public CalledMethod[] expectOrderedCalls(String[] methods) { return delegate.expectOrderedCalls(methods); } /** * @see biz.xsoftware.mock.MockObject#expectUnorderedCalls(java.lang.String[]) */ public CalledMethod[] expectUnorderedCalls(String[] methods) { return delegate.expectUnorderedCalls(methods); } /** * @see biz.xsoftware.mock.MockObject#addThrowException(java.lang.String, java.lang.Throwable) */ public void addThrowException(String method, Throwable e) { delegate.addThrowException(method, e); } /** * @see biz.xsoftware.mock.MockObject#addReturnValue(java.lang.String, java.lang.Object) */ public void addReturnValue(String method, Object o) { delegate.addReturnValue(method, o); } /** (non-Javadoc) * @see biz.xsoftware.mock.MockObject#setDefaultReturnValue(java.lang.String, java.lang.Object) */ public void setDefaultReturnValue(String method, Object o) { 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(); } /** * @see biz.xsoftware.mock.MockObject#setIgnoredMethods(java.lang.String[]) */ public void setIgnoredMethods(String[] methods) { delegate.setIgnoredMethods(methods); } public void setCloner(Cloner c) { delegate.setCloner(c); } public Object inst() { // TODO Auto-generated method stub return null; } } --- TestExample.java DELETED --- --- NEW FILE: SysUnderTest.java.bak --- /* * Created on Jun 28, 2004 * * To change the template for this generated file go to * Window - Preferences - Java - Code Generation - Code and Comments */ package biz.xsoftware.examples.timer; import java.util.Timer; import java.util.TimerTask; import javax.swing.event.EventListenerList; /** * The SysUnderTest here is a Calendar which notifies users of a * scheduled event. */ public class SysUnderTest { private Timer timer; private EventListenerList listenerList = new EventListenerList(); /** * @showcode */ public SysUnderTest(Timer t) { timer = t; } /** * @showcode */ public void addEvent(String title, long delay) { timer.schedule(new CalendarEvent(title), delay); } /** * @showcode */ public void addScheduleListener(ScheduleListener l) { listenerList.add(ScheduleListener.class, l); } /** * @showcode */ public void removeScheduleListener(ScheduleListener l) { listenerList.remove(ScheduleListener.class, l); } private class CalendarEvent extends TimerTask { private String title; /** * @showcode */ public CalendarEvent(String title) { this.title = title; } /** * @showcode */ public void run() { fireEventStarted(title); } } /** * @showcode */ protected void fireEventStarted(String title) { // Guaranteed to return a non-null array Object[] listeners = listenerList.getListenerList(); // Process the listeners last to first, notifying // those that are interested in this event for (int i = listeners.length-2; i>=0; i-=2) { if (listeners[i]==ScheduleListener.class) { ((ScheduleListener)listeners[i+1]).eventStarted(title); } } } } --- NEW FILE: TestExample.java.bak --- /* * Created on Jun 28, 2004 * * To change the template for this generated file go to * Window - Preferences - Java - Code Generation - Code and Comments */ package biz.xsoftware.examples.timer; import java.util.TimerTask; import junit.framework.TestCase; import biz.xsoftware.mock.MockObjectFactory; import biz.xsoftware.mock.MockObject; /** * JUnit Suite of TestCases for demonstrating mocking out Timer in the * java util package. * * @author Dean Hiller */ public class TestExample extends TestCase { private MockObject mockListener; private MockTimer mockTimer; private SysUnderTest calendar; /** * @showcode */ public TestExample(String name) { super(name); } /** * @showcode */ protected void setUp() { mockTimer = new MockTimer(); calendar = new SysUnderTest(mockTimer); mockListener = MockObjectFactory.createMock(ScheduleListener.class); calendar.addScheduleListener((ScheduleListener)mockListener); } /** * @showcode */ protected void tearDown() { calendar.removeScheduleListener((ScheduleListener)mockListener); } /** * @showcode */ public void testBasicCalendar() { String title = "some event"; long delay = 50000; calendar.addEvent(title, delay); Object[] params = mockTimer.expectCall("schedule").getAllParams(); //param[0] is a timer task TimerTask task = (TimerTask)params[0]; assertEquals("Should have set the timer for "+delay+" ms", new Long(delay), params[1]); //run the task now instead of waiting 50000ms task.run(); params = mockListener.expectCall("eventStarted").getAllParams(); assertEquals("title should be the same", title, params[0]); } } --- SysUnderTest.java DELETED --- --- MockTimer.java DELETED --- |
Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/examples/socket In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20241/javasrc/biz/xsoftware/examples/socket Added Files: MockServer.java.bak OtherSubsystem.java.bak SysUnderTest.java.bak TCPSocket.java.bak TCPSocketImpl.java.bak TCPSocketMock.java.bak TesExample.java.bak Removed Files: MockServer.java OtherSubsystem.java SysUnderTest.java TCPSocket.java TCPSocketImpl.java TCPSocketMock.java TesExample.java Log Message: get code coverage to be 80% or higher. --- NEW FILE: MockServer.java.bak --- /* * Created on Jul 3, 2004 * * To change the template for this generated file go to * Window - Preferences - Java - Code Generation - Code and Comments */ package biz.xsoftware.examples.socket; import java.net.InetSocketAddress; /** * The MockServer that the SysUnderTest talks to. * * @author Dean Hiller */ public class MockServer { /** * @showcode */ public InetSocketAddress start() { return null; } /** * @showcode */ public void stop() { } /** * @showcode */ public void closeSocket() { } } --- NEW FILE: TCPSocket.java.bak --- /* * Created on Jul 3, 2004 * * To change the template for this generated file go to * Window - Preferences - Java - Code Generation - Code and Comments */ package biz.xsoftware.examples.socket; import java.io.IOException; import java.nio.ByteBuffer; /** * Abstraction of a Socket to allow testing. * * @author Dean Hiller */ public interface TCPSocket { public int read(ByteBuffer b) throws IOException; public int write(ByteBuffer b) throws IOException; } --- TCPSocketMock.java DELETED --- --- TesExample.java DELETED --- --- TCPSocketImpl.java DELETED --- --- NEW FILE: OtherSubsystem.java.bak --- /* * Created on Jul 3, 2004 * * To change the template for this generated file go to * Window - Preferences - Java - Code Generation - Code and Comments */ package biz.xsoftware.examples.socket; /** * Some other subsystem. * @author Dean Hiller */ public interface OtherSubsystem { public void cleanup(); } --- SysUnderTest.java DELETED --- --- NEW FILE: TCPSocketImpl.java.bak --- /* * Created on Jul 3, 2004 * * To change the template for this generated file go to * Window - Preferences - Java - Code Generation - Code and Comments */ package biz.xsoftware.examples.socket; import java.io.IOException; import java.net.Socket; import java.nio.ByteBuffer; /** * The real implementation behind TCPSocket. * * @author Dean Hiller */ public class TCPSocketImpl implements TCPSocket { private Socket socket; /** * @showcode */ public TCPSocketImpl(Socket s) { socket = s; } /** * @see biz.xsoftware.examples.socket.TCPSocket#read(java.nio.ByteBuffer) * @showcode */ public int read(ByteBuffer b) throws IOException { return socket.getChannel().read(b); } /** * @see biz.xsoftware.examples.socket.TCPSocket#write(java.nio.ByteBuffer) * @showcode */ public int write(ByteBuffer b) throws IOException { return socket.getChannel().write(b); } } --- NEW FILE: SysUnderTest.java.bak --- /* * Created on Jul 3, 2004 * * To change the template for this generated file go to * Window - Preferences - Java - Code Generation - Code and Comments */ package biz.xsoftware.examples.socket; /** * SysUnderTest that uses TCPSockets to talk to a server. * * @author Dean Hiller */ public class SysUnderTest { /** * @showcode */ public SysUnderTest(TCPSocket s, OtherSubsystem mockSubsys) { } /** * @showcode */ public void sendDataToServer() { } } --- MockServer.java DELETED --- --- NEW FILE: TCPSocketMock.java.bak --- /* * Created on Jul 3, 2004 * * To change the template for this generated file go to * Window - Preferences - Java - Code Generation - Code and Comments */ package biz.xsoftware.examples.socket; import java.io.IOException; import java.nio.ByteBuffer; import biz.xsoftware.mock.MockSuperclass; /** * A mock TCPSocket. * @see TCPSocket * @author Dean Hiller */ public class TCPSocketMock extends MockSuperclass implements TCPSocket { public final static String READ_METHOD = "read method"; public final static String WRITE_METHOD = "write method"; private TCPSocketImpl socket; /** * @showcode */ public TCPSocketMock(TCPSocketImpl socket) { this.socket = socket; } /** * @showcode */ public int read(ByteBuffer b) throws IOException { //allows us to throw Exceptions like the network went down!!! methodCalled(READ_METHOD, b); return socket.read(b); } /** * @showcode */ public int write(ByteBuffer b) throws IOException { //allows us to throw Exceptions like the network went down!!! methodCalled(WRITE_METHOD, b); return socket.read(b); } /* (non-Javadoc) * @see biz.xsoftware.mock.MockSuperclass#getClasses() */ public Class[] getClasses() { return null; } public Object inst() { // TODO Auto-generated method stub return null; } } --- NEW FILE: TesExample.java.bak --- /* * Created on Jun 28, 2004 * * To change the template for this generated file go to * Window - Preferences - Java - Code Generation - Code and Comments */ package biz.xsoftware.examples.socket; import java.io.IOException; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.Socket; import junit.framework.TestCase; import biz.xsoftware.mock.MockObjectFactory; import biz.xsoftware.mock.MockObject; /** * JUnit Suite of TestCases for demonstrating mocking out socket * interfaces to test network failures. * * @author Dean Hiller */ public class TesExample extends TestCase { private SysUnderTest sysUnderTest; private MockObject mockSubsys; private TCPSocketMock mockSocket; private MockServer mockServer; private Socket s; /** * @showcode */ public TesExample(String name) { super(name); } /** * @showcode */ public void setUp() throws Exception { s = new Socket(); mockServer = new MockServer(); InetSocketAddress serverAddr = mockServer.start(); InetAddress localHost = InetAddress.getLocalHost(); s.bind(new InetSocketAddress(localHost, 0)); s.connect(serverAddr); TCPSocketImpl tcpSock = new TCPSocketImpl(s); mockSocket = new TCPSocketMock(tcpSock); mockSubsys = MockObjectFactory.createMock(OtherSubsystem.class); sysUnderTest = new SysUnderTest(mockSocket, (OtherSubsystem)mockSubsys); } /** * @showcode */ public void tearDown() throws IOException { mockServer.stop(); s.close(); } /** * Test that upon network problems like IOException when writing to server * that other subsystems get cleaned up properly. The simple test below * shows how this can be done and extended to more complicated network * recovery algorithms. * * @showcode */ public void testNetworkProblems() { mockSocket.addThrowException("write", new IOException("problems writing to server")); sysUnderTest.sendDataToServer(); mockSubsys.expectCall("cleanup"); } /** * Test that when the server unexpectedly closes it's socket, the system * tears down correctly on this unexpected event. * * @showcode */ public void testServerClosingSocket() { mockServer.closeSocket(); mockSubsys.expectCall("cleanup"); } } --- OtherSubsystem.java DELETED --- --- TCPSocket.java DELETED --- |
|
From: Nobody <fas...@us...> - 2006-01-01 00:20:58
|
Update of /cvsroot/mocklib/mocklib2/bldfiles In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20041 Modified Files: directory.properties Log Message: change junit pattern Index: directory.properties =================================================================== RCS file: /cvsroot/mocklib/mocklib2/bldfiles/directory.properties,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** directory.properties 27 Jun 2005 03:40:32 -0000 1.1 --- directory.properties 1 Jan 2006 00:20:50 -0000 1.2 *************** *** 116,120 **** #----------------------------------------------------------------------- junit.pattern1=biz/xsoftware/test/**/Test*.class ! junit.pattern2=**/test/Test*.class javadoc.pattern=**/*.java --- 116,120 ---- #----------------------------------------------------------------------- junit.pattern1=biz/xsoftware/test/**/Test*.class ! junit.pattern2=biz/xsoftware/examples/**/Test*.class javadoc.pattern=**/*.java |
|
From: Nobody <fas...@us...> - 2005-12-31 15:23:39
|
Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30434 Modified Files: Behavior.java Log Message: add documentation Index: Behavior.java =================================================================== RCS file: /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2/Behavior.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Behavior.java 23 Dec 2005 01:33:05 -0000 1.1 --- Behavior.java 31 Dec 2005 15:23:26 -0000 1.2 *************** *** 3,10 **** /** * A marker interface that signifies that the implementation is a behavior ! * and cloner class. Methods for the behavior has the exact same signature as the ! * method. The cloner method has the <methodName>Clone with the same signature ! * as the method to clone the parameters and returns the cloned parameters as ! * an object array. * * @author Dann Ormond --- 3,14 ---- /** * A marker interface that signifies that the implementation is a behavior ! * and cloner class. If you implement this class, your implementation class ! * must have two methods. It must have a behavior method and a clone method. ! * The behavior method must have the same exact signature of the method you ! * expect to be called(ie. when you called MockObject.expect, you passed in ! * the method you expected to be called). The clone method will be called ! * <methodName>Clone with the same signature as the method to clone ! * the parameters and returns the cloned parameters as an object array. ! * * * @author Dann Ormond |
|
From: Nobody <fas...@us...> - 2005-12-23 01:47:25
|
Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/test2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23380/javasrc/biz/xsoftware/test2 Removed Files: TestMockCreator.java Log Message: remove unused tests. --- TestMockCreator.java DELETED --- |
|
From: Nobody <fas...@us...> - 2005-12-23 01:33:17
|
Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21295/javasrc/biz/xsoftware/mock2 Added Files: Behavior.java CalledMethod.java MockObject.java MockObjectFactory.java Log Message: add api we are implementing. --- NEW FILE: Behavior.java --- package biz.xsoftware.mock2; /** * A marker interface that signifies that the implementation is a behavior * and cloner class. Methods for the behavior has the exact same signature as the * method. The cloner method has the <methodName>Clone with the same signature * as the method to clone the parameters and returns the cloned parameters as * an object array. * * @author Dann Ormond * */ public interface Behavior { } --- NEW FILE: CalledMethod.java --- package biz.xsoftware.mock2; /** * A representation of a called method. This bean holds the parameters, * method name, and the stack trace for a specific invocation of a method. * * @author Dann Ormond * */ public interface CalledMethod { public String getMethodName(); public Object[] getParameters(); public String getStackTrace(); } --- NEW FILE: MockObject.java --- package biz.xsoftware.mock2; /** * * @author Dann Ormond * */ public interface MockObject { /** * Expect a method to be called with no return value. The default timeout is * 10 seconds. * * @param methodName * the name of the method to expect * @param vargs * the optional parmeter types of the method call * @return the CalledMethod information that will be filled after the method * is called */ public CalledMethod expect(String methodName, Class[] vargs); /** * Expect a method to be called an returning the specified return value. The * default timeout is 10 seconds. * * @param returnValue * the value to return from the method call * @param methodName * the name of the method to expect * @param vargs * the optional parameter types of the method call * @return the CalledMethod information that will be filled after the method * is called */ public CalledMethod expect(Object returnValue, String methodName, Class[] vargs); /** * Expect a method to be called an throw an exception rather than return * normal. The default timeout is 10 seconds. * * @param methodName * the name of the method to expect * @param throwable * the exception to throw from the method * @param vargs * the optional parameter types of the method call * @return the CalledMethod information that will be filled after the method * is called */ public CalledMethod expect(String methodName, Throwable throwable, Class[] vargs); /** * Expect a method to be called with the specified behavior to modify the * parameters and return value as needed. The default timeout is 10 seconds. * * @param methodName * the name of the method to expect * @param behavior * the behavior to handle cloning managing of the return value * @param params * the optional parameter types of the method call * @return the CalledMethod information that will be filled after the method * is called */ public CalledMethod expect(String methodName, Behavior behavior, Class[] params); /*************************************************************************** * SAME METHODS AS ABOVE BUT WITH TIMEOUT PARAMETER **************************************************************************/ /** * Expect a method to be called with no return value. * * @param methodName * the name of the method to expect * @param timeout * The time to wait for method to be called before failing test * @param vargs * the optional parmeter types of the method call * @return the CalledMethod information that will be filled after the method * is called */ public CalledMethod expect(String methodName, long timeout, Class[] vargs); /** * Expect a method to be called an returning the specified return value. * * @param returnValue * the value to return from the method call * @param methodName * the name of the method to expect * @param timeout * The time to wait for method to be called before failing test * @param vargs * the optional parameter types of the method call * @return the CalledMethod information that will be filled after the method * is called */ public CalledMethod expect(Object returnValue, String methodName, long timeout, Class[] vargs); /** * Expect a method to be called an throw an exception rather than return * normal. * * @param methodName * the name of the method to expect * @param throwable * the exception to throw from the method * @param timeout * The time to wait for method to be called before failing test * @param vargs * the optional parameter types of the method call * @return the CalledMethod information that will be filled after the method * is called */ public CalledMethod expect(String methodName, Throwable throwable, long timeout, Class[] vargs); /** * Expect a method to be called with the specified behavior to modify the * parameters and return value as needed. * * @param methodName * the name of the method to expect * @param behavior * the behavior to handle cloning managing of the return value * @param timeout * The time to wait for method to be called before failing test * @param params * the optional parameter types of the method call * @return the CalledMethod information that will be filled after the method * is called */ public CalledMethod expect(String methodName, Behavior behavior, long timeout, Class[] params); /** * Verifies that the expected methods are called within the timeout. */ public void verify(); /** * Add a method to the ignore list. * * @param methodName * the name of the method to ignore * @param vargs * the optional parameter types of the method call */ public void addIgnoreMethod(String methodName, Class[] vargs); /** * Remove a method from the ignore list. * * @param methodName * the name of the method to ignore * @param vargs * the optinal parameter types of the method call */ public void removeIgnoreMethod(String methodName, Class[] vargs); /** * Sets the default return value for a method call and adds the method to * the ignore list. * * @param returnValue * the value to return for specific method calls * @param methodName * the name of the method * @param vargs * the optional parameter types of the method calls */ public void setDefaultReturnValue(Object returnValue, String methodName, Class[] vargs); /** * Creates returns an instance of the mocked object. * * @return an instance of the mocked object */ public Object instance(); } --- NEW FILE: MockObjectFactory.java --- package biz.xsoftware.mock2; /** * The factory class that creates MockObjects * * @author Dann Ormond * */ public abstract class MockObjectFactory { public static MockObject createMock(Class[] interfacesToMock) { // TODO: Implement me! return null; } public static MockObject createMock(Class interfaceToMock) { return createMock(new Class[] { interfaceToMock }); } public static MockObject createMock(Class interfaceToMock, Object realObject) { // TODO: Implement me! return null; } } |
Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20268/javasrc/biz/xsoftware/mock2 Removed Files: CalledMethod.java ExpectFailedException.java MockObject2.java MockObjectFactory2.java MockTest.java VerifyResult.java Log Message: erase old files. --- MockObjectFactory2.java DELETED --- --- VerifyResult.java DELETED --- --- ExpectFailedException.java DELETED --- --- CalledMethod.java DELETED --- --- MockTest.java DELETED --- --- MockObject2.java DELETED --- |
Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2/helper In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20268/javasrc/biz/xsoftware/mock2/helper Removed Files: Behavior.java MethodDesc.java MockObjectImpl.java MockSuperclass2.java Record.java Recorder.java RecordType.java Log Message: erase old files. --- RecordType.java DELETED --- --- Recorder.java DELETED --- --- Record.java DELETED --- --- Behavior.java DELETED --- --- MethodDesc.java DELETED --- --- MockObjectImpl.java DELETED --- --- MockSuperclass2.java DELETED --- |
|
From: Nobody <fas...@us...> - 2005-12-21 22:55:09
|
Update of /cvsroot/mocklib/mocklib2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27791 Modified Files: build Log Message: trigger build Index: build =================================================================== RCS file: /cvsroot/mocklib/mocklib2/build,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** build 21 Dec 2005 22:40:06 -0000 1.27 --- build 21 Dec 2005 22:54:57 -0000 1.28 *************** *** 1,4 **** - - #************************************ # Generated file. Do not modify --- 1,2 ---- |
|
From: Nobody <fas...@us...> - 2005-12-21 22:40:14
|
Update of /cvsroot/mocklib/mocklib2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24011 Modified Files: build Log Message: test email from build Index: build =================================================================== RCS file: /cvsroot/mocklib/mocklib2/build,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** build 21 Dec 2005 22:36:38 -0000 1.26 --- build 21 Dec 2005 22:40:06 -0000 1.27 *************** *** 1,2 **** --- 1,4 ---- + + #************************************ # Generated file. Do not modify |
|
From: Nobody <fas...@us...> - 2005-12-21 22:36:46
|
Update of /cvsroot/mocklib/mocklib2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23302 Modified Files: build Log Message: trigger build Index: build =================================================================== RCS file: /cvsroot/mocklib/mocklib2/build,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** build 21 Dec 2005 22:26:02 -0000 1.25 --- build 21 Dec 2005 22:36:38 -0000 1.26 *************** *** 1,5 **** - - - #************************************ # Generated file. Do not modify --- 1,2 ---- |