You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dj...@apache.org on 2003/12/10 08:48:13 UTC

cvs commit: incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound ConnectionManagerDeployment.java ConnectionTrackingInterceptor.java SubjectInterceptor.java

djencks     2003/12/09 23:48:12

  Modified:    modules/core/src/test/org/apache/geronimo/connector/outbound
                        ConnectionTrackingInterceptorTest.java
                        LocalXAResourceInsertionInterceptorTest.java
                        SubjectInterceptorTest.java
                        TransactionCachingInterceptorTest.java
                        TransactionEnlistingInterceptorTest.java
                        XAResourceInsertionInterceptorTest.java
               modules/core/src/java/org/apache/geronimo/connector/outbound
                        ConnectionManagerDeployment.java
                        ConnectionTrackingInterceptor.java
                        SubjectInterceptor.java
  Added:       modules/core/src/test/org/apache/geronimo/connector/outbound
                        ConnectionManagerTestUtils.java
  Log:
  Move re-association functionality to SubjectInterceptor and refactor tests to use a common superclass
  
  Revision  Changes    Path
  1.2       +37 -159   incubator-geronimo/modules/core/src/test/org/apache/geronimo/connector/outbound/ConnectionTrackingInterceptorTest.java
  
  Index: ConnectionTrackingInterceptorTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/test/org/apache/geronimo/connector/outbound/ConnectionTrackingInterceptorTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ConnectionTrackingInterceptorTest.java	9 Dec 2003 04:17:39 -0000	1.1
  +++ ConnectionTrackingInterceptorTest.java	10 Dec 2003 07:48:12 -0000	1.2
  @@ -56,23 +56,12 @@
   
   package org.apache.geronimo.connector.outbound;
   
  -import java.util.HashSet;
   import java.util.Collection;
  +import java.util.HashSet;
   import java.util.Set;
  -import java.security.Principal;
  -import java.io.PrintWriter;
   
   import javax.resource.ResourceException;
  -import javax.resource.spi.ManagedConnection;
  -import javax.resource.spi.ConnectionRequestInfo;
  -import javax.resource.spi.ConnectionEventListener;
  -import javax.resource.spi.LocalTransaction;
  -import javax.resource.spi.ManagedConnectionMetaData;
  -import javax.resource.spi.DissociatableManagedConnection;
  -import javax.security.auth.Subject;
  -import javax.transaction.xa.XAResource;
   
  -import junit.framework.TestCase;
   import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTracker;
   
   /**
  @@ -82,78 +71,79 @@
    * @version $Revision$ $Date$
    *
    * */
  -public class ConnectionTrackingInterceptorTest extends TestCase
  -    implements ConnectionTracker, ConnectionInterceptor, SecurityDomain {
  +public class ConnectionTrackingInterceptorTest extends ConnectionManagerTestUtils
  +    implements ConnectionTracker{
   
       private final static String key = "test-name";
       private ConnectionTrackingInterceptor connectionTrackingInterceptor;
   
  -    private Subject subject;
   
       private ConnectionTrackingInterceptor obtainedConnectionTrackingInterceptor;
  -    private ConnectionInfo obtainedConnectionInfo;
  +    private ConnectionInfo obtainedTrackedConnectionInfo;
   
       private ConnectionTrackingInterceptor releasedConnectionTrackingInterceptor;
  -    private ConnectionInfo releasedConnectionInfo;
  -    private boolean gotConnection;
  -    private boolean returnedConnection;
  +    private ConnectionInfo releasedTrackedConnectionInfo;
   
       private Collection connectionInfos;
       private Set unshareable;
   
  -    private ManagedConnection managedConnection;
  -
       protected void setUp() throws Exception {
  +        super.setUp();
           connectionTrackingInterceptor = new ConnectionTrackingInterceptor(this, key, this, this);
       }
   
       protected void tearDown() throws Exception {
  +        super.tearDown();
           connectionTrackingInterceptor = null;
  -        subject = null;
           managedConnection = null;
           obtainedConnectionTrackingInterceptor = null;
  -        obtainedConnectionInfo = null;
  +        obtainedTrackedConnectionInfo = null;
           releasedConnectionTrackingInterceptor = null;
  -        releasedConnectionInfo = null;
  -        gotConnection = false;
  -        returnedConnection = false;
  +        releasedTrackedConnectionInfo = null;
       }
   
       public void testConnectionRegistration() throws Exception {
  -        ConnectionInfo connectionInfo = new ConnectionInfo();
  +        ConnectionInfo connectionInfo = makeConnectionInfo();
           connectionTrackingInterceptor.getConnection(connectionInfo);
           assertTrue("Expected handleObtained call with our connectionTrackingInterceptor",
                   connectionTrackingInterceptor == obtainedConnectionTrackingInterceptor);
           assertTrue("Expected handleObtained call with our connectionInfo",
  -                connectionInfo == obtainedConnectionInfo);
  +                connectionInfo == obtainedTrackedConnectionInfo);
           //release connection handle
           connectionTrackingInterceptor.returnConnection(connectionInfo, ConnectionReturnAction.RETURN_HANDLE);
           assertTrue("Expected handleReleased call with our connectionTrackingInterceptor",
                       connectionTrackingInterceptor == releasedConnectionTrackingInterceptor);
               assertTrue("Expected handleReleased call with our connectionInfo",
  -                    connectionInfo == releasedConnectionInfo);
  +                    connectionInfo == releasedTrackedConnectionInfo);
   
       }
   
  -    //Well, subject is null if this is called directly
  +
  +
       public void testEnterWithNullSubject() throws Exception {
  -        ConnectionInfo connectionInfo = new ConnectionInfo();
  -        //easy way to get ManagedConnectionInfo set up
  +        getConnectionAndReenter();
  +        //expect no re-association
  +        assertTrue("Expected no connection asked for", obtainedConnectionInfo == null);
  +        assertTrue("Expected no connection returned", returnedConnectionInfo == null);
  +    }
  +
  +    private void getConnectionAndReenter() throws ResourceException {
  +        ConnectionInfo connectionInfo = makeConnectionInfo();
           connectionTrackingInterceptor.getConnection(connectionInfo);
           //reset our test indicator
  -        gotConnection = false;
  +        obtainedConnectionInfo = null;
           connectionInfos = new HashSet();
           connectionInfos.add(connectionInfo);
           unshareable = new HashSet();
           connectionTrackingInterceptor.enter(connectionInfos, unshareable);
  -        //expect no re-association
  -        assertTrue("Expected no connection asked for", !gotConnection);
  -        assertTrue("Expected no connection returned", !returnedConnection);
       }
   
       public void testEnterWithSameSubject() throws Exception {
           makeSubject("foo");
  -        testEnterWithNullSubject();
  +        getConnectionAndReenter();
  +        //decision on re-association happens in subject interceptor
  +        assertTrue("Expected connection asked for", obtainedConnectionInfo != null);
  +        assertTrue("Expected no connection returned", returnedConnectionInfo == null);
       }
   
       public void testEnterWithChangedSubject() throws Exception {
  @@ -161,15 +151,16 @@
           makeSubject("bar");
           connectionTrackingInterceptor.enter(connectionInfos, unshareable);
           //expect re-association
  -        assertTrue("Expected connection asked for", gotConnection);
  -        assertTrue("Expected connection returned", returnedConnection);
  +        assertTrue("Expected connection asked for", obtainedConnectionInfo != null);
  +        //connection is returned by SubjectInterceptor
  +        assertTrue("Expected no connection returned", returnedConnectionInfo == null);
       }
   
       public void testExitWithNonDissociatableConnection() throws Exception {
           managedConnection = new TestPlainManagedConnection();
           testEnterWithSameSubject();
           connectionTrackingInterceptor.exit(connectionInfos, unshareable);
  -        assertTrue("Expected no connection returned", !returnedConnection);
  +        assertTrue("Expected no connection returned", returnedConnectionInfo == null);
           assertEquals("Expected one info in connectionInfos", connectionInfos.size(), 1);
       }
   
  @@ -177,29 +168,23 @@
           managedConnection = new TestDissociatableManagedConnection();
           testEnterWithSameSubject();
           connectionTrackingInterceptor.exit(connectionInfos, unshareable);
  -        assertTrue("Expected connection returned", returnedConnection);
  +        assertTrue("Expected connection returned", returnedConnectionInfo != null);
           assertEquals("Expected no infos in connectionInfos", connectionInfos.size(), 0);
       }
   
  -    private void makeSubject(String principalName) {
  -        subject = new Subject();
  -        Set principals = subject.getPrincipals();
  -        principals.add(new TestPrincipal(principalName));
  -    }
  -
       //ConnectionTracker interface
       public void handleObtained(
               ConnectionTrackingInterceptor connectionTrackingInterceptor,
               ConnectionInfo connectionInfo) {
           obtainedConnectionTrackingInterceptor = connectionTrackingInterceptor;
  -        obtainedConnectionInfo = connectionInfo;
  +        obtainedTrackedConnectionInfo = connectionInfo;
       }
   
       public void handleReleased(
               ConnectionTrackingInterceptor connectionTrackingInterceptor,
               ConnectionInfo connectionInfo) {
           releasedConnectionTrackingInterceptor = connectionTrackingInterceptor;
  -        releasedConnectionInfo = connectionInfo;
  +        releasedTrackedConnectionInfo = connectionInfo;
       }
   
       public ConnectorTransactionContext getConnectorTransactionContext() {
  @@ -208,118 +193,11 @@
   
       //ConnectionInterceptor interface
       public void getConnection(ConnectionInfo connectionInfo) throws ResourceException {
  -        ManagedConnectionInfo managedConnectionInfo = new ManagedConnectionInfo(null, null);
  +        super.getConnection(connectionInfo);
  +        ManagedConnectionInfo managedConnectionInfo = connectionInfo.getManagedConnectionInfo();
           managedConnectionInfo.setConnectionEventListener(new GeronimoConnectionEventListener(null, managedConnectionInfo));
           managedConnectionInfo.setSubject(subject);
           managedConnectionInfo.setManagedConnection(managedConnection);
  -        connectionInfo.setManagedConnectionInfo(managedConnectionInfo);
  -        gotConnection = true;
  -    }
  -
  -    public void returnConnection(ConnectionInfo connectionInfo, ConnectionReturnAction connectionReturnAction) {
  -        returnedConnection = true;
  -    }
  -
  -    //SecurityDomain interface
  -    public Subject getSubject() {
  -        return subject;
  -    }
  -
  -    private static class TestPrincipal implements Principal {
  -
  -        private final String name;
  -
  -        public TestPrincipal(String name) {
  -            this.name = name;
  -        }
  -        public String getName() {
  -            return name;
  -        }
  -
  -    }
  -
  -    private static class TestPlainManagedConnection implements ManagedConnection {
  -        public Object getConnection(Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException {
  -            return null;
  -        }
  -
  -        public void destroy() throws ResourceException {
  -        }
  -
  -        public void cleanup() throws ResourceException {
  -        }
  -
  -        public void associateConnection(Object connection) throws ResourceException {
  -        }
  -
  -        public void addConnectionEventListener(ConnectionEventListener listener) {
  -        }
  -
  -        public void removeConnectionEventListener(ConnectionEventListener listener) {
  -        }
  -
  -        public XAResource getXAResource() throws ResourceException {
  -            return null;
  -        }
  -
  -        public LocalTransaction getLocalTransaction() throws ResourceException {
  -            return null;
  -        }
  -
  -        public ManagedConnectionMetaData getMetaData() throws ResourceException {
  -            return null;
  -        }
  -
  -        public void setLogWriter(PrintWriter out) throws ResourceException {
  -        }
  -
  -        public PrintWriter getLogWriter() throws ResourceException {
  -            return null;
  -        }
  -
       }
   
  -    private static class TestDissociatableManagedConnection implements ManagedConnection, DissociatableManagedConnection {
  -        public void dissociateConnections() throws ResourceException {
  -        }
  -
  -        public Object getConnection(Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException {
  -            return null;
  -        }
  -
  -        public void destroy() throws ResourceException {
  -        }
  -
  -        public void cleanup() throws ResourceException {
  -        }
  -
  -        public void associateConnection(Object connection) throws ResourceException {
  -        }
  -
  -        public void addConnectionEventListener(ConnectionEventListener listener) {
  -        }
  -
  -        public void removeConnectionEventListener(ConnectionEventListener listener) {
  -        }
  -
  -        public XAResource getXAResource() throws ResourceException {
  -            return null;
  -        }
  -
  -        public LocalTransaction getLocalTransaction() throws ResourceException {
  -            return null;
  -        }
  -
  -        public ManagedConnectionMetaData getMetaData() throws ResourceException {
  -            return null;
  -        }
  -
  -        public void setLogWriter(PrintWriter out) throws ResourceException {
  -        }
  -
  -        public PrintWriter getLogWriter() throws ResourceException {
  -            return null;
  -        }
  -
  -    }
   }
  
  
  
  1.2       +8 -55     incubator-geronimo/modules/core/src/test/org/apache/geronimo/connector/outbound/LocalXAResourceInsertionInterceptorTest.java
  
  Index: LocalXAResourceInsertionInterceptorTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/test/org/apache/geronimo/connector/outbound/LocalXAResourceInsertionInterceptorTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LocalXAResourceInsertionInterceptorTest.java	9 Dec 2003 04:17:39 -0000	1.1
  +++ LocalXAResourceInsertionInterceptorTest.java	10 Dec 2003 07:48:12 -0000	1.2
  @@ -56,18 +56,8 @@
   
   package org.apache.geronimo.connector.outbound;
   
  -import java.io.PrintWriter;
  -
   import javax.resource.ResourceException;
   import javax.resource.spi.LocalTransaction;
  -import javax.resource.spi.ManagedConnection;
  -import javax.resource.spi.ConnectionRequestInfo;
  -import javax.resource.spi.ConnectionEventListener;
  -import javax.resource.spi.ManagedConnectionMetaData;
  -import javax.security.auth.Subject;
  -import javax.transaction.xa.XAResource;
  -
  -import junit.framework.TestCase;
   
   /**
    *
  @@ -75,38 +65,36 @@
    * @version $Revision$ $Date$
    *
    * */
  -public class LocalXAResourceInsertionInterceptorTest extends TestCase
  -    implements ConnectionInterceptor {
  +public class LocalXAResourceInsertionInterceptorTest extends ConnectionManagerTestUtils {
   
       private LocalXAResourceInsertionInterceptor localXAResourceInsertionInterceptor;
       private LocalTransaction localTransaction;
   
       protected void setUp() throws Exception {
  +        super.setUp();
           localXAResourceInsertionInterceptor = new LocalXAResourceInsertionInterceptor(this);
       }
   
       protected void tearDown() throws Exception {
  +        super.tearDown();
           localXAResourceInsertionInterceptor = null;
       }
   
       public void testInsertLocalXAResource() throws Exception {
  -        ManagedConnectionInfo managedConnectionInfo = new ManagedConnectionInfo(null, null);
  -        ConnectionInfo connectionInfo = new ConnectionInfo(managedConnectionInfo);
  +        ConnectionInfo connectionInfo = makeConnectionInfo();
           localXAResourceInsertionInterceptor.getConnection(connectionInfo);
  -        LocalXAResource returnedLocalXAResource = (LocalXAResource)managedConnectionInfo.getXAResource();
  +        LocalXAResource returnedLocalXAResource = (LocalXAResource)connectionInfo.getManagedConnectionInfo().getXAResource();
           assertTrue("Expected the same LocalTransaction", localTransaction == returnedLocalXAResource.localTransaction);
       }
   
       public void getConnection(ConnectionInfo connectionInfo) throws ResourceException {
  +        super.getConnection(connectionInfo);
           localTransaction = new TestLocalTransaction();
           TestManagedConnection managedConnection = new TestManagedConnection(localTransaction);
           ManagedConnectionInfo managedConnectionInfo = connectionInfo.getManagedConnectionInfo();
           managedConnectionInfo.setManagedConnection(managedConnection);
       }
   
  -    public void returnConnection(ConnectionInfo connectionInfo, ConnectionReturnAction connectionReturnAction) {
  -    }
  -
       private static class TestLocalTransaction implements LocalTransaction {
           public void begin() throws ResourceException {
           }
  @@ -119,7 +107,7 @@
   
       }
   
  -    private static class TestManagedConnection implements ManagedConnection {
  +    private static class TestManagedConnection extends TestPlainManagedConnection {
   
           private final LocalTransaction localTransaction;
   
  @@ -127,43 +115,8 @@
               this.localTransaction = localTransaction;
           }
   
  -        public Object getConnection(Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException {
  -            return null;
  -        }
  -
  -        public void destroy() throws ResourceException {
  -        }
  -
  -        public void cleanup() throws ResourceException {
  -        }
  -
  -        public void associateConnection(Object connection) throws ResourceException {
  -        }
  -
  -        public void addConnectionEventListener(ConnectionEventListener listener) {
  -        }
  -
  -        public void removeConnectionEventListener(ConnectionEventListener listener) {
  -        }
  -
  -        public XAResource getXAResource() throws ResourceException {
  -            return null;
  -        }
  -
           public LocalTransaction getLocalTransaction() throws ResourceException {
               return localTransaction;
           }
  -
  -        public ManagedConnectionMetaData getMetaData() throws ResourceException {
  -            return null;
  -        }
  -
  -        public void setLogWriter(PrintWriter out) throws ResourceException {
  -        }
  -
  -        public PrintWriter getLogWriter() throws ResourceException {
  -            return null;
  -        }
  -
       }
   }
  
  
  
  1.2       +31 -24    incubator-geronimo/modules/core/src/test/org/apache/geronimo/connector/outbound/SubjectInterceptorTest.java
  
  Index: SubjectInterceptorTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/test/org/apache/geronimo/connector/outbound/SubjectInterceptorTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SubjectInterceptorTest.java	9 Dec 2003 04:17:39 -0000	1.1
  +++ SubjectInterceptorTest.java	10 Dec 2003 07:48:12 -0000	1.2
  @@ -57,9 +57,6 @@
   package org.apache.geronimo.connector.outbound;
   
   import javax.security.auth.Subject;
  -import javax.resource.ResourceException;
  -
  -import junit.framework.TestCase;
   
   /**
    *
  @@ -67,29 +64,24 @@
    * @version $Revision$ $Date$
    *
    * */
  -public class SubjectInterceptorTest extends TestCase
  -    implements SecurityDomain, ConnectionInterceptor{
  +public class SubjectInterceptorTest extends ConnectionManagerTestUtils {
   
       private SubjectInterceptor subjectInterceptor;
   
  -    private Subject subject;
  -
  -    private ConnectionInfo obtainedConnectionInfo;
  -    private ConnectionInfo returnedConnectionInfo;
  -
       protected void setUp() throws Exception {
  +        super.setUp();
           subjectInterceptor = new SubjectInterceptor(this, this);
       }
   
  -    protected void tearDown() throws Exception {
  +    protected  void tearDown() throws Exception {
  +        super.tearDown();
           subjectInterceptor = null;
  -        subject = null;
       }
   
       public void testGetConnection() throws Exception {
           subject = new Subject();
  -        ManagedConnectionInfo managedConnectionInfo = new ManagedConnectionInfo(null, null);
  -        ConnectionInfo connectionInfo = new ConnectionInfo(managedConnectionInfo);
  +        ConnectionInfo connectionInfo = makeConnectionInfo();
  +        ManagedConnectionInfo managedConnectionInfo = connectionInfo.getManagedConnectionInfo();
           subjectInterceptor.getConnection(connectionInfo);
           assertTrue("Expected call to next with same connectionInfo", connectionInfo == obtainedConnectionInfo);
           assertTrue("Expected the same managedConnectionInfo", managedConnectionInfo == connectionInfo.getManagedConnectionInfo());
  @@ -97,21 +89,36 @@
       }
   
       public void testReturnConnection() throws Exception {
  -        ConnectionInfo connectionInfo = new ConnectionInfo();
  +        ConnectionInfo connectionInfo = makeConnectionInfo();
           subjectInterceptor.returnConnection(connectionInfo, ConnectionReturnAction.RETURN_HANDLE);
           assertTrue("Expected call to next with same connectionInfo", connectionInfo == returnedConnectionInfo);
       }
   
  -
  -    public Subject getSubject() {
  -        return subject;
  +    public void testEnterWithSameSubject() throws Exception {
  +        makeSubject("foo");
  +        ConnectionInfo connectionInfo = makeConnectionInfo();
  +        managedConnection = new TestPlainManagedConnection();
  +        subjectInterceptor.getConnection(connectionInfo);
  +        //reset our test indicator
  +        obtainedConnectionInfo = null;
  +        subjectInterceptor.getConnection(connectionInfo);
  +        assertTrue("Expected connection asked for", obtainedConnectionInfo == null);
  +        assertTrue("Expected no connection returned", returnedConnectionInfo == null);
       }
   
  -    public void getConnection(ConnectionInfo connectionInfo) throws ResourceException {
  -        obtainedConnectionInfo = connectionInfo;
  +    public void testEnterWithChangedSubject() throws Exception {
  +        makeSubject("foo");
  +        ConnectionInfo connectionInfo = makeConnectionInfo();
  +        managedConnection = new TestPlainManagedConnection();
  +        subjectInterceptor.getConnection(connectionInfo);
  +        //reset our test indicator
  +        obtainedConnectionInfo = null;
  +        makeSubject("bar");
  +        subjectInterceptor.getConnection(connectionInfo);
  +        //expect re-association
  +        assertTrue("Expected connection asked for", obtainedConnectionInfo != null);
  +        //connection is returned by SubjectInterceptor
  +        assertTrue("Expected connection returned", returnedConnectionInfo != null);
       }
   
  -    public void returnConnection(ConnectionInfo connectionInfo, ConnectionReturnAction connectionReturnAction) {
  -        returnedConnectionInfo = connectionInfo;
  -    }
   }
  
  
  
  1.2       +35 -41    incubator-geronimo/modules/core/src/test/org/apache/geronimo/connector/outbound/TransactionCachingInterceptorTest.java
  
  Index: TransactionCachingInterceptorTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/test/org/apache/geronimo/connector/outbound/TransactionCachingInterceptorTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TransactionCachingInterceptorTest.java	9 Dec 2003 04:17:39 -0000	1.1
  +++ TransactionCachingInterceptorTest.java	10 Dec 2003 07:48:12 -0000	1.2
  @@ -57,10 +57,9 @@
   package org.apache.geronimo.connector.outbound;
   
   import javax.resource.ResourceException;
  -import javax.transaction.TransactionManager;
   import javax.transaction.Transaction;
  +import javax.transaction.TransactionManager;
   
  -import junit.framework.TestCase;
   import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTracker;
   import org.apache.geronimo.connector.outbound.connectiontracking.defaultimpl.DefaultTransactionContext;
   import org.apache.geronimo.transaction.manager.TransactionManagerImpl;
  @@ -71,23 +70,21 @@
    * @version $Revision$ $Date$
    *
    * */
  -public class TransactionCachingInterceptorTest extends TestCase
  -        implements ConnectionInterceptor, ConnectionTracker {
  +public class TransactionCachingInterceptorTest extends ConnectionManagerTestUtils
  +        implements ConnectionTracker {
   
       private TransactionManager transactionManager;
       private TransactionCachingInterceptor transactionCachingInterceptor;
       private DefaultTransactionContext defaultTransactionContext;
  -    private boolean gotConnection;
  -    private boolean returnedConnection;
   
       protected void setUp() throws Exception {
  +        super.setUp();
           transactionManager = new TransactionManagerImpl();
           transactionCachingInterceptor = new TransactionCachingInterceptor(this, this);
  -        gotConnection = false;
  -        returnedConnection = false;
       }
   
       protected void tearDown() throws Exception {
  +        super.tearDown();
           transactionManager = null;
           transactionCachingInterceptor = null;
       }
  @@ -96,17 +93,18 @@
           transactionManager.begin();
           Transaction transaction = transactionManager.getTransaction();
           defaultTransactionContext = new DefaultTransactionContext(transaction);
  -        ConnectionInfo connectionInfo1 = new ConnectionInfo();
  +        ConnectionInfo connectionInfo1 = makeConnectionInfo();
           transactionCachingInterceptor.getConnection(connectionInfo1);
  -        assertTrue("Expected to get an initial connection", gotConnection);
  -        assertTrue("Expected nothing returned yet", !returnedConnection);
  +        assertTrue("Expected to get an initial connection", obtainedConnectionInfo != null);
  +        assertTrue("Expected nothing returned yet", returnedConnectionInfo == null);
           assertTrue("Expected the same ManagedConnectionInfo in the TransactionContext as was returned",
  -                connectionInfo1.getManagedConnectionInfo() == defaultTransactionContext.getManagedConnectionInfo(transactionCachingInterceptor));
  -        gotConnection = false;
  +                connectionInfo1.getManagedConnectionInfo()
  +                == defaultTransactionContext.getManagedConnectionInfo(transactionCachingInterceptor));
  +        obtainedConnectionInfo = null;
           ConnectionInfo connectionInfo2 = new ConnectionInfo();
           transactionCachingInterceptor.getConnection(connectionInfo2);
  -        assertTrue("Expected to not get a second connection", !gotConnection);
  -        assertTrue("Expected nothing returned yet", !returnedConnection);
  +        assertTrue("Expected to not get a second connection", obtainedConnectionInfo == null);
  +        assertTrue("Expected nothing returned yet", returnedConnectionInfo == null);
           assertTrue("Expected the same ManagedConnectionInfo in both ConnectionInfos",
                   connectionInfo1.getManagedConnectionInfo() == connectionInfo2.getManagedConnectionInfo());
           assertTrue("Expected the same ManagedConnectionInfo in the TransactionContext as was returned",
  @@ -115,24 +113,24 @@
           //we didn't create any handles, so the "ManagedConnection" should be returned.
           assertTrue("Expected TransactionContext to report active", defaultTransactionContext.isActive());
           transactionManager.commit();
  -        assertTrue("Expected connection to be returned", returnedConnection);
  +        assertTrue("Expected connection to be returned", returnedConnectionInfo != null);
           assertTrue("Expected TransactionContext to report inactive", !defaultTransactionContext.isActive());
   
       }
   
       public void testGetConnectionOutsideTransaction() throws Exception {
           defaultTransactionContext = new DefaultTransactionContext(null);
  -        ConnectionInfo connectionInfo1 = new ConnectionInfo();
  +        ConnectionInfo connectionInfo1 = makeConnectionInfo();
           transactionCachingInterceptor.getConnection(connectionInfo1);
  -        assertTrue("Expected to get an initial connection", gotConnection);
  -        assertTrue("Expected nothing returned yet", !returnedConnection);
  +        assertTrue("Expected to get an initial connection", obtainedConnectionInfo != null);
  +        assertTrue("Expected nothing returned yet", returnedConnectionInfo == null);
           assertTrue("Expected no ManagedConnectionInfo in the TransactionContext",
                   null == defaultTransactionContext.getManagedConnectionInfo(transactionCachingInterceptor));
  -        gotConnection = false;
  -        ConnectionInfo connectionInfo2 = new ConnectionInfo();
  +        obtainedConnectionInfo = null;
  +        ConnectionInfo connectionInfo2 = makeConnectionInfo();
           transactionCachingInterceptor.getConnection(connectionInfo2);
  -        assertTrue("Expected to get a second connection", gotConnection);
  -        assertTrue("Expected nothing returned yet", !returnedConnection);
  +        assertTrue("Expected to get a second connection", obtainedConnectionInfo != null);
  +        assertTrue("Expected nothing returned yet", returnedConnectionInfo == null);
           assertTrue("Expected different ManagedConnectionInfo in both ConnectionInfos",
                   connectionInfo1.getManagedConnectionInfo() != connectionInfo2.getManagedConnectionInfo());
           assertTrue("Expected no ManagedConnectionInfo in the TransactionContext",
  @@ -140,10 +138,10 @@
           //we didn't create any handles, so the "ManagedConnection" should be returned.
           assertTrue("Expected TransactionContext to report inactive", !defaultTransactionContext.isActive());
           transactionCachingInterceptor.returnConnection(connectionInfo1, ConnectionReturnAction.RETURN_HANDLE);
  -        assertTrue("Expected connection to be returned", returnedConnection);
  -        returnedConnection = false;
  +        assertTrue("Expected connection to be returned", returnedConnectionInfo != null);
  +        returnedConnectionInfo = null;
           transactionCachingInterceptor.returnConnection(connectionInfo2, ConnectionReturnAction.RETURN_HANDLE);
  -        assertTrue("Expected connection to be returned", returnedConnection);
  +        assertTrue("Expected connection to be returned", returnedConnectionInfo != null);
   
           assertTrue("Expected TransactionContext to report inactive", !defaultTransactionContext.isActive());
   
  @@ -154,19 +152,19 @@
           Transaction transaction1 = transactionManager.getTransaction();
           defaultTransactionContext = new DefaultTransactionContext(transaction1);
           DefaultTransactionContext defaultTransactionContext1 = defaultTransactionContext;
  -        ConnectionInfo connectionInfo1 = new ConnectionInfo();
  +        ConnectionInfo connectionInfo1 = makeConnectionInfo();
           transactionCachingInterceptor.getConnection(connectionInfo1);
  -        gotConnection = false;
  +        obtainedConnectionInfo = null;
   
           //start a second transaction
           transactionManager.suspend();
           transactionManager.begin();
           Transaction transaction2 = transactionManager.getTransaction();
           defaultTransactionContext = new DefaultTransactionContext(transaction2);
  -        ConnectionInfo connectionInfo2 = new ConnectionInfo();
  +        ConnectionInfo connectionInfo2 = makeConnectionInfo();
           transactionCachingInterceptor.getConnection(connectionInfo2);
  -        assertTrue("Expected to get a second connection", gotConnection);
  -        assertTrue("Expected nothing returned yet", !returnedConnection);
  +        assertTrue("Expected to get a second connection", obtainedConnectionInfo != null);
  +        assertTrue("Expected nothing returned yet", returnedConnectionInfo == null);
           assertTrue("Expected different ManagedConnectionInfo in each ConnectionInfos",
                   connectionInfo1.getManagedConnectionInfo() != connectionInfo2.getManagedConnectionInfo());
           assertTrue("Expected the same ManagedConnectionInfo in the TransactionContext as was returned",
  @@ -175,28 +173,24 @@
           //we didn't create any handles, so the "ManagedConnection" should be returned.
           assertTrue("Expected TransactionContext to report active", defaultTransactionContext.isActive());
           transactionManager.commit();
  -        assertTrue("Expected connection to be returned", returnedConnection);
  +        assertTrue("Expected connection to be returned", returnedConnectionInfo != null);
           assertTrue("Expected TransactionContext to report inactive", !defaultTransactionContext.isActive());
  -        returnedConnection = false;
  +        returnedConnectionInfo = null;
           //resume first transaction
           transactionManager.resume(transaction1);
           defaultTransactionContext = defaultTransactionContext1;
           transactionManager.commit();
  -        assertTrue("Expected connection to be returned", returnedConnection);
  +        assertTrue("Expected connection to be returned", returnedConnectionInfo != null);
           assertTrue("Expected TransactionContext to report inactive", !defaultTransactionContext.isActive());
       }
   
   //interface implementations
       public void getConnection(ConnectionInfo connectionInfo) throws ResourceException {
  -        gotConnection = true;
  -        ManagedConnectionInfo managedConnectionInfo = new ManagedConnectionInfo(null, null);
  +        super.getConnection(connectionInfo);
  +        ManagedConnectionInfo managedConnectionInfo = connectionInfo.getManagedConnectionInfo();
           managedConnectionInfo.setConnectionEventListener(new GeronimoConnectionEventListener(null, managedConnectionInfo));
  -        connectionInfo.setManagedConnectionInfo(managedConnectionInfo);
       }
   
  -    public void returnConnection(ConnectionInfo connectionInfo, ConnectionReturnAction connectionReturnAction) {
  -        returnedConnection = true;
  -    }
   
       public void handleObtained(
               ConnectionTrackingInterceptor connectionTrackingInterceptor,
  
  
  
  1.2       +7 -11     incubator-geronimo/modules/core/src/test/org/apache/geronimo/connector/outbound/TransactionEnlistingInterceptorTest.java
  
  Index: TransactionEnlistingInterceptorTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/test/org/apache/geronimo/connector/outbound/TransactionEnlistingInterceptorTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TransactionEnlistingInterceptorTest.java	9 Dec 2003 04:17:39 -0000	1.1
  +++ TransactionEnlistingInterceptorTest.java	10 Dec 2003 07:48:12 -0000	1.2
  @@ -62,7 +62,6 @@
   import javax.transaction.xa.Xid;
   import javax.transaction.xa.XAException;
   
  -import junit.framework.TestCase;
   import org.apache.geronimo.transaction.manager.TransactionManagerImpl;
   
   /**
  @@ -71,8 +70,8 @@
    * @version $Revision$ $Date$
    *
    * */
  -public class TransactionEnlistingInterceptorTest extends TestCase
  -    implements ConnectionInterceptor, XAResource {
  +public class TransactionEnlistingInterceptorTest extends ConnectionManagerTestUtils
  +    implements XAResource {
   
       private TransactionEnlistingInterceptor transactionEnlistingInterceptor;
       private TransactionManager transactionManager;
  @@ -82,11 +81,13 @@
       private boolean committed;
   
       protected void setUp() throws Exception {
  +        super.setUp();
           transactionManager = new TransactionManagerImpl();
           transactionEnlistingInterceptor = new TransactionEnlistingInterceptor(this, transactionManager);
       }
   
       protected void tearDown() throws Exception {
  +        super.tearDown();
           transactionManager = null;
           transactionEnlistingInterceptor = null;
           started = false;
  @@ -96,7 +97,7 @@
       }
   
       public void testNoTransaction() throws Exception {
  -        ConnectionInfo connectionInfo = getConnectionInfo();
  +        ConnectionInfo connectionInfo = makeConnectionInfo();
           transactionEnlistingInterceptor.getConnection(connectionInfo);
           assertTrue("Expected not started", !started);
           assertTrue("Expected not ended", !ended);
  @@ -106,7 +107,7 @@
       }
   
       public void testTransaction() throws Exception {
  -        ConnectionInfo connectionInfo = getConnectionInfo();
  +        ConnectionInfo connectionInfo = makeConnectionInfo();
           transactionManager.begin();
           transactionEnlistingInterceptor.getConnection(connectionInfo);
           assertTrue("Expected started", started);
  @@ -118,11 +119,6 @@
           assertTrue("Expected returned", returned);
           transactionManager.commit();
           assertTrue("Expected committed", committed);
  -    }
  -
  -    private ConnectionInfo getConnectionInfo() {
  -        ManagedConnectionInfo managedConnectionInfo = new ManagedConnectionInfo(null, null);
  -        return new ConnectionInfo(managedConnectionInfo);
       }
   
       //ConnectionInterceptor
  
  
  
  1.2       +11 -59    incubator-geronimo/modules/core/src/test/org/apache/geronimo/connector/outbound/XAResourceInsertionInterceptorTest.java
  
  Index: XAResourceInsertionInterceptorTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/test/org/apache/geronimo/connector/outbound/XAResourceInsertionInterceptorTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XAResourceInsertionInterceptorTest.java	9 Dec 2003 04:17:39 -0000	1.1
  +++ XAResourceInsertionInterceptorTest.java	10 Dec 2003 07:48:12 -0000	1.2
  @@ -56,20 +56,10 @@
   
   package org.apache.geronimo.connector.outbound;
   
  -import java.io.PrintWriter;
  -
   import javax.resource.ResourceException;
  -import javax.resource.spi.ManagedConnection;
  -import javax.resource.spi.ConnectionRequestInfo;
  -import javax.resource.spi.ConnectionEventListener;
  -import javax.resource.spi.LocalTransaction;
  -import javax.resource.spi.ManagedConnectionMetaData;
  +import javax.transaction.xa.XAException;
   import javax.transaction.xa.XAResource;
   import javax.transaction.xa.Xid;
  -import javax.transaction.xa.XAException;
  -import javax.security.auth.Subject;
  -
  -import junit.framework.TestCase;
   
   /**
    *
  @@ -77,36 +67,30 @@
    * @version $Revision$ $Date$
    *
    * */
  -public class XAResourceInsertionInterceptorTest extends TestCase
  -    implements ConnectionInterceptor {
  +public class XAResourceInsertionInterceptorTest extends ConnectionManagerTestUtils
  +    {
   
       private XAResourceInsertionInterceptor xaResourceInsertionInterceptor;
       private XAResource xaResource;
   
       protected void setUp() throws Exception {
  +        super.setUp();
           xaResourceInsertionInterceptor = new XAResourceInsertionInterceptor(this);
       }
   
       protected void tearDown() throws Exception {
  +        super.tearDown();
           xaResourceInsertionInterceptor = null;
       }
   
       public void testInsertXAResource() throws Exception {
  -        ManagedConnectionInfo managedConnectionInfo = new ManagedConnectionInfo(null, null);
  -        ConnectionInfo connectionInfo = new ConnectionInfo(managedConnectionInfo);
  -        xaResourceInsertionInterceptor.getConnection(connectionInfo);
  -        assertTrue("Expected the same XAResource", xaResource == managedConnectionInfo.getXAResource());
  -    }
  -
  -    public void getConnection(ConnectionInfo connectionInfo) throws ResourceException {
  +        ConnectionInfo connectionInfo = makeConnectionInfo();
           xaResource = new TestXAResource();
  -        ManagedConnection managedConnection = new TestManagedConnection(xaResource);
  -        ManagedConnectionInfo managedConnectionInfo = connectionInfo.getManagedConnectionInfo();
  -        managedConnectionInfo.setManagedConnection(managedConnection);
  +        managedConnection = new TestManagedConnection(xaResource);
  +        xaResourceInsertionInterceptor.getConnection(connectionInfo);
  +        assertTrue("Expected the same XAResource", xaResource == connectionInfo.getManagedConnectionInfo().getXAResource());
       }
   
  -    public void returnConnection(ConnectionInfo connectionInfo, ConnectionReturnAction connectionReturnAction) {
  -    }
   
       private static class TestXAResource implements XAResource {
           public void commit(Xid xid, boolean onePhase) throws XAException {
  @@ -146,50 +130,18 @@
   
       }
   
  -    private static class TestManagedConnection implements ManagedConnection {
  +    private static class TestManagedConnection extends TestPlainManagedConnection {
   
           private final XAResource xaResource;
   
           public TestManagedConnection(XAResource xaResource) {
               this.xaResource = xaResource;
           }
  -        public Object getConnection(Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException {
  -            return null;
  -        }
  -
  -        public void destroy() throws ResourceException {
  -        }
  -
  -        public void cleanup() throws ResourceException {
  -        }
  -
  -        public void associateConnection(Object connection) throws ResourceException {
  -        }
  -
  -        public void addConnectionEventListener(ConnectionEventListener listener) {
  -        }
  -
  -        public void removeConnectionEventListener(ConnectionEventListener listener) {
  -        }
   
           public XAResource getXAResource() throws ResourceException {
               return xaResource;
           }
   
  -        public LocalTransaction getLocalTransaction() throws ResourceException {
  -            return null;
  -        }
  -
  -        public ManagedConnectionMetaData getMetaData() throws ResourceException {
  -            return null;
  -        }
  -
  -        public void setLogWriter(PrintWriter out) throws ResourceException {
  -        }
  -
  -        public PrintWriter getLogWriter() throws ResourceException {
  -            return null;
  -        }
   
       }
   }
  
  
  
  1.1                  incubator-geronimo/modules/core/src/test/org/apache/geronimo/connector/outbound/ConnectionManagerTestUtils.java
  
  Index: ConnectionManagerTestUtils.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  package org.apache.geronimo.connector.outbound;
  
  import java.security.Principal;
  import java.util.Set;
  import java.io.PrintWriter;
  
  import javax.security.auth.Subject;
  import javax.resource.ResourceException;
  import javax.resource.spi.ManagedConnection;
  import javax.resource.spi.ConnectionRequestInfo;
  import javax.resource.spi.ConnectionEventListener;
  import javax.resource.spi.LocalTransaction;
  import javax.resource.spi.ManagedConnectionMetaData;
  import javax.resource.spi.DissociatableManagedConnection;
  import javax.transaction.xa.XAResource;
  
  import junit.framework.TestCase;
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2003/12/10 07:48:12 $
   *
   * */
  public class ConnectionManagerTestUtils extends TestCase implements SecurityDomain, ConnectionInterceptor {
      protected Subject subject;
      protected ConnectionInfo obtainedConnectionInfo;
      protected ConnectionInfo returnedConnectionInfo;
      protected ManagedConnection managedConnection;
  
      protected void setUp() throws Exception {
      }
  
      protected void tearDown() throws Exception {
          subject = null;
          obtainedConnectionInfo = null;
          returnedConnectionInfo = null;
          managedConnection = null;
      }
  
      public void testNothing() throws Exception {
      }
  
      //SecurityDomain implementation
      public Subject getSubject() {
          return subject;
      }
  
      //ConnectorInterceptor implementation
      public void getConnection(ConnectionInfo connectionInfo) throws ResourceException {
          ManagedConnectionInfo managedConnectionInfo = connectionInfo.getManagedConnectionInfo();
          managedConnectionInfo.setManagedConnection(managedConnection);
          obtainedConnectionInfo = connectionInfo;
      }
  
      public void returnConnection(ConnectionInfo connectionInfo, ConnectionReturnAction connectionReturnAction) {
          returnedConnectionInfo = connectionInfo;
      }
  
      protected void makeSubject(String principalName) {
          subject = new Subject();
          Set principals = subject.getPrincipals();
          principals.add(new TestPrincipal(principalName));
      }
  
      protected ConnectionInfo makeConnectionInfo() {
          ManagedConnectionInfo managedConnectionInfo = new ManagedConnectionInfo(null, null);
          return new ConnectionInfo(managedConnectionInfo);
      }
  
      private static class TestPrincipal implements Principal {
  
          private final String name;
  
          public TestPrincipal(String name) {
              this.name = name;
          }
          public String getName() {
              return name;
          }
  
      }
  
      protected static class TestPlainManagedConnection implements ManagedConnection {
          public Object getConnection(Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException {
              return null;
          }
  
          public void destroy() throws ResourceException {
          }
  
          public void cleanup() throws ResourceException {
          }
  
          public void associateConnection(Object connection) throws ResourceException {
          }
  
          public void addConnectionEventListener(ConnectionEventListener listener) {
          }
  
          public void removeConnectionEventListener(ConnectionEventListener listener) {
          }
  
          public XAResource getXAResource() throws ResourceException {
              return null;
          }
  
          public LocalTransaction getLocalTransaction() throws ResourceException {
              return null;
          }
  
          public ManagedConnectionMetaData getMetaData() throws ResourceException {
              return null;
          }
  
          public void setLogWriter(PrintWriter out) throws ResourceException {
          }
  
          public PrintWriter getLogWriter() throws ResourceException {
              return null;
          }
  
      }
  
      protected static class TestDissociatableManagedConnection implements ManagedConnection, DissociatableManagedConnection {
          public void dissociateConnections() throws ResourceException {
          }
  
          public Object getConnection(Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException {
              return null;
          }
  
          public void destroy() throws ResourceException {
          }
  
          public void cleanup() throws ResourceException {
          }
  
          public void associateConnection(Object connection) throws ResourceException {
          }
  
          public void addConnectionEventListener(ConnectionEventListener listener) {
          }
  
          public void removeConnectionEventListener(ConnectionEventListener listener) {
          }
  
          public XAResource getXAResource() throws ResourceException {
              return null;
          }
  
          public LocalTransaction getLocalTransaction() throws ResourceException {
              return null;
          }
  
          public ManagedConnectionMetaData getMetaData() throws ResourceException {
              return null;
          }
  
          public void setLogWriter(PrintWriter out) throws ResourceException {
          }
  
          public PrintWriter getLogWriter() throws ResourceException {
              return null;
          }
  
      }
  }
  
  
  
  1.4       +8 -17     incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/ConnectionManagerDeployment.java
  
  Index: ConnectionManagerDeployment.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/ConnectionManagerDeployment.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ConnectionManagerDeployment.java	9 Dec 2003 04:16:25 -0000	1.3
  +++ ConnectionManagerDeployment.java	10 Dec 2003 07:48:12 -0000	1.4
  @@ -63,11 +63,9 @@
   
   import org.apache.geronimo.connector.deployment.ConnectionManagerFactory;
   import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTracker;
  -import org.apache.geronimo.kernel.service.AbstractManagedObject;
  -import org.apache.geronimo.kernel.service.GeronimoMBeanTarget;
  -import org.apache.geronimo.kernel.service.GeronimoMBeanContext;
  -import org.apache.geronimo.kernel.jmx.MBeanProxyFactory;
   import org.apache.geronimo.kernel.jmx.JMXUtil;
  +import org.apache.geronimo.kernel.service.GeronimoMBeanContext;
  +import org.apache.geronimo.kernel.service.GeronimoMBeanTarget;
   
   /**
    * ConnectionManagerDeployment is an mbean that sets up a ProxyConnectionManager
  @@ -152,16 +150,14 @@
               }
           }
           if (useSubject || useConnectionRequestInfo) {
  -            stack =
  -                    new MultiPoolConnectionInterceptor(
  +            stack = new MultiPoolConnectionInterceptor(
                               stack,
                               maxSize,
                               blockingTimeout,
                               useSubject,
                               useConnectionRequestInfo);
           } else {
  -            stack =
  -                    new SinglePoolConnectionInterceptor(
  +            stack = new SinglePoolConnectionInterceptor(
                               stack,
                               null,
                               null,
  @@ -172,19 +168,14 @@
               stack = new SubjectInterceptor(stack, securityDomain);
           }
           if (useTransactions) {
  -            stack =
  -                    new TransactionEnlistingInterceptor(stack, transactionManager);
  +            stack = new TransactionEnlistingInterceptor(stack, transactionManager);
               if (useTransactionCaching) {
  -                stack =
  -                        new TransactionCachingInterceptor(
  -                                stack,
  -                                connectionTracker);
  +                stack = new TransactionCachingInterceptor(stack, connectionTracker);
               }
           }
           stack = new ConnectionHandleInterceptor(stack);
           if (connectionTracker != null) {
  -            stack =
  -                    new ConnectionTrackingInterceptor(
  +            stack = new ConnectionTrackingInterceptor(
                               stack,
                               jndiName,
                               connectionTracker,
  
  
  
  1.2       +7 -3      incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/ConnectionTrackingInterceptor.java
  
  Index: ConnectionTrackingInterceptor.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/ConnectionTrackingInterceptor.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ConnectionTrackingInterceptor.java	9 Dec 2003 04:15:20 -0000	1.1
  +++ ConnectionTrackingInterceptor.java	10 Dec 2003 07:48:12 -0000	1.2
  @@ -113,11 +113,12 @@
               //should probably check to see if subjects are consistent,
               //and if not raise an exception.  Also need to check if
               //the spec says anything about this.
  -            return;
  +            //this is wrong
           }
           if (securityDomain == null) {
  -            return;
  +            return;    //this is wrong: need a "bouncing" subjectInterceptor
           }
  +
           Subject currentSubject = null;
           try {
               currentSubject = securityDomain.getSubject();
  @@ -130,6 +131,8 @@
           }
           for (Iterator i = connectionInfos.iterator(); i.hasNext();) {
               ConnectionInfo connectionInfo = (ConnectionInfo) i.next();
  +            getConnection(connectionInfo);
  +            /*
               ManagedConnectionInfo originalManagedConnectionInfo = connectionInfo.getManagedConnectionInfo();
               //Is this check correct?  perhaps more credentials got
               //added without changing the relevant credential we use.
  @@ -152,6 +155,7 @@
                   //process the removal of the handle from the previous mc
                   returnConnection(returningConnectionInfo, ConnectionReturnAction.RETURN_HANDLE);
               }
  +            */
           }
   
       }
  
  
  
  1.4       +30 -6     incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/SubjectInterceptor.java
  
  Index: SubjectInterceptor.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/SubjectInterceptor.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SubjectInterceptor.java	9 Dec 2003 04:16:25 -0000	1.3
  +++ SubjectInterceptor.java	10 Dec 2003 07:48:12 -0000	1.4
  @@ -80,15 +80,39 @@
       }
   
       public void getConnection(ConnectionInfo connectionInfo) throws ResourceException {
  -        Subject subject = null;
  +        Subject currentSubject = null;
           try {
  -            subject = securityDomain.getSubject();
  +            currentSubject = securityDomain.getSubject();
           } catch (SecurityException e) {
               throw new ResourceException("Can not obtain Subject for login", e);
           }
  -        ManagedConnectionInfo mci = connectionInfo.getManagedConnectionInfo();
  -        mci.setSubject(subject);
  -        next.getConnection(connectionInfo);
  +        assert currentSubject != null;
  +        ManagedConnectionInfo originalManagedConnectionInfo = connectionInfo.getManagedConnectionInfo();
  +        //No existing managed connection, get an appropriate one and return.
  +        if (originalManagedConnectionInfo.getManagedConnection() == null) {
  +            originalManagedConnectionInfo.setSubject(currentSubject);
  +            next.getConnection(connectionInfo);
  +        } else if (!currentSubject.equals(originalManagedConnectionInfo.getSubject())) {
  +            //existing managed connection, wrong subject: must re-associate.
  +            //make a ConnectionInfo to process removing the handle from the old mc
  +            ConnectionInfo returningConnectionInfo = new ConnectionInfo();
  +            returningConnectionInfo.setManagedConnectionInfo(originalManagedConnectionInfo);
  +            //This should decrement handle count, but not close the handle, when returnConnection is called
  +            //I'm not sure how to test/assure this.
  +            returningConnectionInfo.setConnectionHandle(connectionInfo.getConnectionHandle());
  +
  +            //make a new ManagedConnectionInfo for the mc we will ask for
  +            ManagedConnectionInfo newManagedConnectionInfo =
  +                    new ManagedConnectionInfo(
  +                            originalManagedConnectionInfo.getManagedConnectionFactory(),
  +                            originalManagedConnectionInfo.getConnectionRequestInfo());
  +            newManagedConnectionInfo.setSubject(currentSubject);
  +            connectionInfo.setManagedConnectionInfo(newManagedConnectionInfo);
  +            next.getConnection(connectionInfo);
  +            //process the removal of the handle from the previous mc
  +            returnConnection(returningConnectionInfo, ConnectionReturnAction.RETURN_HANDLE);
  +        }
  +        //otherwise, the current ManagedConnection matches the security info, we keep it.
       }
   
       public void returnConnection(