KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ejb3 > test > dd > unit > ApplicationClientXmlTestCase


1 /*
2  * JBoss, Home of Professional Open Source
3  * Copyright 2005, JBoss Inc., and individual contributors as indicated
4  * by the @authors tag. See the copyright.txt in the distribution for a
5  * full listing of individual contributors.
6  *
7  * This is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as
9  * published by the Free Software Foundation; either version 2.1 of
10  * the License, or (at your option) any later version.
11  *
12  * This software is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this software; if not, write to the Free
19  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21  */

22 package org.jboss.ejb3.test.dd.unit;
23
24 import java.net.URL JavaDoc;
25 import java.util.Iterator JavaDoc;
26
27 import junit.framework.Test;
28 import junit.framework.TestCase;
29 import junit.framework.TestSuite;
30
31 import org.jboss.ejb3.metamodel.ApplicationClientDD;
32 import org.jboss.ejb3.metamodel.ApplicationClientDDObjectFactory;
33 import org.jboss.ejb3.metamodel.LifecycleCallback;
34 import org.jboss.metamodel.descriptor.EnvEntry;
35
36 /**
37  * Comment
38  *
39  * @author <a HREF="mailto:carlo.dewolf@jboss.com">Carlo de Wolf</a>
40  * @version $Revision: $
41  */

42 public class ApplicationClientXmlTestCase extends TestCase
43 {
44    public void testUnmarshalDDXsd() throws Exception JavaDoc
45    {
46       URL JavaDoc xmlUrl = getResourceUrl("dd/application-client-test1.xml");
47       assertNotNull(xmlUrl);
48       ApplicationClientDD dd = ApplicationClientDDObjectFactory.parse(xmlUrl);
49       assertNotNull(dd);
50       
51       assertEquals("Test1", dd.getDisplayName());
52       //assertEquals("application client dd test", dd.getDescription());
53

54       assertEquals(1, dd.getEnvEntries().size());
55       
56       {
57          Iterator JavaDoc<EnvEntry> i = dd.getEnvEntries().iterator();
58          
59          EnvEntry ee = i.next();
60          assertEquals("envTest", ee.getEnvEntryName());
61          assertEquals("java.lang.String", ee.getEnvEntryType());
62          assertEquals("Hello world", ee.getEnvEntryValue());
63       }
64       
65       assertEquals(1, dd.getPostConstructs().size());
66       
67       {
68          Iterator JavaDoc<LifecycleCallback> i = dd.getPostConstructs().iterator();
69          LifecycleCallback lc = i.next();
70          assertNull(lc.getLifecycleCallbackClass());
71          assertEquals("postConstruct", lc.getLifecycleCallbackMethod());
72       }
73       
74       assertEquals(1, dd.getPreDestroys().size());
75       
76       {
77          Iterator JavaDoc<LifecycleCallback> i = dd.getPreDestroys().iterator();
78          LifecycleCallback lc = i.next();
79          assertNull(lc.getLifecycleCallbackClass());
80          assertEquals("preDestroy", lc.getLifecycleCallbackMethod());
81       }
82    }
83    
84    private static URL JavaDoc getResourceUrl(String JavaDoc name)
85    {
86       URL JavaDoc url = Thread.currentThread().getContextClassLoader().getResource(name);
87       if (url == null)
88       {
89          throw new IllegalStateException JavaDoc("Resource not found: " + name);
90       }
91       return url;
92    }
93
94    public static Test suite() throws Exception JavaDoc
95    {
96       return new TestSuite(ApplicationClientXmlTestCase.class);
97    }
98    
99 }
100
Popular Tags