Search in sources :

Example 11 with SQLTransactionRollbackException

use of java.sql.SQLTransactionRollbackException in project jdk8u_jdk by JetBrains.

the class SQLTransactionRollbackExceptionTests method test12.

/**
     * Validate that the ordering of the returned Exceptions is correct
     * using traditional while loop
     */
@Test
public void test12() {
    SQLTransactionRollbackException ex = new SQLTransactionRollbackException("Exception 1", t1);
    SQLTransactionRollbackException ex1 = new SQLTransactionRollbackException("Exception 2");
    SQLTransactionRollbackException ex2 = new SQLTransactionRollbackException("Exception 3", t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    SQLException sqe = ex;
    while (sqe != null) {
        assertTrue(msgs[num++].equals(sqe.getMessage()));
        Throwable c = sqe.getCause();
        while (c != null) {
            assertTrue(msgs[num++].equals(c.getMessage()));
            c = c.getCause();
        }
        sqe = sqe.getNextException();
    }
}
Also used : SQLTransactionRollbackException(java.sql.SQLTransactionRollbackException) SQLException(java.sql.SQLException) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

Example 12 with SQLTransactionRollbackException

use of java.sql.SQLTransactionRollbackException in project jdk8u_jdk by JetBrains.

the class SQLTransactionRollbackExceptionTests method test11.

/**
     * Validate that the ordering of the returned Exceptions is correct
     * using for-each loop
     */
@Test
public void test11() {
    SQLTransactionRollbackException ex = new SQLTransactionRollbackException("Exception 1", t1);
    SQLTransactionRollbackException ex1 = new SQLTransactionRollbackException("Exception 2");
    SQLTransactionRollbackException ex2 = new SQLTransactionRollbackException("Exception 3", t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    for (Throwable e : ex) {
        assertTrue(msgs[num++].equals(e.getMessage()));
    }
}
Also used : SQLTransactionRollbackException(java.sql.SQLTransactionRollbackException) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

Example 13 with SQLTransactionRollbackException

use of java.sql.SQLTransactionRollbackException in project jdk8u_jdk by JetBrains.

the class SQLTransactionRollbackExceptionTests method test4.

/**
     * Create SQLTransactionRollbackException with message, SQLState, and error code
     */
@Test
public void test4() {
    SQLTransactionRollbackException ex = new SQLTransactionRollbackException(reason, state, errorCode);
    assertTrue(ex.getMessage().equals(reason) && ex.getSQLState().equals(state) && ex.getCause() == null && ex.getErrorCode() == errorCode);
}
Also used : SQLTransactionRollbackException(java.sql.SQLTransactionRollbackException) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

Example 14 with SQLTransactionRollbackException

use of java.sql.SQLTransactionRollbackException in project jdk8u_jdk by JetBrains.

the class SQLTransactionRollbackExceptionTests method test13.

/**
     * Create SQLTransactionRollbackException and validate it is an instance of
     * SQLNonTransientException
     */
@Test
public void test13() {
    Exception ex = new SQLTransactionRollbackException();
    assertTrue(ex instanceof SQLTransientException);
}
Also used : SQLTransactionRollbackException(java.sql.SQLTransactionRollbackException) SQLTransientException(java.sql.SQLTransientException) SQLException(java.sql.SQLException) SQLTransactionRollbackException(java.sql.SQLTransactionRollbackException) SQLTransientException(java.sql.SQLTransientException) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

Example 15 with SQLTransactionRollbackException

use of java.sql.SQLTransactionRollbackException in project jdk8u_jdk by JetBrains.

the class SQLTransactionRollbackExceptionTests method test8.

/**
     * Create SQLTransactionRollbackException with null Throwable
     */
@Test
public void test8() {
    SQLTransactionRollbackException ex = new SQLTransactionRollbackException((Throwable) null);
    assertTrue(ex.getMessage() == null && ex.getSQLState() == null && ex.getCause() == null && ex.getErrorCode() == 0);
}
Also used : SQLTransactionRollbackException(java.sql.SQLTransactionRollbackException) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

Aggregations

SQLTransactionRollbackException (java.sql.SQLTransactionRollbackException)17 Test (org.testng.annotations.Test)14 BaseTest (util.BaseTest)14 SQLException (java.sql.SQLException)4 PreparedStatement (java.sql.PreparedStatement)3 Connection (java.sql.Connection)2 Statement (java.sql.Statement)2 SQLTransientException (java.sql.SQLTransientException)1