KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > web > deployment > WebAppDConfigTest


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
18 package org.apache.geronimo.web.deployment;
19
20 import java.net.URL JavaDoc;
21 import java.util.Arrays JavaDoc;
22
23 import javax.enterprise.deploy.model.DDBean JavaDoc;
24 import javax.enterprise.deploy.model.DDBeanRoot JavaDoc;
25 import javax.enterprise.deploy.spi.DeploymentConfiguration JavaDoc;
26
27 import junit.framework.TestCase;
28 import org.apache.geronimo.deployment.tools.loader.WebDeployable;
29
30 /**
31  * @version $Rev: 476049 $ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
32  */

33 public class WebAppDConfigTest extends TestCase {
34     private DeploymentConfiguration JavaDoc config;
35     private WebDeployable deployable;
36     private DDBeanRoot JavaDoc ddBeanRoot;
37     private WebAppDConfigRoot configRoot;
38
39     public void testWebAppRoot() throws Exception JavaDoc {
40         assertNotNull(configRoot);
41         assertTrue(Arrays.equals(new String JavaDoc[]{"web-app"}, configRoot.getXpaths()));
42         assertNotNull(configRoot.getDConfigBean(ddBeanRoot.getChildBean("web-app")[0]));
43         assertNull(configRoot.getDConfigBean(ddBeanRoot.getChildBean("web-app/description")[0]));
44     }
45
46     public void testWebApp() throws Exception JavaDoc {
47         DDBean JavaDoc ddBean = ddBeanRoot.getChildBean("web-app")[0];
48         WebAppDConfigBean webApp = (WebAppDConfigBean) configRoot.getDConfigBean(ddBean);
49         assertNotNull(webApp);
50 /*
51         String[] xpaths = webApp.getXpaths();
52         assertTrue(Arrays.equals(
53                 new String[]{
54                     "ejb-ref",
55                     "ejb-local-ref",
56                     "message-destination-ref",
57                     "resource-env-ref",
58                     "resource-ref",
59                 },
60                 xpaths)
61         );
62 */

63     }
64
65 /*
66     public void testEJBRef() throws Exception {
67         DDBean ddBean = ddBeanRoot.getChildBean("web-app")[0];
68         WebAppDConfigBean webApp = (WebAppDConfigBean) configRoot.getDConfigBean(ddBean);
69         DDBean[] ddBeans = ddBean.getChildBean(webApp.getXpaths()[0]);
70         assertEquals(2, ddBeans.length);
71         assertEquals("fake-ejb-ref", ddBeans[0].getChildBean("ejb-ref-name")[0].getText());
72         assertEquals("another-ejb-ref", ddBeans[1].getChildBean("ejb-ref-name")[0].getText());
73
74         EJBRefDConfigBean ejbRef0 = (EJBRefDConfigBean) webApp.getDConfigBean(ddBeans[0]);
75         EJBRefDConfigBean ejbRef1 = (EJBRefDConfigBean) webApp.getDConfigBean(ddBeans[1]);
76         assertNotNull(ejbRef0);
77         assertEquals(ddBeans[0], ejbRef0.getDDBean());
78         assertNotNull(ejbRef1);
79         assertEquals(ddBeans[1], ejbRef1.getDDBean());
80         assertTrue(ejbRef0 != ejbRef1);
81     }
82 */

83
84 /*
85     public void testEJBLocalRef() throws Exception {
86         DDBean ddBean = ddBeanRoot.getChildBean("web-app")[0];
87         WebAppDConfigBean webApp = (WebAppDConfigBean) configRoot.getDConfigBean(ddBean);
88         DDBean[] ddBeans = ddBean.getChildBean(webApp.getXpaths()[1]);
89         assertEquals(2, ddBeans.length);
90         assertEquals("fake-ejb-local-ref", ddBeans[0].getChildBean("ejb-ref-name")[0].getText());
91         assertEquals("another-ejb-local-ref", ddBeans[1].getChildBean("ejb-ref-name")[0].getText());
92
93         EJBLocalRefDConfigBean ejbRef0 = (EJBLocalRefDConfigBean) webApp.getDConfigBean(ddBeans[0]);
94         EJBLocalRefDConfigBean ejbRef1 = (EJBLocalRefDConfigBean) webApp.getDConfigBean(ddBeans[1]);
95         assertNotNull(ejbRef0);
96         assertEquals(ddBeans[0], ejbRef0.getDDBean());
97         assertNotNull(ejbRef1);
98         assertEquals(ddBeans[1], ejbRef1.getDDBean());
99         assertTrue(ejbRef0 != ejbRef1);
100     }
101 */

102
103     protected void setUp() throws Exception JavaDoc {
104         super.setUp();
105         ClassLoader JavaDoc classLoader = Thread.currentThread().getContextClassLoader();
106         URL JavaDoc warDir = classLoader.getResource("deployables/war1/");
107         deployable = new WebDeployable(warDir);
108         config = new WARConfiguration(deployable);
109
110         ddBeanRoot = deployable.getDDBeanRoot();
111         configRoot = (WebAppDConfigRoot) config.getDConfigBeanRoot(ddBeanRoot);
112     }
113
114     protected void tearDown() throws Exception JavaDoc {
115         super.tearDown();
116     }
117 }
118
Popular Tags