1 19 20 package org.netbeans.modules.j2ee.deployment.impl; 21 22 import javax.enterprise.deploy.shared.ModuleType ; 23 import javax.enterprise.deploy.spi.*; 24 import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException ; 25 import javax.enterprise.deploy.spi.factories.DeploymentFactory ; 26 import org.netbeans.modules.j2ee.deployment.plugins.api.*; 27 import org.netbeans.modules.j2ee.deployment.impl.ui.RegistryNodeProvider; 28 import org.netbeans.modules.j2ee.deployment.plugins.api.StartServer; 29 33 public class ServerRegistryTest extends ServerRegistryTestBase { 34 35 public ServerRegistryTest(String testName) { 36 super(testName); 37 } 38 39 45 public void testPluginLayerFile() { 46 ServerRegistry registry = ServerRegistry.getInstance(); 47 System.out.println ("registry:" + registry); 48 Server testPlugin = registry.getServer("Test"); 49 if (testPlugin == null || ! testPlugin.getShortName().equals("Test")) 50 fail("Could not get testPlugin: "+testPlugin); 51 52 DeploymentFactory factory = testPlugin.getDeploymentFactory(); 53 assertNotNull ("No DeploymentFactory for test plugin", factory); 54 55 RegistryNodeProvider nodeProvider = testPlugin.getNodeProvider(); 56 assertNotNull ("No RegistryNodeProvider for test plugin", nodeProvider); 57 58 OptionalDeploymentManagerFactory optionalFactory = testPlugin.getOptionalFactory(); 59 assertNotNull ("No OptionalDeploymentManagerFactory for test plugin", optionalFactory); 60 61 DeploymentManager manager = null; 62 try { 63 manager = testPlugin.getDisconnectedDeploymentManager(); 64 assertNotNull ("No DeploymentManager for test plugin", manager); 65 } catch (DeploymentManagerCreationException dce) { 66 fail(dce.getLocalizedMessage()); 67 } 68 69 IncrementalDeployment incrementalDepl = optionalFactory.getIncrementalDeployment(manager); 70 assertNotNull ("No IncrementalDeployment for test plugin", incrementalDepl); 71 72 StartServer start = optionalFactory.getStartServer(manager); 73 assertNotNull ("No StartServer for test plugin", start); 74 75 String url = "fooservice"; 76 ServerInstance instance = registry.getServerInstance(url); 77 if (instance == null || ! instance.getUrl().equals(url)) { 78 fail("Failed: expected: " + url + " got: " + instance); 79 } 80 } 81 82 public void testDeploymentFileNames() { 83 ServerRegistry registry = ServerRegistry.getInstance(); 84 Server testPlugin = registry.getServer("Test"); 85 if (testPlugin == null || ! testPlugin.getShortName().equals("Test")) { 86 fail("Could not get testPlugin: "+testPlugin); 87 } 88 String expected = "META-INF/context.xml"; 89 String [] names = testPlugin.getDeploymentPlanFiles(ModuleType.WAR); 90 if (names == null || names.length != 1) { 91 fail("Got null or incorrect deploy plan file paths: " + names); 92 } else if (! names[0].equals(expected)) { 93 fail("Expected: "+expected+" Got: "+names[0]); 94 } 95 } 96 } 97 | Popular Tags |