/** * Lifecycle start, before the suite is executed * * @throws Throwable throwable exception */ @BeforeClass public static void beforeClass() throws Throwable { // Create and set an embedded JCA instance embedded = EmbeddedFactory.create(false); // Startup embedded.startup(); // Deploy Naming and Transaction URL naming = XATxConnectionManagerTestCase.class.getClassLoader().getResource("naming.xml"); URL transaction = XATxConnectionManagerTestCase.class.getClassLoader().getResource("transaction.xml"); embedded.deploy(naming); embedded.deploy(transaction); TransactionIntegration ti = embedded.lookup("TransactionIntegration", TransactionIntegration.class); assertNotNull(ti); mcf = new MockManagedConnectionFactory(); PoolConfiguration pc = new PoolConfiguration(); PoolFactory pf = new PoolFactory(); Pool pool = pf.create(PoolStrategy.ONE_POOL, mcf, pc, true, true); ConnectionManagerFactory cmf = new ConnectionManagerFactory(); ConnectionManager connectionManager = cmf.createTransactional( TransactionSupportLevel.XATransaction, pool, null, null, false, null, true, true, false, null, FlushStrategy.FAILING_CONNECTION_ONLY, null, null, ti, Boolean.FALSE, null, null, null, null); assertNotNull(connectionManager); assertTrue(connectionManager instanceof TxConnectionManager); txConnectionManager = (TxConnectionManager) connectionManager; }
/** * testAllocateConnectionWrongMCF. * * @throws ResourceException for exception */ @Test(expected = ResourceException.class) public void testAllocateConnectionWrongMCF() throws ResourceException { AbstractConnectionManager connectionManager = new MockConnectionManager(); PoolConfiguration pc = new PoolConfiguration(); PoolFactory pf = new PoolFactory(); Pool pool = pf.create(PoolStrategy.ONE_POOL, new MockManagedConnectionFactory(), pc, false, true); pool.setConnectionListenerFactory(connectionManager); connectionManager.setPool(pool); connectionManager.allocateConnection(new MockManagedConnectionFactory(), null); }
/** testPoolNotNull. */ @Test public void testPoolNotNull() { AbstractConnectionManager connectionManager = new MockConnectionManager(); assertNull(connectionManager.getPool()); PoolConfiguration pc = new PoolConfiguration(); PoolFactory pf = new PoolFactory(); Pool pool = pf.create(PoolStrategy.ONE_POOL, new MockManagedConnectionFactory(), pc, false, true); pool.setConnectionListenerFactory(connectionManager); connectionManager.setPool(pool); assertNotNull(connectionManager.getPool()); }