mocklib-checkins Mailing List for mocklib (Page 10)
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-11 05:14:47
|
Update of /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/mock In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv615/input/javasrc/biz/xsoftware/mock Modified Files: MockObject.java Log Message: add javadoc comments. Index: MockObject.java =================================================================== RCS file: /cvsroot/mocklib/mocklib3/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 10 Sep 2006 18:44:06 -0000 1.3 --- MockObject.java 11 Sep 2006 05:14:44 -0000 1.4 *************** *** 52,57 **** /** * Set the DefaultReturnValue for a 'method' ! * @param method The method ! * @param argTypes TODO */ public void setDefaultReturnValue(Object o, String method, Class... argTypes); --- 52,58 ---- /** * Set the DefaultReturnValue for a 'method' ! * ! * @param method The method name to set the default return value for ! * @param argTypes Optionally specify the type of parameters of the method */ public void setDefaultReturnValue(Object o, String method, Class... argTypes); *************** *** 78,82 **** * @param e The exception to throw on method. * @param method The method to throw the exception on when it is called. ! * @param argTypes TODO */ public void addThrowException(Throwable e, String method, Class... argTypes); --- 79,83 ---- * @param e The exception to throw on method. * @param method The method to throw the exception on when it is called. ! * @param argTypes Optionally specify the type of parameters of the method */ public void addThrowException(Throwable e, String method, Class... argTypes); *************** *** 93,97 **** * @param o The object to return that is added to the queue * @param method The method that when called returns first value on queue ! * @param argTypes TODO */ public void addReturnValue(Object o, String method, Class... argTypes); --- 94,98 ---- * @param o The object to return that is added to the queue * @param method The method that when called returns first value on queue ! * @param argTypes Optionally specify the type of parameters of the method */ public void addReturnValue(Object o, String method, Class... argTypes); *************** *** 103,106 **** --- 104,110 ---- * in 'methods' variable so if one of the methods in this array is * called, it will not result in an exception. + * + * @param method The name of the method to ignore + * @param argTypes Optionally specify the type of parameters of the method */ public void addIgnoredMethod(String method, Class ... argTypes); *************** *** 108,111 **** --- 112,118 ---- /** * Removes the method from the ignored methods set. + * + * @param method The name of the method to not ignore + * @param argTypes Optionally specify the type of parameters of the method */ public void removeIgnoredMethod(String method, Class ... argTypes); |
From: Nobody <fas...@us...> - 2006-09-11 05:08:39
|
Update of /cvsroot/mocklib/mocklib3/input/staging/mocklib In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv30632/input/staging/mocklib Removed Files: index.html README.html Log Message: checking in html changes, and adding new version of emma. --- README.html DELETED --- --- index.html DELETED --- |
From: Nobody <fas...@us...> - 2006-09-11 05:08:39
|
Update of /cvsroot/mocklib/mocklib3/tools/emma In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv30632/tools/emma Modified Files: emma_ant.jar emma.jar Log Message: checking in html changes, and adding new version of emma. Index: emma.jar =================================================================== RCS file: /cvsroot/mocklib/mocklib3/tools/emma/emma.jar,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 Binary files /tmp/cvstDcZcy and /tmp/cvsgglJVe differ Index: emma_ant.jar =================================================================== RCS file: /cvsroot/mocklib/mocklib3/tools/emma/emma_ant.jar,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 Binary files /tmp/cvspidhxJ and /tmp/cvsZNbwAq differ |
From: Nobody <fas...@us...> - 2006-09-11 05:08:39
|
Update of /cvsroot/mocklib/mocklib3/input/staging In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv30632/input/staging Added Files: README.html index.html Log Message: checking in html changes, and adding new version of emma. --- NEW FILE: README.html --- <HTML> <h1><a href="index.html">Click here for documentation</a></h1> </HTML> --- NEW FILE: index.html --- <HTML> <TITLE>MockLib</TITLE> <BODY> <h1>MockLib</h1> This is a very small library but powerful enough to create most of your mockobjects for you. The ones it can't create, you can leverage the library to create. <br/><br/> <a href="http://sourceforge.net/projects/mockobject">MockLib</a> <br/><br/> <a href="http://sourceforge.net/project/showfiles.php?group_id=113040&package_id=122340">Download MockLib library plus these web pages</a> <br/> <a href="codecoverage/index.html">Test coverage report</a> <br/> <a href="findbugs/index.html">FindBugs report</a> <br/> <a href="impl/index.html">MockLib Javadoc</a> <br/><br/> <h3>All MockLib Examples</h3> <ol> <li><a href="htmlcode/basic_example.html">Basic Examples</a> - Basic Examples to help get started</li> <li><a href="htmlcode/listener_example.html">Listener Example 1</a> - How to test listener implementations</li> <li><a href="htmlcode/listener_example2.html">Listener Example 2</a> - How to mock listeners</li> <li><a href="htmlcode/timer_example2.html">Timer Example</a> - How to test a Timer that goes off in 24 hours in just milliseconds </li> <li><a href="htmlcode/advanced_example.html">Returning Mocks from Mocks</a> - How to mock out a more complicated api, and trigger events from one system and make sure things happen to another system based on those events</li> <li><a href="htmlcode/socket_example.html">Simulating Network Connections</a> - Example on how to simulate network connection failures</li> <li><a href="htmlcode/behavior_example.html">Running Snippets of Code</a> - Example on how to tell a mockobject to run a snippet of code and why this needs to be done sometimes</li> </ol> <a href="examples/index.html">All MockLib Examples</a> <br/><br/><br/><br/> <a href=http://sourceforge.net> <IMG src=http://sourceforge.net/sflogo.php?group_id=113040 width=210 height=62 border=0 alt=SourceForge Logo> </a> </BODY> </HTML> |
From: Nobody <fas...@us...> - 2006-09-11 05:08:39
|
Update of /cvsroot/mocklib/mocklib3/input/staging/htmlcode In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv30632/input/staging/htmlcode Added Files: behavior_example.html socket_example.html basic_example.html timer_example2.html listener_example.html listener_example2.html advanced_example.html timer_example.html Log Message: checking in html changes, and adding new version of emma. --- NEW FILE: basic_example.html --- <html> <body> <h1>Basic Examples</h1> <h2>Basic Examples to help get started</h2> This example consists of a few tests on one system. Here are the files for this example.... <ul> <li><a href="biz/xsoftware/examples/basic/TestExample.java.html"> TestExample.java - The tests themselves. To follow the example, read through the javadoc of the class. Then read the TestExample.setUp() methods javadoc and comments, then read the test's javadoc and comments</a></li> <li><a href="biz/xsoftware/examples/basic/SysUnderTest.java.html"> SysUnderTest.java - The system we are testing</a></li> <li><a href="biz/xsoftware/examples/basic/CreditAuthorizationSvc.java.html"> CreditAuthorizationSvc.java - A system we are mocking</a></li> <li><a href="biz/xsoftware/examples/basic/GiftCardAccountSvc.java.html"> GiftCardAccountSvc.java - Another system we are mocking</a></li> <li><a href="biz/xsoftware/examples/basic/PurchaseException.java.html"> PurchaseException.java - An exception that is part of an api</a></li> </ul> </body> </html> --- NEW FILE: listener_example2.html --- <html> <body> <h1>Listener Example 2</h1> <h2>Mocking Listeners</h2> This is the oppossite of <a href="listener_example.html"/>Listener Example 1</a>. Instead of the legacy system having an addListener method, the system we want to test has an addListener method. This means, we need to mock the listener we pass to the addListener method so we can verify events are fired properly. This example consists of a few tests on one system. Here are the files for this example.... <ul> <li><a href="biz/xsoftware/examples/listener2/TestExample.java.html"> TestExample.java - The tests themselves</a></li> <li><a href="biz/xsoftware/examples/listener2/SysUnderTest.java.html"> SysUnderTest.java - The system we are testing</a></li> <li><a href="biz/xsoftware/examples/listener2/UserListener.java.html"> UserListener.java - The listener we are mocking</a></li> </body> </html> --- NEW FILE: timer_example2.html --- <html> <body> <h1>>Timer Example</h1> <h2>How to test a Timer that goes off in 24 hours in just milliseconds</h2> This example shows how to make unit test involving a Timer such that you control when the timer goes off. This example consists of a few tests on one system. Here are the files for this example.... <ul> <li><a href="biz/xsoftware/examples/timer2/TestExample.java.html"> TestExample.java - The tests themselves</a></li> <li><a href="biz/xsoftware/examples/timer2/SysUnderTest.java.html"> SysUnderTest.java - The system we are testing</a></li> <li><a href="biz/xsoftware/examples/timer2/TimerInterface.java.html"> TimerInterface.java - The timer we are mocking</a></li> <li><a href="biz/xsoftware/examples/timer2/TimerInterfaceImpl.java.html"> TimerInterfaceImpl.java - The timer used in the real running system</a></li> </body> </html> --- NEW FILE: listener_example.html --- <html> <body> <h1>Listener Example 1</h1> <h2>Test Implementations of Listeners</h2> Some of the systems we want to test will add listeners to apis we want to mock. These tests show examples of just that. It shows how to simulate multiple events being fired from a legacy system back into your code and in so doing test the implementation of the listener you added. This example consists of a few tests on one system. Here are the files for this example.... <ul> <li><a href="biz/xsoftware/examples/listener/TestExample.java.html"> TestExample.java - The tests themselves</a></li> <li><a href="biz/xsoftware/examples/listener/SysUnderTest.java.html"> SysUnderTest.java - The system we are testing</a></li> <li><a href="biz/xsoftware/examples/listener/LegacySystem.java.html"> LegacySystem.java - A system we are mocking</a></li> <li><a href="biz/xsoftware/examples/listener/LegacyDisplayListener.java.html"> LegacyDisplayListener.java - A listener that is part of the LegacySystem API</a></li> </ul> </body> </html> --- NEW FILE: timer_example.html --- <html> <body> <h1>>Basic Examples - Basic Examples to help get started</h1> This example consists of three example tests on one system. The files for the test and the system are the following.... <ul> <li><a href="biz/xsoftware/examples/basic/TestExample.java.html"> TestExample.java - The tests themselves</a></li> <li><a href="biz/xsoftware/examples/basic/SysUnderTest.java.html"> SysUnderTest.java - The system we are testing</a></li> <li><a href="biz/xsoftware/examples/basic/CreditAuthorizationSvc.java.html"> CreditAuthorizationSvc.java - A system we are mocking</a></li> <li><a href="biz/xsoftware/examples/basic/GiftCardAccountSvc.java.html"> GiftCardAccountSvc.java - Another system we are mocking</a></li> <li><a href="biz/xsoftware/examples/basic/PurchaseException.java.html"> PurchaseException.java - An exception that is part of an api</a></li> </ul> </body> </html> --- NEW FILE: behavior_example.html --- <html> <body> <h1>Adding Behavior Example</h1> In certain cases, you may need to simulate a system modifying parameters that were passed into it. While it is not good to have a contract like this with params that are used for in/out operations, these do exist. One example is jdk's nio write methods that take a ByteBuffer This example consists of a few tests on one system. Here are the files for this example.... <ul> <li><a href="biz/xsoftware/examples/behavior/TestExample.java.html"> TestExample.java - The tests themselves</a></li> <li><a href="biz/xsoftware/examples/behavior/TCPSocket.java.html"> TCPSocket.java - The interface we will mock</a></li> </body> </html> --- NEW FILE: socket_example.html --- <html> <body> <h1>Socket Example</h1> <h2>Example on how to simulate network connection failures</h2> This example consists of a few tests on one system. Here are the files for this example.... <ul> <li><a href="biz/xsoftware/examples/socket/TestExample.java.html"> TestExample.java - The tests themselves</a></li> <li><a href="biz/xsoftware/examples/socket/SysUnderTest.java.html"> SysUnderTest.java - The system we are testing</a></li> <li><a href="biz/xsoftware/examples/socket/OtherSubsystem.java.html"> OtherSubsystem.java - The timer we are mocking</a></li> <li><a href="biz/xsoftware/examples/socket/TCPSocket.java.html"> TCPSocket.java - The socket interface we would write</a></li> <li><a href="biz/xsoftware/examples/socket/TCPSocketImpl.java.html"> TCPSocketImpl.java - What the socket implementation would look like</a></li> </body> </html> --- NEW FILE: advanced_example.html --- <html> <body> <h1>How to return Mocks from Mocks</h1> This shows How to mock our a more complicated api, and trigger events from one system and make sure things happen to another system based on those events. It also demonstrates how to return a mock from a mock which is very useful in testing complex apis such as jdk's nio subsystem. This example consists of three example tests on one system. The files for the test and the system are the following.... <ul> <li><a href="biz/xsoftware/examples/advanced/TestExample.java.html"> TestExample.java - The tests themselves</a></li> <li><a href="biz/xsoftware/examples/advanced/SysUnderTest.java.html"> SysUnderTest.java - The system we are testing</a></li> <li><a href="biz/xsoftware/examples/advanced/TaskRecordService.java.html"> TaskRecordService.java - A system we are mocking</a></li> <li><a href="biz/xsoftware/examples/advanced/TaskSystemService.java.html"> TaskSystemService.java - Another system we are mocking</a></li> <li><a href="biz/xsoftware/examples/advanced/User.java.html"> User.java - An interface we will be mocking that TaskRecordService.getUser method returns</a></li> </ul> </body> </html> |
From: Nobody <fas...@us...> - 2006-09-11 05:08:22
|
Update of /cvsroot/mocklib/mocklib3/input/staging/htmlcode In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv30621/input/staging/htmlcode Log Message: Directory /cvsroot/mocklib/mocklib3/input/staging/htmlcode added to the repository |
From: Nobody <fas...@us...> - 2006-09-11 05:04:51
|
Update of /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/examples/behavior In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv28952/input/javasrc/biz/xsoftware/examples/behavior Added Files: TCPSocket.java TestExample.java Log Message: add behavior example and fix socket example. --- NEW FILE: TestExample.java --- /* * 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.behavior; import java.io.IOException; import java.nio.ByteBuffer; import junit.framework.TestCase; import biz.xsoftware.mock.Behavior; import biz.xsoftware.mock.MockObject; import biz.xsoftware.mock.MockObjectFactory; /** * JUnit Suite of TestCases for demonstrating mocking out socket * interfaces to test network failures. * * @author Dean Hiller */ public class TestExample extends TestCase { private MockObject mockSocket; private TCPSocket tcpSocket; /** * @showcode */ public TestExample(String name) { super(name); } /** * @showcode */ public void setUp() throws Exception { mockSocket = MockObjectFactory.createMock(TCPSocket.class); tcpSocket = (TCPSocket)mockSocket; } /** * @showcode */ public void tearDown() throws IOException { } /** * 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. * @throws IOException * * @showcode */ public void testNetworkProblems() throws IOException { mockSocket.addBehavior(new MyBehavior(), "write"); byte[] data = new byte[] { 1, 2, 3, 4 }; ByteBuffer b = ByteBuffer.allocate(100); b.put(data); b.flip(); tcpSocket.write(b); //now, our mockobject better have simulated what a real tcpSocket would do... assertEquals(0, b.remaining()); //now the param passed to the mockobject better be what we passed..... ByteBuffer b2 = (ByteBuffer) mockSocket.expect("write").getAllParams()[0]; byte[] actual = new byte[4]; b2.get(actual); assertEquals(data.length, actual.length); for(int i = 0; i < actual.length; i++) { assertEquals(data[i], actual[i]); } } private class MyBehavior implements Behavior { public Object[] writeCloner(ByteBuffer b) { ByteBuffer clone = ByteBuffer.allocate(b.capacity()); clone.put(b); //rewind original buffer so it appears not have been modified by //cloning method.... b.rewind(); //flip the clone and it will match the given buffer exactly.... clone.flip(); //return the clone return new Object[] { clone }; } public int write(ByteBuffer b) { //simulate the ByteBuffer being read.... int remaining = b.remaining(); byte[] data = new byte[remaining]; b.get(data); return remaining; } } } --- NEW FILE: TCPSocket.java --- /* * 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.behavior; 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; } |
From: Nobody <fas...@us...> - 2006-09-11 05:04:51
|
Update of /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/examples/socket In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv28952/input/javasrc/biz/xsoftware/examples/socket Added Files: TestExample.java SysUnderTest.java OtherSubsystem.java TCPSocket.java TCPSocketImpl.java Removed Files: MockServer.java.bak SysUnderTest.java.bak TesExample.java.bak OtherSubsystem.java.bak TCPSocket.java.bak TCPSocketImpl.java.bak TCPSocketMock.java.bak Log Message: add behavior example and fix socket example. --- MockServer.java.bak DELETED --- --- TCPSocket.java.bak DELETED --- --- TCPSocketMock.java.bak DELETED --- --- TCPSocketImpl.java.bak DELETED --- --- NEW FILE: OtherSubsystem.java --- package biz.xsoftware.examples.socket; import java.nio.ByteBuffer; public interface OtherSubsystem { public ByteBuffer getUserData(int id); public void failedToSendUser(int id); } --- NEW FILE: TestExample.java --- /* * 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.nio.ByteBuffer; import junit.framework.TestCase; import biz.xsoftware.mock.CalledMethod; import biz.xsoftware.mock.MockObject; import biz.xsoftware.mock.MockObjectFactory; /** * JUnit Suite of TestCases for demonstrating mocking out socket * interfaces to test network failures. * * @author Dean Hiller */ public class TestExample extends TestCase { private SysUnderTest sysUnderTest; private MockObject mockSubsys; private MockObject mockSocket; /** * @showcode */ public TestExample(String name) { super(name); } /** * @showcode */ public void setUp() throws Exception { mockSubsys = MockObjectFactory.createMock(OtherSubsystem.class); mockSocket = MockObjectFactory.createMock(TCPSocket.class); sysUnderTest = new SysUnderTest((TCPSocket)mockSocket, (OtherSubsystem)mockSubsys); } /** * @showcode */ public void tearDown() throws IOException { } /** * 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(new IOException("problems writing to server"), "write"); ByteBuffer buffer = ByteBuffer.allocate(100); buffer.put(new byte[] { 1, 2, 3, 4}); buffer.flip(); mockSubsys.addReturnValue(buffer, "getUserData"); int id = 10; sysUnderTest.sendUserToServer(10); CalledMethod[] methods = mockSubsys.expect("getUserData", "failedToSendUser"); CalledMethod getUserData = methods[0]; CalledMethod failedToSend = methods[1]; assertEquals(new Integer(id), getUserData.getAllParams()[0]); assertEquals(new Integer(id), failedToSend.getParameter(0)); } } --- SysUnderTest.java.bak DELETED --- --- NEW FILE: TCPSocketImpl.java --- /* * 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 --- /* * 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; /** * SysUnderTest that uses TCPSockets to talk to a server. * * @author Dean Hiller */ public class SysUnderTest { private TCPSocket s; private OtherSubsystem userService; /** * @showcode */ public SysUnderTest(TCPSocket s, OtherSubsystem userSvc) { this.s = s; this.userService = userSvc; } /** * @showcode */ public void sendUserToServer(int id) { ByteBuffer userData = userService.getUserData(id); try { s.write(userData); } catch(IOException e) { userService.failedToSendUser(id); } } } --- TesExample.java.bak DELETED --- --- OtherSubsystem.java.bak DELETED --- --- NEW FILE: TCPSocket.java --- /* * 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; } |
From: Nobody <fas...@us...> - 2006-09-11 05:04:45
|
Update of /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/examples/behavior In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv28935/input/javasrc/biz/xsoftware/examples/behavior Log Message: Directory /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/examples/behavior added to the repository |
From: Nobody <fas...@us...> - 2006-09-11 03:58:20
|
Update of /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/examples/timer2 In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv2333/input/javasrc/biz/xsoftware/examples/timer2 Modified Files: TimerInterfaceImpl.java Log Message: minor changes Index: TimerInterfaceImpl.java =================================================================== RCS file: /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/examples/timer2/TimerInterfaceImpl.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TimerInterfaceImpl.java 11 Sep 2006 00:34:10 -0000 1.1 --- TimerInterfaceImpl.java 11 Sep 2006 03:58:16 -0000 1.2 *************** *** 7,11 **** public class TimerInterfaceImpl implements TimerInterface { ! private Timer timer; public void cancelTask(TimerTask task) { --- 7,11 ---- public class TimerInterfaceImpl implements TimerInterface { ! private Timer timer = new Timer(); public void cancelTask(TimerTask task) { |
From: Nobody <fas...@us...> - 2006-09-11 03:58:20
|
Update of /cvsroot/mocklib/mocklib3/bldfiles In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv2333/bldfiles Modified Files: directory.properties Log Message: minor changes Index: directory.properties =================================================================== RCS file: /cvsroot/mocklib/mocklib3/bldfiles/directory.properties,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** directory.properties 10 Sep 2006 22:49:06 -0000 1.2 --- directory.properties 11 Sep 2006 03:58:16 -0000 1.3 *************** *** 124,128 **** # MISCELLANEOUS #----------------------------------------------------------------------- ! junit.pattern1=biz/xsoftware/test/**/Test*.class junit.pattern2=biz/xsoftware/examples/**/Test*.class --- 124,128 ---- # MISCELLANEOUS #----------------------------------------------------------------------- ! junit.pattern1=**/Test*.class junit.pattern2=biz/xsoftware/examples/**/Test*.class |
From: Nobody <fas...@us...> - 2006-09-11 03:47:43
|
Update of /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/examples/basic In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv30309/input/javasrc/biz/xsoftware/examples/basic Modified Files: SysUnderTest.java TestExample.java CreditAuthorizationSvc.java Log Message: add more to the examples. Index: TestExample.java =================================================================== RCS file: /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/examples/basic/TestExample.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TestExample.java 10 Sep 2006 18:44:06 -0000 1.3 --- TestExample.java 11 Sep 2006 03:47:39 -0000 1.4 *************** *** 13,18 **** /** ! * This is the class actually holding the test Examples for you to look at. * * @author Dean Hiller */ --- 13,35 ---- /** ! * This example has 3 tests. ! * ! * testBasicSunnyDay ! * ! * This verifies that the correct amount of money was ! * taken from the credit card and taken from the correct ! * user. It then verifies the correct amount of money was ! * put on the gift card ! * ! * testFailureOfAuthorization ! * ! * In this test we test that a failure from CreditAuthSvc ! * results in the correct StoreUnderTest behavior which in this ! * instance is to throw an exception to the user. * + * testFailureOfBuyingGiftCard + * + * This tests to make sure if putting money on the gift card fails that + * we will return money back to the users credit card. * @author Dean Hiller */ *************** *** 32,35 **** --- 49,57 ---- /** + * Setup for all the tests consists of created MockObjects that will simulate + * the CreditAuthorizationSvc and GiftCardAccountSvc. Then using + * dependency injection(inversion of control) pattern, these are given to + * the SysUnderTest which has no idea they are not the real thing. + * * @showcode * @see junit.framework.TestCase#setUp() *************** *** 37,43 **** --- 59,69 ---- @Override public void setUp() { + //first, create a mock CreditAuthorizationSvc mockCreditSvc = MockObjectFactory.createMock(CreditAuthorizationSvc.class); + //next, create a mock GiftCardAccountSvc mockGiftSvc = MockObjectFactory.createMock(GiftCardAccountSvc.class); + //Create the system we are going to test by passing these mock objects + //into the constructor.... CreditAuthorizationSvc credit = (CreditAuthorizationSvc)mockCreditSvc; GiftCardAccountSvc gift = (GiftCardAccountSvc)mockGiftSvc; *************** *** 46,64 **** /** ! * Test that when we purchase an item from the SysUnderTest ! * that the CreditAuthorization Svc is used to verify the ! * customer has that amount of money on his credit card. * * @see SysUnderTest#purchase * @showcode */ ! public void testBasicSysUnderTest() { String user = "user1"; double amount = 340.99; - 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]); } --- 72,103 ---- /** ! * This verifies that the correct amount of money was ! * taken from the credit card and taken from the correct ! * user. It then verifies the correct amount of money was ! * put on the gift card * * @see SysUnderTest#purchase * @showcode */ ! public void testBasicSunnyDay() { String user = "user1"; double amount = 340.99; ! //now, purhase a gift card with user=user and amount=amount ! sysUnderTest.buyGiftCard(user, amount); ! ! CalledMethod m1 = mockCreditSvc.expect("takeMoney"); ! Object[] paramsToAuthorize = m1.getAllParams(); ! //method signature of takeMoney = ! // public void takeMoney(String user, double usDollars); ! //This first assert verifies that the first parameter pass into that was equal to user assertEquals("User should be the same", user, paramsToAuthorize[0]); + //This next assert verifies the second parameter passed to the + //takeMoney method was the amount.... assertEquals("Amount should have been the same", new Double(amount), paramsToAuthorize[1]); + + //lastly, we also expect putMoneyOnCard to be called with the correct amount... + CalledMethod m2 = mockGiftSvc.expect("putMoneyOnCard"); + assertEquals("Money on gift card should be correct", amount, m2.getAllParams()[1]); } *************** *** 72,92 **** */ public void testFailureOfAuthorization() { ! mockCreditSvc.addThrowException(new RuntimeException("test robustness of StoreUnderTest"), "authorize"); String user = "user1"; double amount = 340.99; try { ! sysUnderTest.purchase("itemA", user, amount); ! fail("Expecting exactly the IllegalStateException for some odd reason(didn't want to define my own)"); ! } catch(PurchaseException e) {} } /** ! * Test that ! * <ol> ! * <li>Money is taken from users credit account</li> ! * <li>Put money on card, but cause failure</li> ! * <li>Assert that money is put back in users credit account</li> ! * </ol> * * @see SysUnderTest#buyGiftCard --- 111,130 ---- */ public void testFailureOfAuthorization() { ! //we want to tell mockCreditSvc to simulate a failure ! //by throwing an exception on the takeMoney method call ! mockCreditSvc.addThrowException(new IllegalStateException("cause failure"), "takeMoney"); String user = "user1"; double amount = 340.99; try { ! //in this case, we just expect an exception and nothing else... ! sysUnderTest.buyGiftCard(user, amount); ! fail("Expecting exactly the exact exception thrown here, but that didn't happen"); ! } catch(IllegalStateException e) {} } /** ! * This tests to make sure if putting money on the gift card fails that ! * we will return money back to the users credit card. * * @see SysUnderTest#buyGiftCard *************** *** 94,97 **** --- 132,136 ---- */ public void testFailureOfBuyingGiftCard() { + //Now, we want to simulate a failure that should cause recovery to occur.... mockGiftSvc.addThrowException(new RuntimeException("cause failure in subsystem"), "putMoneyOnCard"); *************** *** 99,109 **** double amount = 40.01; try { sysUnderTest.buyGiftCard(user, amount); fail("Should have thrown exception"); } catch(PurchaseException e) {} ! //make sure takeMoney then return money was called which would happen ! //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("takeMoney", "returnMoney"); CalledMethod takeMoney = methods[0]; --- 138,148 ---- double amount = 40.01; try { + //Now call the system which should recover sysUnderTest.buyGiftCard(user, amount); fail("Should have thrown exception"); } catch(PurchaseException e) {} ! //make sure takeMoney then return money was called which should happen ! //in our failure case. CalledMethod[] methods = mockCreditSvc.expect("takeMoney", "returnMoney"); CalledMethod takeMoney = methods[0]; Index: CreditAuthorizationSvc.java =================================================================== RCS file: /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/examples/basic/CreditAuthorizationSvc.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CreditAuthorizationSvc.java 10 Sep 2006 18:25:52 -0000 1.1 --- CreditAuthorizationSvc.java 11 Sep 2006 03:47:39 -0000 1.2 *************** *** 14,23 **** public interface CreditAuthorizationSvc { - /** - * @param user - * @param usDollars - */ - public void authorize(String user, double usDollars); - public void takeMoney(String user, double usDollars); public void returnMoney(String user, double usDollars); --- 14,17 ---- Index: SysUnderTest.java =================================================================== RCS file: /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/examples/basic/SysUnderTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SysUnderTest.java 10 Sep 2006 18:25:52 -0000 1.1 --- SysUnderTest.java 11 Sep 2006 03:47:39 -0000 1.2 *************** *** 27,43 **** * @showcode */ - public void purchase(String item, String user, double usDollars) { - try { - creditSvc.authorize(user, usDollars); - } catch(RuntimeException e) { - throw new PurchaseException(e); - } - - //if authorize succeeded, go delete an item from the - //Inventory as we successfully sold it. - } - /** - * @showcode - */ public void buyGiftCard(String user, double usDollars) { creditSvc.takeMoney(user, usDollars); --- 27,30 ---- |
From: Nobody <fas...@us...> - 2006-09-11 03:47:43
|
Update of /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/examples/listener In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv30309/input/javasrc/biz/xsoftware/examples/listener Modified Files: TestExample.java Log Message: add more to the examples. Index: TestExample.java =================================================================== RCS file: /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/examples/listener/TestExample.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TestExample.java 11 Sep 2006 00:34:10 -0000 1.2 --- TestExample.java 11 Sep 2006 03:47:39 -0000 1.3 *************** *** 12,17 **** /** ! * JUnit Suite of TestCases for demonstrating mocking out listeners to ! * test for events under certain circumstances. * * @author Dean Hiller --- 12,29 ---- /** ! * This example has the following tests ! * ! * testBasicListener ! * ! * When we create SysUnderTest, in setup we expected it to add ! * a LegacyDisplayListener to the legacy system. In setup, we retrieved ! * that listener so in the test we can now fire display update events ! * and make sure the system does update the display. ! * ! * testTwoClearEvents ! * ! * In this test, we want to make sure that if the legacy system fires ! * two clear events the system still works and there are no exceptions from ! * our system back to the legacy system. * * @author Dean Hiller *************** *** 36,40 **** --- 48,58 ---- mockLegacy = MockObjectFactory.createMock(LegacySystem.class); + //Create the System Under Test using dependency injection.... sysUnderTest = new SysUnderTest((LegacySystem)mockLegacy); + + //As soon as we create the System Under Test, we expect the + //SysUnderTest will add a DisplayListener to the legacy system. + //We then retrieve that implementation of DisplayListener here + //for later use.... Object[] params = mockLegacy.expect("setDisplayListener").getAllParams(); displayListener = (LegacyDisplayListener)params[0]; *************** *** 46,55 **** /** ! * Tests when the legacy system fires a display update event, ! * that our system display is updated * * @showcode - * @see SysUnderTest#addLegacyListener - * @see LegacySystemListener#legacyEventOccurred */ public void testBasicListener() { --- 64,73 ---- /** ! * When we create SysUnderTest, in setup we expected it to add ! * a LegacyDisplayListener to the legacy system. In setup, we retrieved ! * that listener so in the test we can now fire display update events ! * and make sure the system does update the display. * * @showcode */ public void testBasicListener() { *************** *** 67,79 **** /** ! * This test makes sure there are no bugs when two ! * clear events are fired from the legacy system * */ public void testTwoClearEvents() { - //if either of these throw an exception, JUnit will - //fail the test for me.... displayListener.clearDisplay(); displayListener.clearDisplay(); } --- 85,103 ---- /** ! * In this test, we want to make sure that if the legacy system fires ! * two clear events the system still works and there are no exceptions from ! * our system back to the legacy system. * + * @showcode */ public void testTwoClearEvents() { displayListener.clearDisplay(); + assertEquals("", sysUnderTest.getDisplay()); + + //If SysUnderTest.MyDisplayListener.clearDisplay threw an exception because + //of a bug, it would cause the exception to be thrown from this method + //and fail this test..... displayListener.clearDisplay(); + assertEquals("", sysUnderTest.getDisplay()); } |
From: Nobody <fas...@us...> - 2006-09-11 03:47:43
|
Update of /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/examples/timer2 In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv30309/input/javasrc/biz/xsoftware/examples/timer2 Modified Files: TestExample.java Log Message: add more to the examples. Index: TestExample.java =================================================================== RCS file: /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/examples/timer2/TestExample.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TestExample.java 11 Sep 2006 00:34:10 -0000 1.2 --- TestExample.java 11 Sep 2006 03:47:39 -0000 1.3 *************** *** 16,21 **** /** ! * JUnit Suite of TestCases for demonstrating mocking out a user ! * created Timer interface. * * @author Dean Hiller --- 16,31 ---- /** ! * This example has the following tests ! * ! * testBasicCalendar ! * ! * Tests a few things ! * 1. Tests scheduling an event ! * 2. Tests that event was scheduled at the propert time ! * 3. Tests the event going off and verifying expected event behavior ! * ! * testCancelOfEvent ! * ! * Tests scheduling and cancelling the event. * * @author Dean Hiller *************** *** 38,43 **** --- 48,57 ---- @Override public void setUp() { + //Create a mockTimer which acts as a cache for TimerTasks..... mockTimer = MockObjectFactory.createMock(TimerInterface.class); calendar = new SysUnderTest((TimerInterface) mockTimer); + + //Create and add a mockListener which we use to verify receiving of the + //proper events.... mockListener = MockObjectFactory.createMock(ScheduleListener.class); calendar.addScheduleListener((ScheduleListener)mockListener); *************** *** 51,54 **** --- 65,73 ---- } /** + * Tests a few things + * 1. Tests scheduling an event + * 2. Tests that event was scheduled at the propert time + * 3. Tests the event going off and verifying expected event behavior + * * @showcode */ *************** *** 57,73 **** long delay = 50000; calendar.addEvent(title, delay); ! CalledMethod method = mockTimer.expect("schedule"); ! //param[0] is a timer task TimerTask task = (TimerTask)method.getParameter(0); assertEquals("Should have set the timer for "+delay+" ms", new Long(delay), method.getParameter(1)); //run the task now instead of waiting 50000ms task.run(); method = mockListener.expect("eventStarted"); assertEquals("title should be the same", title, method.getParameter(0)); } public void testCancelOfEvent() { String title = "some event"; --- 76,102 ---- long delay = 50000; calendar.addEvent(title, delay); ! ! //When an event is added, we expect schedule on the timer to be called... CalledMethod method = mockTimer.expect("schedule"); ! //param[0] is the mock object's cached timer task.... TimerTask task = (TimerTask)method.getParameter(0); assertEquals("Should have set the timer for "+delay+" ms", new Long(delay), method.getParameter(1)); + //We already verified it was scheduled in the future, so there is + //no need to wait till run the task then //run the task now instead of waiting 50000ms task.run(); + //expect that the listener's eventStarted method is called with the + //propert event title method = mockListener.expect("eventStarted"); assertEquals("title should be the same", title, method.getParameter(0)); } + /** + * Tests scheduling and cancelling the event. + * + * @showcode + */ public void testCancelOfEvent() { String title = "some event"; *************** *** 82,87 **** --- 111,118 ---- calendar.cancelEvent(title); + //make sure the event is actually cancelled CalledMethod method2 = mockTimer.expect("cancelTask"); TimerTask cancelledTask = (TimerTask)method.getParameter(0); + //Make sure the correct TimerTask is cancelled.... assertSame(task, cancelledTask); } |
From: Nobody <fas...@us...> - 2006-09-11 03:47:43
|
Update of /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/examples/listener2 In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv30309/input/javasrc/biz/xsoftware/examples/listener2 Modified Files: TestExample.java SysUnderTest.java Log Message: add more to the examples. Index: TestExample.java =================================================================== RCS file: /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/examples/listener2/TestExample.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TestExample.java 11 Sep 2006 00:34:10 -0000 1.1 --- TestExample.java 11 Sep 2006 03:47:39 -0000 1.2 *************** *** 13,18 **** /** ! * JUnit Suite of TestCases for demonstrating mocking out listeners to ! * test for events under certain circumstances. * * @author Dean Hiller --- 13,28 ---- /** ! * This example has the following tests ! * ! * testBasicListener ! * ! * Tests when a user is added to the system, we get an event ! * and tests when he is deleted, we get an event. ! * ! * testAddUserTwice ! * ! * This test that when I add a user that is already added, we do ! * not fire a second event telling client systems the user was ! * added again which would be a lie * * @author Dean Hiller Index: SysUnderTest.java =================================================================== RCS file: /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/examples/listener2/SysUnderTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SysUnderTest.java 11 Sep 2006 00:34:10 -0000 1.1 --- SysUnderTest.java 11 Sep 2006 03:47:39 -0000 1.2 *************** *** 13,20 **** /** - * The SysUnderTest here is an adapter to a legacy system. The SysUnderTest - * might be on a different thread or the same thread. For events from - * a legacy system, the SysUnderTest alot of the time may be on a different - * thread listening on some socket to the legacy system. * * @author Dean Hiller --- 13,16 ---- |
From: Nobody <fas...@us...> - 2006-09-11 00:34:14
|
Update of /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/examples/timer2 In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv15922/input/javasrc/biz/xsoftware/examples/timer2 Modified Files: SysUnderTest.java TimerInterface.java TestExample.java Added Files: TimerInterfaceImpl.java Log Message: clean up examples. Index: TimerInterface.java =================================================================== RCS file: /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/examples/timer2/TimerInterface.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TimerInterface.java 10 Sep 2006 18:25:57 -0000 1.1 --- TimerInterface.java 11 Sep 2006 00:34:10 -0000 1.2 *************** *** 17,20 **** --- 17,21 ---- public interface TimerInterface { + public void cancelTask(TimerTask task); public void cancel(); public int purge(); --- NEW FILE: TimerInterfaceImpl.java --- package biz.xsoftware.examples.timer2; import java.util.Date; import java.util.Timer; import java.util.TimerTask; public class TimerInterfaceImpl implements TimerInterface { private Timer timer; public void cancelTask(TimerTask task) { task.cancel(); } public void cancel() { timer.cancel(); } public int purge() { return timer.purge(); } public void schedule(TimerTask task, Date firstTime, long period) { timer.schedule(task, firstTime, period); } public void schedule(TimerTask task, Date time) { timer.schedule(task, time); } public void schedule(TimerTask task, long delay, long period) { timer.schedule(task, delay, period); } public void schedule(TimerTask task, long delay) { timer.schedule(task, delay); } public void scheduleAtFixedRate(TimerTask task, Date firstTime, long period) { timer.scheduleAtFixedRate(task, firstTime, period); } public void scheduleAtFixedRate(TimerTask task, long delay, long period) { timer.scheduleAtFixedRate(task, delay, period); } } Index: TestExample.java =================================================================== RCS file: /cvsroot/mocklib/mocklib3/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 10 Sep 2006 18:25:57 -0000 1.1 --- TestExample.java 11 Sep 2006 00:34:10 -0000 1.2 *************** *** 70,73 **** } ! } --- 70,88 ---- } ! public void testCancelOfEvent() { ! String title = "some event"; ! long delay = 50000; ! calendar.addEvent(title, delay); ! ! CalledMethod method = mockTimer.expect("schedule"); ! //param[0] is a timer task ! TimerTask task = (TimerTask)method.getParameter(0); ! assertEquals("Should have set the timer for "+delay+" ms", new Long(delay), method.getParameter(1)); ! ! calendar.cancelEvent(title); ! ! CalledMethod method2 = mockTimer.expect("cancelTask"); ! TimerTask cancelledTask = (TimerTask)method.getParameter(0); ! assertSame(task, cancelledTask); ! } } Index: SysUnderTest.java =================================================================== RCS file: /cvsroot/mocklib/mocklib3/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 10 Sep 2006 18:25:57 -0000 1.1 --- SysUnderTest.java 11 Sep 2006 00:34:10 -0000 1.2 *************** *** 7,10 **** --- 7,12 ---- package biz.xsoftware.examples.timer2; + import java.util.HashMap; + import java.util.Map; import java.util.TimerTask; *************** *** 21,24 **** --- 23,29 ---- private TimerInterface timer; private EventListenerList listenerList = new EventListenerList(); + private Map<String, CalendarEvent> titleToEvent = new HashMap<String, CalendarEvent>(); + + /** * @showcode *************** *** 31,36 **** */ public void addEvent(String title, long delay) { ! timer.schedule(new CalendarEvent(title), delay); } /** * @showcode --- 36,44 ---- */ public void addEvent(String title, long delay) { ! CalendarEvent evt = new CalendarEvent(title); ! titleToEvent.put(title, evt); ! timer.schedule(evt, delay); } + /** * @showcode *************** *** 76,78 **** --- 84,90 ---- } } + public void cancelEvent(String title) { + CalendarEvent event = titleToEvent.get(title); + timer.cancelTask(event); + } } |
Update of /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/examples/advanced In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv15922/input/javasrc/biz/xsoftware/examples/advanced Modified Files: SysUnderTest.java TestExample.java Added Files: TaskSystemService.java Removed Files: TaskSystem.java Location.java Log Message: clean up examples. --- Location.java DELETED --- Index: TestExample.java =================================================================== RCS file: /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/examples/advanced/TestExample.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TestExample.java 10 Sep 2006 18:44:06 -0000 1.3 --- TestExample.java 11 Sep 2006 00:34:10 -0000 1.4 *************** *** 36,43 **** @Override public void setUp() { ! mockTaskSvc = MockObjectFactory.createMock(TaskSystem.class); mockRecord = MockObjectFactory.createMock(TaskRecordService.class); ! sysUnderTest = new SysUnderTest((TaskRecordService)mockRecord, (TaskSystem)mockTaskSvc); } --- 36,43 ---- @Override public void setUp() { ! mockTaskSvc = MockObjectFactory.createMock(TaskSystemService.class); mockRecord = MockObjectFactory.createMock(TaskRecordService.class); ! sysUnderTest = new SysUnderTest((TaskRecordService)mockRecord, (TaskSystemService)mockTaskSvc); } --- TaskSystem.java DELETED --- Index: SysUnderTest.java =================================================================== RCS file: /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/examples/advanced/SysUnderTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SysUnderTest.java 10 Sep 2006 18:25:58 -0000 1.1 --- SysUnderTest.java 11 Sep 2006 00:34:10 -0000 1.2 *************** *** 16,25 **** private TaskRecordService msgSystem; ! private TaskSystem taskSystem; /** * @showcode */ ! public SysUnderTest(TaskRecordService msgSystem, TaskSystem t) { this.msgSystem = msgSystem; this.taskSystem = t; --- 16,25 ---- private TaskRecordService msgSystem; ! private TaskSystemService taskSystem; /** * @showcode */ ! public SysUnderTest(TaskRecordService msgSystem, TaskSystemService t) { this.msgSystem = msgSystem; this.taskSystem = t; --- NEW FILE: TaskSystemService.java --- /* * Created on Jul 15, 2004 * * To change the template for this generated file go to * Window - Preferences - Java - Code Generation - Code and Comments */ package biz.xsoftware.examples.advanced; import biz.xsoftware.examples.timer.ScheduleListener; /** * * @author Dean Hiller */ public interface TaskSystemService { public void addScheduleListener(ScheduleListener l); public void removeScheduleListener(ScheduleListener l); } |
Update of /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/examples/listener In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv15922/input/javasrc/biz/xsoftware/examples/listener Modified Files: SysUnderTest.java LegacySystem.java TestExample.java Added Files: LegacyDisplayListener.java Removed Files: LegacySystemListener.java Log Message: clean up examples. Index: LegacySystem.java =================================================================== RCS file: /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/examples/listener/LegacySystem.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** LegacySystem.java 10 Sep 2006 18:25:47 -0000 1.1 --- LegacySystem.java 11 Sep 2006 00:34:10 -0000 1.2 *************** *** 1,22 **** - /* - * 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.listener; - - /** - * Interface to what would normally be a real LegacySystemAdapter. - * @author Dean Hiller - */ public interface LegacySystem { ! /** ! * @param listener ! */ ! void setLegacyListener(LegacySystemListener listener); ! } --- 1,7 ---- package biz.xsoftware.examples.listener; public interface LegacySystem { ! public void setDisplayListener(LegacyDisplayListener l); } --- NEW FILE: LegacyDisplayListener.java --- package biz.xsoftware.examples.listener; public interface LegacyDisplayListener { public void clearDisplay(); public void updateDisplay(String s); } Index: TestExample.java =================================================================== RCS file: /cvsroot/mocklib/mocklib3/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 10 Sep 2006 18:25:47 -0000 1.1 --- TestExample.java 11 Sep 2006 00:34:10 -0000 1.2 *************** *** 20,27 **** private MockObject mockLegacy; - private MockObject mockListener1; - private MockObject mockListener2; private SysUnderTest sysUnderTest; ! private LegacySystemListener legacyListener; /** --- 20,25 ---- private MockObject mockLegacy; private SysUnderTest sysUnderTest; ! private LegacyDisplayListener displayListener; /** *************** *** 37,46 **** public void setUp() { mockLegacy = MockObjectFactory.createMock(LegacySystem.class); - mockListener1 = MockObjectFactory.createMock(LegacySystemListener.class); - mockListener2 = MockObjectFactory.createMock(LegacySystemListener.class); sysUnderTest = new SysUnderTest((LegacySystem)mockLegacy); ! Object[] params = mockLegacy.expect("setLegacyListener").getAllParams(); ! legacyListener = (LegacySystemListener)params[0]; } @Override --- 35,42 ---- public void setUp() { mockLegacy = MockObjectFactory.createMock(LegacySystem.class); sysUnderTest = new SysUnderTest((LegacySystem)mockLegacy); ! Object[] params = mockLegacy.expect("setDisplayListener").getAllParams(); ! displayListener = (LegacyDisplayListener)params[0]; } @Override *************** *** 50,59 **** /** ! * Tests that when the legacy system fires and event to it's only ! * legacy listener, all listeners on the sysUnderTest that were added ! * receive the event. No matter what the threading model, this test ! * will pass since expect call will wait until the event happens. If ! * the event never happens, the expectCall will timeout and throw an ! * ExpectFailedException claiming it never got the event. * * @showcode --- 46,51 ---- /** ! * Tests when the legacy system fires a display update event, ! * that our system display is updated * * @showcode *************** *** 62,75 **** */ public void testBasicListener() { ! sysUnderTest.addLegacyListener((LegacySystemListener)mockListener1); ! sysUnderTest.addLegacyListener((LegacySystemListener)mockListener2); ! //have legacy system fire event to it's one and only listener ! legacyListener.legacyEventOccurred(5); ! mockListener1.expect("legacyEventOccurred"); ! mockListener2.expect("legacyEventOccurred"); } } --- 54,80 ---- */ public void testBasicListener() { ! String display="fakeSet"; ! displayListener.updateDisplay(display); ! //verify it was updated ! assertEquals(display, sysUnderTest.getDisplay()); ! //fire another one for fun ! String display2 = "fakeSet2222"; ! displayListener.updateDisplay(display2); ! assertEquals(display2, sysUnderTest.getDisplay()); } + /** + * This test makes sure there are no bugs when two + * clear events are fired from the legacy system + * + */ + public void testTwoClearEvents() { + //if either of these throw an exception, JUnit will + //fail the test for me.... + displayListener.clearDisplay(); + displayListener.clearDisplay(); + } } --- LegacySystemListener.java DELETED --- Index: SysUnderTest.java =================================================================== RCS file: /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/examples/listener/SysUnderTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SysUnderTest.java 10 Sep 2006 18:25:47 -0000 1.1 --- SysUnderTest.java 11 Sep 2006 00:34:10 -0000 1.2 *************** *** 1,55 **** - /* - * 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.listener; - import javax.swing.event.EventListenerList; - - /** - * The SysUnderTest here is an adapter to a legacy system. The SysUnderTest - * might be on a different thread or the same thread. For events from - * a legacy system, the SysUnderTest alot of the time may be on a different - * thread listening on some socket to the legacy system. - * - * @author Dean Hiller - */ public class SysUnderTest { ! private EventListenerList listenerList = new EventListenerList(); ! private LegacySystem legacySys; public SysUnderTest(LegacySystem sys) { ! legacySys = sys; ! legacySys.setLegacyListener(new LegacyListener()); } ! private class LegacyListener implements LegacySystemListener { ! public void legacyEventOccurred(int i) { ! fireLegacyEvent(i); } } ! ! ! public void addLegacyListener(LegacySystemListener l) { ! listenerList.add(LegacySystemListener.class, l); ! } ! public void removeLegacyListener(LegacySystemListener l) { ! listenerList.remove(LegacySystemListener.class, l); } - - protected void fireLegacyEvent(int num) { - // 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]==LegacySystemListener.class) { - // Lazily create the event: - ((LegacySystemListener)listeners[i+1]).legacyEventOccurred(num); - } - } - } } --- 1,26 ---- package biz.xsoftware.examples.listener; public class SysUnderTest { ! private String currentDisplay = ""; public SysUnderTest(LegacySystem sys) { ! sys.setDisplayListener(new MyDisplayListener()); } ! private class MyDisplayListener implements LegacyDisplayListener { ! ! public void clearDisplay() { ! currentDisplay = ""; } + + public void updateDisplay(String s) { + currentDisplay = s; + } + } ! ! public Object getDisplay() { ! return currentDisplay; } } |
From: Nobody <fas...@us...> - 2006-09-11 00:34:13
|
Update of /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/examples/listener2 In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv15922/input/javasrc/biz/xsoftware/examples/listener2 Added Files: SysUnderTest.java UserListener.java TestExample.java Log Message: clean up examples. --- NEW FILE: TestExample.java --- /* * 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.listener2; import junit.framework.TestCase; import biz.xsoftware.mock.CalledMethod; import biz.xsoftware.mock.MockObjectFactory; import biz.xsoftware.mock.MockObject; /** * JUnit Suite of TestCases for demonstrating mocking out listeners to * test for events under certain circumstances. * * @author Dean Hiller */ public class TestExample extends TestCase { private MockObject mockListener; private SysUnderTest sysUnderTest; /** * @showcode */ public TestExample(String name) { super(name); } /** * @showcode */ @Override public void setUp() { mockListener = MockObjectFactory.createMock(UserListener.class); sysUnderTest = new SysUnderTest(); } @Override public void tearDown() { } /** * Tests when a user is added to the system, we get an event * and tests when he is deleted, we get an event. * * @showcode * @see SysUnderTest#addLegacyListener * @see LegacySystemListener#legacyEventOccurred */ public void testBasicListener() { sysUnderTest.addUserListener((UserListener)mockListener); String user = "abc"; sysUnderTest.addUser(user); CalledMethod method = mockListener.expect("userAdded"); String actualUser = (String)method.getAllParams()[0]; assertEquals(user, actualUser); sysUnderTest.deleteUser(user); String actualUser2 = (String)method.getAllParams()[0]; assertEquals(user, actualUser2); } /** * This test that when I add a user that is already added, we do * not fire a second event telling client systems the user was * added again which would be a lie */ public void testAddUserTwice() { sysUnderTest.addUserListener((UserListener)mockListener); String user = "abc"; sysUnderTest.addUser(user); CalledMethod method = mockListener.expect("userAdded"); String actualUser = (String)method.getAllParams()[0]; assertEquals(user, actualUser); try { sysUnderTest.addUser(user); fail("Should have thrown IllegalArgumentException and did not"); }catch(IllegalArgumentException e) { } mockListener.expect(MockObject.NONE); } } --- NEW FILE: UserListener.java --- package biz.xsoftware.examples.listener2; import java.util.EventListener; public interface UserListener extends EventListener { public void userAdded(String userName); public void userDeleted(String userName); } --- NEW FILE: SysUnderTest.java --- /* * 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.listener2; import java.util.HashSet; import java.util.Set; import javax.swing.event.EventListenerList; /** * The SysUnderTest here is an adapter to a legacy system. The SysUnderTest * might be on a different thread or the same thread. For events from * a legacy system, the SysUnderTest alot of the time may be on a different * thread listening on some socket to the legacy system. * * @author Dean Hiller */ public class SysUnderTest { private EventListenerList listenerList = new EventListenerList(); private Set<String> names = new HashSet<String>(); public SysUnderTest() { } public void addUser(String userName) { if(names.contains(userName)) throw new IllegalArgumentException("The user="+userName+" is already in the system"); names.add(userName); fireUserAdded(userName); } public void deleteUser(String userName) { boolean isRemoved = names.remove(userName); if(!isRemoved) throw new IllegalArgumentException("The user="+userName+" is not in the system"); fireUserDeleted(userName); } public void addUserListener(UserListener l) { listenerList.add(UserListener.class, l); } public void removeUserListener(UserListener l) { listenerList.remove(UserListener.class, l); } protected void fireUserAdded(String userName) { // 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]==UserListener.class) { // Lazily create the event: ((UserListener)listeners[i+1]).userAdded(userName); } } } protected void fireUserDeleted(String userName) { // 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]==UserListener.class) { // Lazily create the event: ((UserListener)listeners[i+1]).userDeleted(userName); } } } } |
From: Nobody <fas...@us...> - 2006-09-11 00:34:13
|
Update of /cvsroot/mocklib/mocklib3/bldfiles In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv15922/bldfiles Modified Files: release.xml Log Message: clean up examples. Index: release.xml =================================================================== RCS file: /cvsroot/mocklib/mocklib3/bldfiles/release.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** release.xml 10 Sep 2006 18:25:53 -0000 1.1 --- release.xml 11 Sep 2006 00:34:10 -0000 1.2 *************** *** 93,101 **** <target name="createdist" depends="javadocexamples"> <echo message="codecov=${codecov.report}"/> <copy todir="${projstaging}"> ! <fileset dir="${codecov.report}"/> <fileset dir="${jardist}" includes="${jar.name}"/> </copy> <!-- <copy file="README" tofile="${dist.build.dir}/README" overwrite="yes" /> --- 93,106 ---- <target name="createdist" depends="javadocexamples"> <echo message="codecov=${codecov.report}"/> + <copy todir="${projstaging}"> + <fileset dir="${staging.in}"/> + </copy> <copy todir="${projstaging}"> ! <fileset dir="${reports}"/> <fileset dir="${jardist}" includes="${jar.name}"/> </copy> + <delete dir="${projstaging}/javadoc"/> + <!-- <copy file="README" tofile="${dist.build.dir}/README" overwrite="yes" /> |
From: Nobody <fas...@us...> - 2006-09-11 00:34:09
|
Update of /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/examples/listener2 In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv15898/input/javasrc/biz/xsoftware/examples/listener2 Log Message: Directory /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/examples/listener2 added to the repository |
From: Nobody <fas...@us...> - 2006-09-10 22:49:10
|
Update of /cvsroot/mocklib/mocklib3/bldfiles In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv5604/bldfiles Modified Files: directory.properties build.xml Log Message: add java2html tool Index: build.xml =================================================================== RCS file: /cvsroot/mocklib/mocklib3/bldfiles/build.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** build.xml 10 Sep 2006 18:25:53 -0000 1.1 --- build.xml 10 Sep 2006 22:49:06 -0000 1.2 *************** *** 62,65 **** --- 62,72 ---- <property name="checkstyle.dir" value="${tool.dir}/checkstyle" /> + <property name="java2html.location" location="${tool.dir}/ant-java2html"/> + <path id="java2html.lib"> + <fileset dir="${java2html.location}"> + <include name="**/*.jar"/> + </fileset> + </path> + <property name="osgi.location" location="${tool.dir}/ant-osgi"/> <path id="osgi.ant.lib"> *************** *** 68,71 **** --- 75,79 ---- </fileset> </path> + <!-- *********************************************************************** *************** *** 142,145 **** --- 150,158 ---- </taskdef> + <taskdef name="java2html" + classname="de.java2html.anttasks.Java2HtmlTask" + classpathref="java2html.lib" + /> + <taskdef name="bundleinfo" classname="org.knopflerfish.ant.taskdefs.bundle.BundleInfoTask" classpathref="osgi.ant.lib"/> <taskdef name="bundlemanifest" classname="org.knopflerfish.ant.taskdefs.bundle.BundleManifestTask" classpathref="osgi.ant.lib"/> *************** *** 592,602 **** *********************************************************************** --> ! <target name="checkstyle" depends="create-src" description="Runs checkstyle against the code"> ! <mkdir dir="${checkstyle.report}"/> ! <checkstyle config="${checkstyle.dir}/config.xml"> ! <fileset dir="${javacode}" includes="**/*.java"/> ! <formatter type="plain" toFile="${checkstyle.report}/index.html"/> ! </checkstyle> ! </target> <!-- --- 605,625 ---- *********************************************************************** --> ! <target name="checkstyle" depends="create-src" description="Runs checkstyle against the code"> ! <mkdir dir="${checkstyle.report}"/> ! <checkstyle config="${checkstyle.dir}/config.xml"> ! <fileset dir="${javacode}" includes="**/*.java"/> ! <formatter type="plain" toFile="${checkstyle.report}/index.html"/> ! </checkstyle> ! </target> ! ! <target name="java2html"> ! <mkdir dir="${html.code}"/> ! <java2html srcdir="${javacode}" destdir="${html.code}" ! includes="**/*.java" ! style="eclipse" ! showLineNumbers="true" ! showFileName="true" ! showTableBorder="true"/> ! </target> <!-- *************** *** 605,609 **** *********************************************************************** --> ! <target name="all" depends="testall,checkstyle,findbugs,javadoc"> </target> --- 628,632 ---- *********************************************************************** --> ! <target name="all" depends="testall,checkstyle,findbugs,javadoc,java2html"> </target> Index: directory.properties =================================================================== RCS file: /cvsroot/mocklib/mocklib3/bldfiles/directory.properties,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** directory.properties 10 Sep 2006 18:25:53 -0000 1.1 --- directory.properties 10 Sep 2006 22:49:06 -0000 1.2 *************** *** 37,40 **** --- 37,42 ---- checkstyle.report=${reports}/checkstyle javadoc =${reports}/javadoc + html.code =${reports}/htmlcode + #contains the javadoc of biz.xsoftware.api |
From: Nobody <fas...@us...> - 2006-09-10 22:49:10
|
Update of /cvsroot/mocklib/mocklib3/tools/ant-java2html In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv5604/tools/ant-java2html Added Files: java2html.jar Log Message: add java2html tool --- NEW FILE: java2html.jar --- (This appears to be a binary file; contents omitted.) |
From: Nobody <fas...@us...> - 2006-09-10 22:49:01
|
Update of /cvsroot/mocklib/mocklib3/tools/ant-java2html In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv5593/tools/ant-java2html Log Message: Directory /cvsroot/mocklib/mocklib3/tools/ant-java2html added to the repository |
From: Nobody <fas...@us...> - 2006-09-10 22:35:34
|
Update of /cvsroot/mocklib/mocklib3/bldfiles In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv32615/bldfiles Modified Files: design.xml Log Message: mocklib3 should be about complete. probably some tweaks it could use later. Index: design.xml =================================================================== RCS file: /cvsroot/mocklib/mocklib3/bldfiles/design.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** design.xml 10 Sep 2006 18:25:53 -0000 1.1 --- design.xml 10 Sep 2006 22:35:21 -0000 1.2 *************** *** 15,48 **** <!-- should use something like this instead on a per project basis --> ! <package name="apiAndImpl" package="biz.xsoftware.mock"> <depends>junit</depends> </package> - <package name="api2" package="biz.xsoftware.mock2"/> - <package name="testapi" package="biz.xsoftware.test.mock" subpackages="include"> ! <depends>apiAndImpl</depends> ! <depends>junit</depends> ! </package> ! <package name="examples" package="biz.xsoftware.examples" subpackages="include"> ! <depends>apiAndImpl</depends> ! <depends>api2</depends> <depends>junit</depends> </package> ! ! <package name="impl2" package="biz.xsoftware.mock2.impl"> ! <depends>api2</depends> </package> ! <package name="testapi2" package="biz.xsoftware.test.mock2" subpackages="include"> ! <depends>api2</depends> <depends>junit</depends> </package> ! <package name="examples2" package="biz.xsoftware.examples2" subpackages="include"> ! <depends>api2</depends> <depends>junit</depends> </package> - - </design> \ No newline at end of file --- 15,41 ---- <!-- should use something like this instead on a per project basis --> ! <package name="api" package="biz.xsoftware.mock"> <depends>junit</depends> </package> <package name="testapi" package="biz.xsoftware.test.mock" subpackages="include"> ! <depends>api</depends> <depends>junit</depends> </package> ! <package name="impl" package="biz.xsoftware.mock.impl"> ! <depends>api</depends> </package> ! ! <package name="testImpl" package="biz.xsoftware.mock.impl.test"> ! <depends>api</depends> ! <depends>impl</depends> <depends>junit</depends> </package> ! ! <package name="examples" package="biz.xsoftware.examples" subpackages="include"> ! <depends>api</depends> <depends>junit</depends> </package> </design> \ No newline at end of file |