KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > client > builder > PlanParsingTest


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * 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  */

17 package org.apache.geronimo.client.builder;
18
19 import java.io.File JavaDoc;
20 import java.util.Collections JavaDoc;
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 /**
33  */

34 public class PlanParsingTest extends TestSupport {
35
36     private AppClientModuleBuilder builder;
37
38     protected void setUp() throws Exception JavaDoc {
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 JavaDoc {
43         File JavaDoc resourcePlan = new File JavaDoc(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 JavaDoc {
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         // System.out.println(appClient.toString());
65
}
66
67     public void testConnectorInclude() throws Exception JavaDoc {
68         File JavaDoc resourcePlan = new File JavaDoc(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