1 17 package org.apache.geronimo.client.builder; 18 19 import java.io.File ; 20 import java.util.Collections ; 21 22 import org.apache.geronimo.testsupport.TestSupport; 23 24 import org.apache.geronimo.xbeans.geronimo.client.GerApplicationClientDocument; 25 import org.apache.geronimo.xbeans.geronimo.client.GerApplicationClientType; 26 import org.apache.geronimo.xbeans.geronimo.naming.GerResourceRefType; 27 import org.apache.geronimo.kernel.repository.Environment; 28 import org.apache.geronimo.deployment.xbeans.EnvironmentType; 29 import org.apache.geronimo.deployment.xbeans.ArtifactType; 30 import org.apache.geronimo.deployment.xmlbeans.XmlBeansUtil; 31 32 34 public class PlanParsingTest extends TestSupport { 35 36 private AppClientModuleBuilder builder; 37 38 protected void setUp() throws Exception { 39 builder = new AppClientModuleBuilder(new Environment(), null, null, null, null, Collections.EMPTY_LIST, null, null, null, null); 40 } 41 42 public void testResourceRef() throws Exception { 43 File resourcePlan = new File (BASEDIR, "src/test/resources/plans/plan1.xml"); 44 assertTrue(resourcePlan.exists()); 45 GerApplicationClientType appClient = builder.getGeronimoAppClient(resourcePlan, null, true, null, null, null); 46 assertEquals(1, appClient.getResourceRefArray().length); 47 } 48 49 public void testConstructPlan() throws Exception { 50 GerApplicationClientDocument appClientDoc = GerApplicationClientDocument.Factory.newInstance(); 51 GerApplicationClientType appClient = appClientDoc.addNewApplicationClient(); 52 EnvironmentType clientEnvironmentType = appClient.addNewClientEnvironment(); 53 ArtifactType clientId = clientEnvironmentType.addNewModuleId(); 54 clientId.setGroupId("group"); 55 clientId.setArtifactId("artifact"); 56 EnvironmentType serverEnvironmentType = appClient.addNewServerEnvironment(); 57 serverEnvironmentType.setModuleId(clientId); 58 59 GerResourceRefType ref = appClient.addNewResourceRef(); 60 ref.setRefName("ref"); 61 ref.setResourceLink("target"); 62 63 XmlBeansUtil.validateDD(appClient); 64 } 66 67 public void testConnectorInclude() throws Exception { 68 File resourcePlan = new File (BASEDIR, "src/test/resources/plans/plan2.xml"); 69 assertTrue(resourcePlan.exists()); 70 GerApplicationClientType appClient = builder.getGeronimoAppClient(resourcePlan, null, true, null, null, null); 71 assertEquals(1, appClient.getResourceRefArray().length); 72 assertEquals(1, appClient.getResourceArray().length); 73 } 74 } 75 | Popular Tags |