1 22 package org.jboss.test.server.profileservice; 23 24 import java.io.File ; 25 import java.net.URL ; 26 import java.util.ArrayList ; 27 28 import org.jboss.deployers.plugins.structure.AbstractDeploymentContext; 29 import org.jboss.deployers.spi.deployment.MainDeployer; 30 import org.jboss.deployers.spi.structure.DeploymentContext; 31 import org.jboss.profileservice.spi.Profile; 32 import org.jboss.profileservice.spi.ProfileKey; 33 import org.jboss.profileservice.spi.ProfileService; 34 import org.jboss.system.server.profileservice.ProfileServiceBootstrap; 35 import org.jboss.test.BaseTestCase; 36 import org.jboss.virtual.VFS; 37 import org.jboss.virtual.VirtualFile; 38 import org.jboss.Main; 39 40 46 public class MainTestCase extends BaseTestCase 47 { 48 public MainTestCase(String name) 49 { 50 super(name); 51 } 52 53 55 59 public void testCreateDefaultProfile() throws Throwable 60 { 61 URL bootstrapDir = super.getResource("/bootstrap"); 63 log.info("bootstrapDir: "+bootstrapDir); 64 URL resourcesDir = new URL (bootstrapDir, ".."); 65 log.info("resourcesDir: "+resourcesDir); 66 System.setProperty("jboss.server.home.url", resourcesDir.toString()); 67 68 ProfileServiceBootstrap psb = new ProfileServiceBootstrap(); 70 psb.setDeployerBeansPrefix("bootstrap/default/"); 71 psb.bootstrap(); 72 ProfileService ps = psb.getProfileService(); 73 ProfileKey defaultKey = new ProfileKey("default"); 74 Profile profile = ps.getProfile(defaultKey); 75 DeploymentContext testBeans = profile.getDeployment("test-beans.xml"); 76 if( testBeans == null ) 77 { 78 if( profile == null ) 79 profile = ps.newProfile(defaultKey); 80 MainDeployer deployer = psb.getMainDeployer(); 81 VFS vfs = VFS.getVFS(resourcesDir); 82 VirtualFile file = vfs.findChildFromRoot("deploy/beans/test-beans.xml"); 83 testBeans = new AbstractDeploymentContext(file); 84 deployer.addDeploymentContext(testBeans); 85 profile.addDeployment(testBeans); 86 } 87 testBeans = profile.getDeployment("test-beans.xml"); 89 assertNotNull(testBeans); 90 } 93 94 99 public void testDefaultStartup() throws Exception 100 { 101 URL bootstrapDir = super.getResource("/bootstrap"); 103 log.info("bootstrapDir: "+bootstrapDir); 104 URL resourcesDir = new URL (bootstrapDir, ".."); 105 log.info("resourcesDir: "+resourcesDir); 106 System.setProperty("jboss.server.home.url", resourcesDir.toString()); 107 File supportDir = new File ("output/tests-support"); 109 System.setProperty("jbosstest.support.dir", supportDir.toString()); 110 System.setProperty("jboss.server.deployerBeansPrefix", "bootstrap/default/"); 112 113 ArrayList <String > args = new ArrayList <String >(); 114 String [] tmp = {}; 115 Main main = new Main(); 116 main.boot(args.toArray(tmp)); 117 } 118 119 } 120 | Popular Tags |