1 22 package org.jboss.test.server.profileservice; 23 24 import java.io.File ; 25 import java.security.CodeSource ; 26 27 import org.jboss.Main; 28 import org.jboss.dependency.spi.ControllerState; 29 import org.jboss.kernel.Kernel; 30 import org.jboss.kernel.spi.registry.KernelRegistry; 31 import org.jboss.kernel.spi.registry.KernelRegistryEntry; 32 import org.jboss.system.server.Server; 33 import org.jboss.system.server.profileservice.ServerImpl; 34 import org.jboss.test.BaseTestCase; 35 36 45 public class MainWithSimpleHotDeployTestCase extends BaseTestCase 46 { 47 public MainWithSimpleHotDeployTestCase(String name) 48 { 49 super(name); 50 } 51 52 54 57 @Override 58 protected void configureLogging() 59 { 60 } 62 63 68 public void testDefaultStartup() throws Exception 69 { 70 String deployPrefix = ""; 71 String deployDirEnv = System.getenv("jbosstest.deploy.dir"); 73 String deployDirProp = System.getProperty("jbosstest.deploy.dir"); 74 if( deployDirProp == null && deployDirEnv != null ) 75 { 76 System.setProperty("jbosstest.deploy.dir", deployDirEnv); 77 deployDirProp = deployDirEnv; 78 } 79 String supportDirEnv = System.getenv("jbosstest.support.dir"); 80 String supportDirProp = System.getProperty("jbosstest.support.dir"); 81 if( supportDirProp == null && supportDirEnv != null ) 82 { 83 System.setProperty("jbosstest.support.dir", supportDirEnv); 84 supportDirProp = supportDirEnv; 85 } 86 87 if( supportDirProp == null ) 88 { 89 File resourcesDir = new File ("output/eclipse-resources"); 91 File classesDir = new File ("output/eclipse-test-classes"); 92 deployDirProp = resourcesDir.toURL().toExternalForm(); 93 supportDirProp = classesDir.toURL().toExternalForm(); 94 System.setProperty("jbosstest.deploy.dir", deployDirProp); 95 System.setProperty("jbosstest.support.dir", supportDirProp); 96 deployPrefix = "tests/bootstrap/defaulthotdeploy/"; 97 } 98 assertNotNull("jbosstest.support.dir != null", supportDirProp); 99 assertNotNull("jbosstest.deploy.dir != null", deployDirProp); 100 102 103 String [] args = {"-c", "defaulthotdeploy", "-Djboss.server.deployerBeansPrefix="+deployPrefix}; 104 Main main = new Main(); 105 main.boot(args); 106 Server server = main.getServer(); 107 assertTrue("Server", server instanceof ServerImpl); 108 ServerImpl serverImpl = (ServerImpl) server; 109 110 Kernel kernel = serverImpl.getKernel(); 112 assertInstalled(kernel, "ProfileService"); 113 assertInstalled(kernel, "MainDeployer"); 114 assertInstalled(kernel, "BeanDeployer"); 115 assertInstalled(kernel, "VFSDeploymentScanner"); 116 KernelRegistry registry = kernel.getRegistry(); 117 KernelRegistryEntry entry = registry.getEntry("VFSDeploymentScanner"); 118 126 127 assertInstalled(kernel, "VFSClassLoader"); 129 assertInstalled(kernel, "TestBean"); 130 assertInstalled(kernel, "VFSClassLoader-unpacked"); 131 assertInstalled(kernel, "TestBean-unpacked"); 132 entry = registry.getEntry("TestBean"); 133 Object testBean = entry.getTarget(); 134 CodeSource testBeanCS = testBean.getClass().getProtectionDomain().getCodeSource(); 135 log.info("TestBean.CS: "+testBeanCS); 136 log.info("TestBean.ClassLoader: "+testBean.getClass().getClassLoader()); 137 138 139 main.shutdown(); 141 } 142 143 private void assertInstalled(Kernel kernel, String name) 144 { 145 KernelRegistry registry = kernel.getRegistry(); 146 KernelRegistryEntry entry = registry.getEntry(name); 147 assertEquals(name+" Installed", ControllerState.INSTALLED, entry.getState()); 148 } 149 } 150 | Popular Tags |