[jboss-cvs] JBossAS SVN: r110321 - in projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager: unit and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Jan 11 08:06:22 EST 2011
Author: maeste
Date: 2011-01-11 08:06:21 -0500 (Tue, 11 Jan 2011)
New Revision: 110321
Removed:
projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/unit/nontx/
Modified:
projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/tx/TxConnectionManagerTestCase.java
projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/tx/XATxConnectionManagerTestCase.java
projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/unit/AbstractConnectionManagerTestCase.java
Log:
removing testGetManagedConnections() from abstractConnectionManagerTestCase, moving it on concrete calsses test cases. Moreover we are now verifying that the method is injecting correct connection listener
Modified: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/tx/TxConnectionManagerTestCase.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/tx/TxConnectionManagerTestCase.java 2011-01-11 12:44:57 UTC (rev 110320)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/tx/TxConnectionManagerTestCase.java 2011-01-11 13:06:21 UTC (rev 110321)
@@ -27,6 +27,8 @@
import org.jboss.jca.core.connectionmanager.common.MockConnectionRequestInfo;
import org.jboss.jca.core.connectionmanager.common.MockHandle;
import org.jboss.jca.core.connectionmanager.common.MockManagedConnectionFactory;
+import org.jboss.jca.core.connectionmanager.listener.ConnectionListener;
+import org.jboss.jca.core.connectionmanager.listener.TxConnectionListener;
import org.jboss.jca.core.connectionmanager.pool.api.Pool;
import org.jboss.jca.core.connectionmanager.pool.api.PoolConfiguration;
import org.jboss.jca.core.connectionmanager.pool.api.PoolFactory;
@@ -39,6 +41,7 @@
import javax.resource.spi.ManagedConnectionFactory;
import javax.resource.spi.TransactionSupport.TransactionSupportLevel;
+import javax.security.auth.Subject;
import javax.transaction.RollbackException;
import javax.transaction.TransactionManager;
@@ -47,6 +50,7 @@
import org.junit.Test;
import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsInstanceOf.instanceOf;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
@@ -271,6 +275,30 @@
}
/**
+ * connectionListenerInjectedIntoManagedConnectionShouldBeNoTx
+ * @throws Exception in case of error and test fail
+ */
+ @Test
+ public void connectionListenerInjectedIntoManagedConnectionShouldBeNoTx() throws Exception
+ {
+ ConnectionListener listener = null;
+
+ TxConnectionManagerImpl txCm = ((TxConnectionManagerImpl) txConnectionManager);
+
+ Subject subject = null;
+
+ if (txCm.getSubjectFactory() != null && txCm.getSecurityDomainJndiName() != null)
+ {
+ subject = txCm.getSubjectFactory().createSubject(txCm.getSecurityDomainJndiName());
+ }
+
+ listener = txCm.getManagedConnection(subject, new MockConnectionRequestInfo());
+
+ assertNotNull(listener);
+ assertThat(listener, instanceOf(TxConnectionListener.class));
+ }
+
+ /**
* Lifecycle start, before the suite is executed
* @throws Throwable throwable exception
*/
Modified: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/tx/XATxConnectionManagerTestCase.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/tx/XATxConnectionManagerTestCase.java 2011-01-11 12:44:57 UTC (rev 110320)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/tx/XATxConnectionManagerTestCase.java 2011-01-11 13:06:21 UTC (rev 110321)
@@ -26,6 +26,8 @@
import org.jboss.jca.core.connectionmanager.common.MockConnectionRequestInfo;
import org.jboss.jca.core.connectionmanager.common.MockHandle;
import org.jboss.jca.core.connectionmanager.common.MockManagedConnectionFactory;
+import org.jboss.jca.core.connectionmanager.listener.ConnectionListener;
+import org.jboss.jca.core.connectionmanager.listener.TxConnectionListener;
import org.jboss.jca.core.connectionmanager.pool.api.Pool;
import org.jboss.jca.core.connectionmanager.pool.api.PoolConfiguration;
import org.jboss.jca.core.connectionmanager.pool.api.PoolFactory;
@@ -39,6 +41,7 @@
import javax.resource.spi.ConnectionManager;
import javax.resource.spi.ManagedConnectionFactory;
import javax.resource.spi.TransactionSupport.TransactionSupportLevel;
+import javax.security.auth.Subject;
import javax.transaction.RollbackException;
import javax.transaction.TransactionManager;
@@ -47,6 +50,7 @@
import org.junit.Test;
import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsInstanceOf.instanceOf;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
@@ -229,6 +233,30 @@
}
/**
+ * connectionListenerInjectedIntoManagedConnectionShouldBeNoTx
+ * @throws Exception in case of error and test fail
+ */
+ @Test
+ public void connectionListenerInjectedIntoManagedConnectionShouldBeTx() throws Exception
+ {
+ ConnectionListener listener = null;
+
+ TxConnectionManagerImpl txCm = ((TxConnectionManagerImpl) txConnectionManager);
+
+ Subject subject = null;
+
+ if (txCm.getSubjectFactory() != null && txCm.getSecurityDomainJndiName() != null)
+ {
+ subject = txCm.getSubjectFactory().createSubject(txCm.getSecurityDomainJndiName());
+ }
+
+ listener = txCm.getManagedConnection(subject, new MockConnectionRequestInfo());
+
+ assertNotNull(listener);
+ assertThat(listener, instanceOf(TxConnectionListener.class));
+ }
+
+ /**
* Lifecycle start, before the suite is executed
* @throws Throwable throwable exception
*/
Modified: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/unit/AbstractConnectionManagerTestCase.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/unit/AbstractConnectionManagerTestCase.java 2011-01-11 12:44:57 UTC (rev 110320)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/unit/AbstractConnectionManagerTestCase.java 2011-01-11 13:06:21 UTC (rev 110321)
@@ -44,13 +44,13 @@
/**
* AbstractConnectionManagerTestCase.
*
- * @author <a href="mailto:gurkanerdogdu at yahoo.com">Gurkan Erdogdu</a>
- * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ * @author <a href="mailto:gurkanerdogdu at yahoo.com">Gurkan Erdogdu</a>
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
*/
public class AbstractConnectionManagerTestCase
{
/**
- * testPoolNotNull.
+ * testPoolNotNull.
*/
@Test
public void testPoolNotNull()
@@ -58,16 +58,16 @@
AbstractConnectionManager connectionManager = new MockConnectionManager();
assertNull(connectionManager.getPool());
- PoolConfiguration pc = new PoolConfiguration();
- PoolFactory pf = new PoolFactory();
-
+ PoolConfiguration pc = new PoolConfiguration();
+ PoolFactory pf = new PoolFactory();
+
Pool pool = pf.create(PoolStrategy.ONE_POOL, new MockManagedConnectionFactory(), pc, false);
pool.setConnectionListenerFactory(connectionManager);
connectionManager.setPool(pool);
assertNotNull(connectionManager.getPool());
}
-
+
/**
* testGetCachedConnectionManager.
*/
@@ -79,7 +79,7 @@
connectionManager.setCachedConnectionManager(new CachedConnectionManager(null));
assertNotNull(connectionManager.getCachedConnectionManager());
}
-
+
/**
* testJndiName.
*/
@@ -92,7 +92,7 @@
assertNotNull(connectionManager.getJndiName());
assertEquals("jndi_name", connectionManager.getJndiName());
}
-
+
/**
* testSecDomainJndiName.
*/
@@ -103,7 +103,7 @@
assertNull(connectionManager.getSecurityDomainJndiName());
connectionManager.setSecurityDomainJndiName("jndi_name");
assertNotNull(connectionManager.getSecurityDomainJndiName());
- assertEquals("jndi_name", connectionManager.getSecurityDomainJndiName());
+ assertEquals("jndi_name", connectionManager.getSecurityDomainJndiName());
}
/**
@@ -126,13 +126,13 @@
{
return null;
}
-
+
};
connectionManager.setSubjectFactory(fact);
assertNotNull(connectionManager.getSubjectFactory());
assertEquals(fact, connectionManager.getSubjectFactory());
}
-
+
/**
* testGetManagedConnectionFactory.
*/
@@ -143,9 +143,9 @@
assertNull(connectionManager.getManagedConnectionFactory());
MockManagedConnectionFactory mcf = new MockManagedConnectionFactory();
- PoolConfiguration pc = new PoolConfiguration();
- PoolFactory pf = new PoolFactory();
-
+ PoolConfiguration pc = new PoolConfiguration();
+ PoolFactory pf = new PoolFactory();
+
Pool pool = pf.create(PoolStrategy.ONE_POOL, mcf, pc, false);
pool.setConnectionListenerFactory(connectionManager);
connectionManager.setPool(pool);
@@ -153,7 +153,7 @@
assertNotNull(connectionManager.getManagedConnectionFactory());
assertEquals(mcf, connectionManager.getManagedConnectionFactory());
}
-
+
/**
* testAllocationRetry.
*/
@@ -165,7 +165,7 @@
connectionManager.setAllocationRetry(5);
assertEquals(5, connectionManager.getAllocationRetry());
}
-
+
/**
* setAllocationRetryInMilisec.
*/
@@ -177,8 +177,8 @@
connectionManager.setAllocationRetryWaitMillis(5000L);
assertEquals(5000L, connectionManager.getAllocationRetryWaitMillis());
}
-
-
+
+
/**
* testGetTransactionManagerInstance.
*/
@@ -188,7 +188,7 @@
AbstractConnectionManager connectionManager = new MockConnectionManager();
assertNull(connectionManager.getTransactionManager());
}
-
+
/**
* testGetManagedConnectionFactoryIsNull.
*/
@@ -199,7 +199,7 @@
connectionManager.setPool(null);
assertNull(connectionManager.getManagedConnectionFactory());
}
-
+
/**
* testGetManagedConnectionInShutdownedManager
* @throws ResourceException for exception
@@ -211,7 +211,7 @@
connectionManager.setShutDown(true);
connectionManager.getManagedConnection(null, null);
}
-
+
/**
* testAllocateConnectionPoolNull.
* @throws ResourceException for exception
@@ -223,7 +223,7 @@
connectionManager.setPool(null);
connectionManager.allocateConnection(null, null);
}
-
+
/**
* testAllocateConnectionWrongMCF.
* @throws ResourceException for exception
@@ -233,27 +233,18 @@
{
AbstractConnectionManager connectionManager = new MockConnectionManager();
- PoolConfiguration pc = new PoolConfiguration();
- PoolFactory pf = new PoolFactory();
-
+ PoolConfiguration pc = new PoolConfiguration();
+ PoolFactory pf = new PoolFactory();
+
Pool pool = pf.create(PoolStrategy.ONE_POOL, new MockManagedConnectionFactory(), pc, false);
pool.setConnectionListenerFactory(connectionManager);
connectionManager.setPool(pool);
connectionManager.allocateConnection(new MockManagedConnectionFactory(), null);
}
-
+
+
/**
- * testGetManagedConnections.
- */
- @Test
- public void testGetManagedConnections()
- {
- AbstractConnectionManager connectionManager = new MockConnectionManager();
-
- }
-
- /**
* testIdleTimeout.
* @throws Exception for exception
*/
@@ -261,9 +252,9 @@
public void testIdleTimeout() throws Exception
{
AbstractConnectionManager connectionManager = new MockConnectionManager();
-
+
}
-
+
/**
* testPartialIdleTimeout.
* @throws Exception for exception.
@@ -272,9 +263,9 @@
public void testPartialIdleTimeout() throws Exception
{
AbstractConnectionManager connectionManager = new MockConnectionManager();
-
+
}
-
+
/**
* testFillToMin.
* @throws Exception for exception
@@ -284,7 +275,7 @@
{
AbstractConnectionManager connectionManager = new MockConnectionManager();
}
-
+
/**
* testPrefillPool.
* @throws Exception for exception
@@ -294,7 +285,7 @@
{
AbstractConnectionManager connectionManager = new MockConnectionManager();
}
-
+
/**
* testNonStrictMinPool.
* @throws Exception for exception
@@ -304,7 +295,7 @@
{
AbstractConnectionManager connectionManager = new MockConnectionManager();
}
-
+
/**
* testStrictMinPool.
* @throws Exception for exception
@@ -314,7 +305,7 @@
{
AbstractConnectionManager connectionManager = new MockConnectionManager();
}
-
+
/**
* testMisConfiguredFillToMin.
* @throws Exception for exception
@@ -323,7 +314,7 @@
{
AbstractConnectionManager connectionManager = new MockConnectionManager();
}
-
+
/**
* testChangedMaximum.
* @throws Exception for exception.
@@ -333,7 +324,7 @@
{
AbstractConnectionManager connectionManager = new MockConnectionManager();
}
-
+
/**
* testAllocationRetry.
* @throws Exception for exception.
@@ -343,9 +334,9 @@
{
AbstractConnectionManager connectionManager = new MockConnectionManager();
}
-
+
/**
- * testAllocationRetryMultiThread.
+ * testAllocationRetryMultiThread.
* @throws Exception for exception
*/
public void testAllocationRetryMultiThread() throws Exception
More information about the jboss-cvs-commits
mailing list