KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > rift > coad > lib > deployment > DeploymentMonitorTest


1 /*
2  * DeploymentMonitorTest.java
3  * JUnit based test
4  *
5  * Created on February 9, 2007, 6:54 AM
6  */

7
8 package com.rift.coad.lib.deployment;
9
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 JavaDoc {
22         /**
23          * The run method
24          */

25         public void run() {
26             DeploymentMonitor.getInstance().waitUntilInitDeployComplete();
27             waiting = false;
28         }
29     }
30     
31     private boolean waiting = true;
32     
33     public DeploymentMonitorTest(String JavaDoc testName) {
34         super(testName);
35     }
36
37     protected void setUp() throws Exception JavaDoc {
38     }
39
40     protected void tearDown() throws Exception JavaDoc {
41     }
42     
43     
44     /**
45      * Test of com.rift.coad.lib.deployment.DeploymentMonitor.
46      */

47     public void testDeploymentMonitor() throws Exception JavaDoc {
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 }
69
Popular Tags