Search in sources :

Example 6 with SQLIntegrityConstraintViolationException

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

the class SQLIntegrityConstraintViolationExceptionTests method test12.

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

Example 7 with SQLIntegrityConstraintViolationException

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

the class SQLIntegrityConstraintViolationExceptionTests method test13.

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

Example 8 with SQLIntegrityConstraintViolationException

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

the class SQLIntegrityConstraintViolationExceptionTests method test8.

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

Example 9 with SQLIntegrityConstraintViolationException

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

the class SQLIntegrityConstraintViolationExceptionTests method test3.

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

Example 10 with SQLIntegrityConstraintViolationException

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

the class SQLIntegrityConstraintViolationExceptionTests method test5.

/**
     * Create SQLIntegrityConstraintViolationException with message, SQLState, errorCode, and Throwable
     */
@Test
public void test5() {
    SQLIntegrityConstraintViolationException ex = new SQLIntegrityConstraintViolationException(reason, state, errorCode, t);
    assertTrue(ex.getMessage().equals(reason) && ex.getSQLState().equals(state) && cause.equals(ex.getCause().toString()) && ex.getErrorCode() == errorCode);
}
Also used : SQLIntegrityConstraintViolationException(java.sql.SQLIntegrityConstraintViolationException) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

Aggregations

SQLIntegrityConstraintViolationException (java.sql.SQLIntegrityConstraintViolationException)14 Test (org.testng.annotations.Test)14 BaseTest (util.BaseTest)14 SQLException (java.sql.SQLException)2 SQLNonTransientException (java.sql.SQLNonTransientException)1