1 22 package org.jboss.ejb3.test.dd.unit; 23 24 import java.net.URL ; 25 import java.util.Iterator ; 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 42 public class ApplicationClientXmlTestCase extends TestCase 43 { 44 public void testUnmarshalDDXsd() throws Exception 45 { 46 URL 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 54 assertEquals(1, dd.getEnvEntries().size()); 55 56 { 57 Iterator <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 <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 <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 getResourceUrl(String name) 85 { 86 URL url = Thread.currentThread().getContextClassLoader().getResource(name); 87 if (url == null) 88 { 89 throw new IllegalStateException ("Resource not found: " + name); 90 } 91 return url; 92 } 93 94 public static Test suite() throws Exception 95 { 96 return new TestSuite(ApplicationClientXmlTestCase.class); 97 } 98 99 } 100 | Popular Tags |