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.plugins.api.InstanceProperties; 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 GenericInstanceTest extends NbTestCase { 36 37 private ConstantsProvider cProvider; 38 private ServerProvider sProvider; 39 40 47 public GenericInstanceTest(String name, ConstantsProvider cProvider, ServerProvider sProvider) { 48 super(name); 49 50 this.cProvider = cProvider; 51 this.sProvider = sProvider; 52 } 53 54 57 public void addInstanceTest() { 58 try { 59 InstanceProperties ip = InstanceProperties.createInstanceProperties( 61 cProvider.getServerURI(), cProvider.getUsername(), 62 cProvider.getPassword(), cProvider.getDisplayName()); 63 64 sProvider.setServerSpecificProperties(ip); 66 67 ServerRegistry.getInstance().checkInstanceExists(cProvider.getServerURI()); 69 } catch(Exception e) { 70 fail(e.getMessage()); 71 } 72 } 73 74 77 public void removeInstanceTest() { 78 try { 79 ServerInstance si = ServerRegistry.getInstance().getServerInstance(cProvider.getServerURI()); 81 82 if (!si.isRemoveForbidden()) 84 si.remove(); 85 else 86 return; 87 88 if (null != ServerRegistry.getInstance().getServerInstance(cProvider.getServerURI())) 90 throw new Exception (NbBundle.getMessage(GenericInstanceTest.class, "MSG_Remove_Failed", cProvider.getServerURI())); 91 } catch(Exception e) { 92 fail(e.getMessage()); 93 } 94 } 95 } | Popular Tags |