[jboss-cvs] JBossAS SVN: r110309 - in projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager: unit/nontx and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Jan 10 04:25:17 EST 2011
Author: maeste
Date: 2011-01-10 04:25:17 -0500 (Mon, 10 Jan 2011)
New Revision: 110309
Added:
projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/notx/NoTxConnectionManagerTestCase.java
Removed:
projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/unit/nontx/NonTxConnectionManagerTestCase.java
Log:
JBJCA-489
Copied: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/notx/NoTxConnectionManagerTestCase.java (from rev 110306, projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/unit/nontx/NonTxConnectionManagerTestCase.java)
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/notx/NoTxConnectionManagerTestCase.java (rev 0)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/notx/NoTxConnectionManagerTestCase.java 2011-01-10 09:25:17 UTC (rev 110309)
@@ -0,0 +1,142 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008-2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jca.core.connectionmanager.notx;
+
+import org.jboss.jca.core.api.connectionmanager.ConnectionManager;
+import org.jboss.jca.core.connectionmanager.ConnectionManagerFactory;
+import org.jboss.jca.core.connectionmanager.NoTxConnectionManager;
+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.NoTxConnectionListener;
+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;
+import org.jboss.jca.core.connectionmanager.pool.api.PoolStrategy;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ManagedConnectionFactory;
+import javax.resource.spi.TransactionSupport.TransactionSupportLevel;
+import javax.security.auth.Subject;
+import javax.transaction.TransactionManager;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * NonTxConnectionManagerTestCase.
+ * @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 NoTxConnectionManagerTestCase
+{
+ private static ConnectionManager connectionManager = null;
+
+ private static ManagedConnectionFactory mcf = null;
+
+ /**
+ * Initialize.
+ */
+ @BeforeClass
+ public static void init()
+ {
+ TransactionManager tm = null;
+ assertNull(tm);
+
+ mcf = new MockManagedConnectionFactory();
+ PoolConfiguration pc = new PoolConfiguration();
+ PoolFactory pf = new PoolFactory();
+
+ Pool pool = pf.create(PoolStrategy.ONE_POOL, mcf, pc, true);
+
+ ConnectionManagerFactory cmf = new ConnectionManagerFactory();
+ connectionManager = cmf.createNonTransactional(TransactionSupportLevel.NoTransaction, pool, null, null);
+ assertNotNull(connectionManager);
+
+ assertTrue(connectionManager instanceof NoTxConnectionManager);
+ }
+
+ /**
+ * Test allocate connection.
+ */
+ @Test
+ public void allocateCOnnectionShouldReturnCorrectHandle()
+ {
+ Object object = null;
+ try
+ {
+ object = connectionManager.allocateConnection(mcf, new MockConnectionRequestInfo());
+ }
+ catch (ResourceException e)
+ {
+ e.printStackTrace();
+ }
+
+ assertNotNull(object);
+ assertTrue(object instanceof MockHandle);
+ }
+
+ /**
+ * connectionListenerInjectedIntoManagedConnectionShouldBeNoTx
+ */
+ @Test
+ public void connectionListenerInjectedIntoManagedConnectionShouldBeNoTx()
+ {
+ ConnectionListener listener = null;
+ try
+ {
+ NoTxConnectionManagerImpl noTxCm = ((NoTxConnectionManagerImpl)connectionManager);
+
+ Subject subject = null;
+
+ if (noTxCm.getSubjectFactory() != null && noTxCm.getSecurityDomainJndiName() != null)
+ {
+ subject = noTxCm.getSubjectFactory().createSubject(noTxCm.getSecurityDomainJndiName());
+ }
+
+ listener = noTxCm.getManagedConnection(subject, new MockConnectionRequestInfo());
+ }
+ catch (ResourceException e)
+ {
+ e.printStackTrace();
+ }
+
+ assertNotNull(listener);
+ assertTrue(listener instanceof NoTxConnectionListener);
+ }
+
+ /**
+ * Destroy.
+ */
+ @AfterClass
+ public static void destroy()
+ {
+ connectionManager = null;
+ mcf = null;
+ }
+}
Deleted: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/unit/nontx/NonTxConnectionManagerTestCase.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/unit/nontx/NonTxConnectionManagerTestCase.java 2011-01-08 04:49:35 UTC (rev 110308)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/unit/nontx/NonTxConnectionManagerTestCase.java 2011-01-10 09:25:17 UTC (rev 110309)
@@ -1,108 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008-2009, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.jca.core.connectionmanager.unit.nontx;
-
-import org.jboss.jca.core.api.connectionmanager.ConnectionManager;
-import org.jboss.jca.core.connectionmanager.ConnectionManagerFactory;
-import org.jboss.jca.core.connectionmanager.NoTxConnectionManager;
-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.pool.api.Pool;
-import org.jboss.jca.core.connectionmanager.pool.api.PoolConfiguration;
-import org.jboss.jca.core.connectionmanager.pool.api.PoolFactory;
-import org.jboss.jca.core.connectionmanager.pool.api.PoolStrategy;
-
-import javax.resource.ResourceException;
-import javax.resource.spi.ManagedConnectionFactory;
-import javax.resource.spi.TransactionSupport.TransactionSupportLevel;
-import javax.transaction.TransactionManager;
-
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * NonTxConnectionManagerTestCase.
- * @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 NonTxConnectionManagerTestCase
-{
- private static ConnectionManager connectionManager = null;
-
- private static ManagedConnectionFactory mcf = null;
-
- /**
- * Initialize.
- */
- @BeforeClass
- public static void init()
- {
- TransactionManager tm = null;
- assertNull(tm);
-
- mcf = new MockManagedConnectionFactory();
- PoolConfiguration pc = new PoolConfiguration();
- PoolFactory pf = new PoolFactory();
-
- Pool pool = pf.create(PoolStrategy.ONE_POOL, mcf, pc, true);
-
- ConnectionManagerFactory cmf = new ConnectionManagerFactory();
- connectionManager = cmf.createNonTransactional(TransactionSupportLevel.NoTransaction, pool, null, null);
- assertNotNull(connectionManager);
-
- assertTrue(connectionManager instanceof NoTxConnectionManager);
- }
-
- /**
- * Test allocate connection.
- */
- @Test
- public void testAllocateConnection()
- {
- Object object = null;
- try
- {
- object = connectionManager.allocateConnection(mcf, new MockConnectionRequestInfo());
- }
- catch (ResourceException e)
- {
- e.printStackTrace();
- }
-
- assertNotNull(object);
- assertTrue(object instanceof MockHandle);
- }
-
- /**
- * Destroy.
- */
- @AfterClass
- public static void destroy()
- {
- connectionManager = null;
- mcf = null;
- }
-}
More information about the jboss-cvs-commits
mailing list