1 22 package org.jboss.test.jca.test; 23 24 import junit.framework.Test; 25 26 import org.jboss.test.JBossTestCase; 27 import org.jboss.test.jca.adminobject.TestImplementation; 28 import org.jboss.test.jca.adminobject.TestImplementation2; 29 import org.jboss.test.jca.adminobject.TestInterface; 30 import org.jboss.test.jca.adminobject.TestInterface2; 31 32 38 public class AdminObjectUnitTestCase extends JBossTestCase 39 { 40 41 public AdminObjectUnitTestCase (String name) 42 { 43 super(name); 44 } 45 46 public static Test suite() throws Exception 47 { 48 return getDeploySetup(AdminObjectUnitTestCase.class, "testadminobject.rar"); 49 } 50 51 public void testAdminObject() throws Throwable 52 { 53 deploy("testadminobject-service.xml"); 55 try 56 { 57 Object obj = getInitialContext().lookup("test/jca/TestInterface"); 58 assertTrue("Instanceof TestInterface", obj instanceof TestInterface); 59 assertTrue("Instanceof TestImplementation", obj instanceof TestImplementation); 60 TestImplementation impl = (TestImplementation) obj; 61 assertEquals("StringValue", impl.getStringProperty()); 62 assertEquals(new Integer (123), impl.getIntegerProperty()); 63 64 obj = getInitialContext().lookup("test/jca/TestInterface2"); 65 assertTrue("Instanceof TestInterface2", obj instanceof TestInterface2); 66 assertTrue("Instanceof TestImplementation2", obj instanceof TestImplementation2); 67 TestImplementation2 impl2 = (TestImplementation2) obj; 68 assertEquals(new Integer (456), impl2.getStringProperty()); 69 } 70 finally 71 { 72 undeploy("testadminobject-service.xml"); 73 } 74 } 76 77 protected void assertNotBound() throws Exception 78 { 79 try 80 { 81 getInitialContext().lookup("test/jca/TestInterface"); 82 fail("test/jca/TestInterface is bound"); 83 } 84 catch (Exception expected) 85 { 86 } 87 88 try 89 { 90 getInitialContext().lookup("test/jca/TestInterface2"); 91 fail("test/jca/TestInterface2 is bound"); 92 } 93 catch (Exception expected) 94 { 95 } 96 } 97 } 98 | Popular Tags |