01: /*
02: * DeploymentMonitorTest.java
03: * JUnit based test
04: *
05: * Created on February 9, 2007, 6:54 AM
06: */
07:
08: package com.rift.coad.lib.deployment;
09:
10: import junit.framework.*;
11:
12: /**
13: *
14: * @author mincemeat
15: */
16: public class DeploymentMonitorTest extends TestCase {
17:
18: /**
19: * This class test the deployment wait method
20: */
21: public class TestThread extends Thread {
22: /**
23: * The run method
24: */
25: public void run() {
26: DeploymentMonitor.getInstance()
27: .waitUntilInitDeployComplete();
28: waiting = false;
29: }
30: }
31:
32: private boolean waiting = true;
33:
34: public DeploymentMonitorTest(String testName) {
35: super (testName);
36: }
37:
38: protected void setUp() throws Exception {
39: }
40:
41: protected void tearDown() throws Exception {
42: }
43:
44: /**
45: * Test of com.rift.coad.lib.deployment.DeploymentMonitor.
46: */
47: public void testDeploymentMonitor() throws Exception {
48: System.out.println("testDeploymentMonitor");
49:
50: DeploymentMonitor expResult = DeploymentMonitor.getInstance();
51: DeploymentMonitor result = DeploymentMonitor.getInstance();
52: assertEquals(expResult, result);
53:
54: TestThread testThread = new TestThread();
55: testThread.start();
56:
57: assertEquals(result.isInitDeployComplete(), false);
58: Thread.sleep(500);
59: assertEquals(waiting, true);
60: result.initDeployCompleted();
61: assertEquals(result.isInitDeployComplete(), true);
62: Thread.sleep(500);
63: assertEquals(waiting, false);
64: result.terminate();
65: assertEquals(result.isTerminated(), true);
66: }
67:
68: }
|