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());
}
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);
}
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()));
}
}
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);
}
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);
}
Aggregations