1 22 package org.jboss.test.jca.test; 23 24 import java.rmi.RemoteException ; 25 26 import javax.management.Attribute ; 27 import javax.management.ObjectName ; 28 import javax.resource.ResourceException ; 29 30 import junit.framework.Test; 31 32 import org.jboss.test.JBossTestCase; 33 import org.jboss.test.jca.interfaces.UserTxSession; 34 import org.jboss.test.jca.interfaces.UserTxSessionHome; 35 36 42 public class CachedConnectionErrorUnitTestCase extends JBossTestCase 43 { 44 public CachedConnectionErrorUnitTestCase (String name) 45 { 46 super(name); 47 } 48 49 protected void setError(Boolean value) throws Exception 50 { 51 ObjectName CCM = new ObjectName ("jboss.jca:service=CachedConnectionManager"); 52 getServer().setAttribute(CCM, new Attribute ("Error", value)); 53 } 54 55 protected void setUp() throws Exception 56 { 57 setError(Boolean.TRUE); 58 } 59 60 protected void tearDown() throws Exception 61 { 62 setError(Boolean.FALSE); 63 } 64 65 public static Test suite() throws Exception 66 { 67 Test t1 = getDeploySetup(CachedConnectionErrorUnitTestCase.class, "jcatest.jar"); 68 Test t2 = getDeploySetup(t1, "testadapter-ds.xml"); 69 return getDeploySetup(t2, "jbosstestadapter.rar"); 70 } 71 72 public void testCachedConnectionError() throws Exception 73 { 74 UserTxSessionHome sh = (UserTxSessionHome) getInitialContext().lookup("UserTxSession"); 75 UserTxSession s = sh.create(); 76 try 77 { 78 s.testUnclosedError(); 79 fail("Should not be here"); 80 } 81 catch (RemoteException expected) 82 { 83 log.debug("Got the expected exception RemoteException:", expected); 84 Throwable linked = expected.getCause(); 85 assertTrue("Not the expected exception: " + linked, linked != null && linked instanceof ResourceException ); 86 } 87 } 88 } 89 | Popular Tags |