Search in sources :

Example 11 with SQLTransientException

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

the class SQLTransientExceptionTests method test10.

/**
     * Serialize a SQLTransientException and make sure you can read it back properly
     */
@Test
public void test10() throws Exception {
    SQLTransientException e = new SQLTransientException(reason, state, errorCode, t);
    SQLTransientException ex1 = createSerializedException(e);
    assertTrue(reason.equals(ex1.getMessage()) && ex1.getSQLState().equals(state) && cause.equals(ex1.getCause().toString()) && ex1.getErrorCode() == errorCode);
}
Also used : SQLTransientException(java.sql.SQLTransientException) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

Example 12 with SQLTransientException

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

the class SQLTransientExceptionTests method test12.

/**
     * Validate that the ordering of the returned Exceptions is correct
     * using traditional while loop
     */
@Test
public void test12() {
    SQLTransientException ex = new SQLTransientException("Exception 1", t1);
    SQLTransientException ex1 = new SQLTransientException("Exception 2");
    SQLTransientException ex2 = new SQLTransientException("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 : SQLException(java.sql.SQLException) SQLTransientException(java.sql.SQLTransientException) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

Example 13 with SQLTransientException

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

the class SQLTransientExceptionTests method test3.

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

Example 14 with SQLTransientException

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

the class SQLTransientConnectionExceptionTests method test13.

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

Example 15 with SQLTransientException

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

the class SQLTransientExceptionTests method test9.

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

Aggregations

SQLTransientException (java.sql.SQLTransientException)17 Test (org.testng.annotations.Test)16 BaseTest (util.BaseTest)16 SQLException (java.sql.SQLException)5 SQLTimeoutException (java.sql.SQLTimeoutException)1 SQLTransactionRollbackException (java.sql.SQLTransactionRollbackException)1 SQLTransientConnectionException (java.sql.SQLTransientConnectionException)1 Random (java.util.Random)1