1 19 20 package org.netbeans.modules.test.serverplugins.generic; 21 22 import org.netbeans.junit.NbTestCase; 23 import org.netbeans.modules.j2ee.deployment.impl.ServerInstance; 24 import org.netbeans.modules.j2ee.deployment.impl.ServerRegistry; 25 import org.netbeans.modules.j2ee.deployment.impl.ui.ProgressUI; 26 import org.netbeans.modules.test.serverplugins.api.ConstantsProvider; 27 import org.netbeans.modules.test.serverplugins.api.ServerProvider; 28 import org.openide.util.NbBundle; 29 30 35 public class GenericRunTest extends NbTestCase { 36 37 private ConstantsProvider cProvider; 38 private ServerProvider sProvider; 39 40 47 public GenericRunTest(String name, ConstantsProvider cProvider, ServerProvider sProvider) { 48 super(name); 49 50 this.cProvider = cProvider; 51 this.sProvider = sProvider; 52 } 53 54 57 public void startServerTest() { 58 try { 59 ServerInstance si = ServerRegistry.getInstance().getServerInstance(cProvider.getServerURI()); 61 62 if (si.isRunning()) 64 return; 65 66 if (!si.canStartServer()) 68 return; 69 70 ProgressUI pui = new ProgressUI(NbBundle.getMessage(GenericInstanceTest.class, 72 "MSG_Starting", cProvider.getServerURI()), false); 73 si.setServerState(ServerInstance.STATE_WAITING); 74 75 try { 76 pui.start(); 77 si.start(pui); 78 } finally { 79 pui.finish(); 80 } 81 82 if (!si.isRunning()) 84 throw new Exception (NbBundle.getMessage(GenericInstanceTest.class, "MSG_Start_Failed", cProvider.getServerURI())); 85 } catch(Exception e) { 86 fail(e.getMessage()); 87 } 88 } 89 90 93 public void startDebugServerTest() { 94 try { 95 ServerInstance si = ServerRegistry.getInstance().getServerInstance(cProvider.getServerURI()); 97 98 if (si.isRunning()) 100 return; 101 102 if (!si.canStartServer() || !si.isDebugSupported()) 104 return; 105 106 ProgressUI pui = new ProgressUI(NbBundle.getMessage(GenericInstanceTest.class, 108 "MSG_Starting_Debug", cProvider.getServerURI()), false); 109 si.setServerState(ServerInstance.STATE_WAITING); 110 111 try { 112 pui.start(); 113 si.startDebug(pui); 114 } finally { 115 pui.finish(); 116 } 117 118 if (!si.isRunning()) 120 throw new Exception (NbBundle.getMessage(GenericInstanceTest.class, "MSG_Start_Debug_Failed", cProvider.getServerURI())); 121 } catch(Exception e) { 122 fail(e.getMessage()); 123 } 124 } 125 126 129 public void stopServerTest() { 130 try { 131 ServerInstance si = ServerRegistry.getInstance().getServerInstance(cProvider.getServerURI()); 133 134 if (!si.isRunning()) 136 return; 137 138 ProgressUI pui = new ProgressUI(NbBundle.getMessage(GenericInstanceTest.class, 140 "MSG_Stopping", cProvider.getServerURI()), false); 141 si.setServerState(ServerInstance.STATE_WAITING); 142 143 try { 144 pui.start(); 145 si.stop(pui); 146 } finally { 147 pui.finish(); 148 } 149 150 if (si.isRunning()) 152 throw new Exception (NbBundle.getMessage(GenericInstanceTest.class, 153 "MSG_Stop_Failed", cProvider.getServerURI())); 154 } catch(Exception e) { 155 fail(e.getMessage()); 156 } 157 } 158 } | Popular Tags |