1 19 20 package org.netbeans.modules.j2ee.sun.test; 21 22 import org.netbeans.junit.NbTestCase; 23 import org.netbeans.junit.NbTestSuite; 24 import org.netbeans.modules.j2ee.deployment.impl.ServerInstance; 25 import org.netbeans.modules.j2ee.deployment.impl.ServerRegistry; 26 import org.netbeans.modules.j2ee.deployment.impl.ui.ProgressUI; 27 28 32 public class StartStopServerTest extends NbTestCase { 33 34 private final int SLEEP = 10000; 35 36 public StartStopServerTest(String testName) { 37 super(testName); 38 } 39 40 public void startServer() { 41 try { 42 ServerInstance inst = ServerRegistry.getInstance().getServerInstance(Util._URL); 43 44 if(inst.isRunning()) 45 return; 46 47 ProgressUI pui = new ProgressUI("Start Sjsas", true); 48 inst.start(pui); 49 50 Util.sleep(SLEEP); 51 52 if(!inst.isRunning()) 53 throw new Exception ("Sjsas server start failed"); 54 55 if (inst.isDebuggable(null)) 56 fail("Server started in debug... it should not have done that"); 57 58 Util.sleep(SLEEP); 59 } catch(Exception e) { 60 fail(e.getMessage()); 61 } 62 } 63 64 public void stopServer() { 65 try { 66 ServerInstance inst = ServerRegistry.getInstance().getServerInstance(Util._URL); 67 68 if(!inst.isRunning()) 69 return; 70 71 ProgressUI pui = new ProgressUI("Stop Sjsas", true); 72 inst.stop(pui); 73 74 Util.sleep(SLEEP); 75 76 if(inst.isRunning()) 77 throw new Exception ("Sjsas server stop failed"); 78 79 Util.sleep(SLEEP); 80 } catch(Exception e) { 81 fail(e.getMessage()); 82 } 83 } 84 85 public void restartServer() { 86 try { 87 ServerInstance inst = ServerRegistry.getInstance().getServerInstance(Util._URL); 88 89 if(!inst.isRunning()) 90 return; 91 92 ProgressUI pui = new ProgressUI("Restart Sjsas", true); 93 inst.restart(pui); 94 95 Util.sleep(SLEEP); 96 97 if(!inst.isRunning()) 98 throw new Exception ("Sjsas server restart failed"); 99 100 Util.sleep(SLEEP); 101 } catch(Exception e) { 102 fail(e.getMessage()); 103 } 104 } 105 106 public void startDebugServer() { 107 try { 108 ServerInstance inst = ServerRegistry.getInstance().getServerInstance(Util._URL); 109 110 if(inst.isRunning()) 111 return; 112 113 ProgressUI pui = new ProgressUI("Start Debug Sjsas", true); 114 inst.startDebug(pui); 115 116 Util.sleep(SLEEP); 117 118 if(!inst.isRunning()) 119 throw new Exception ("Sjsas server start debug failed"); 120 121 if (!inst.isDebuggable(null)) 122 fail("server isn't debuggable..."); 123 124 Util.sleep(SLEEP); 125 } catch(Exception e) { 126 fail(e.getMessage()); 127 } 128 } 129 130 public static NbTestSuite suite() { 131 NbTestSuite suite = new NbTestSuite("StartStopServerTest"); 132 suite.addTest(new AddRemoveSjsasInstanceTest("addSjsasInstance")); 133 suite.addTest(new StartStopServerTest("startDebugServer")); 135 suite.addTest(new StartStopServerTest("restartServer")); 136 suite.addTest(new StartStopServerTest("stopServer")); 137 suite.addTest(new StartStopServerTest("startServer")); 138 suite.addTest(new StartStopServerTest("restartServer")); 139 suite.addTest(new StartStopServerTest("stopServer")); 140 suite.addTest(new StartStopServerTest("startServer")); 142 suite.addTest(new AddRemoveSjsasInstanceTest("removeSjsasInstance")); 143 return suite; 144 } 145 } | Popular Tags |