Search in sources :

Example 6 with LazyConnection

use of org.jboss.as.test.integration.jca.lazyconnectionmanager.rar.LazyConnection in project wildfly by wildfly.

the class LazyAssociationXATransactionTestCase method testBasic.

@Test
public void testBasic() throws Throwable {
    assertNotNull(lcf);
    assertNotNull(userTransaction);
    boolean status = true;
    userTransaction.begin();
    LazyConnection lc = null;
    try {
        lc = lcf.getConnection();
        assertTrue(lc.isManagedConnectionSet());
        lc.closeManagedConnection();
        assertFalse(lc.isManagedConnectionSet());
        lc.associate();
        assertTrue(lc.isManagedConnectionSet());
        assertFalse(lc.isEnlisted());
        assertTrue(lc.enlist());
        assertTrue(lc.isEnlisted());
    } catch (Throwable t) {
        logger.error(t.getMessage(), t);
        status = false;
        fail("Throwable:" + t.getMessage());
    } finally {
        if (lc != null) {
            lc.close();
        }
        if (status) {
            userTransaction.commit();
        } else {
            userTransaction.rollback();
        }
    }
}
Also used : LazyConnection(org.jboss.as.test.integration.jca.lazyconnectionmanager.rar.LazyConnection) Test(org.junit.Test)

Example 7 with LazyConnection

use of org.jboss.as.test.integration.jca.lazyconnectionmanager.rar.LazyConnection in project wildfly by wildfly.

the class LazyAssociationLocalTransactionEnlistmentFalseTestCase method verifyEagerlyEnlisted.

@Test
public void verifyEagerlyEnlisted() throws Throwable {
    assertNotNull(lcf);
    assertNotNull(userTransaction);
    boolean status = true;
    userTransaction.begin();
    LazyConnection lc = null;
    try {
        lc = lcf.getConnection();
        assertTrue(lc.isManagedConnectionSet());
        assertTrue(lc.closeManagedConnection());
        assertFalse(lc.isManagedConnectionSet());
        assertTrue(lc.associate());
        assertTrue(lc.isManagedConnectionSet());
        assertTrue(lc.isEnlisted());
    } catch (Throwable t) {
        logger.error(t.getMessage(), t);
        status = false;
        fail("Throwable:" + t.getMessage());
    } finally {
        if (lc != null) {
            lc.close();
        }
        if (status) {
            userTransaction.commit();
        } else {
            userTransaction.rollback();
        }
    }
}
Also used : LazyConnection(org.jboss.as.test.integration.jca.lazyconnectionmanager.rar.LazyConnection) Test(org.junit.Test)

Example 8 with LazyConnection

use of org.jboss.as.test.integration.jca.lazyconnectionmanager.rar.LazyConnection in project wildfly by wildfly.

the class LazyAssociationLocalTransactionTestCase method testBasic.

@Test
public void testBasic() throws Throwable {
    assertNotNull(lcf);
    assertNotNull(userTransaction);
    boolean status = true;
    userTransaction.begin();
    LazyConnection lc = null;
    try {
        lc = lcf.getConnection();
        assertTrue(lc.isManagedConnectionSet());
        assertTrue(lc.closeManagedConnection());
        assertFalse(lc.isManagedConnectionSet());
        assertTrue(lc.associate());
        assertTrue(lc.isManagedConnectionSet());
        assertFalse(lc.isEnlisted());
        assertTrue(lc.enlist());
        assertTrue(lc.isEnlisted());
    } catch (Throwable t) {
        logger.error(t.getMessage(), t);
        status = false;
        fail("Throwable:" + t.getMessage());
    } finally {
        if (lc != null) {
            lc.close();
        }
        if (status) {
            userTransaction.commit();
        } else {
            userTransaction.rollback();
        }
    }
}
Also used : LazyConnection(org.jboss.as.test.integration.jca.lazyconnectionmanager.rar.LazyConnection) Test(org.junit.Test)

Example 9 with LazyConnection

use of org.jboss.as.test.integration.jca.lazyconnectionmanager.rar.LazyConnection in project wildfly by wildfly.

the class LazyAssociationSharableDefaultTestCase method testBasic.

@Test
public void testBasic() {
    assertNotNull(lcf);
    LazyConnection lc = null;
    try {
        lc = lcf.getConnection();
        assertTrue(lc.isManagedConnectionSet());
        assertTrue(lc.closeManagedConnection());
        assertFalse(lc.isManagedConnectionSet());
        assertTrue(lc.associate());
        assertTrue(lc.isManagedConnectionSet());
        assertFalse(lc.isEnlisted());
        assertTrue(lc.enlist());
        assertFalse(lc.isEnlisted());
    } catch (Throwable t) {
        logger.error(t.getMessage(), t);
        fail("Throwable:" + t.getMessage());
    } finally {
        if (lc != null) {
            lc.close();
        }
    }
}
Also used : LazyConnection(org.jboss.as.test.integration.jca.lazyconnectionmanager.rar.LazyConnection) Test(org.junit.Test)

Example 10 with LazyConnection

use of org.jboss.as.test.integration.jca.lazyconnectionmanager.rar.LazyConnection in project wildfly by wildfly.

the class LazyAssociationSharableDefaultTestCase method testTwoConnections.

/**
     * Two connections - one managed connection
     *
     * @throws Throwable Thrown if case of an error
     */
@Test
public void testTwoConnections() {
    assertNotNull(lcf);
    LazyConnection lc1 = null;
    LazyConnection lc2 = null;
    try {
        lc1 = lcf.getConnection();
        assertTrue(lc1.isManagedConnectionSet());
        lc2 = lcf.getConnection();
        assertTrue(lc2.isManagedConnectionSet());
        assertFalse(lc1.isManagedConnectionSet());
        assertTrue(lc2.closeManagedConnection());
        assertFalse(lc1.isManagedConnectionSet());
        assertFalse(lc2.isManagedConnectionSet());
        assertTrue(lc1.associate());
        assertTrue(lc1.isManagedConnectionSet());
        assertFalse(lc2.isManagedConnectionSet());
    } catch (Throwable t) {
        logger.error(t.getMessage(), t);
        fail("Throwable:" + t.getMessage());
    } finally {
        if (lc1 != null) {
            lc1.close();
        }
        if (lc2 != null) {
            lc2.close();
        }
    }
}
Also used : LazyConnection(org.jboss.as.test.integration.jca.lazyconnectionmanager.rar.LazyConnection) Test(org.junit.Test)

Aggregations

LazyConnection (org.jboss.as.test.integration.jca.lazyconnectionmanager.rar.LazyConnection)12 Test (org.junit.Test)12 ResourceException (javax.resource.ResourceException)1 ManagedConnectionPool (org.jboss.jca.core.connectionmanager.pool.mcp.ManagedConnectionPool)1