/** * Validate that the ordering of the returned Exceptions is correct * using for-each loop */ @Test public void test11() { SQLTransactionRollbackException ex = new SQLTransactionRollbackException("Exception 1", t1); SQLTransactionRollbackException ex1 = new SQLTransactionRollbackException("Exception 2"); SQLTransactionRollbackException ex2 = new SQLTransactionRollbackException("Exception 3", t2); ex.setNextException(ex1); ex.setNextException(ex2); int num = 0; for (Throwable e : ex) { assertTrue(msgs[num++].equals(e.getMessage())); } }
/** * Validate that the ordering of the returned Exceptions is correct * using traditional while loop */ @Test public void test12() { SQLTransactionRollbackException ex = new SQLTransactionRollbackException("Exception 1", t1); SQLTransactionRollbackException ex1 = new SQLTransactionRollbackException("Exception 2"); SQLTransactionRollbackException ex2 = new SQLTransactionRollbackException("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(); } }
public void testTimeout() throws SQLException { Connection con1 = openDefaultConnection(); Connection con2 = openDefaultConnection(); con1.setAutoCommit(false); con2.setAutoCommit(false); con1.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE); con2.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE); con1.createStatement().execute( "select * from EXCEPTION_TABLE1 for update"); try { con2.createStatement().execute( "select * from EXCEPTION_TABLE1 for update"); fail("Statement didn't fail."); } catch (SQLTransactionRollbackException e) { assertTrue("Unexpected SQL State: " + e.getSQLState(), e.getSQLState().startsWith("40")); } con1.rollback(); con1.close(); con2.rollback(); con2.close(); }
@Override public Cluster[] loadClustersForClusterSet(ClusterSet cs) throws SQLException { PreparedStatement st = con.prepareStatement("select distinct id from vss.clusters where cs_id = ?"); st.setInt(1, cs.getID()); List<Cluster> list; try (ResultSet rs = st.executeQuery()) { list = new LinkedList<>(); while (rs.next()) { list.add(loadCluster(rs.getInt(1), cs)); } Collections.sort(list, new Comparator<Cluster>() { @Override public int compare(Cluster o1, Cluster o2) { return o2.size() - o1.size(); } }); return list.toArray(new Cluster[list.size()]); } catch (SQLTransactionRollbackException e) { logger.showException(e); return new Cluster[0]; } }
/** * @test java.sql.SQLTransactionRollbackException(String, String) */ public void test_Constructor_LStringLString() { SQLTransactionRollbackException sQLTransactionRollbackException = new SQLTransactionRollbackException( "MYTESTSTRING1", "MYTESTSTRING2"); assertNotNull(sQLTransactionRollbackException); assertEquals( "The SQLState of SQLTransactionRollbackException set and get should be equivalent", "MYTESTSTRING2", sQLTransactionRollbackException.getSQLState()); assertEquals( "The reason of SQLTransactionRollbackException set and get should be equivalent", "MYTESTSTRING1", sQLTransactionRollbackException.getMessage()); assertEquals( "The error code of SQLTransactionRollbackException should be 0", sQLTransactionRollbackException.getErrorCode(), 0); }
/** * @test java.sql.SQLTransactionRollbackException(Throwable) */ public void test_Constructor_LThrowable() { Throwable cause = new Exception("MYTHROWABLE"); SQLTransactionRollbackException sQLTransactionRollbackException = new SQLTransactionRollbackException( cause); assertNotNull(sQLTransactionRollbackException); assertEquals( "The reason of SQLTransactionRollbackException should be equals to cause.toString()", "java.lang.Exception: MYTHROWABLE", sQLTransactionRollbackException.getMessage()); assertNull( "The SQLState of SQLTransactionRollbackException should be null", sQLTransactionRollbackException.getSQLState()); assertEquals( "The error code of SQLTransactionRollbackException should be 0", sQLTransactionRollbackException.getErrorCode(), 0); assertEquals( "The cause of SQLTransactionRollbackException set and get should be equivalent", cause, sQLTransactionRollbackException.getCause()); }
/** * @test java.sql.SQLTransactionRollbackException(Throwable) */ public void test_Constructor_LThrowable_1() { SQLTransactionRollbackException sQLTransactionRollbackException = new SQLTransactionRollbackException( (Throwable) null); assertNotNull(sQLTransactionRollbackException); assertNull( "The SQLState of SQLTransactionRollbackException should be null", sQLTransactionRollbackException.getSQLState()); assertNull( "The reason of SQLTransactionRollbackException should be null", sQLTransactionRollbackException.getMessage()); assertEquals( "The error code of SQLTransactionRollbackException should be 0", sQLTransactionRollbackException.getErrorCode(), 0); assertNull( "The cause of SQLTransactionRollbackException should be null", sQLTransactionRollbackException.getCause()); }
/** * @test java.sql.SQLTransactionRollbackException(String, Throwable) */ public void test_Constructor_LStringLThrowable() { Throwable cause = new Exception("MYTHROWABLE"); SQLTransactionRollbackException sQLTransactionRollbackException = new SQLTransactionRollbackException( "MYTESTSTRING", cause); assertNotNull(sQLTransactionRollbackException); assertEquals( "The reason of SQLTransactionRollbackException set and get should be equivalent", "MYTESTSTRING", sQLTransactionRollbackException.getMessage()); assertNull( "The SQLState of SQLTransactionRollbackException should be null", sQLTransactionRollbackException.getSQLState()); assertEquals( "The error code of SQLTransactionRollbackException should be 0", sQLTransactionRollbackException.getErrorCode(), 0); assertEquals( "The cause of SQLTransactionRollbackException set and get should be equivalent", cause, sQLTransactionRollbackException.getCause()); }
/** * @test java.sql.SQLTransactionRollbackException(String, Throwable) */ public void test_Constructor_LStringLThrowable_1() { SQLTransactionRollbackException sQLTransactionRollbackException = new SQLTransactionRollbackException( "MYTESTSTRING", (Throwable) null); assertNotNull(sQLTransactionRollbackException); assertEquals( "The reason of SQLTransactionRollbackException set and get should be equivalent", "MYTESTSTRING", sQLTransactionRollbackException.getMessage()); assertNull( "The SQLState of SQLTransactionRollbackException should be null", sQLTransactionRollbackException.getSQLState()); assertEquals( "The error code of SQLTransactionRollbackException should be 0", sQLTransactionRollbackException.getErrorCode(), 0); assertNull( "The cause of SQLTransactionRollbackException should be null", sQLTransactionRollbackException.getCause()); }
/** * @test java.sql.SQLTransactionRollbackException(String, Throwable) */ public void test_Constructor_LStringLThrowable_2() { Throwable cause = new Exception("MYTHROWABLE"); SQLTransactionRollbackException sQLTransactionRollbackException = new SQLTransactionRollbackException( null, cause); assertNotNull(sQLTransactionRollbackException); assertNull( "The reason of SQLTransactionRollbackException should be null", sQLTransactionRollbackException.getMessage()); assertNull( "The SQLState of SQLTransactionRollbackException should be null", sQLTransactionRollbackException.getSQLState()); assertEquals( "The error code of SQLTransactionRollbackException should be 0", sQLTransactionRollbackException.getErrorCode(), 0); }
/** * @test java.sql.SQLTransactionRollbackException(String, Throwable) */ public void test_Constructor_LStringLThrowable_3() { SQLTransactionRollbackException sQLTransactionRollbackException = new SQLTransactionRollbackException( (String) null, (Throwable) null); assertNotNull(sQLTransactionRollbackException); assertNull( "The SQLState of SQLTransactionRollbackException should be null", sQLTransactionRollbackException.getSQLState()); assertNull( "The reason of SQLTransactionRollbackException should be null", sQLTransactionRollbackException.getMessage()); assertEquals( "The error code of SQLTransactionRollbackException should be 0", sQLTransactionRollbackException.getErrorCode(), 0); assertNull( "The cause of SQLTransactionRollbackException should be null", sQLTransactionRollbackException.getCause()); }
/** * @test java.sql.SQLTransactionRollbackException(String, String, Throwable) */ public void test_Constructor_LStringLStringLThrowable() { Throwable cause = new Exception("MYTHROWABLE"); SQLTransactionRollbackException sQLTransactionRollbackException = new SQLTransactionRollbackException( "MYTESTSTRING1", "MYTESTSTRING2", cause); assertNotNull(sQLTransactionRollbackException); assertEquals( "The SQLState of SQLTransactionRollbackException set and get should be equivalent", "MYTESTSTRING2", sQLTransactionRollbackException.getSQLState()); assertEquals( "The reason of SQLTransactionRollbackException set and get should be equivalent", "MYTESTSTRING1", sQLTransactionRollbackException.getMessage()); assertEquals( "The error code of SQLTransactionRollbackException should be 0", sQLTransactionRollbackException.getErrorCode(), 0); assertEquals( "The cause of SQLTransactionRollbackException set and get should be equivalent", cause, sQLTransactionRollbackException.getCause()); }
/** * @test java.sql.SQLTransactionRollbackException(String, String, Throwable) */ public void test_Constructor_LStringLStringLThrowable_1() { SQLTransactionRollbackException sQLTransactionRollbackException = new SQLTransactionRollbackException( "MYTESTSTRING1", "MYTESTSTRING2", null); assertNotNull(sQLTransactionRollbackException); assertEquals( "The SQLState of SQLTransactionRollbackException set and get should be equivalent", "MYTESTSTRING2", sQLTransactionRollbackException.getSQLState()); assertEquals( "The reason of SQLTransactionRollbackException set and get should be equivalent", "MYTESTSTRING1", sQLTransactionRollbackException.getMessage()); assertEquals( "The error code of SQLTransactionRollbackException should be 0", sQLTransactionRollbackException.getErrorCode(), 0); assertNull( "The cause of SQLTransactionRollbackException should be null", sQLTransactionRollbackException.getCause()); }
/** * @test java.sql.SQLTransactionRollbackException(String, String, Throwable) */ public void test_Constructor_LStringLStringLThrowable_2() { Throwable cause = new Exception("MYTHROWABLE"); SQLTransactionRollbackException sQLTransactionRollbackException = new SQLTransactionRollbackException( "MYTESTSTRING", null, cause); assertNotNull(sQLTransactionRollbackException); assertNull( "The SQLState of SQLTransactionRollbackException should be null", sQLTransactionRollbackException.getSQLState()); assertEquals( "The reason of SQLTransactionRollbackException set and get should be equivalent", "MYTESTSTRING", sQLTransactionRollbackException.getMessage()); assertEquals( "The error code of SQLTransactionRollbackException should be 0", sQLTransactionRollbackException.getErrorCode(), 0); assertEquals( "The cause of SQLTransactionRollbackException set and get should be equivalent", cause, sQLTransactionRollbackException.getCause()); }
/** * @test java.sql.SQLTransactionRollbackException(String, String, Throwable) */ public void test_Constructor_LStringLStringLThrowable_3() { SQLTransactionRollbackException sQLTransactionRollbackException = new SQLTransactionRollbackException( "MYTESTSTRING", null, null); assertNotNull(sQLTransactionRollbackException); assertNull( "The SQLState of SQLTransactionRollbackException should be null", sQLTransactionRollbackException.getSQLState()); assertEquals( "The reason of SQLTransactionRollbackException set and get should be equivalent", "MYTESTSTRING", sQLTransactionRollbackException.getMessage()); assertEquals( "The error code of SQLTransactionRollbackException should be 0", sQLTransactionRollbackException.getErrorCode(), 0); assertNull( "The cause of SQLTransactionRollbackException should be null", sQLTransactionRollbackException.getCause()); }
/** * @test java.sql.SQLTransactionRollbackException(String, String, Throwable) */ public void test_Constructor_LStringLStringLThrowable_4() { Throwable cause = new Exception("MYTHROWABLE"); SQLTransactionRollbackException sQLTransactionRollbackException = new SQLTransactionRollbackException( null, "MYTESTSTRING", cause); assertNotNull(sQLTransactionRollbackException); assertEquals( "The SQLState of SQLTransactionRollbackException set and get should be equivalent", "MYTESTSTRING", sQLTransactionRollbackException.getSQLState()); assertNull( "The reason of SQLTransactionRollbackException should be null", sQLTransactionRollbackException.getMessage()); assertEquals( "The error code of SQLTransactionRollbackException should be 0", sQLTransactionRollbackException.getErrorCode(), 0); assertEquals( "The cause of SQLTransactionRollbackException set and get should be equivalent", cause, sQLTransactionRollbackException.getCause()); }
/** * @test java.sql.SQLTransactionRollbackException(String, String, Throwable) */ public void test_Constructor_LStringLStringLThrowable_5() { SQLTransactionRollbackException sQLTransactionRollbackException = new SQLTransactionRollbackException( null, "MYTESTSTRING", null); assertNotNull(sQLTransactionRollbackException); assertEquals( "The SQLState of SQLTransactionRollbackException set and get should be equivalent", "MYTESTSTRING", sQLTransactionRollbackException.getSQLState()); assertNull( "The reason of SQLTransactionRollbackException should be null", sQLTransactionRollbackException.getMessage()); assertEquals( "The error code of SQLTransactionRollbackException should be 0", sQLTransactionRollbackException.getErrorCode(), 0); assertNull( "The cause of SQLTransactionRollbackException should be null", sQLTransactionRollbackException.getCause()); }
/** * @test java.sql.SQLTransactionRollbackException(String, String, Throwable) */ public void test_Constructor_LStringLStringLThrowable_6() { Throwable cause = new Exception("MYTHROWABLE"); SQLTransactionRollbackException sQLTransactionRollbackException = new SQLTransactionRollbackException( null, null, cause); assertNotNull(sQLTransactionRollbackException); assertNull( "The SQLState of SQLTransactionRollbackException should be null", sQLTransactionRollbackException.getSQLState()); assertNull( "The reason of SQLTransactionRollbackException should be null", sQLTransactionRollbackException.getMessage()); assertEquals( "The error code of SQLTransactionRollbackException should be 0", sQLTransactionRollbackException.getErrorCode(), 0); assertEquals( "The cause of SQLTransactionRollbackException set and get should be equivalent", cause, sQLTransactionRollbackException.getCause()); }
/** * @test java.sql.SQLTransactionRollbackException(String, String, Throwable) */ public void test_Constructor_LStringLStringLThrowable_7() { SQLTransactionRollbackException sQLTransactionRollbackException = new SQLTransactionRollbackException( null, null, null); assertNotNull(sQLTransactionRollbackException); assertNull( "The SQLState of SQLTransactionRollbackException should be null", sQLTransactionRollbackException.getSQLState()); assertNull( "The reason of SQLTransactionRollbackException should be null", sQLTransactionRollbackException.getMessage()); assertEquals( "The error code of SQLTransactionRollbackException should be 0", sQLTransactionRollbackException.getErrorCode(), 0); assertNull( "The cause of SQLTransactionRollbackException should be null", sQLTransactionRollbackException.getCause()); }
/** * @test java.sql.SQLTransactionRollbackException(String, String, int, * Throwable) */ public void test_Constructor_LStringLStringILThrowable() { Throwable cause = new Exception("MYTHROWABLE"); SQLTransactionRollbackException sQLTransactionRollbackException = new SQLTransactionRollbackException( "MYTESTSTRING1", "MYTESTSTRING2", 1, cause); assertNotNull(sQLTransactionRollbackException); assertEquals( "The SQLState of SQLTransactionRollbackException set and get should be equivalent", "MYTESTSTRING2", sQLTransactionRollbackException.getSQLState()); assertEquals( "The reason of SQLTransactionRollbackException set and get should be equivalent", "MYTESTSTRING1", sQLTransactionRollbackException.getMessage()); assertEquals( "The error code of SQLTransactionRollbackException should be 1", sQLTransactionRollbackException.getErrorCode(), 1); assertEquals( "The cause of SQLTransactionRollbackException set and get should be equivalent", cause, sQLTransactionRollbackException.getCause()); }
/** * @test java.sql.SQLTransactionRollbackException(String, String, int, * Throwable) */ public void test_Constructor_LStringLStringILThrowable_1() { SQLTransactionRollbackException sQLTransactionRollbackException = new SQLTransactionRollbackException( "MYTESTSTRING1", "MYTESTSTRING2", 1, null); assertNotNull(sQLTransactionRollbackException); assertEquals( "The SQLState of SQLTransactionRollbackException set and get should be equivalent", "MYTESTSTRING2", sQLTransactionRollbackException.getSQLState()); assertEquals( "The reason of SQLTransactionRollbackException set and get should be equivalent", "MYTESTSTRING1", sQLTransactionRollbackException.getMessage()); assertEquals( "The error code of SQLTransactionRollbackException should be 1", sQLTransactionRollbackException.getErrorCode(), 1); assertNull( "The cause of SQLTransactionRollbackException should be null", sQLTransactionRollbackException.getCause()); }
/** * @test java.sql.SQLTransactionRollbackException(String, String, int, * Throwable) */ public void test_Constructor_LStringLStringILThrowable_2() { Throwable cause = new Exception("MYTHROWABLE"); SQLTransactionRollbackException sQLTransactionRollbackException = new SQLTransactionRollbackException( "MYTESTSTRING1", "MYTESTSTRING2", 0, cause); assertNotNull(sQLTransactionRollbackException); assertEquals( "The SQLState of SQLTransactionRollbackException set and get should be equivalent", "MYTESTSTRING2", sQLTransactionRollbackException.getSQLState()); assertEquals( "The reason of SQLTransactionRollbackException set and get should be equivalent", "MYTESTSTRING1", sQLTransactionRollbackException.getMessage()); assertEquals( "The error code of SQLTransactionRollbackException should be 0", sQLTransactionRollbackException.getErrorCode(), 0); assertEquals( "The cause of SQLTransactionRollbackException set and get should be equivalent", cause, sQLTransactionRollbackException.getCause()); }
/** * @test java.sql.SQLTransactionRollbackException(String, String, int, * Throwable) */ public void test_Constructor_LStringLStringILThrowable_3() { SQLTransactionRollbackException sQLTransactionRollbackException = new SQLTransactionRollbackException( "MYTESTSTRING1", "MYTESTSTRING2", 0, null); assertNotNull(sQLTransactionRollbackException); assertEquals( "The SQLState of SQLTransactionRollbackException set and get should be equivalent", "MYTESTSTRING2", sQLTransactionRollbackException.getSQLState()); assertEquals( "The reason of SQLTransactionRollbackException set and get should be equivalent", "MYTESTSTRING1", sQLTransactionRollbackException.getMessage()); assertEquals( "The error code of SQLTransactionRollbackException should be 0", sQLTransactionRollbackException.getErrorCode(), 0); assertNull( "The cause of SQLTransactionRollbackException should be null", sQLTransactionRollbackException.getCause()); }
/** * @test java.sql.SQLTransactionRollbackException(String, String, int, * Throwable) */ public void test_Constructor_LStringLStringILThrowable_4() { Throwable cause = new Exception("MYTHROWABLE"); SQLTransactionRollbackException sQLTransactionRollbackException = new SQLTransactionRollbackException( "MYTESTSTRING1", "MYTESTSTRING2", -1, cause); assertNotNull(sQLTransactionRollbackException); assertEquals( "The SQLState of SQLTransactionRollbackException set and get should be equivalent", "MYTESTSTRING2", sQLTransactionRollbackException.getSQLState()); assertEquals( "The reason of SQLTransactionRollbackException set and get should be equivalent", "MYTESTSTRING1", sQLTransactionRollbackException.getMessage()); assertEquals( "The error code of SQLTransactionRollbackException should be -1", sQLTransactionRollbackException.getErrorCode(), -1); assertEquals( "The cause of SQLTransactionRollbackException set and get should be equivalent", cause, sQLTransactionRollbackException.getCause()); }
/** * @test java.sql.SQLTransactionRollbackException(String, String, int, * Throwable) */ public void test_Constructor_LStringLStringILThrowable_5() { SQLTransactionRollbackException sQLTransactionRollbackException = new SQLTransactionRollbackException( "MYTESTSTRING1", "MYTESTSTRING2", -1, null); assertNotNull(sQLTransactionRollbackException); assertEquals( "The SQLState of SQLTransactionRollbackException set and get should be equivalent", "MYTESTSTRING2", sQLTransactionRollbackException.getSQLState()); assertEquals( "The reason of SQLTransactionRollbackException set and get should be equivalent", "MYTESTSTRING1", sQLTransactionRollbackException.getMessage()); assertEquals( "The error code of SQLTransactionRollbackException should be -1", sQLTransactionRollbackException.getErrorCode(), -1); assertNull( "The cause of SQLTransactionRollbackException should be null", sQLTransactionRollbackException.getCause()); }
/** * @test java.sql.SQLTransactionRollbackException(String, String, int, * Throwable) */ public void test_Constructor_LStringLStringILThrowable_6() { Throwable cause = new Exception("MYTHROWABLE"); SQLTransactionRollbackException sQLTransactionRollbackException = new SQLTransactionRollbackException( "MYTESTSTRING", null, 1, cause); assertNotNull(sQLTransactionRollbackException); assertNull( "The SQLState of SQLTransactionRollbackException should be null", sQLTransactionRollbackException.getSQLState()); assertEquals( "The reason of SQLTransactionRollbackException set and get should be equivalent", "MYTESTSTRING", sQLTransactionRollbackException.getMessage()); assertEquals( "The error code of SQLTransactionRollbackException should be 1", sQLTransactionRollbackException.getErrorCode(), 1); assertEquals( "The cause of SQLTransactionRollbackException set and get should be equivalent", cause, sQLTransactionRollbackException.getCause()); }
/** * @test java.sql.SQLTransactionRollbackException(String, String, int, * Throwable) */ public void test_Constructor_LStringLStringILThrowable_7() { SQLTransactionRollbackException sQLTransactionRollbackException = new SQLTransactionRollbackException( "MYTESTSTRING", null, 1, null); assertNotNull(sQLTransactionRollbackException); assertNotNull(sQLTransactionRollbackException); assertNull( "The SQLState of SQLTransactionRollbackException should be null", sQLTransactionRollbackException.getSQLState()); assertEquals( "The reason of SQLTransactionRollbackException set and get should be equivalent", "MYTESTSTRING", sQLTransactionRollbackException.getMessage()); assertEquals( "The error code of SQLTransactionRollbackException should be 1", sQLTransactionRollbackException.getErrorCode(), 1); assertNull( "The cause of SQLTransactionRollbackException should be null", sQLTransactionRollbackException.getCause()); }
/** * @test java.sql.SQLTransactionRollbackException(String, String, int, * Throwable) */ public void test_Constructor_LStringLStringILThrowable_8() { Throwable cause = new Exception("MYTHROWABLE"); SQLTransactionRollbackException sQLTransactionRollbackException = new SQLTransactionRollbackException( "MYTESTSTRING", null, 0, cause); assertNotNull(sQLTransactionRollbackException); assertNull( "The SQLState of SQLTransactionRollbackException should be null", sQLTransactionRollbackException.getSQLState()); assertEquals( "The reason of SQLTransactionRollbackException set and get should be equivalent", "MYTESTSTRING", sQLTransactionRollbackException.getMessage()); assertEquals( "The error code of SQLTransactionRollbackException should be 0", sQLTransactionRollbackException.getErrorCode(), 0); assertEquals( "The cause of SQLTransactionRollbackException set and get should be equivalent", cause, sQLTransactionRollbackException.getCause()); }
/** * @test java.sql.SQLTransactionRollbackException(String, String, int, * Throwable) */ public void test_Constructor_LStringLStringILThrowable_9() { SQLTransactionRollbackException sQLTransactionRollbackException = new SQLTransactionRollbackException( "MYTESTSTRING", null, 0, null); assertNotNull(sQLTransactionRollbackException); assertNull( "The SQLState of SQLTransactionRollbackException should be null", sQLTransactionRollbackException.getSQLState()); assertEquals( "The reason of SQLTransactionRollbackException set and get should be equivalent", "MYTESTSTRING", sQLTransactionRollbackException.getMessage()); assertEquals( "The error code of SQLTransactionRollbackException should be 0", sQLTransactionRollbackException.getErrorCode(), 0); assertNull( "The cause of SQLTransactionRollbackException should be null", sQLTransactionRollbackException.getCause()); }