01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */package org.apache.geronimo.client.builder;
17:
18: import java.io.File;
19: import java.util.Collections;
20:
21: import org.apache.geronimo.testsupport.TestSupport;
22:
23: import org.apache.geronimo.xbeans.geronimo.client.GerApplicationClientDocument;
24: import org.apache.geronimo.xbeans.geronimo.client.GerApplicationClientType;
25: import org.apache.geronimo.xbeans.geronimo.naming.GerResourceRefType;
26: import org.apache.geronimo.kernel.repository.Environment;
27: import org.apache.geronimo.kernel.repository.ArtifactResolver;
28: import org.apache.geronimo.kernel.repository.Repository;
29: import org.apache.geronimo.deployment.xbeans.EnvironmentType;
30: import org.apache.geronimo.deployment.xbeans.ArtifactType;
31: import org.apache.geronimo.deployment.xmlbeans.XmlBeansUtil;
32: import org.apache.geronimo.j2ee.deployment.ModuleBuilderExtension;
33:
34: /**
35: */
36: public class PlanParsingTest extends TestSupport {
37:
38: private ArtifactResolver clientArtifactResolver = null;
39: private AppClientModuleBuilder builder;
40:
41: protected void setUp() throws Exception {
42: super .setUp();
43: builder = new AppClientModuleBuilder(new Environment(), null,
44: null, null, null, null, Collections
45: .<Repository> emptyList(), null, null, null,
46: Collections.<ModuleBuilderExtension> emptyList(),
47: clientArtifactResolver);
48: builder.doStart();
49: }
50:
51: protected void tearDown() throws Exception {
52: super .tearDown();
53: builder.doStop();
54: }
55:
56: public void testResourceRef() throws Exception {
57: File resourcePlan = new File(BASEDIR,
58: "src/test/resources/plans/plan1.xml");
59: assertTrue(resourcePlan.exists());
60: GerApplicationClientType appClient = builder
61: .getGeronimoAppClient(resourcePlan, null, true, null,
62: null, null);
63: assertEquals(1, appClient.getResourceRefArray().length);
64: }
65:
66: public void testConstructPlan() throws Exception {
67: GerApplicationClientDocument appClientDoc = GerApplicationClientDocument.Factory
68: .newInstance();
69: GerApplicationClientType appClient = appClientDoc
70: .addNewApplicationClient();
71: EnvironmentType clientEnvironmentType = appClient
72: .addNewClientEnvironment();
73: ArtifactType clientId = clientEnvironmentType.addNewModuleId();
74: clientId.setGroupId("group");
75: clientId.setArtifactId("artifact");
76: EnvironmentType serverEnvironmentType = appClient
77: .addNewServerEnvironment();
78: serverEnvironmentType.setModuleId(clientId);
79:
80: GerResourceRefType ref = appClient.addNewResourceRef();
81: ref.setRefName("ref");
82: ref.setResourceLink("target");
83:
84: XmlBeansUtil.validateDD(appClient);
85: // System.out.println(appClient.toString());
86: }
87:
88: public void testConnectorInclude() throws Exception {
89: File resourcePlan = new File(BASEDIR,
90: "src/test/resources/plans/plan2.xml");
91: assertTrue(resourcePlan.exists());
92: GerApplicationClientType appClient = builder
93: .getGeronimoAppClient(resourcePlan, null, true, null,
94: null, null);
95: assertEquals(1, appClient.getResourceRefArray().length);
96: assertEquals(1, appClient.getResourceArray().length);
97: }
98: }
|