KickJava   Java API By Example, From Geeks To Geeks.

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


1 /**
2  *
3  * Copyright 2003-2004 The Apache Software Foundation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * 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.tomcat.deployment;
19
20 import java.util.Arrays JavaDoc;
21 import javax.enterprise.deploy.model.DDBean JavaDoc;
22 import javax.enterprise.deploy.model.DDBeanRoot JavaDoc;
23 import javax.enterprise.deploy.spi.DeploymentConfiguration JavaDoc;
24
25 import junit.framework.TestCase;
26 import org.apache.geronimo.deployment.tools.loader.WebDeployable;
27
28 /**
29  * @version $Rev: 56771 $ $Date: 2004-11-06 12:58:54 -0700 (Sat, 06 Nov 2004) $
30  */

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

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

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

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