Search in sources :

Example 1 with DataTruncation

use of java.sql.DataTruncation in project spring-framework by spring-projects.

the class SQLErrorCodeSQLExceptionTranslatorTests method dataTruncationTranslation.

@Test
public void dataTruncationTranslation() {
    SQLExceptionTranslator sext = new SQLErrorCodeSQLExceptionTranslator(ERROR_CODES);
    SQLException dataAccessEx = new SQLException("", "", 5);
    DataTruncation dataTruncation = new DataTruncation(1, true, true, 1, 1, dataAccessEx);
    DataAccessResourceFailureException daex = (DataAccessResourceFailureException) sext.translate("task", "SQL", dataTruncation);
    assertEquals(dataTruncation, daex.getCause());
}
Also used : SQLException(java.sql.SQLException) DataAccessResourceFailureException(org.springframework.dao.DataAccessResourceFailureException) DataTruncation(java.sql.DataTruncation) Test(org.junit.Test)

Example 2 with DataTruncation

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

the class DataTruncationTests method test1.

/**
     * Create DataTruncation object indicating a truncation on write
     */
@Test
public void test1() {
    onRead = false;
    DataTruncation e = new DataTruncation(index, parameter, onRead, dataSize, transferSize);
    assertTrue(e.getMessage().equals(dtReason) && e.getSQLState().equals(WRITE_TRUNCATION) && e.getCause() == null && e.getErrorCode() == dterrorCode && e.getParameter() == parameter && e.getRead() == onRead && e.getDataSize() == dataSize && e.getTransferSize() == transferSize && e.getIndex() == index);
}
Also used : DataTruncation(java.sql.DataTruncation) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

Example 3 with DataTruncation

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

the class DataTruncationTests method test11.

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

Example 4 with DataTruncation

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

the class DataTruncationTests method test4.

/**
     * Create DataTruncation object indicating a truncation on read and you can
     * pass a -1 for the index
     */
@Test
public void test4() {
    onRead = true;
    int negIndex = -1;
    DataTruncation e = new DataTruncation(negIndex, parameter, onRead, dataSize, transferSize);
    assertTrue(e.getMessage().equals(dtReason) && e.getSQLState().equals(READ_TRUNCATION) && e.getCause() == null && e.getErrorCode() == dterrorCode && e.getParameter() == parameter && e.getRead() == onRead && e.getDataSize() == dataSize && e.getTransferSize() == transferSize && e.getIndex() == negIndex);
}
Also used : DataTruncation(java.sql.DataTruncation) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

Example 5 with DataTruncation

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

the class DataTruncationTests method test.

/**
     * Create DataTruncation object indicating a truncation on read
     */
@Test
public void test() {
    onRead = true;
    DataTruncation e = new DataTruncation(index, parameter, onRead, dataSize, transferSize);
    assertTrue(e.getMessage().equals(dtReason) && e.getSQLState().equals(READ_TRUNCATION) && e.getCause() == null && e.getErrorCode() == dterrorCode && e.getParameter() == parameter && e.getRead() == onRead && e.getDataSize() == dataSize && e.getTransferSize() == transferSize && e.getIndex() == index);
}
Also used : DataTruncation(java.sql.DataTruncation) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

Aggregations

DataTruncation (java.sql.DataTruncation)10 Test (org.testng.annotations.Test)8 BaseTest (util.BaseTest)8 SQLException (java.sql.SQLException)2 UniqueKeyException (org.jumpmind.db.sql.UniqueKeyException)1 CsvData (org.jumpmind.symmetric.io.data.CsvData)1 Data (org.jumpmind.symmetric.model.Data)1 Trigger (org.jumpmind.symmetric.model.Trigger)1 Test (org.junit.Test)1 DataAccessResourceFailureException (org.springframework.dao.DataAccessResourceFailureException)1