1 17 package org.apache.geronimo.tomcat.deployment; 18 19 import java.io.File ; 20 import java.net.URL ; 21 import java.util.Collections ; 22 23 import junit.framework.TestCase; 24 import org.apache.geronimo.deployment.xbeans.ArtifactType; 25 import org.apache.geronimo.deployment.xbeans.EnvironmentType; 26 import org.apache.geronimo.deployment.xmlbeans.XmlBeansUtil; 27 import org.apache.geronimo.deployment.service.GBeanBuilder; 28 import org.apache.geronimo.gbean.AbstractName; 29 import org.apache.geronimo.gbean.AbstractNameQuery; 30 import org.apache.geronimo.j2ee.deployment.WebServiceBuilder; 31 import org.apache.geronimo.j2ee.deployment.NamingBuilderCollection; 32 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory; 33 import org.apache.geronimo.kernel.Jsr77Naming; 34 import org.apache.geronimo.kernel.Naming; 35 import org.apache.geronimo.kernel.repository.Artifact; 36 import org.apache.geronimo.kernel.repository.Environment; 37 import org.apache.geronimo.xbeans.geronimo.naming.GerResourceRefType; 38 import org.apache.geronimo.xbeans.geronimo.web.GerWebAppDocument; 39 import org.apache.geronimo.xbeans.geronimo.web.GerWebAppType; 40 import org.apache.geronimo.xbeans.geronimo.web.tomcat.TomcatWebAppType; 41 import org.apache.geronimo.security.deployment.GeronimoSecurityBuilderImpl; 42 import org.apache.geronimo.naming.deployment.ResourceEnvironmentSetter; 43 import org.apache.geronimo.naming.deployment.ResourceEnvironmentBuilder; 44 import org.apache.xmlbeans.XmlObject; 45 46 48 public class PlanParsingTest extends TestCase { 49 private ClassLoader classLoader = this.getClass().getClassLoader(); 50 51 private Naming naming = new Jsr77Naming(); 52 private Artifact baseId = new Artifact("test", "base", "1", "car"); 53 private AbstractName baseRootName = naming.createRootName(baseId, "root", NameFactory.SERVICE_MODULE); 54 private AbstractNameQuery tomcatContainerObjectName = new AbstractNameQuery(naming.createChildName(baseRootName, "TomcatContainer", NameFactory.GERONIMO_SERVICE)); 55 private WebServiceBuilder webServiceBuilder = null; 56 private Environment defaultEnvironment = new Environment(); 57 private TomcatModuleBuilder builder; 58 59 protected void setUp() throws Exception { 60 builder = new TomcatModuleBuilder(defaultEnvironment, tomcatContainerObjectName, Collections.singleton(webServiceBuilder), Collections.singleton(new GeronimoSecurityBuilderImpl()), Collections.singleton(new GBeanBuilder(null, null)), new NamingBuilderCollection(null, null), new MockResourceEnvironmentSetter(), null); 61 } 62 63 public void testResourceRef() throws Exception { 64 URL resourceURL = classLoader.getResource("plans/plan1.xml"); 65 File resourcePlan = new File (resourceURL.getFile()); 66 assertTrue(resourcePlan.exists()); 67 TomcatWebAppType tomcatWebApp = builder.getTomcatWebApp(resourcePlan, null, true, null, null); 68 assertEquals(1, tomcatWebApp.getResourceRefArray().length); 69 } 70 71 public void testConstructPlan() throws Exception { 72 GerWebAppDocument tomcatWebAppDoc = GerWebAppDocument.Factory.newInstance(); 73 GerWebAppType tomcatWebAppType = tomcatWebAppDoc.addNewWebApp(); 74 EnvironmentType environmentType = tomcatWebAppType.addNewEnvironment(); 75 ArtifactType artifactType = environmentType.addNewModuleId(); 76 artifactType.setArtifactId("foo"); 77 78 GerResourceRefType ref = tomcatWebAppType.addNewResourceRef(); 79 ref.setRefName("ref"); 80 ref.setResourceLink("target"); 81 82 XmlBeansUtil.validateDD(tomcatWebAppType); 83 } 84 85 } 86 | Popular Tags |