Search in sources :

Example 1 with ConnectionImple

use of com.arjuna.ats.internal.jdbc.ConnectionImple in project narayana by jbosstm.

the class ConnectionImpleTest method closeConnectionWithoutTransaction.

@Test
public void closeConnectionWithoutTransaction() throws SQLException {
    ConnectionImple connectionToTest = getConnectionToTest();
    // Initialises the connection
    connectionToTest.clearWarnings();
    connectionToTest.close();
    verify(connection, times(1)).close();
}
Also used : ConnectionImple(com.arjuna.ats.internal.jdbc.ConnectionImple) Test(org.junit.Test)

Example 2 with ConnectionImple

use of com.arjuna.ats.internal.jdbc.ConnectionImple in project narayana by jbosstm.

the class ConnectionImpleTest method checkIfConnectionIsClosedInAfterCompletion.

@Test
public void checkIfConnectionIsClosedInAfterCompletion() throws Exception {
    transactionManager.begin();
    ConnectionImple connectionToTest = getConnectionToTest();
    // Initialises the connection
    connectionToTest.clearWarnings();
    transactionManager.getTransaction().registerSynchronization(new Synchronization() {

        @Override
        public void beforeCompletion() {
        }

        @Override
        public void afterCompletion(int status) {
            try {
                connectionToTest.isClosed();
            } catch (SQLException e) {
                fail("Could not check isClosed on connection: " + e.getMessage());
            }
        }
    });
    transactionManager.commit();
    verify(connection, times(2)).isClosed();
}
Also used : SQLException(java.sql.SQLException) Synchronization(javax.transaction.Synchronization) ConnectionImple(com.arjuna.ats.internal.jdbc.ConnectionImple) Test(org.junit.Test)

Example 3 with ConnectionImple

use of com.arjuna.ats.internal.jdbc.ConnectionImple in project narayana by jbosstm.

the class ConnectionImpleTest method closeConnectionWithTransaction.

@Test
public void closeConnectionWithTransaction() throws Exception {
    transactionManager.begin();
    // Normally driver does this
    transactionManager.getTransaction().enlistResource(xaResource);
    ConnectionImple connectionToTest = getConnectionToTest();
    // Initialises the connection
    connectionToTest.clearWarnings();
    connectionToTest.close();
    verify(connection, times(1)).close();
}
Also used : ConnectionImple(com.arjuna.ats.internal.jdbc.ConnectionImple) Test(org.junit.Test)

Example 4 with ConnectionImple

use of com.arjuna.ats.internal.jdbc.ConnectionImple in project narayana by jbosstm.

the class ConnectionImpleTest method closeConnectionInAfterCompletion.

@Test
public void closeConnectionInAfterCompletion() throws Exception {
    transactionManager.begin();
    // Normally driver does this
    transactionManager.getTransaction().enlistResource(xaResource);
    ConnectionImple connectionToTest = getConnectionToTest();
    // Initialises the connection
    connectionToTest.clearWarnings();
    transactionManager.getTransaction().registerSynchronization(new Synchronization() {

        @Override
        public void beforeCompletion() {
        }

        @Override
        public void afterCompletion(int status) {
            try {
                connectionToTest.close();
            } catch (SQLException e) {
                fail("Could not close the connection: " + e);
            }
        }
    });
    transactionManager.commit();
    verify(connection, times(1)).close();
}
Also used : SQLException(java.sql.SQLException) Synchronization(javax.transaction.Synchronization) ConnectionImple(com.arjuna.ats.internal.jdbc.ConnectionImple) Test(org.junit.Test)

Example 5 with ConnectionImple

use of com.arjuna.ats.internal.jdbc.ConnectionImple in project narayana by jbosstm.

the class ConnectionImpleTest method checkIfConnectionIsClosedWithoutTransaction.

@Test
public void checkIfConnectionIsClosedWithoutTransaction() throws SQLException {
    ConnectionImple connectionToTest = getConnectionToTest();
    // Initialises the connection
    connectionToTest.clearWarnings();
    connectionToTest.isClosed();
    verify(connection, times(2)).isClosed();
}
Also used : ConnectionImple(com.arjuna.ats.internal.jdbc.ConnectionImple) Test(org.junit.Test)

Aggregations

ConnectionImple (com.arjuna.ats.internal.jdbc.ConnectionImple)6 Test (org.junit.Test)6 SQLException (java.sql.SQLException)2 Synchronization (javax.transaction.Synchronization)2