1 17 18 package org.apache.geronimo.connector.outbound; 19 20 import javax.resource.ResourceException ; 21 import javax.resource.spi.LocalTransaction ; 22 23 29 public class LocalXAResourceInsertionInterceptorTest extends ConnectionInterceptorTestUtils { 30 31 private LocalXAResourceInsertionInterceptor localXAResourceInsertionInterceptor; 32 private LocalTransaction localTransaction; 33 private String name = "LocalXAResource"; 34 35 protected void setUp() throws Exception { 36 super.setUp(); 37 localXAResourceInsertionInterceptor = new LocalXAResourceInsertionInterceptor(this, name); 38 } 39 40 protected void tearDown() throws Exception { 41 super.tearDown(); 42 localXAResourceInsertionInterceptor = null; 43 } 44 45 public void testInsertLocalXAResource() throws Exception { 46 ConnectionInfo connectionInfo = makeConnectionInfo(); 47 localXAResourceInsertionInterceptor.getConnection(connectionInfo); 48 LocalXAResource returnedLocalXAResource = (LocalXAResource) connectionInfo.getManagedConnectionInfo().getXAResource(); 49 assertTrue("Expected the same LocalTransaction", localTransaction == returnedLocalXAResource.localTransaction); 50 } 51 52 public void getConnection(ConnectionInfo connectionInfo) throws ResourceException { 53 super.getConnection(connectionInfo); 54 localTransaction = new TestLocalTransaction(); 55 TestManagedConnection managedConnection = new TestManagedConnection(localTransaction); 56 ManagedConnectionInfo managedConnectionInfo = connectionInfo.getManagedConnectionInfo(); 57 managedConnectionInfo.setManagedConnection(managedConnection); 58 } 59 60 private static class TestLocalTransaction implements LocalTransaction { 61 public void begin() throws ResourceException { 62 } 63 64 public void commit() throws ResourceException { 65 } 66 67 public void rollback() throws ResourceException { 68 } 69 70 } 71 72 private static class TestManagedConnection extends TestPlainManagedConnection { 73 74 private final LocalTransaction localTransaction; 75 76 public TestManagedConnection(LocalTransaction localTransaction) { 77 this.localTransaction = localTransaction; 78 } 79 80 public LocalTransaction getLocalTransaction() throws ResourceException { 81 return localTransaction; 82 } 83 } 84 } 85 | Popular Tags |