1 19 20 package org.netbeans.modules.j2ee.sun.test; 21 22 import java.io.File ; 23 import org.netbeans.junit.NbTestCase; 24 import org.netbeans.junit.NbTestSuite; 25 import org.netbeans.modules.j2ee.deployment.impl.ServerInstance; 26 import org.netbeans.modules.j2ee.deployment.impl.ServerRegistry; 27 import org.netbeans.modules.j2ee.sun.ide.j2ee.ui.AddDomainWizardIterator; 28 import org.openide.WizardDescriptor; 29 import org.openide.WizardDescriptor.Panel; 30 31 35 public class AddRemoveSjsasInstanceTest extends NbTestCase { 36 37 private final int SLEEP = 10000; 38 39 public AddRemoveSjsasInstanceTest(String testName) { 40 super(testName); 41 } 42 43 public void addSjsasInstance() { 44 try { 45 AddDomainWizardIterator inst = new AddDomainWizardIterator(); 46 WizardDescriptor wizard = new WizardDescriptor(new Panel[] {}); 47 wizard.putProperty(Util.PLATFORM_LOCATION, new File (Util._PLATFORM_LOCATION)); 48 wizard.putProperty(Util.INSTALL_LOCATION, Util._INSTALL_LOCATION); 49 wizard.putProperty(Util.PROP_DISPLAY_NAME, Util._DISPLAY_NAME); 50 wizard.putProperty(Util.HOST, Util._HOST); 51 wizard.putProperty(Util.PORT, Util._PORT); 52 wizard.putProperty(Util.DOMAIN, Util._DOMAIN); 53 wizard.putProperty(Util.USER_NAME, Util._USER_NAME); 54 wizard.putProperty(Util.PASSWORD, Util._PASSWORD); 55 56 inst.initialize(wizard); 57 inst.instantiate(); 58 59 ServerRegistry.getInstance().checkInstanceExists(Util._URL); 60 61 Util.sleep(SLEEP); 62 } catch(Exception e) { 63 fail(e.getMessage()); 64 } 65 } 66 67 public void removeSjsasInstance() { 68 try { 69 Util.sleep(SLEEP); 70 71 ServerInstance inst = ServerRegistry.getInstance().getServerInstance(Util._URL); 72 boolean wasRunning = inst.isRunning(); 73 74 inst.remove(); 75 76 if (wasRunning) { 77 Util.sleep(SLEEP); 78 } 79 80 try { 81 ServerRegistry.getInstance().checkInstanceExists(Util._URL); 82 } catch(Exception e) { 83 if (wasRunning && inst.isRunning()) 84 fail("remove did not stop the instance"); 85 String instances[] = ServerRegistry.getInstance().getInstanceURLs(); 86 if (null != instances) 87 if (instances.length > 1) 88 fail("too many instances"); 89 return; 90 } 91 92 fail("Sjsas instance still exists !"); 93 } catch(Exception e) { 94 fail(e.getMessage()); 95 } 96 } 97 98 public static NbTestSuite suite() { 99 NbTestSuite suite = new NbTestSuite("AddRemoveSjsasInstanceTest"); 100 suite.addTest(new AddRemoveSjsasInstanceTest("addSjsasInstance")); 101 suite.addTest(new AddRemoveSjsasInstanceTest("removeSjsasInstance")); 102 return suite; 103 } 104 } | Popular Tags |