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 2004/04/08 00:37:11 UTC
cvs commit: incubator-geronimo/modules/connector/src/test/org/apache/geronimo/connector/outbound ConnectionManagerTest.java ConnectionManagerTestUtils.java ConnectionTrackingInterceptorTest.java PoolDequeTest.java
djencks 2004/04/07 15:37:11
Modified: modules/connector/src/java/org/apache/geronimo/connector/outbound
ConnectionInfo.java
ConnectionTrackingInterceptor.java
MCFConnectionInterceptor.java
ManagedConnectionInfo.java
SinglePoolConnectionInterceptor.java
modules/connector/src/test/org/apache/geronimo/connector/outbound
ConnectionManagerTest.java
ConnectionManagerTestUtils.java
ConnectionTrackingInterceptorTest.java
PoolDequeTest.java
Log:
Fix a lot of problems found by Hamilton Verissimo de Oliveira (following his suggestions for the most part)
Revision Changes Path
1.4 +19 -1 incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/ConnectionInfo.java
Index: ConnectionInfo.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/ConnectionInfo.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ConnectionInfo.java 10 Mar 2004 09:58:32 -0000 1.3
+++ ConnectionInfo.java 7 Apr 2004 22:37:10 -0000 1.4
@@ -63,10 +63,28 @@
/**
* Set the Connection value.
- * @param newConnection The new Connection value.
+ * @param connection The new Connection value.
*/
public void setConnectionHandle(Object connection) {
+ assert this.connection == null;
this.connection = connection;
+ }
+
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (obj instanceof ConnectionInfo) {
+ ConnectionInfo other = (ConnectionInfo) obj;
+ return (connection == other.connection)
+ && (mci == other.mci);
+ }
+ return false;
+ }
+
+ public int hashCode() {
+ return ((connection != null) ? connection.hashCode() : 7) ^
+ ((mci != null) ? mci.hashCode() : 7);
}
} // ConnectionInfo
1.7 +5 -2 incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/ConnectionTrackingInterceptor.java
Index: ConnectionTrackingInterceptor.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/ConnectionTrackingInterceptor.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ConnectionTrackingInterceptor.java 6 Apr 2004 00:21:21 -0000 1.6
+++ ConnectionTrackingInterceptor.java 7 Apr 2004 22:37:10 -0000 1.7
@@ -109,7 +109,7 @@
throw new ResourceException("Can not obtain Subject for login", e);
}
//TODO figure out which is right here
- assert currentSubject != null;
+ //assert currentSubject != null;
if (currentSubject == null) {
//check to see if mci.getSubject() is null?
return;
@@ -132,10 +132,13 @@
ManagedConnection managedConnection = managedConnectionInfo.getManagedConnection();
if (managedConnection instanceof DissociatableManagedConnection
&& managedConnectionInfo.isFirstConnectionInfo(connectionInfo)) {
+ int size = connectionInfos.size();
i.remove();
+ assert size - 1 == connectionInfos.size();
((DissociatableManagedConnection) managedConnection).dissociateConnections();
managedConnectionInfo.clearConnectionHandles();
returnConnection(connectionInfo, ConnectionReturnAction.RETURN_HANDLE);
+ assert size - 1 == connectionInfos.size();
}
}
}
1.4 +2 -1 incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/MCFConnectionInterceptor.java
Index: MCFConnectionInterceptor.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/MCFConnectionInterceptor.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- MCFConnectionInterceptor.java 10 Mar 2004 09:58:32 -0000 1.3
+++ MCFConnectionInterceptor.java 7 Apr 2004 22:37:10 -0000 1.4
@@ -43,6 +43,7 @@
mci.setManagedConnection(mc);
GeronimoConnectionEventListener listener = new GeronimoConnectionEventListener(head.getStack(), mci);
mci.setConnectionEventListener(listener);
+ mc.addConnectionEventListener(listener);
}
public void returnConnection(
1.6 +1 -0 incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/ManagedConnectionInfo.java
Index: ManagedConnectionInfo.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/ManagedConnectionInfo.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ManagedConnectionInfo.java 6 Apr 2004 00:21:21 -0000 1.5
+++ ManagedConnectionInfo.java 7 Apr 2004 22:37:10 -0000 1.6
@@ -79,6 +79,7 @@
}
public void setManagedConnection(ManagedConnection managedConnection) {
+ assert this.managedConnection == null;
this.managedConnection = managedConnection;
}
1.4 +3 -17 incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/SinglePoolConnectionInterceptor.java
Index: SinglePoolConnectionInterceptor.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/SinglePoolConnectionInterceptor.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SinglePoolConnectionInterceptor.java 10 Mar 2004 09:58:32 -0000 1.3
+++ SinglePoolConnectionInterceptor.java 7 Apr 2004 22:37:10 -0000 1.4
@@ -39,7 +39,7 @@
*/
public class SinglePoolConnectionInterceptor implements ConnectionInterceptor {
- private static Log log = LogFactory.getLog(GeronimoConnectionEventListener.class.getName());
+ private static Log log = LogFactory.getLog(SinglePoolConnectionInterceptor.class.getName());
private final ConnectionInterceptor next;
@@ -84,7 +84,7 @@
}
return;
} else {
- newMCI = (ManagedConnectionInfo) pool.removeFirst();
+ newMCI = pool.removeLast();
} // end of else
try {
ManagedConnection matchedMC =
@@ -164,7 +164,7 @@
} else {
synchronized (pool) {
mci.setLastUsed(System.currentTimeMillis());
- pool.addFirst(mci);
+ pool.addLast(mci);
}
} // end of else
@@ -188,20 +188,6 @@
return first > last;
}
- public ManagedConnectionInfo removeFirst() {
- if (isEmpty()) {
- throw new IllegalStateException("deque is empty");
- }
- return deque[first++];
- }
-
- public void addFirst(ManagedConnectionInfo mci) {
- if (first == 0) {
- throw new IllegalStateException("deque is at first element already");
- }
-
- deque[--first] = mci;
- }
public void addLast(ManagedConnectionInfo mci) {
if (last == deque.length - 1) {
1.8 +3 -6 incubator-geronimo/modules/connector/src/test/org/apache/geronimo/connector/outbound/ConnectionManagerTest.java
Index: ConnectionManagerTest.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/connector/src/test/org/apache/geronimo/connector/outbound/ConnectionManagerTest.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ConnectionManagerTest.java 6 Apr 2004 00:21:21 -0000 1.7
+++ ConnectionManagerTest.java 7 Apr 2004 22:37:10 -0000 1.8
@@ -34,6 +34,7 @@
import org.apache.geronimo.connector.outbound.connectiontracking.DefaultInterceptor;
import org.apache.geronimo.kernel.Kernel;
import org.apache.geronimo.security.bridge.RealmBridge;
+import org.apache.geronimo.security.ContextManager;
import org.apache.geronimo.transaction.manager.TransactionManagerImpl;
import org.apache.geronimo.transaction.InstanceContext;
import org.apache.geronimo.transaction.TransactionContext;
@@ -62,7 +63,6 @@
//dependencies
protected RealmBridge realmBridge = this;
protected ConnectionTrackingCoordinator connectionTrackingCoordinator;
- protected Kernel kernel;
protected TransactionManager transactionManager;
protected ConnectionManagerDeployment connectionManagerDeployment;
@@ -78,11 +78,10 @@
protected void setUp() throws Exception {
connectionTrackingCoordinator = new ConnectionTrackingCoordinator();
- kernel = new Kernel("test.kernel", "testdomain");
- kernel.boot();
transactionManager = new TransactionManagerImpl();
mockManagedConnectionFactory = new MockManagedConnectionFactory();
subject = new Subject();
+ ContextManager.setCurrentCaller(subject);
connectionManagerDeployment = new ConnectionManagerDeployment(useConnectionRequestInfo,
useSubject,
useTransactionCaching,
@@ -101,8 +100,6 @@
protected void tearDown() throws Exception {
connectionTrackingCoordinator = null;
- kernel.shutdown();
- kernel = null;
transactionManager = null;
mockManagedConnectionFactory = null;
connectionManagerDeployment = null;
1.5 +4 -2 incubator-geronimo/modules/connector/src/test/org/apache/geronimo/connector/outbound/ConnectionManagerTestUtils.java
Index: ConnectionManagerTestUtils.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/connector/src/test/org/apache/geronimo/connector/outbound/ConnectionManagerTestUtils.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ConnectionManagerTestUtils.java 6 Apr 2004 00:21:21 -0000 1.4
+++ ConnectionManagerTestUtils.java 7 Apr 2004 22:37:10 -0000 1.5
@@ -67,7 +67,9 @@
//ConnectorInterceptor implementation
public void getConnection(ConnectionInfo connectionInfo) throws ResourceException {
ManagedConnectionInfo managedConnectionInfo = connectionInfo.getManagedConnectionInfo();
- managedConnectionInfo.setManagedConnection(managedConnection);
+ if (managedConnectionInfo.getManagedConnection() == null) {
+ managedConnectionInfo.setManagedConnection(managedConnection);
+ }
obtainedConnectionInfo = connectionInfo;
}
1.5 +9 -4 incubator-geronimo/modules/connector/src/test/org/apache/geronimo/connector/outbound/ConnectionTrackingInterceptorTest.java
Index: ConnectionTrackingInterceptorTest.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/connector/src/test/org/apache/geronimo/connector/outbound/ConnectionTrackingInterceptorTest.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ConnectionTrackingInterceptorTest.java 10 Mar 2004 09:58:34 -0000 1.4
+++ ConnectionTrackingInterceptorTest.java 7 Apr 2004 22:37:10 -0000 1.5
@@ -127,9 +127,10 @@
public void testExitWithDissociatableConnection() throws Exception {
managedConnection = new TestDissociatableManagedConnection();
testEnterWithSameSubject();
+ assertEquals("Expected one info in connectionInfos", 1, connectionInfos.size());
connectionTrackingInterceptor.exit(connectionInfos, unshareable);
assertTrue("Expected connection returned", returnedConnectionInfo != null);
- assertEquals("Expected no infos in connectionInfos", connectionInfos.size(), 0);
+ assertEquals("Expected no infos in connectionInfos", 0, connectionInfos.size());
}
//ConnectionTracker interface
@@ -157,8 +158,12 @@
ManagedConnectionInfo managedConnectionInfo = connectionInfo.getManagedConnectionInfo();
managedConnectionInfo.setConnectionEventListener(new GeronimoConnectionEventListener(null, managedConnectionInfo));
managedConnectionInfo.setSubject(subject);
- managedConnectionInfo.setManagedConnection(managedConnection);
- connectionInfo.setConnectionHandle(new Object());
+ if (managedConnectionInfo.getManagedConnection() == null) {
+ managedConnectionInfo.setManagedConnection(managedConnection);
+ }
+ if (connectionInfo.getConnectionHandle() == null) {
+ connectionInfo.setConnectionHandle(new Object());
+ }
managedConnectionInfo.addConnectionHandle(connectionInfo);
}
1.4 +0 -16 incubator-geronimo/modules/connector/src/test/org/apache/geronimo/connector/outbound/PoolDequeTest.java
Index: PoolDequeTest.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/connector/src/test/org/apache/geronimo/connector/outbound/PoolDequeTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- PoolDequeTest.java 10 Mar 2004 09:58:34 -0000 1.3
+++ PoolDequeTest.java 7 Apr 2004 22:37:10 -0000 1.4
@@ -44,22 +44,6 @@
}
}
- public void testFillAndEmptyFirst() throws Exception {
- SinglePoolConnectionInterceptor.PoolDeque pool = new SinglePoolConnectionInterceptor.PoolDeque(MAX_SIZE);
- for (int i = 0; i < MAX_SIZE; i++) {
- pool.addLast(new ManagedConnectionInfo(null, null));
- }
- ManagedConnectionInfo[] mcis = new ManagedConnectionInfo[MAX_SIZE];
- for (int i = 0; i < MAX_SIZE; i++) {
- mcis[i] = pool.removeFirst();
- }
- assertTrue("Expected pool to be empty!", pool.isEmpty());
-
- for (int i = 0; i < MAX_SIZE; i++) {
- pool.addFirst(mcis[i]);
- }
-
- }
public void testFillAndEmptyLast() throws Exception {
SinglePoolConnectionInterceptor.PoolDeque pool = new SinglePoolConnectionInterceptor.PoolDeque(MAX_SIZE);