use of java.sql.BatchUpdateException in project jdk8u_jdk by JetBrains.
the class BatchUpdateExceptionTests method test13.
/**
* De-Serialize a BatchUpdateException from JDBC 4.0 and make sure you can
* read it back properly
*/
@Test
public void test13() throws Exception {
String reason1 = "This was the error msg";
String state1 = "user defined sqlState";
String cause1 = "java.lang.Throwable: throw 1";
int errorCode1 = 99999;
Throwable t = new Throwable("throw 1");
int[] uc1 = { 1, 2, 21 };
long[] luc1 = { 1, 2, 21 };
ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(SerializedBatchUpdateException.DATA));
BatchUpdateException bue = (BatchUpdateException) ois.readObject();
assertTrue(reason1.equals(bue.getMessage()) && bue.getSQLState().equals(state1) && bue.getErrorCode() == errorCode1 && cause1.equals(bue.getCause().toString()) && Arrays.equals(bue.getLargeUpdateCounts(), luc1) && Arrays.equals(bue.getUpdateCounts(), uc1));
}
use of java.sql.BatchUpdateException in project jdk8u_jdk by JetBrains.
the class BatchUpdateExceptionTests method test14.
/**
* Serialize a BatchUpdateException with an Integer.MAX_VALUE + 1 and
* validate you can read it back properly
*/
@Test
public void test14() throws Exception {
int[] uc1 = { Integer.MAX_VALUE, Integer.MAX_VALUE + 1 };
long[] luc1 = { Integer.MAX_VALUE, Integer.MAX_VALUE + 1 };
BatchUpdateException be = new BatchUpdateException(reason, state, errorCode, luc1, t);
BatchUpdateException bue = createSerializedException(be);
assertTrue(reason.equals(bue.getMessage()) && bue.getSQLState().equals(state) && cause.equals(bue.getCause().toString()) && bue.getErrorCode() == errorCode && Arrays.equals(bue.getLargeUpdateCounts(), luc1) && Arrays.equals(bue.getUpdateCounts(), uc1));
}
use of java.sql.BatchUpdateException in project jdk8u_jdk by JetBrains.
the class BatchUpdateExceptionTests method test6.
/**
* Create BatchUpdateException with message, Throwable, and update counts
*/
@Test
public void test6() {
BatchUpdateException ex = new BatchUpdateException(reason, uc, t);
assertTrue(ex.getMessage().equals(reason) && ex.getSQLState() == null && cause.equals(ex.getCause().toString()) && ex.getErrorCode() == 0 && Arrays.equals(ex.getUpdateCounts(), uc) && Arrays.equals(ex.getLargeUpdateCounts(), luc));
}
use of java.sql.BatchUpdateException in project jdk8u_jdk by JetBrains.
the class BatchUpdateExceptionTests method test8.
/**
* Create BatchUpdateException with message, SQLState, errorCode code
* Throwable, and update counts
*/
@Test
public void test8() {
BatchUpdateException ex = new BatchUpdateException(reason, state, errorCode, uc, t);
assertTrue(ex.getMessage().equals(reason) && ex.getSQLState().equals(state) && cause.equals(ex.getCause().toString()) && ex.getErrorCode() == errorCode && Arrays.equals(ex.getUpdateCounts(), uc) && Arrays.equals(ex.getLargeUpdateCounts(), luc));
}
use of java.sql.BatchUpdateException in project jdk8u_jdk by JetBrains.
the class BatchUpdateExceptionTests method test16.
/**
* Validate that the ordering of the returned Exceptions is correct
* using traditional while loop
*/
@Test
public void test16() {
BatchUpdateException ex = new BatchUpdateException("Exception 1", uc, t1);
BatchUpdateException ex1 = new BatchUpdateException("Exception 2", uc);
BatchUpdateException ex2 = new BatchUpdateException("Exception 3", uc, t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
SQLException sqe = ex;
int num = 0;
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();
}
}
Aggregations