1 7 8 package com.rift.coad.lib.deployment; 9 10 import junit.framework.*; 11 12 16 public class DeploymentMonitorTest extends TestCase { 17 18 21 public class TestThread extends Thread { 22 25 public void run() { 26 DeploymentMonitor.getInstance().waitUntilInitDeployComplete(); 27 waiting = false; 28 } 29 } 30 31 private boolean waiting = true; 32 33 public DeploymentMonitorTest(String testName) { 34 super(testName); 35 } 36 37 protected void setUp() throws Exception { 38 } 39 40 protected void tearDown() throws Exception { 41 } 42 43 44 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 } 69 | Popular Tags |