[jboss-cvs] JBossAS SVN: r110351 - in projects/jboss-jca/trunk/core/src: test/java/org/jboss/jca/core/connectionmanager/listener and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Jan 13 09:11:49 EST 2011
Author: maeste
Date: 2011-01-13 09:11:49 -0500 (Thu, 13 Jan 2011)
New Revision: 110351
Modified:
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/listener/AbstractConnectionListener.java
projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/listener/NoTxConnectionListenerTestCase.java
Log:
testin AbstractConnectionListenerMethod throgh NoTxConnectionLister
Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/listener/AbstractConnectionListener.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/listener/AbstractConnectionListener.java 2011-01-13 14:11:03 UTC (rev 110350)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/listener/AbstractConnectionListener.java 2011-01-13 14:11:49 UTC (rev 110351)
@@ -46,13 +46,13 @@
*/
public abstract class AbstractConnectionListener implements ConnectionListener
{
- private Logger log = Logger.getLogger(getClass());
+ private final Logger log = Logger.getLogger(getClass());
/** Log trace */
protected boolean trace;
/** Connection Manager */
- private ConnectionManager cm;
+ private final ConnectionManager cm;
/** Managed connection */
private final ManagedConnection managedConnection;
@@ -70,7 +70,7 @@
private final CopyOnWriteArrayList<Object> connectionHandles = new CopyOnWriteArrayList<Object>();
/** Track by transaction or not */
- private AtomicBoolean trackByTx = new AtomicBoolean(false);
+ private final AtomicBoolean trackByTx = new AtomicBoolean(false);
/** Connection last use */
private long lastUse;
@@ -398,6 +398,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String toString()
{
StringBuffer buffer = new StringBuffer(100);
Modified: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/listener/NoTxConnectionListenerTestCase.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/listener/NoTxConnectionListenerTestCase.java 2011-01-13 14:11:03 UTC (rev 110350)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/listener/NoTxConnectionListenerTestCase.java 2011-01-13 14:11:49 UTC (rev 110351)
@@ -90,6 +90,80 @@
assertThat(((MockManagedConnection) listener.getManagedConnection()).cleanUpCalled(), is(1));
}
+ @Test
+ public void connectionErrorOccuredShouldFreeManagedCOnnection() throws Exception
+ {
+ ConnectionListener listener = null;
+
+ Subject subject = null;
+
+ if (noTxCm.getSubjectFactory() != null && noTxCm.getSecurityDomainJndiName() != null)
+ {
+ subject = noTxCm.getSubjectFactory().createSubject(noTxCm.getSecurityDomainJndiName());
+ }
+ MockConnectionRequestInfo cri = new MockConnectionRequestInfo();
+
+ Object connection = noTxCm.allocateConnection(mcf, cri);
+ listener = noTxCm.getManagedConnection(subject, cri);
+
+ assertNotNull(listener);
+ assertThat(listener, instanceOf(NoTxConnectionListener.class));
+ listener.registerConnection(connection);
+ ConnectionEvent event = new ConnectionEvent(listener.getManagedConnection(),
+ ConnectionEvent.CONNECTION_ERROR_OCCURRED);
+
+ listener.connectionErrorOccurred(event);
+ assertThat(listener.isManagedConnectionFree(), is(true));
+ }
+
+ @Test
+ public void unregisterAssociationShouldFreeManagedCOnnection() throws Exception
+ {
+ ConnectionListener listener = null;
+
+ Subject subject = null;
+
+ if (noTxCm.getSubjectFactory() != null && noTxCm.getSecurityDomainJndiName() != null)
+ {
+ subject = noTxCm.getSubjectFactory().createSubject(noTxCm.getSecurityDomainJndiName());
+ }
+ MockConnectionRequestInfo cri = new MockConnectionRequestInfo();
+
+ Object connection = noTxCm.allocateConnection(mcf, cri);
+ listener = noTxCm.getManagedConnection(subject, cri);
+
+ assertNotNull(listener);
+ assertThat(listener, instanceOf(NoTxConnectionListener.class));
+ listener.registerConnection(connection);
+
+ noTxCm.unregisterAssociation(listener, connection);
+
+ assertThat(listener.isManagedConnectionFree(), is(true));
+ }
+
+ @Test
+ public void unregisterNotYetCreatedAssociationShouldNotThrowException() throws Exception
+ {
+ ConnectionListener listener = null;
+
+ Subject subject = null;
+
+ if (noTxCm.getSubjectFactory() != null && noTxCm.getSecurityDomainJndiName() != null)
+ {
+ subject = noTxCm.getSubjectFactory().createSubject(noTxCm.getSecurityDomainJndiName());
+ }
+ MockConnectionRequestInfo cri = new MockConnectionRequestInfo();
+
+ Object connection = noTxCm.allocateConnection(mcf, cri);
+ listener = noTxCm.getManagedConnection(subject, cri);
+
+ assertNotNull(listener);
+ assertThat(listener, instanceOf(NoTxConnectionListener.class));
+
+ noTxCm.unregisterAssociation(listener, connection);
+
+ }
+
/**
* Lifecycle start, before the suite is executed
* @throws Throwable throwable exception
More information about the jboss-cvs-commits
mailing list