mocklib-checkins Mailing List for mocklib (Page 14)
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-09-10 18:20:43
|
Update of /cvsroot/mocklib/mocklib3/tools/package-list/junit In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv24474/tools/package-list/junit Log Message: Directory /cvsroot/mocklib/mocklib3/tools/package-list/junit added to the repository |
From: Nobody <fas...@us...> - 2006-09-10 18:20:43
|
Update of /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/manifest In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv24474/input/javasrc/biz/xsoftware/manifest Log Message: Directory /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/manifest added to the repository |
From: Nobody <fas...@us...> - 2006-09-10 18:20:43
|
Update of /cvsroot/mocklib/mocklib3/tools/checkstyle In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv24474/tools/checkstyle Log Message: Directory /cvsroot/mocklib/mocklib3/tools/checkstyle added to the repository |
From: Nobody <fas...@us...> - 2006-09-10 18:20:42
|
Update of /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv24474/input/javasrc/biz/xsoftware Log Message: Directory /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware added to the repository |
From: Nobody <fas...@us...> - 2006-09-10 18:20:42
|
Update of /cvsroot/mocklib/mocklib3/input/javasrc/biz In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv24474/input/javasrc/biz Log Message: Directory /cvsroot/mocklib/mocklib3/input/javasrc/biz added to the repository |
From: Nobody <fas...@us...> - 2006-09-10 18:20:42
|
Update of /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/examples/timer2 In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv24474/input/javasrc/biz/xsoftware/examples/timer2 Log Message: Directory /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/examples/timer2 added to the repository |
From: Nobody <fas...@us...> - 2006-09-10 18:20:42
|
Update of /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/examples/basic In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv24474/input/javasrc/biz/xsoftware/examples/basic Log Message: Directory /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/examples/basic added to the repository |
From: Nobody <fas...@us...> - 2006-09-10 18:20:42
|
Update of /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/examples/listener In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv24474/input/javasrc/biz/xsoftware/examples/listener Log Message: Directory /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/examples/listener added to the repository |
From: Nobody <fas...@us...> - 2006-09-10 18:20:42
|
Update of /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/test In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv24474/input/javasrc/biz/xsoftware/test Log Message: Directory /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/test added to the repository |
From: Nobody <fas...@us...> - 2006-09-10 18:20:42
|
Update of /cvsroot/mocklib/mocklib3/input/misc In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv24474/input/misc Log Message: Directory /cvsroot/mocklib/mocklib3/input/misc added to the repository |
From: Nobody <fas...@us...> - 2006-09-10 18:20:42
|
Update of /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/examples/advanced In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv24474/input/javasrc/biz/xsoftware/examples/advanced Log Message: Directory /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/examples/advanced added to the repository |
From: Nobody <fas...@us...> - 2006-09-10 18:20:42
|
Update of /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/test/mock In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv24474/input/javasrc/biz/xsoftware/test/mock Log Message: Directory /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/test/mock added to the repository |
From: Nobody <fas...@us...> - 2006-09-10 18:20:42
|
Update of /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/examples In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv24474/input/javasrc/biz/xsoftware/examples Log Message: Directory /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/examples added to the repository |
From: Nobody <fas...@us...> - 2006-09-10 18:20:41
|
Update of /cvsroot/mocklib/mocklib3/bldfiles/bak In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv24474/bldfiles/bak Log Message: Directory /cvsroot/mocklib/mocklib3/bldfiles/bak added to the repository |
From: Nobody <fas...@us...> - 2006-09-10 18:20:41
|
Update of /cvsroot/mocklib/mocklib3/input/javasrc In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv24474/input/javasrc Log Message: Directory /cvsroot/mocklib/mocklib3/input/javasrc added to the repository |
From: Nobody <fas...@us...> - 2006-09-10 18:20:41
|
Update of /cvsroot/mocklib/mocklib3/input In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv24474/input Log Message: Directory /cvsroot/mocklib/mocklib3/input added to the repository |
From: Nobody <fas...@us...> - 2006-09-10 18:19:42
|
Update of /cvsroot/mocklib/mocklib3 In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv24010/mocklib3 Log Message: Directory /cvsroot/mocklib/mocklib3 added to the repository |
From: Nobody <fas...@us...> - 2006-09-10 18:01:21
|
Update of /cvsroot/mocklib/mocklib/input/javasrc/biz/xsoftware/examples/timer In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv16469/input/javasrc/biz/xsoftware/examples/timer Removed Files: SysUnderTest.java TestExample.java MockTimer.java Log Message: clean up mocklib 1. It is not 1.4 compatible and is pretty much the final mocklib1 --- TestExample.java DELETED --- --- SysUnderTest.java DELETED --- --- MockTimer.java DELETED --- |
From: Nobody <fas...@us...> - 2006-09-10 18:01:21
|
Update of /cvsroot/mocklib/mocklib/.settings In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv16469/.settings Added Files: org.eclipse.jdt.ui.prefs org.eclipse.jdt.core.prefs Log Message: clean up mocklib 1. It is not 1.4 compatible and is pretty much the final mocklib1 --- NEW FILE: org.eclipse.jdt.core.prefs --- #Sun Sep 10 12:01:27 MDT 2006 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.4 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=1.4 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning org.eclipse.jdt.core.compiler.source=1.4 --- NEW FILE: org.eclipse.jdt.ui.prefs --- #Sun Sep 10 12:01:27 MDT 2006 eclipse.preferences.version=1 internal.default.compliance=user |
From: Nobody <fas...@us...> - 2006-09-10 18:01:21
|
Update of /cvsroot/mocklib/mocklib/input/javasrc/biz/xsoftware/mock In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv16469/input/javasrc/biz/xsoftware/mock Modified Files: ExpectFailedException.java CalledMethod.java MockObjectImpl.java MockSuperclass.java MockObject.java MockObjectFactory.java Cloner.java Added Files: Behavior.java Log Message: clean up mocklib 1. It is not 1.4 compatible and is pretty much the final mocklib1 Index: MockObjectFactory.java =================================================================== RCS file: /cvsroot/mocklib/mocklib/input/javasrc/biz/xsoftware/mock/MockObjectFactory.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** MockObjectFactory.java 24 Jun 2005 12:57:00 -0000 1.3 --- MockObjectFactory.java 10 Sep 2006 18:01:12 -0000 1.4 *************** *** 16,19 **** --- 16,41 ---- public abstract class MockObjectFactory { + private MockObjectFactory() {} + + /** + * Creates a MockObject based on your interface. One way to use it + * for a mock listener is below.<br/><br/> + * See examples for other non-listener mock objects. + * <PRE> + * MockSuperclass mockActionList = MockObjectFactory.createMock(ActionListener.class); + * button.addActionListener((ActionListener)mockActionList); + * button.setPressed(true); + * Object o = mockActionList.expectEvent("actionPerformed"); + * ActionEvent evt = (ActionEvent)o; + * assertEquals(evt.getSource(), button); + * </PRE> + * @param theInterface you want the mockObject to implement. + * @param id The object id used in the logs so you can differentiate mockobjects + * @return The mockObject that can receive events, and JUnit test + * cases can call expect event on. + */ + public static MockObject createMock(String id, Class theInterface) { + return createMock(new Class[] { theInterface }); + } /** *************** *** 36,40 **** return createMock(new Class[] { theInterface }); } ! /** * Creates a MockObject based on your interface. One way to use it --- 58,62 ---- return createMock(new Class[] { theInterface }); } ! /** * Creates a MockObject based on your interface. One way to use it *************** *** 57,60 **** --- 79,105 ---- */ public static MockObject createMock(Class[] interfaces) { + return createMock("(no id specified)", interfaces); + } + + /** + * Creates a MockObject based on your interface. One way to use it + * for mock listeners is below(This can help guarantee order between + * two different listeners).<br/><br/> + * See examples for other non-listener mock objects. + * <PRE> + * Class[] c = new Class[] {ActionListener.class, WindowListener.class}; + * MockSuperclass mockList = MockObjectFactory.createMock(c); + * button.addActionListener((ActionListener)mockList); + * window.addWindowListener((WindowListener)mockList); + * button.setPressed(true); + * Object o = mockList.expectEvent("actionPerformed"); + * ActionEvent evt = (ActionEvent)o; + * assertEquals(evt.getSource(), button); + * </PRE> + * @param interfaces The interfaces you want the mockObject to implement. + * @return The mockObject that can receive events, and JUnit test + * cases can call expect event on. + */ + public static MockObject createMock(String id, Class[] interfaces) { Class[] interfacesPlusMock = new Class[interfaces.length+1]; interfacesPlusMock[0] = MockObject.class; *************** *** 64,71 **** ClassLoader cl = MockObjectFactory.class.getClassLoader(); ! MockObjectImpl impl = new MockObjectImpl(interfaces); Object o = Proxy.newProxyInstance(cl, interfacesPlusMock, impl); MockObject m = (MockObject)o; ! return m; } --- 109,116 ---- ClassLoader cl = MockObjectFactory.class.getClassLoader(); ! MockObjectImpl impl = new MockObjectImpl(id, interfaces); Object o = Proxy.newProxyInstance(cl, interfacesPlusMock, impl); MockObject m = (MockObject)o; ! return m; } --- NEW FILE: Behavior.java --- /** * Copyright (C) 2006 Carrier Access, Corp. */ package biz.xsoftware.mock; /** * Use MethodBehavior interface instead of Behavior interface */ public interface Behavior { /** * @param params * @return */ public Object[] clone(Object[] params); /** * @param params */ public Object runMethod(Object[] params); } Index: ExpectFailedException.java =================================================================== RCS file: /cvsroot/mocklib/mocklib/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 7 May 2005 18:26:17 -0000 1.1 --- ExpectFailedException.java 10 Sep 2006 18:01:12 -0000 1.2 *************** *** 18,21 **** --- 18,25 ---- /** + * + */ + private static final long serialVersionUID = 1L; + /** * Expect failed because an event never came and waiting finally timed out. */ *************** *** 25,34 **** * all your expected methods were called. */ ! public static final String UNEXPECTED_CALL_AFTER = "Another method that was not expected nor ignored was called after all the expected method calls"; /** * Expect failed because a method you did not list in expected methods was called * before or during the other methods you did expect. */ ! public static final String UNEXPECTED_CALL_BEFORE ="Another method that was not expected nor ignored was called before all the expected method calls were called"; /** * Expect failed because you expected no methods to be called, but a method was called. --- 29,40 ---- * all your expected methods were called. */ ! public static final String UNEXPECTED_CALL_AFTER = ! "Another method that was not expected nor ignored was called after all the expected method calls"; /** * Expect failed because a method you did not list in expected methods was called * before or during the other methods you did expect. */ ! public static final String UNEXPECTED_CALL_BEFORE = ! "Another method that was not expected nor ignored was called before all the expected method calls were called"; /** * Expect failed because you expected no methods to be called, but a method was called. Index: Cloner.java =================================================================== RCS file: /cvsroot/mocklib/mocklib/input/javasrc/biz/xsoftware/mock/Cloner.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Cloner.java 19 Jun 2005 03:09:57 -0000 1.1 --- Cloner.java 10 Sep 2006 18:01:12 -0000 1.2 *************** *** 14,18 **** * @return */ ! public Object clone(Object o); } --- 14,18 ---- * @return */ ! public Object[] clone(Object[] o); } Index: CalledMethod.java =================================================================== RCS file: /cvsroot/mocklib/mocklib/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 7 May 2005 18:26:17 -0000 1.1 --- CalledMethod.java 10 Sep 2006 18:01:12 -0000 1.2 *************** *** 44,48 **** /** * - * @return */ public Object[] getAllParams() { --- 44,47 ---- *************** *** 53,57 **** return howItWasCalled; } ! public String toString() { List paramList = null; if(params != null) --- 52,56 ---- return howItWasCalled; } ! public String toString() { List paramList = null; if(params != null) Index: MockObject.java =================================================================== RCS file: /cvsroot/mocklib/mocklib/input/javasrc/biz/xsoftware/mock/MockObject.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** MockObject.java 24 Jun 2005 12:57:00 -0000 1.3 --- MockObject.java 10 Sep 2006 18:01:12 -0000 1.4 *************** *** 7,14 **** package biz.xsoftware.mock; /** * The interface all mock objects implement. This is the interface used * by the unit tests once the mock object is created. ! * * @author Dean Hiller */ --- 7,15 ---- package biz.xsoftware.mock; + /** * The interface all mock objects implement. This is the interface used * by the unit tests once the mock object is created. ! * * @author Dean Hiller */ *************** *** 24,31 **** */ public static String ANY = "'Any method'"; ! /** * 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. --- 25,32 ---- */ public static String ANY = "'Any method'"; ! /** * 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. *************** *** 33,39 **** * @param method The expected method. * @return An array of params that were passed to the methods called ! */ public CalledMethod expectCall(String method); ! /** * Waits for all the methods to be called. If any of the methods --- 34,66 ---- * @param method The expected method. * @return An array of params that were passed to the methods called ! * ! * @deprecated please use expect(String method) ! */ public CalledMethod expectCall(String method); ! ! /** ! * 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. ! * ! * @param method The expected method. ! * @return An array of params that were passed to the methods called ! */ ! public CalledMethod expect(String method); ! ! /** ! * 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. ! * ! * @param methods The expected method(s) in the correct order. ! * @return An array or arrays of params that were passed to the methods called ! */ ! public CalledMethod[] expect(String[] methods); ! /** * Waits for all the methods to be called. If any of the methods *************** *** 42,59 **** * 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. ! * * @param methods The expected methods in the correct order. * @return An array or arrays of params that were passed to the methods called ! */ public CalledMethod[] expectOrderedCalls(String[] methods); ! /** * Expect many methods to be called irrelevant of the order in which they are * called. ! * * @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); --- 69,90 ---- * 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. ! * * @param methods The expected methods in the correct order. * @return An array or arrays of params that were passed to the methods called ! * ! * @deprecated please use expectCall(String ... methods) ! */ public CalledMethod[] expectOrderedCalls(String[] methods); ! /** * Expect many methods to be called irrelevant of the order in which they are * called. ! * * @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. + * + * @deprecated this will go away soon, unless you email me that you depend on it. */ public CalledMethod[] expectUnorderedCalls(String[] methods); *************** *** 75,79 **** * <li> RuntimeException for Subclasses of MockSuperclass</li> * </ol> ! * * @param method The method to throw the exception on when it is called. * @param e The exception to throw on method. --- 106,110 ---- * <li> RuntimeException for Subclasses of MockSuperclass</li> * </ol> ! * * @param method The method to throw the exception on when it is called. * @param e The exception to throw on method. *************** *** 83,87 **** * Add a return value to return when 'method' is called. * <br></br> ! * This can be called multiple times and each call will add * to a queue. When 'method' is called, it will return * the first value on the queue. If the queue is null, --- 114,118 ---- * Add a return value to return when 'method' is called. * <br></br> ! * This can be called multiple times and each call will add * to a queue. When 'method' is called, it will return * the first value on the queue. If the queue is null, *************** *** 90,115 **** * <br></br> * Use Integer to return int, Long for long, etc. ! * * @param method The method that when called returns first value on queue * @param o The object to return that is added to the queue */ public void addReturnValue(String method, Object o); ! /** * 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); ! public void setCloner(Cloner c); /** * Set the DefaultReturnValue for a 'method' ! * @param method The method */ public void setDefaultReturnValue(String method, Object o); ! public void setExpectTimeout(int timeout); ! ! public int getExpectTimeout(); } --- 121,176 ---- * <br></br> * Use Integer to return int, Long for long, etc. ! * * @param method The method that when called returns first value on queue * @param o The object to return that is added to the queue */ public void addReturnValue(String method, Object o); ! /** * 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. + * + * @deprecated please use ignore(String ... methods) */ public void setIgnoredMethods(String[] methods); ! ! ! /** ! * When calling expect, the MockObject will ignore this method, ! * so it will not result in an exception. ! */ ! public void addIgnore(String method); ! ! /** ! * When calling expect, 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 addIgnore(String[] methods); ! ! ! /** ! * Removes the method from the ignored methods set. ! */ ! public void removeIgnore(String method); ! ! /** ! * Removes the methods from the ignored methods set. ! */ ! public void removeIgnore(String[] methods); ! public void setCloner(Cloner c); /** * Set the DefaultReturnValue for a 'method' ! * @param method The method */ public void setDefaultReturnValue(String method, Object o); ! public void setExpectTimeout(int timeout); ! ! public int getExpectTimeout(); ! ! public void addBehavior(String string, Behavior behavior); ! } Index: MockSuperclass.java =================================================================== RCS file: /cvsroot/mocklib/mocklib/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 26 Jun 2005 11:57:28 -0000 1.6 --- MockSuperclass.java 10 Sep 2006 18:01:12 -0000 1.7 *************** *** 6,15 **** --- 6,18 ---- import java.util.ArrayList; import java.util.HashMap; + import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; + import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; [...1034 lines suppressed...] ! public Class[] getClasses() { return new Class[] {this.getClass()}; } ! public void setCloner(Cloner c) { cloner = c; } + + public void addBehavior(String method, Behavior behavior) { + if(method == null) + throw new IllegalArgumentException("method parameter cannot be null"); + List l = (List) methodToReturnVal.get(method); + if(l == null) { + l = new ArrayList(); + methodToReturnVal.put(method, l); + } + l.add(behavior); + } } Index: MockObjectImpl.java =================================================================== RCS file: /cvsroot/mocklib/mocklib/input/javasrc/biz/xsoftware/mock/MockObjectImpl.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** MockObjectImpl.java 24 Jun 2005 12:57:01 -0000 1.3 --- MockObjectImpl.java 10 Sep 2006 18:01:12 -0000 1.4 *************** *** 11,27 **** import java.lang.reflect.Method; import java.util.HashMap; 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 */ class MockObjectImpl extends MockSuperclass implements InvocationHandler { ! private static Map isMethodInSuper = new HashMap(); private Class[] classes; --- 11,26 ---- import java.lang.reflect.Method; import java.util.HashMap; + import java.util.HashSet; import java.util.Map; ! import java.util.Set; /** * @author Dean Hiller */ class MockObjectImpl extends MockSuperclass implements InvocationHandler { ! private static Set isMethodInSuper = new HashSet(); ! private static Map primitiveToClass = new HashMap(); private Class[] classes; *************** *** 31,44 **** Method[] m = c.getMethods(); for(int i = 0; i < m.length; i++) { ! isMethodInSuper.put(m[i], Boolean.TRUE); } c = Object.class; m = c.getMethods(); for(int i = 0; i < m.length; i++) { ! isMethodInSuper.put(m[i], Boolean.TRUE); ! } } ! public MockObjectImpl(Class[] interfaces) { this.classes = interfaces; } --- 30,53 ---- Method[] m = c.getMethods(); for(int i = 0; i < m.length; i++) { ! isMethodInSuper.add(m[i]); } c = Object.class; m = c.getMethods(); for(int i = 0; i < m.length; i++) { ! isMethodInSuper.add(m[i]); ! } ! ! primitiveToClass.put(Integer.TYPE, Integer.class); ! primitiveToClass.put(Double.TYPE, Double.class); ! primitiveToClass.put(Float.TYPE, Float.class); ! primitiveToClass.put(Boolean.TYPE, Boolean.class); ! primitiveToClass.put(Character.TYPE, Character.class); ! primitiveToClass.put(Byte.TYPE, Byte.class); ! primitiveToClass.put(Short.TYPE, Short.class); ! primitiveToClass.put(Long.TYPE, Long.class); } ! public MockObjectImpl(String id, Class[] interfaces) { ! super(id); this.classes = interfaces; } *************** *** 47,56 **** */ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { ! Object o = isMethodInSuper.get(method); ! if(o != null) return callSuperMethod(proxy, method, args); ! ! return methodCalledImpl(method.getName(), args); } /** * --- 56,164 ---- */ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { ! if(isMethodInSuper.contains(method)) return callSuperMethod(proxy, method, args); ! ! Object o = methodCalledImpl(method.getName(), args); ! ! Class returnType = method.getReturnType(); ! ! if(returnType == null) ! throw new RuntimeException("This is a bug or something"); ! ! String methodString = getCleanMethodString(method); ! if(returnType.equals(void.class)) { ! //The return type is void ! if(o != null) ! throw new IllegalArgumentException("You are trying to return something on a method that returns void.\n" + ! "Method="+methodString+" value you tried to return="+o); ! } else { ! //Return type is not void...(could be primitive or Object) ! ! if(o == null) { ! if(returnType.isPrimitive()) ! throw new IllegalArgumentException("Must call addReturnValue and " + ! "specify a non-null value as method="+methodString+" returns a primitive value"); ! } else if(returnType.isPrimitive()) { ! //TODO: this is not working correctly no matter what I do here..... ! Class primitiveClass = (Class) primitiveToClass.get(returnType); ! if(!primitiveClass.isInstance(o)) ! throw new IllegalArgumentException("You specified an incorrect return type on method\n="+methodString+"\n" ! +"You specified a return type of="+o.getClass() ! +" which needs to be or extend type="+returnType); ! } else if(!returnType.isInstance(o)) //if not a primitive, make sure is assignable.... ! throw new IllegalArgumentException("You specified an incorrect return type on method\n="+methodString+"\n" ! +"You specified a return type of="+o.getClass()+" which needs to be or extend type="+returnType); ! } ! ! return o; } + + /** + * @param method + * @return + */ + private String getCleanMethodString(Method method) + { + String retType = method.getReturnType().getName(); + String methodArgs = retType+" "+method.getName()+"("; + Class[] parameterTypes = method.getParameterTypes(); + for(int ii = 0; ii < parameterTypes.length; ii++) + { + Class arg = method.getParameterTypes()[ii]; + methodArgs += arg.getName(); + if(ii < parameterTypes.length -1) + methodArgs += ", "; + } + return methodArgs+")"; + } + + + // private void handlePrimitiveReturns(String methodName, Object ret, Class<?> expectedReturnType) + // { + // Class<?>[] primitiveTypes = {Integer.TYPE, Double.TYPE, Float.TYPE, Boolean.TYPE, + // Character.TYPE, Byte.TYPE, Short.TYPE, Long.TYPE}; + // Object[] primitiveClasses = {Integer.class, Double.class, Float.class, Boolean.class, + // Character.class, Byte.class, Short.class, Long.class}; + // if(ret.getClass().isPrimitive() && expectedReturnType.isPrimitive()) + // { + // for(Class<?> currentType : primitiveTypes) + // { + // if(ret.getClass() == currentType && expectedReturnType != currentType) + // { + // throwTypeException(methodName, ret, ret.getClass().getName(), expectedReturnType.getName()); + // } + // } + // } + // else if(ret.getClass().isPrimitive()) + // { + // for(int ii = 0; ii < primitiveTypes.length; ii++) + // { + // if(ret.getClass() == primitiveTypes[ii] && expectedReturnType != primitiveClasses[ii]) + // { + // throwTypeException(methodName, ret, ret.getClass().getName(), expectedReturnType.getName()); + // } + // } + // } + // else + // { + // for(int ii = 0; ii < primitiveTypes.length; ii++) + // { + // if(expectedReturnType == primitiveTypes[ii] && ret.getClass() != primitiveClasses[ii]) + // { + // throwTypeException(methodName, ret, ret.getClass().getName(), expectedReturnType.getName()); + // } + // } + // } + // } + // + // private void throwTypeException(String methodName, Object returnValue, + // String returnType, String expectedReturnType) + // { + // throw new RuntimeException("You specified an incorrect return type for " + + // "ignored or expected method " + methodName + "()" + + // "\nYou specified: \"" + returnValue + "\" of type " + + // returnType + " but should have been of type " + expectedReturnType); + // } + /** * *************** *** 59,63 **** * @param m This is the method that was invoked * @param args These are the arguments that were passed to the method - * @return * @throws Throwable */ --- 167,170 ---- *************** *** 73,78 **** if(e.getCause() != null) throw e.getCause(); ! else ! throw e; } } --- 180,184 ---- if(e.getCause() != null) throw e.getCause(); ! throw e; } } *************** *** 80,86 **** * @see biz.xsoftware.mock.MockSuperclass#getClasses() */ ! public Class[] getClasses() { return classes; } } --- 186,196 ---- * @see biz.xsoftware.mock.MockSuperclass#getClasses() */ ! public Class[] getClasses() { return classes; } + public Object inst() { + // TODO Auto-generated method stub + return null; + } } |
Update of /cvsroot/mocklib/mocklib/input/javasrc/biz/xsoftware/test In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv16469/input/javasrc/biz/xsoftware/test Modified Files: TestMockCreator.java MockOne.java Car.java TestOrderedCalls.java Added Files: OldBehavior.java CarImpl.java Identical.java Log Message: clean up mocklib 1. It is not 1.4 compatible and is pretty much the final mocklib1 Index: TestMockCreator.java =================================================================== RCS file: /cvsroot/mocklib/mocklib/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 8 May 2005 05:19:05 -0000 1.2 --- TestMockCreator.java 10 Sep 2006 18:01:12 -0000 1.3 *************** *** 8,11 **** --- 8,12 ---- import java.io.IOException; + import junit.framework.TestCase; import junit.framework.TestSuite; *************** *** 13,24 **** 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 { --- 14,22 ---- import biz.xsoftware.mock.CalledMethod; import biz.xsoftware.mock.ExpectFailedException; import biz.xsoftware.mock.MockObject; + import biz.xsoftware.mock.MockObjectFactory; /** * @author Dean Hiller */ public class TestMockCreator extends TestCase { *************** *** 40,44 **** String methodName = "callMeSecond"; ! CalledMethod method = m.expectCall(methodName); assertEquals("method name should be the same", methodName, method.getMethodName()); --- 38,42 ---- String methodName = "callMeSecond"; ! CalledMethod method = m.expect(methodName); assertEquals("method name should be the same", methodName, method.getMethodName()); *************** *** 64,68 **** try { ! m.expectCall(MockObject.NONE); fail("Should have failed with ExpectFailedException"); } catch(ExpectFailedException e) { --- 62,66 ---- try { ! m.expect(MockObject.NONE); fail("Should have failed with ExpectFailedException"); } catch(ExpectFailedException e) { *************** *** 78,82 **** 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)); --- 76,80 ---- l.multipleParams(param1, param2); ! CalledMethod method = m.expect("multipleParams"); assertEquals("param1 is not correct", param1, method.getParameter(0)); assertEquals("param2 is not correct", param2, method.getParameter(1)); *************** *** 88,92 **** l.callMeSecond("dummy"); try { ! m.expectCall("callMeFirst"); fail("should have thrown exception"); } catch(ExpectFailedException e) {} --- 86,90 ---- l.callMeSecond("dummy"); try { ! m.expect("callMeFirst"); fail("should have thrown exception"); } catch(ExpectFailedException e) {} *************** *** 97,109 **** 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"); } --- 95,107 ---- MockObject car = MockObjectFactory.createMock(Car.class); ! factory.addReturnValue("createCar", 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.expect("createCar"); c.openDoor(); ! car.expect("openDoor"); } *************** *** 126,130 **** l.callMeFirst(expected); ! CalledMethod m = mockList.expectCall(MockObject.ANY); Integer i = (Integer)m.getAllParams()[0]; assertEquals("param should be 1", new Integer(expected), i); --- 124,128 ---- l.callMeFirst(expected); ! CalledMethod m = mockList.expect(MockObject.ANY); Integer i = (Integer)m.getAllParams()[0]; assertEquals("param should be 1", new Integer(expected), i); *************** *** 139,143 **** String[] methods = new String[] { MockObject.ANY, "callMeSecond" }; ! mockList.expectOrderedCalls(methods); } --- 137,141 ---- String[] methods = new String[] { MockObject.ANY, "callMeSecond" }; ! mockList.expect(methods); } *************** *** 146,150 **** try { ! mock.expectCall("noSuchMethod"); fail("This should throw an exception"); } catch(IllegalArgumentException e) { --- 144,148 ---- try { ! mock.expect("noSuchMethod"); fail("This should throw an exception"); } catch(IllegalArgumentException e) { *************** *** 152,156 **** } ! public static void main(String[] args) { TestSuite suite = new TestSuite(); suite.addTest(new TestMockCreator("testWrongMethod")); --- 150,298 ---- } ! public void testDefaultRetVal() { ! MockObject mock = MockObjectFactory.createMock(Identical.class); ! ! mock.setDefaultReturnValue("doThat", new byte[] {4}); ! ! Identical ident = (Identical)mock; ! byte[] retVal = ident.doThat(null); ! ! mock.expect("doThat"); ! ! assertEquals(1, retVal.length); ! assertEquals(4, retVal[0]); ! } ! ! public void testDefaultReturnWithOtherReturns() ! { ! MockObject mock = MockObjectFactory.createMock(Identical.class); ! mock.addReturnValue("doThat", new byte[] {3}); ! mock.setDefaultReturnValue("doThat", new byte[] {4}); ! mock.addReturnValue("doThat", new byte[] {5}); ! ! Identical ident = (Identical)mock; ! byte[] retVal = ident.doThat(null); ! mock.expect("doThat"); ! ! assertEquals(1, retVal.length); ! assertEquals(3, retVal[0]); ! ! retVal = ident.doThat(null); ! mock.expect("doThat"); ! ! assertEquals(1, retVal.length); ! assertEquals(5, retVal[0]); ! ! retVal = ident.doThat(null); ! mock.expect("doThat"); ! ! assertEquals(1, retVal.length); ! assertEquals(4, retVal[0]); ! } ! ! ! public void testReturnInterface() { ! MockObject mock = MockObjectFactory.createMock(FactoryInterface.class); ! ! FactoryInterface factory = (FactoryInterface)mock; ! ! mock.addReturnValue("createCar", new CarImpl()); ! Car car = factory.createCar("id"); ! ! assertEquals(car.getClass(), CarImpl.class); ! ! mock.expect("createCar"); ! } ! ! ! public void testReturnNull() { ! MockObject mock = MockObjectFactory.createMock(FactoryInterface.class); ! ! FactoryInterface factory = (FactoryInterface)mock; ! ! factory.createCar("aaa"); ! ! mock.expect("createCar"); ! } ! ! public void testBadPrimitive() { ! MockObject mock = MockObjectFactory.createMock(Car.class); ! ! Car car = (Car)mock; ! try { ! mock.addReturnValue("getWheelCount", new Long(56)); ! car.getWheelCount(); ! fail("should have thrown exception"); ! } catch(IllegalArgumentException e) { ! } ! } ! ! public void testNullPrimitive() { ! MockObject mock = MockObjectFactory.createMock(Car.class); ! ! Car car = (Car)mock; ! try { ! car.getWheelCount(); ! fail("should have thrown exception"); ! } catch(IllegalArgumentException e) { ! } ! } ! ! public void testPrimitive() { ! MockObject mock = MockObjectFactory.createMock(Car.class); ! ! Car car = (Car)mock; ! mock.addReturnValue("getWheelCount", new Integer(5)); ! car.getWheelCount(); ! ! mock.expect("getWheelCount"); ! } ! ! public void testBehavior() { ! MockObject mock = MockObjectFactory.createMock(Identical.class); ! ! mock.addBehavior("doThat", new OldBehavior()); ! ! Identical ident = (Identical)mock; ! ! byte[] original = new byte[] { 1, 2, 3, 4, 0, 0, 0, 0}; ! byte[] bytes = new byte[] { 1, 2, 3, 4, 0 ,0,0,0}; ! ! byte[] newBytes = ident.doThat(bytes); ! ! CalledMethod m = mock.expect("doThat"); ! byte[] passedIn = (byte[])m.getAllParams()[0]; ! ! assertEquals(original.length, passedIn.length); ! for(int i = 0; i < original.length; i++) { ! assertEquals(original[i], passedIn[i]); ! } ! ! //make sure this is the same byte array we passed in ! assertSame(bytes, newBytes); ! ! for(int i = 0; i < 4; i++) { ! assertEquals(newBytes[i], newBytes[i+4]); ! } ! } ! ! public void testAddRemoveIgnore() ! { ! MockObject mock = MockObjectFactory.createMock(Car.class); ! mock.addIgnore(new String[]{"openDoor", "closeDoor"}); ! ! Car car = (Car)mock; ! car.openDoor(); ! car.closeDoor(); ! ! mock.expect(MockObject.NONE); ! ! mock.removeIgnore("closeDoor"); ! car.closeDoor(); ! ! mock.expect("closeDoor"); ! } ! ! public static void main(String[] args) { TestSuite suite = new TestSuite(); suite.addTest(new TestMockCreator("testWrongMethod")); --- NEW FILE: CarImpl.java --- /** * Copyright (C) 2006 Carrier Access, Corp. */ package biz.xsoftware.test; /** */ public class CarImpl implements Car { /** * @see biz.xsoftware.test.mock.Car#openDoor() */ public void openDoor() { } /** * @see biz.xsoftware.test.mock.Car#closeDoor() */ public void closeDoor() { } /** * @see biz.xsoftware.test.mock.Car#getWheelCount() */ public int getWheelCount() { return 0; } } --- NEW FILE: Identical.java --- /** * Copyright (C) 2006 Carrier Access, Corp. */ package biz.xsoftware.test; /** */ public interface Identical { public byte[] doThat(byte[] data); } --- NEW FILE: OldBehavior.java --- /** * */ package biz.xsoftware.test; import biz.xsoftware.mock.Behavior; class OldBehavior implements Behavior { /** * @see biz.xsoftware.mock.Behavior#clone(java.lang.Object[]) */ public Object[] clone(Object[] params) { Object[] retVal = new Object[params.length]; for(int i = 0; i < retVal.length; i++) { Object val = params[i]; if(val instanceof byte[]) { retVal[i] = cloneBytes((byte[])val); } } return retVal; } private Object cloneBytes(byte[] bytes) { byte[] newBytes = new byte[bytes.length]; for(int i = 0; i < newBytes.length; i++) { newBytes[i] = bytes[i]; } return newBytes; } /** * @see biz.xsoftware.mock.Behavior#runMethod(java.lang.Object[]) */ public Object runMethod(Object[] params) { //we know the test does an 4 byte array, so do that byte[] bytes = (byte[])params[0]; for(int i = 0; i < 4; i++) { bytes[i+4] = bytes[i]; } //make sure to return the same byte buffer so we are really testing this... return bytes; } } Index: MockOne.java =================================================================== RCS file: /cvsroot/mocklib/mocklib/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 7 May 2005 18:26:17 -0000 1.1 --- MockOne.java 10 Sep 2006 18:01:12 -0000 1.2 *************** *** 52,57 **** * @see biz.xsoftware.mock.MockSuperclass#getClasses() */ ! public Class[] getClasses() { return new Class[] { MockOne.class }; } } --- 52,61 ---- * @see biz.xsoftware.mock.MockSuperclass#getClasses() */ ! public Class[] getClasses() { return new Class[] { MockOne.class }; } + public Object inst() { + // TODO Auto-generated method stub + return null; + } } Index: Car.java =================================================================== RCS file: /cvsroot/mocklib/mocklib/input/javasrc/biz/xsoftware/test/Car.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Car.java 7 May 2005 18:26:17 -0000 1.1 --- Car.java 10 Sep 2006 18:01:12 -0000 1.2 *************** *** 18,20 **** --- 18,21 ---- public void closeDoor(); + public int getWheelCount(); } Index: TestOrderedCalls.java =================================================================== RCS file: /cvsroot/mocklib/mocklib/input/javasrc/biz/xsoftware/test/TestOrderedCalls.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TestOrderedCalls.java 8 May 2005 05:19:05 -0000 1.2 --- TestOrderedCalls.java 10 Sep 2006 18:01:12 -0000 1.3 *************** *** 38,42 **** final MockOne one = new MockOne(3000); Thread r = new Thread() { ! public void run() { delay(1000); one.callMeFirst(4); --- 38,42 ---- final MockOne one = new MockOne(3000); Thread r = new Thread() { ! public void run() { delay(1000); one.callMeFirst(4); *************** *** 59,63 **** final MockOne one = new MockOne(3000); Thread r = new Thread() { ! public void run() { delay(1000); one.callMeFirst(4); --- 59,63 ---- final MockOne one = new MockOne(3000); Thread r = new Thread() { ! public void run() { delay(1000); one.callMeFirst(4); *************** *** 86,90 **** final MockOne one = new MockOne(3000); Thread r = new Thread() { ! public void run() { delay(1000); one.callMeFirst(14); --- 86,90 ---- final MockOne one = new MockOne(3000); Thread r = new Thread() { ! public void run() { delay(1000); one.callMeFirst(14); *************** *** 94,97 **** --- 94,98 ---- String[] evts = new String[] { MockOne.SECOND, MockOne.FIRST }; try { + r.run(); one.expectOrderedCalls(evts); fail("Should have failed this test case"); |
From: Nobody <fas...@us...> - 2006-09-10 18:01:18
|
Update of /cvsroot/mocklib/mocklib/input/javasrc/biz/xsoftware/examples/basic In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv16469/input/javasrc/biz/xsoftware/examples/basic Modified Files: TestExample.java PurchaseException.java Log Message: clean up mocklib 1. It is not 1.4 compatible and is pretty much the final mocklib1 Index: TestExample.java =================================================================== RCS file: /cvsroot/mocklib/mocklib/input/javasrc/biz/xsoftware/examples/basic/TestExample.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TestExample.java 7 May 2005 18:26:17 -0000 1.1 --- TestExample.java 10 Sep 2006 18:01:12 -0000 1.2 *************** *** 35,39 **** * @see junit.framework.TestCase#setUp() */ ! public void setUp() { mockCreditSvc = MockObjectFactory.createMock(CreditAuthorizationSvc.class); mockGiftSvc = MockObjectFactory.createMock(GiftCardAccountSvc.class); --- 35,39 ---- * @see junit.framework.TestCase#setUp() */ ! public void setUp() { mockCreditSvc = MockObjectFactory.createMock(CreditAuthorizationSvc.class); mockGiftSvc = MockObjectFactory.createMock(GiftCardAccountSvc.class); *************** *** 57,61 **** sysUnderTest.purchase("itemA", user, amount); ! Object[] paramsToAuthorize = mockCreditSvc.expectCall("authorize").getAllParams(); assertEquals("User should be the same", user, paramsToAuthorize[0]); assertEquals("Amount should have been the same", new Double(amount), paramsToAuthorize[1]); --- 57,61 ---- sysUnderTest.purchase("itemA", user, amount); ! Object[] paramsToAuthorize = mockCreditSvc.expect("authorize").getAllParams(); assertEquals("User should be the same", user, paramsToAuthorize[0]); assertEquals("Amount should have been the same", new Double(amount), paramsToAuthorize[1]); *************** *** 105,112 **** //in a failure case. Also could have made takeMoney ignored instead so //we didn't test the takeMoney and just tested returnMoney. ! String[] calls = new String[2]; ! calls[0] = "takeMoney"; ! calls[1] = "returnMoney"; ! CalledMethod[] methods = mockCreditSvc.expectOrderedCalls(calls); CalledMethod takeMoney = methods[0]; assertEquals("Took from correct user", user, takeMoney.getParameter(0)); --- 105,109 ---- //in a failure case. Also could have made takeMoney ignored instead so //we didn't test the takeMoney and just tested returnMoney. ! CalledMethod[] methods = mockCreditSvc.expect(new String[] {"takeMoney", "returnMoney"}); CalledMethod takeMoney = methods[0]; assertEquals("Took from correct user", user, takeMoney.getParameter(0)); Index: PurchaseException.java =================================================================== RCS file: /cvsroot/mocklib/mocklib/input/javasrc/biz/xsoftware/examples/basic/PurchaseException.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PurchaseException.java 7 May 2005 18:26:17 -0000 1.1 --- PurchaseException.java 10 Sep 2006 18:01:12 -0000 1.2 *************** *** 15,18 **** --- 15,23 ---- /** + * + */ + private static final long serialVersionUID = 1L; + + /** * @param e */ |
From: Nobody <fas...@us...> - 2006-09-10 18:01:18
|
Update of /cvsroot/mocklib/mocklib/input/javasrc/biz/xsoftware/examples/timer2 In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv16469/input/javasrc/biz/xsoftware/examples/timer2 Modified Files: TestExample.java SysUnderTest.java Log Message: clean up mocklib 1. It is not 1.4 compatible and is pretty much the final mocklib1 Index: TestExample.java =================================================================== RCS file: /cvsroot/mocklib/mocklib/input/javasrc/biz/xsoftware/examples/timer2/TestExample.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TestExample.java 7 May 2005 18:26:17 -0000 1.1 --- TestExample.java 10 Sep 2006 18:01:13 -0000 1.2 *************** *** 36,40 **** * @showcode */ ! public void setUp() { mockTimer = MockObjectFactory.createMock(TimerInterface.class); calendar = new SysUnderTest((TimerInterface) mockTimer); --- 36,40 ---- * @showcode */ ! public void setUp() { mockTimer = MockObjectFactory.createMock(TimerInterface.class); calendar = new SysUnderTest((TimerInterface) mockTimer); *************** *** 45,49 **** * @showcode */ ! public void tearDown() { calendar.removeScheduleListener((ScheduleListener)mockListener); } --- 45,49 ---- * @showcode */ ! public void tearDown() { calendar.removeScheduleListener((ScheduleListener)mockListener); } *************** *** 56,60 **** calendar.addEvent(title, delay); ! CalledMethod method = mockTimer.expectCall("schedule"); //param[0] is a timer task TimerTask task = (TimerTask)method.getParameter(0); --- 56,60 ---- calendar.addEvent(title, delay); ! CalledMethod method = mockTimer.expect("schedule"); //param[0] is a timer task TimerTask task = (TimerTask)method.getParameter(0); *************** *** 64,68 **** task.run(); ! method = mockListener.expectCall("eventStarted"); assertEquals("title should be the same", title, method.getParameter(0)); } --- 64,68 ---- task.run(); ! method = mockListener.expect("eventStarted"); assertEquals("title should be the same", title, method.getParameter(0)); } Index: SysUnderTest.java =================================================================== RCS file: /cvsroot/mocklib/mocklib/input/javasrc/biz/xsoftware/examples/timer2/SysUnderTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SysUnderTest.java 7 May 2005 18:26:17 -0000 1.1 --- SysUnderTest.java 10 Sep 2006 18:01:13 -0000 1.2 *************** *** 57,61 **** * @showcode */ ! public void run() { fireEventStarted(title); } --- 57,61 ---- * @showcode */ ! public void run() { fireEventStarted(title); } |
From: Nobody <fas...@us...> - 2006-09-10 18:01:18
|
Update of /cvsroot/mocklib/mocklib/input/javasrc/biz/xsoftware/examples/listener In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv16469/input/javasrc/biz/xsoftware/examples/listener Modified Files: TestExample.java Log Message: clean up mocklib 1. It is not 1.4 compatible and is pretty much the final mocklib1 Index: TestExample.java =================================================================== RCS file: /cvsroot/mocklib/mocklib/input/javasrc/biz/xsoftware/examples/listener/TestExample.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TestExample.java 7 May 2005 18:26:17 -0000 1.1 --- TestExample.java 10 Sep 2006 18:01:13 -0000 1.2 *************** *** 34,38 **** * @showcode */ ! public void setUp() { mockLegacy = MockObjectFactory.createMock(LegacySystem.class); mockListener1 = MockObjectFactory.createMock(LegacySystemListener.class); --- 34,38 ---- * @showcode */ ! public void setUp() { mockLegacy = MockObjectFactory.createMock(LegacySystem.class); mockListener1 = MockObjectFactory.createMock(LegacySystemListener.class); *************** *** 40,47 **** sysUnderTest = new SysUnderTest((LegacySystem)mockLegacy); ! Object[] params = mockLegacy.expectCall("setLegacyListener").getAllParams(); legacyListener = (LegacySystemListener)params[0]; } ! public void tearDown() { } --- 40,47 ---- sysUnderTest = new SysUnderTest((LegacySystem)mockLegacy); ! Object[] params = mockLegacy.expect("setLegacyListener").getAllParams(); legacyListener = (LegacySystemListener)params[0]; } ! public void tearDown() { } *************** *** 66,71 **** legacyListener.legacyEventOccurred(5); ! mockListener1.expectCall("legacyEventOccurred"); ! mockListener2.expectCall("legacyEventOccurred"); } --- 66,71 ---- legacyListener.legacyEventOccurred(5); ! mockListener1.expect("legacyEventOccurred"); ! mockListener2.expect("legacyEventOccurred"); } |
From: Nobody <fas...@us...> - 2006-09-10 18:01:18
|
Update of /cvsroot/mocklib/mocklib/input/javasrc/biz/xsoftware/examples/advanced In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv16469/input/javasrc/biz/xsoftware/examples/advanced Modified Files: TestExample.java Log Message: clean up mocklib 1. It is not 1.4 compatible and is pretty much the final mocklib1 Index: TestExample.java =================================================================== RCS file: /cvsroot/mocklib/mocklib/input/javasrc/biz/xsoftware/examples/advanced/TestExample.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TestExample.java 7 May 2005 18:26:17 -0000 1.1 --- TestExample.java 10 Sep 2006 18:01:12 -0000 1.2 *************** *** 34,38 **** * @showcode */ ! public void setUp() { mockTaskSvc = MockObjectFactory.createMock(TaskSystem.class); mockRecord = MockObjectFactory.createMock(TaskRecordService.class); --- 34,38 ---- * @showcode */ ! public void setUp() { mockTaskSvc = MockObjectFactory.createMock(TaskSystem.class); mockRecord = MockObjectFactory.createMock(TaskRecordService.class); *************** *** 57,61 **** sysUnderTest.sendUserMailWhenTaskStarted(expectedName, expectedTask); ! Object o = mockTaskSvc.expectCall("addScheduleListener").getAllParams()[0]; ScheduleListener l = (ScheduleListener)o; --- 57,61 ---- sysUnderTest.sendUserMailWhenTaskStarted(expectedName, expectedTask); ! Object o = mockTaskSvc.expect("addScheduleListener").getAllParams()[0]; ScheduleListener l = (ScheduleListener)o; *************** *** 63,66 **** --- 63,67 ---- //that a call to getUser results from an event MockObject mockUser = MockObjectFactory.createMock(User.class); + mockUser.addReturnValue("addTaskDone", "foo"); mockRecord.addReturnValue("getUser", mockUser); *************** *** 69,77 **** l.eventStarted(null); ! String actualUserId = (String)mockRecord.expectCall("getUser").getAllParams()[0]; assertEquals("User id was incorrect", expectedName, actualUserId); ! String actualTask = (String)mockUser.expectCall("addTaskDone").getAllParams()[0]; assertEquals("task name was incorrect", expectedTask, actualTask); --- 70,78 ---- l.eventStarted(null); ! String actualUserId = (String)mockRecord.expect("getUser").getAllParams()[0]; assertEquals("User id was incorrect", expectedName, actualUserId); ! String actualTask = (String)mockUser.expect("addTaskDone").getAllParams()[0]; assertEquals("task name was incorrect", expectedTask, actualTask); |