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());
}
|