--- old/test/java/sql/test/sql/BatchUpdateExceptionTests.java 2014-04-21 16:49:49.000000000 -0400 +++ new/test/java/sql/test/sql/BatchUpdateExceptionTests.java 2014-04-21 16:49:49.000000000 -0400 @@ -24,56 +24,23 @@ import java.io.ByteArrayInputStream; import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; import java.sql.BatchUpdateException; import java.sql.SQLException; import java.util.Arrays; import static org.testng.Assert.*; -import org.testng.annotations.AfterClass; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import util.SerializedBatchUpdateException; +import util.BaseTest; -public class BatchUpdateExceptionTests { +public class BatchUpdateExceptionTests extends BaseTest { - private final String reason = "reason"; - private final String state = "SQLState"; - private final String cause = "java.lang.Throwable: cause"; - private final Throwable t1 = new Throwable("cause 1"); - private final Throwable t2 = new Throwable("cause 2"); - private final Throwable t = new Throwable("cause"); - private final int errorCode = 21; private final int[] uc = {1, 2, 3}; private final long[] luc = {1, 2, 3}; - private final String[] msgs = {"Exception 1", "cause 1", "Exception 2", - "Exception 3", "cause 2"}; + private final String testSrcDir = System.getProperty("test.src", ".") + File.separatorChar; - public BatchUpdateExceptionTests() { - } - - @BeforeClass - public static void setUpClass() throws Exception { - } - - @AfterClass - public static void tearDownClass() throws Exception { - } - - @BeforeMethod - public void setUpMethod() throws Exception { - } - - @AfterMethod - public void tearDownMethod() throws Exception { - } - /** * Create BatchUpdateException and setting all objects to null */ @@ -258,13 +225,8 @@ public void test12() throws Exception { BatchUpdateException be = new BatchUpdateException(reason, state, errorCode, uc, t); - ObjectOutputStream out - = new ObjectOutputStream( - new FileOutputStream("BatchUpdateException_JDBC42.ser")); - out.writeObject(be); - ObjectInputStream is = new ObjectInputStream( - new FileInputStream("BatchUpdateException_JDBC42.ser")); - BatchUpdateException bue = (BatchUpdateException) is.readObject(); + BatchUpdateException bue + = createSerializedException(be, "BatchUpdateException_JDBC42.ser"); assertTrue(reason.equals(bue.getMessage()) && bue.getSQLState().equals(state) && cause.equals(bue.getCause().toString()) @@ -273,6 +235,8 @@ && Arrays.equals(bue.getUpdateCounts(), uc)); } + + /** * De-Serialize a BatchUpdateException from JDBC 4.0 and make sure you can * read it back properly @@ -308,13 +272,8 @@ long[] luc1 = {Integer.MAX_VALUE, Integer.MAX_VALUE + 1}; BatchUpdateException be = new BatchUpdateException(reason, state, errorCode, luc1, t); - ObjectOutputStream out - = new ObjectOutputStream( - new FileOutputStream("BatchUpdateException_MAX_INT.ser")); - out.writeObject(be); - ObjectInputStream is = new ObjectInputStream( - new FileInputStream("BatchUpdateException_MAX_INT.ser")); - BatchUpdateException bue = (BatchUpdateException) is.readObject(); + BatchUpdateException bue + = createSerializedException(be, "BatchUpdateException_MAX_INT.ser"); assertTrue(reason.equals(bue.getMessage()) && bue.getSQLState().equals(state) && cause.equals(bue.getCause().toString()) @@ -363,5 +322,5 @@ sqe = sqe.getNextException(); } } - + } --- old/test/java/sql/test/sql/DataTruncationTests.java 2014-04-21 16:49:50.000000000 -0400 +++ new/test/java/sql/test/sql/DataTruncationTests.java 2014-04-21 16:49:50.000000000 -0400 @@ -22,56 +22,26 @@ */ package test.sql; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.sql.SQLException; import java.sql.DataTruncation; +import java.sql.SQLException; import static org.testng.Assert.*; -import org.testng.annotations.AfterClass; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import util.BaseTest; -public class DataTruncationTests { +public class DataTruncationTests extends BaseTest { private final String READ_TRUNCATION = "01004"; private final String WRITE_TRUNCATION = "22001"; - private final String reason = "Data truncation"; - private final String cause = "java.lang.Throwable: cause"; - private final Throwable t = new Throwable("cause"); - private final Throwable t1 = new Throwable("cause 1"); - private final Throwable t2 = new Throwable("cause 2"); - private final int errorCode = 0; - private final String[] msgs = {reason, "cause 1", reason, - reason, "cause 2"}; + private final String dtReason = "Data truncation"; + private final int dterrorCode = 0; + private final String[] dtmsgs = {dtReason, "cause 1", dtReason, + dtReason, "cause 2"}; private boolean onRead = false; private final boolean parameter = false; private final int index = 21; private final int dataSize = 25; private final int transferSize = 10; - public DataTruncationTests() { - } - - @BeforeClass - public static void setUpClass() throws Exception { - } - - @AfterClass - public static void tearDownClass() throws Exception { - } - - @BeforeMethod - public void setUpMethod() throws Exception { - } - - @AfterMethod - public void tearDownMethod() throws Exception { - } - /** * Create DataTruncation object indicating a truncation on read */ @@ -80,10 +50,10 @@ onRead = true; DataTruncation e = new DataTruncation(index, parameter, onRead, dataSize, transferSize); - assertTrue(e.getMessage().equals(reason) + assertTrue(e.getMessage().equals(dtReason) && e.getSQLState().equals(READ_TRUNCATION) && e.getCause() == null - && e.getErrorCode() == errorCode + && e.getErrorCode() == dterrorCode && e.getParameter() == parameter && e.getRead() == onRead && e.getDataSize() == dataSize @@ -99,10 +69,10 @@ onRead = false; DataTruncation e = new DataTruncation(index, parameter, onRead, dataSize, transferSize); - assertTrue(e.getMessage().equals(reason) + assertTrue(e.getMessage().equals(dtReason) && e.getSQLState().equals(WRITE_TRUNCATION) && e.getCause() == null - && e.getErrorCode() == errorCode + && e.getErrorCode() == dterrorCode && e.getParameter() == parameter && e.getRead() == onRead && e.getDataSize() == dataSize @@ -119,10 +89,10 @@ onRead = true; DataTruncation e = new DataTruncation(index, parameter, onRead, dataSize, transferSize, t); - assertTrue(e.getMessage().equals(reason) + assertTrue(e.getMessage().equals(dtReason) && e.getSQLState().equals(READ_TRUNCATION) && cause.equals(e.getCause().toString()) - && e.getErrorCode() == errorCode + && e.getErrorCode() == dterrorCode && e.getParameter() == parameter && e.getRead() == onRead && e.getDataSize() == dataSize @@ -139,10 +109,10 @@ onRead = true;; DataTruncation e = new DataTruncation(index, parameter, onRead, dataSize, transferSize, null); - assertTrue(e.getMessage().equals(reason) + assertTrue(e.getMessage().equals(dtReason) && e.getSQLState().equals(READ_TRUNCATION) && e.getCause() == null - && e.getErrorCode() == errorCode + && e.getErrorCode() == dterrorCode && e.getParameter() == parameter && e.getRead() == onRead && e.getDataSize() == dataSize @@ -160,10 +130,10 @@ int negIndex = -1; DataTruncation e = new DataTruncation(negIndex, parameter, onRead, dataSize, transferSize); - assertTrue(e.getMessage().equals(reason) + assertTrue(e.getMessage().equals(dtReason) && e.getSQLState().equals(READ_TRUNCATION) && e.getCause() == null - && e.getErrorCode() == errorCode + && e.getErrorCode() == dterrorCode && e.getParameter() == parameter && e.getRead() == onRead && e.getDataSize() == dataSize @@ -178,17 +148,11 @@ public void test5() throws Exception { DataTruncation e = new DataTruncation(index, parameter, onRead, dataSize, transferSize); - ObjectOutputStream out - = new ObjectOutputStream( - new FileOutputStream("DataTruncation.ser")); - out.writeObject(e); - ObjectInputStream is = new ObjectInputStream( - new FileInputStream("DataTruncation.ser")); - DataTruncation ex1 = (DataTruncation) is.readObject(); - assertTrue(e.getMessage().equals(reason) + DataTruncation ex1 = createSerializedException(e, "DataTruncation.ser"); + assertTrue(e.getMessage().equals(dtReason) && e.getSQLState().equals(READ_TRUNCATION) && e.getCause() == null - && e.getErrorCode() == errorCode + && e.getErrorCode() == dterrorCode && e.getParameter() == parameter && e.getRead() == onRead && e.getDataSize() == dataSize @@ -212,7 +176,7 @@ ex.setNextException(ex2); int num = 0; for (Throwable e : ex) { - assertTrue(msgs[num++].equals(e.getMessage())); + assertTrue(dtmsgs[num++].equals(e.getMessage())); } } @@ -233,10 +197,10 @@ int num = 0; SQLException sqe = ex; while (sqe != null) { - assertTrue(msgs[num++].equals(sqe.getMessage())); + assertTrue(dtmsgs[num++].equals(sqe.getMessage())); Throwable c = sqe.getCause(); while (c != null) { - assertTrue(msgs[num++].equals(c.getMessage())); + assertTrue(dtmsgs[num++].equals(c.getMessage())); c = c.getCause(); } sqe = sqe.getNextException(); --- old/test/java/sql/test/sql/SQLClientInfoExceptionTests.java 2014-04-21 16:49:52.000000000 -0400 +++ new/test/java/sql/test/sql/SQLClientInfoExceptionTests.java 2014-04-21 16:49:52.000000000 -0400 @@ -22,55 +22,23 @@ */ package test.sql; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; import java.sql.ClientInfoStatus; import java.sql.SQLClientInfoException; import java.sql.SQLException; import java.util.HashMap; import static org.testng.Assert.*; -import org.testng.annotations.AfterClass; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import util.BaseTest; -public class SQLClientInfoExceptionTests { +public class SQLClientInfoExceptionTests extends BaseTest { - private final String reason = "reason"; - private final String state = "SQLState"; - private final String cause = "java.lang.Throwable: cause"; private final HashMap map = new HashMap<>(); - private final Throwable t = new Throwable("cause"); - private final Throwable t1 = new Throwable("cause 1"); - private final Throwable t2 = new Throwable("cause 2"); - private final int errorCode = 21; - private final String[] msgs = {"Exception 1", "cause 1", "Exception 2", - "Exception 3", "cause 2"}; public SQLClientInfoExceptionTests() { map.put("1", ClientInfoStatus.REASON_UNKNOWN_PROPERTY); map.put("21", ClientInfoStatus.REASON_UNKNOWN_PROPERTY); } - @BeforeClass - public static void setUpClass() throws Exception { - } - - @AfterClass - public static void tearDownClass() throws Exception { - } - - @BeforeMethod - public void setUpMethod() throws Exception { - } - - @AfterMethod - public void tearDownMethod() throws Exception { - } - /** * Create SQLClientInfoException and setting all objects to null */ @@ -201,13 +169,8 @@ public void test10() throws Exception { SQLClientInfoException e = new SQLClientInfoException(reason, state, errorCode, map, t); - ObjectOutputStream out - = new ObjectOutputStream( - new FileOutputStream("SQLClientInfoException.ser")); - out.writeObject(e); - ObjectInputStream is = new ObjectInputStream( - new FileInputStream("SQLClientInfoException.ser")); - SQLClientInfoException ex1 = (SQLClientInfoException) is.readObject(); + SQLClientInfoException ex1 = + createSerializedException(e, "SQLClientInfoException.ser"); assertTrue(reason.equals(ex1.getMessage()) && ex1.getSQLState().equals(state) && cause.equals(ex1.getCause().toString()) --- old/test/java/sql/test/sql/SQLDataExceptionTests.java 2014-04-21 16:49:53.000000000 -0400 +++ new/test/java/sql/test/sql/SQLDataExceptionTests.java 2014-04-21 16:49:53.000000000 -0400 @@ -22,50 +22,14 @@ */ package test.sql; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; import java.sql.SQLDataException; import java.sql.SQLException; import java.sql.SQLNonTransientException; import static org.testng.Assert.*; -import org.testng.annotations.AfterClass; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import util.BaseTest; -public class SQLDataExceptionTests { - - private final String reason = "reason"; - private final String state = "SQLState"; - private final String cause = "java.lang.Throwable: cause"; - private final Throwable t = new Throwable("cause"); - private final Throwable t1 = new Throwable("cause 1"); - private final Throwable t2 = new Throwable("cause 2"); - private final int errorCode = 21; - private final String[] msgs = {"Exception 1", "cause 1", "Exception 2", - "Exception 3", "cause 2"}; - - public SQLDataExceptionTests() { - } - - @BeforeClass - public static void setUpClass() throws Exception { - } - - @AfterClass - public static void tearDownClass() throws Exception { - } - - @BeforeMethod - public void setUpMethod() throws Exception { - } - - @AfterMethod - public void tearDownMethod() throws Exception { - } +public class SQLDataExceptionTests extends BaseTest { /** * Create SQLDataException and setting all objects to null @@ -191,13 +155,7 @@ @Test public void test10() throws Exception { SQLDataException e = new SQLDataException(reason, state, errorCode, t); - ObjectOutputStream out - = new ObjectOutputStream( - new FileOutputStream("SQLDataException.ser")); - out.writeObject(e); - ObjectInputStream is = new ObjectInputStream( - new FileInputStream("SQLDataException.ser")); - SQLDataException ex1 = (SQLDataException) is.readObject(); + SQLDataException ex1 = createSerializedException(e, "SQLDataException.ser"); assertTrue(reason.equals(ex1.getMessage()) && ex1.getSQLState().equals(state) && cause.equals(ex1.getCause().toString()) --- old/test/java/sql/test/sql/SQLExceptionTests.java 2014-04-21 16:49:54.000000000 -0400 +++ new/test/java/sql/test/sql/SQLExceptionTests.java 2014-04-21 16:49:54.000000000 -0400 @@ -22,48 +22,12 @@ */ package test.sql; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; import java.sql.SQLException; import static org.testng.Assert.*; -import org.testng.annotations.AfterClass; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import util.BaseTest; -public class SQLExceptionTests { - - private final String reason = "reason"; - private final String state = "SQLState"; - private final String cause = "java.lang.Throwable: cause"; - private final Throwable t = new Throwable("cause"); - private final Throwable t1 = new Throwable("cause 1"); - private final Throwable t2 = new Throwable("cause 2"); - private final int errorCode = 21; - private final String[] msgs = {"Exception 1", "cause 1", "Exception 2", - "Exception 3", "cause 2"}; - - public SQLExceptionTests() { - } - - @BeforeClass - public static void setUpClass() throws Exception { - } - - @AfterClass - public static void tearDownClass() throws Exception { - } - - @BeforeMethod - public void setUpMethod() throws Exception { - } - - @AfterMethod - public void tearDownMethod() throws Exception { - } +public class SQLExceptionTests extends BaseTest { /** * Create SQLException and setting all objects to null @@ -189,13 +153,7 @@ @Test public void test10() throws Exception { SQLException e = new SQLException(reason, state, errorCode, t); - ObjectOutputStream out - = new ObjectOutputStream( - new FileOutputStream("SQLException.ser")); - out.writeObject(e); - ObjectInputStream is = new ObjectInputStream( - new FileInputStream("SQLException.ser")); - SQLException ex1 = (SQLException) is.readObject(); + SQLException ex1 = createSerializedException(e, "SQLException.ser"); assertTrue(reason.equals(ex1.getMessage()) && ex1.getSQLState().equals(state) && cause.equals(ex1.getCause().toString()) --- old/test/java/sql/test/sql/SQLFeatureNotSupportedExceptionTests.java 2014-04-21 16:49:56.000000000 -0400 +++ new/test/java/sql/test/sql/SQLFeatureNotSupportedExceptionTests.java 2014-04-21 16:49:55.000000000 -0400 @@ -22,50 +22,14 @@ */ package test.sql; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.sql.SQLFeatureNotSupportedException; import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; import java.sql.SQLNonTransientException; import static org.testng.Assert.*; -import org.testng.annotations.AfterClass; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import util.BaseTest; -public class SQLFeatureNotSupportedExceptionTests { - - private final String reason = "reason"; - private final String state = "SQLState"; - private final String cause = "java.lang.Throwable: cause"; - private final Throwable t = new Throwable("cause"); - private final Throwable t1 = new Throwable("cause 1"); - private final Throwable t2 = new Throwable("cause 2"); - private final int errorCode = 21; - private final String[] msgs = {"Exception 1", "cause 1", "Exception 2", - "Exception 3", "cause 2"}; - - public SQLFeatureNotSupportedExceptionTests() { - } - - @BeforeClass - public static void setUpClass() throws Exception { - } - - @AfterClass - public static void tearDownClass() throws Exception { - } - - @BeforeMethod - public void setUpMethod() throws Exception { - } - - @AfterMethod - public void tearDownMethod() throws Exception { - } +public class SQLFeatureNotSupportedExceptionTests extends BaseTest { /** * Create SQLFeatureNotSupportedException and setting all objects to null @@ -201,13 +165,8 @@ public void test10() throws Exception { SQLFeatureNotSupportedException e = new SQLFeatureNotSupportedException(reason, state, errorCode, t); - ObjectOutputStream out - = new ObjectOutputStream( - new FileOutputStream("SQLFeatureNotSupportedException.ser")); - out.writeObject(e); - ObjectInputStream is = new ObjectInputStream( - new FileInputStream("SQLFeatureNotSupportedException.ser")); - SQLFeatureNotSupportedException ex1 = (SQLFeatureNotSupportedException) is.readObject(); + SQLFeatureNotSupportedException ex1 = + createSerializedException(e, "SQLFeatureNotSupportedException.ser"); assertTrue(reason.equals(ex1.getMessage()) && ex1.getSQLState().equals(state) && cause.equals(ex1.getCause().toString()) --- old/test/java/sql/test/sql/SQLIntegrityConstraintViolationExceptionTests.java 2014-04-21 16:49:57.000000000 -0400 +++ new/test/java/sql/test/sql/SQLIntegrityConstraintViolationExceptionTests.java 2014-04-21 16:49:56.000000000 -0400 @@ -22,50 +22,14 @@ */ package test.sql; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.sql.SQLIntegrityConstraintViolationException; import java.sql.SQLException; +import java.sql.SQLIntegrityConstraintViolationException; import java.sql.SQLNonTransientException; import static org.testng.Assert.*; -import org.testng.annotations.AfterClass; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import util.BaseTest; -public class SQLIntegrityConstraintViolationExceptionTests { - - private final String reason = "reason"; - private final String state = "SQLState"; - private final String cause = "java.lang.Throwable: cause"; - private final Throwable t = new Throwable("cause"); - private final Throwable t1 = new Throwable("cause 1"); - private final Throwable t2 = new Throwable("cause 2"); - private final int errorCode = 21; - private final String[] msgs = {"Exception 1", "cause 1", "Exception 2", - "Exception 3", "cause 2"}; - - public SQLIntegrityConstraintViolationExceptionTests() { - } - - @BeforeClass - public static void setUpClass() throws Exception { - } - - @AfterClass - public static void tearDownClass() throws Exception { - } - - @BeforeMethod - public void setUpMethod() throws Exception { - } - - @AfterMethod - public void tearDownMethod() throws Exception { - } +public class SQLIntegrityConstraintViolationExceptionTests extends BaseTest { /** * Create SQLIntegrityConstraintViolationException and setting all objects to null @@ -204,14 +168,8 @@ public void test10() throws Exception { SQLIntegrityConstraintViolationException e = new SQLIntegrityConstraintViolationException(reason, state, errorCode, t); - ObjectOutputStream out - = new ObjectOutputStream( - new FileOutputStream("SQLIntegrityConstraintViolationException.ser")); - out.writeObject(e); - ObjectInputStream is = new ObjectInputStream( - new FileInputStream("SQLIntegrityConstraintViolationException.ser")); SQLIntegrityConstraintViolationException ex1 = - (SQLIntegrityConstraintViolationException) is.readObject(); + createSerializedException(e, "SQLIntegrityConstraintViolationException.ser"); assertTrue(reason.equals(ex1.getMessage()) && ex1.getSQLState().equals(state) && cause.equals(ex1.getCause().toString()) --- old/test/java/sql/test/sql/SQLInvalidAuthorizationSpecExceptionTests.java 2014-04-21 16:49:58.000000000 -0400 +++ new/test/java/sql/test/sql/SQLInvalidAuthorizationSpecExceptionTests.java 2014-04-21 16:49:58.000000000 -0400 @@ -22,50 +22,14 @@ */ package test.sql; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.sql.SQLInvalidAuthorizationSpecException; import java.sql.SQLException; +import java.sql.SQLInvalidAuthorizationSpecException; import java.sql.SQLNonTransientException; import static org.testng.Assert.*; -import org.testng.annotations.AfterClass; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import util.BaseTest; -public class SQLInvalidAuthorizationSpecExceptionTests { - - private final String reason = "reason"; - private final String state = "SQLState"; - private final String cause = "java.lang.Throwable: cause"; - private final Throwable t = new Throwable("cause"); - private final Throwable t1 = new Throwable("cause 1"); - private final Throwable t2 = new Throwable("cause 2"); - private final int errorCode = 21; - private final String[] msgs = {"Exception 1", "cause 1", "Exception 2", - "Exception 3", "cause 2"}; - - public SQLInvalidAuthorizationSpecExceptionTests() { - } - - @BeforeClass - public static void setUpClass() throws Exception { - } - - @AfterClass - public static void tearDownClass() throws Exception { - } - - @BeforeMethod - public void setUpMethod() throws Exception { - } - - @AfterMethod - public void tearDownMethod() throws Exception { - } +public class SQLInvalidAuthorizationSpecExceptionTests extends BaseTest { /** * Create SQLInvalidAuthorizationSpecException and setting all objects to @@ -208,13 +172,8 @@ public void test10() throws Exception { SQLInvalidAuthorizationSpecException e = new SQLInvalidAuthorizationSpecException(reason, state, errorCode, t); - ObjectOutputStream out - = new ObjectOutputStream( - new FileOutputStream("SQLInvalidAuthorizationSpecException.ser")); - out.writeObject(e); - ObjectInputStream is = new ObjectInputStream( - new FileInputStream("SQLInvalidAuthorizationSpecException.ser")); - SQLInvalidAuthorizationSpecException ex1 = (SQLInvalidAuthorizationSpecException) is.readObject(); + SQLInvalidAuthorizationSpecException ex1 = + createSerializedException(e, "SQLInvalidAuthorizationSpecException.ser"); assertTrue(reason.equals(ex1.getMessage()) && ex1.getSQLState().equals(state) && cause.equals(ex1.getCause().toString()) --- old/test/java/sql/test/sql/SQLNonTransientConnectionExceptionTests.java 2014-04-21 16:50:00.000000000 -0400 +++ new/test/java/sql/test/sql/SQLNonTransientConnectionExceptionTests.java 2014-04-21 16:49:59.000000000 -0400 @@ -22,50 +22,14 @@ */ package test.sql; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.sql.SQLNonTransientConnectionException; import java.sql.SQLException; +import java.sql.SQLNonTransientConnectionException; import java.sql.SQLNonTransientException; import static org.testng.Assert.*; -import org.testng.annotations.AfterClass; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import util.BaseTest; -public class SQLNonTransientConnectionExceptionTests { - - private final String reason = "reason"; - private final String state = "SQLState"; - private final String cause = "java.lang.Throwable: cause"; - private final Throwable t = new Throwable("cause"); - private final Throwable t1 = new Throwable("cause 1"); - private final Throwable t2 = new Throwable("cause 2"); - private final int errorCode = 21; - private final String[] msgs = {"Exception 1", "cause 1", "Exception 2", - "Exception 3", "cause 2"}; - - public SQLNonTransientConnectionExceptionTests() { - } - - @BeforeClass - public static void setUpClass() throws Exception { - } - - @AfterClass - public static void tearDownClass() throws Exception { - } - - @BeforeMethod - public void setUpMethod() throws Exception { - } - - @AfterMethod - public void tearDownMethod() throws Exception { - } +public class SQLNonTransientConnectionExceptionTests extends BaseTest { /** * Create SQLNonTransientConnectionException and setting all objects to null @@ -203,15 +167,9 @@ @Test public void test10() throws Exception { SQLNonTransientConnectionException e = - new SQLNonTransientConnectionException(reason, state, errorCode, t); - ObjectOutputStream out - = new ObjectOutputStream( - new FileOutputStream("SQLNonTransientConnectionException.ser")); - out.writeObject(e); - ObjectInputStream is = new ObjectInputStream( - new FileInputStream("SQLNonTransientConnectionException.ser")); + new SQLNonTransientConnectionException(reason, state, errorCode, t);; SQLNonTransientConnectionException ex1 = - (SQLNonTransientConnectionException) is.readObject(); + createSerializedException(e, "SQLNonTransientConnectionException.ser"); assertTrue(reason.equals(ex1.getMessage()) && ex1.getSQLState().equals(state) && cause.equals(ex1.getCause().toString()) --- old/test/java/sql/test/sql/SQLNonTransientExceptionTests.java 2014-04-21 16:50:01.000000000 -0400 +++ new/test/java/sql/test/sql/SQLNonTransientExceptionTests.java 2014-04-21 16:50:01.000000000 -0400 @@ -22,49 +22,13 @@ */ package test.sql; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; import java.sql.SQLException; import java.sql.SQLNonTransientException; import static org.testng.Assert.*; -import org.testng.annotations.AfterClass; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import util.BaseTest; -public class SQLNonTransientExceptionTests { - - private final String reason = "reason"; - private final String state = "SQLState"; - private final String cause = "java.lang.Throwable: cause"; - private final Throwable t = new Throwable("cause"); - private final Throwable t1 = new Throwable("cause 1"); - private final Throwable t2 = new Throwable("cause 2"); - private final int errorCode = 21; - private final String[] msgs = {"Exception 1", "cause 1", "Exception 2", - "Exception 3", "cause 2"}; - - public SQLNonTransientExceptionTests() { - } - - @BeforeClass - public static void setUpClass() throws Exception { - } - - @AfterClass - public static void tearDownClass() throws Exception { - } - - @BeforeMethod - public void setUpMethod() throws Exception { - } - - @AfterMethod - public void tearDownMethod() throws Exception { - } +public class SQLNonTransientExceptionTests extends BaseTest { /** * Create SQLNonTransientException and setting all objects to null @@ -194,13 +158,8 @@ public void test10() throws Exception { SQLNonTransientException e = new SQLNonTransientException(reason, state, errorCode, t); - ObjectOutputStream out - = new ObjectOutputStream( - new FileOutputStream("SQLNonTransientException.ser")); - out.writeObject(e); - ObjectInputStream is = new ObjectInputStream( - new FileInputStream("SQLNonTransientException.ser")); - SQLNonTransientException ex1 = (SQLNonTransientException) is.readObject(); + SQLNonTransientException ex1 = + createSerializedException(e, "SQLNonTransientException.ser"); assertTrue(reason.equals(ex1.getMessage()) && ex1.getSQLState().equals(state) && cause.equals(ex1.getCause().toString()) --- old/test/java/sql/test/sql/SQLRecoverableExceptionTests.java 2014-04-21 16:50:03.000000000 -0400 +++ new/test/java/sql/test/sql/SQLRecoverableExceptionTests.java 2014-04-21 16:50:03.000000000 -0400 @@ -22,49 +22,13 @@ */ package test.sql; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.sql.SQLRecoverableException; import java.sql.SQLException; +import java.sql.SQLRecoverableException; import static org.testng.Assert.*; -import org.testng.annotations.AfterClass; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import util.BaseTest; -public class SQLRecoverableExceptionTests { - - private final String reason = "reason"; - private final String state = "SQLState"; - private final String cause = "java.lang.Throwable: cause"; - private final Throwable t = new Throwable("cause"); - private final Throwable t1 = new Throwable("cause 1"); - private final Throwable t2 = new Throwable("cause 2"); - private final int errorCode = 21; - private final String[] msgs = {"Exception 1", "cause 1", "Exception 2", - "Exception 3", "cause 2"}; - - public SQLRecoverableExceptionTests() { - } - - @BeforeClass - public static void setUpClass() throws Exception { - } - - @AfterClass - public static void tearDownClass() throws Exception { - } - - @BeforeMethod - public void setUpMethod() throws Exception { - } - - @AfterMethod - public void tearDownMethod() throws Exception { - } +public class SQLRecoverableExceptionTests extends BaseTest { /** * Create SQLRecoverableException and setting all objects to null @@ -194,13 +158,8 @@ public void test10() throws Exception { SQLRecoverableException e = new SQLRecoverableException(reason, state, errorCode, t); - ObjectOutputStream out - = new ObjectOutputStream( - new FileOutputStream("SQLRecoverableException.ser")); - out.writeObject(e); - ObjectInputStream is = new ObjectInputStream( - new FileInputStream("SQLRecoverableException.ser")); - SQLRecoverableException ex1 = (SQLRecoverableException) is.readObject(); + SQLRecoverableException ex1 = + createSerializedException(e, "SQLRecoverableException.ser"); assertTrue(reason.equals(ex1.getMessage()) && ex1.getSQLState().equals(state) && cause.equals(ex1.getCause().toString()) --- old/test/java/sql/test/sql/SQLSyntaxErrorExceptionTests.java 2014-04-21 16:50:04.000000000 -0400 +++ new/test/java/sql/test/sql/SQLSyntaxErrorExceptionTests.java 2014-04-21 16:50:04.000000000 -0400 @@ -22,50 +22,14 @@ */ package test.sql; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.sql.SQLSyntaxErrorException; import java.sql.SQLException; import java.sql.SQLNonTransientException; +import java.sql.SQLSyntaxErrorException; import static org.testng.Assert.*; -import org.testng.annotations.AfterClass; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import util.BaseTest; -public class SQLSyntaxErrorExceptionTests { - - private final String reason = "reason"; - private final String state = "SQLState"; - private final String cause = "java.lang.Throwable: cause"; - private final Throwable t = new Throwable("cause"); - private final Throwable t1 = new Throwable("cause 1"); - private final Throwable t2 = new Throwable("cause 2"); - private final int errorCode = 21; - private final String[] msgs = {"Exception 1", "cause 1", "Exception 2", - "Exception 3", "cause 2"}; - - public SQLSyntaxErrorExceptionTests() { - } - - @BeforeClass - public static void setUpClass() throws Exception { - } - - @AfterClass - public static void tearDownClass() throws Exception { - } - - @BeforeMethod - public void setUpMethod() throws Exception { - } - - @AfterMethod - public void tearDownMethod() throws Exception { - } +public class SQLSyntaxErrorExceptionTests extends BaseTest { /** * Create SQLSyntaxErrorException and setting all objects to null @@ -196,13 +160,8 @@ SQLSyntaxErrorException e = new SQLSyntaxErrorException(reason, state, errorCode, t); - ObjectOutputStream out - = new ObjectOutputStream( - new FileOutputStream("SQLSyntaxErrorException.ser")); - out.writeObject(e); - ObjectInputStream is = new ObjectInputStream( - new FileInputStream("SQLSyntaxErrorException.ser")); - SQLSyntaxErrorException ex1 = (SQLSyntaxErrorException) is.readObject(); + SQLSyntaxErrorException ex1 = + createSerializedException(e, "SQLSyntaxErrorException.ser"); assertTrue(reason.equals(ex1.getMessage()) && ex1.getSQLState().equals(state) && cause.equals(ex1.getCause().toString()) --- old/test/java/sql/test/sql/SQLTimeoutExceptionTests.java 2014-04-21 16:50:06.000000000 -0400 +++ new/test/java/sql/test/sql/SQLTimeoutExceptionTests.java 2014-04-21 16:50:05.000000000 -0400 @@ -22,50 +22,14 @@ */ package test.sql; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; import java.sql.SQLException; import java.sql.SQLTimeoutException; import java.sql.SQLTransientException; import static org.testng.Assert.*; -import org.testng.annotations.AfterClass; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import util.BaseTest; -public class SQLTimeoutExceptionTests { - - private final String reason = "reason"; - private final String state = "SQLState"; - private final String cause = "java.lang.Throwable: cause"; - private final Throwable t = new Throwable("cause"); - private final Throwable t1 = new Throwable("cause 1"); - private final Throwable t2 = new Throwable("cause 2"); - private final int errorCode = 21; - private final String[] msgs = {"Exception 1", "cause 1", "Exception 2", - "Exception 3", "cause 2"}; - - public SQLTimeoutExceptionTests() { - } - - @BeforeClass - public static void setUpClass() throws Exception { - } - - @AfterClass - public static void tearDownClass() throws Exception { - } - - @BeforeMethod - public void setUpMethod() throws Exception { - } - - @AfterMethod - public void tearDownMethod() throws Exception { - } +public class SQLTimeoutExceptionTests extends BaseTest { /** * Create SQLTimeoutException and setting all objects to null @@ -193,13 +157,8 @@ public void test10() throws Exception { SQLTimeoutException e = new SQLTimeoutException(reason, state, errorCode, t); - ObjectOutputStream out - = new ObjectOutputStream( - new FileOutputStream("SQLTimeoutException.ser")); - out.writeObject(e); - ObjectInputStream is = new ObjectInputStream( - new FileInputStream("SQLTimeoutException.ser")); - SQLTimeoutException ex1 = (SQLTimeoutException) is.readObject(); + SQLTimeoutException ex1 = + createSerializedException(e, "SQLTimeoutException.ser"); assertTrue(reason.equals(ex1.getMessage()) && ex1.getSQLState().equals(state) && cause.equals(ex1.getCause().toString()) --- old/test/java/sql/test/sql/SQLTransactionRollbackExceptionTests.java 2014-04-21 16:50:08.000000000 -0400 +++ new/test/java/sql/test/sql/SQLTransactionRollbackExceptionTests.java 2014-04-21 16:50:07.000000000 -0400 @@ -22,50 +22,14 @@ */ package test.sql; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; import java.sql.SQLException; import java.sql.SQLTransactionRollbackException; import java.sql.SQLTransientException; import static org.testng.Assert.*; -import org.testng.annotations.AfterClass; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import util.BaseTest; -public class SQLTransactionRollbackExceptionTests { - - private final String reason = "reason"; - private final String state = "SQLState"; - private final String cause = "java.lang.Throwable: cause"; - private final Throwable t = new Throwable("cause"); - private final Throwable t1 = new Throwable("cause 1"); - private final Throwable t2 = new Throwable("cause 2"); - private final int errorCode = 21; - private final String[] msgs = {"Exception 1", "cause 1", "Exception 2", - "Exception 3", "cause 2"}; - - public SQLTransactionRollbackExceptionTests() { - } - - @BeforeClass - public static void setUpClass() throws Exception { - } - - @AfterClass - public static void tearDownClass() throws Exception { - } - - @BeforeMethod - public void setUpMethod() throws Exception { - } - - @AfterMethod - public void tearDownMethod() throws Exception { - } +public class SQLTransactionRollbackExceptionTests extends BaseTest { /** * Create SQLTransactionRollbackException and setting all objects to null @@ -202,13 +166,8 @@ public void test10() throws Exception { SQLTransactionRollbackException e = new SQLTransactionRollbackException(reason, state, errorCode, t); - ObjectOutputStream out - = new ObjectOutputStream( - new FileOutputStream("SQLTransactionRollbackException.ser")); - out.writeObject(e); - ObjectInputStream is = new ObjectInputStream( - new FileInputStream("SQLTransactionRollbackException.ser")); - SQLTransactionRollbackException ex1 = (SQLTransactionRollbackException) is.readObject(); + SQLTransactionRollbackException ex1 = + createSerializedException(e, "SQLTransactionRollbackException.ser"); assertTrue(reason.equals(ex1.getMessage()) && ex1.getSQLState().equals(state) && cause.equals(ex1.getCause().toString()) --- old/test/java/sql/test/sql/SQLTransientConnectionExceptionTests.java 2014-04-21 16:50:09.000000000 -0400 +++ new/test/java/sql/test/sql/SQLTransientConnectionExceptionTests.java 2014-04-21 16:50:09.000000000 -0400 @@ -22,50 +22,14 @@ */ package test.sql; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; import java.sql.SQLException; import java.sql.SQLTransientConnectionException; import java.sql.SQLTransientException; import static org.testng.Assert.*; -import org.testng.annotations.AfterClass; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import util.BaseTest; -public class SQLTransientConnectionExceptionTests { - - private final String reason = "reason"; - private final String state = "SQLState"; - private final String cause = "java.lang.Throwable: cause"; - private final Throwable t = new Throwable("cause"); - private final Throwable t1 = new Throwable("cause 1"); - private final Throwable t2 = new Throwable("cause 2"); - private final int errorCode = 21; - private final String[] msgs = {"Exception 1", "cause 1", "Exception 2", - "Exception 3", "cause 2"}; - - public SQLTransientConnectionExceptionTests() { - } - - @BeforeClass - public static void setUpClass() throws Exception { - } - - @AfterClass - public static void tearDownClass() throws Exception { - } - - @BeforeMethod - public void setUpMethod() throws Exception { - } - - @AfterMethod - public void tearDownMethod() throws Exception { - } +public class SQLTransientConnectionExceptionTests extends BaseTest { /** * Create SQLTransientConnectionException and setting all objects to null @@ -202,13 +166,8 @@ public void test10() throws Exception { SQLTransientConnectionException e = new SQLTransientConnectionException(reason, state, errorCode, t); - ObjectOutputStream out - = new ObjectOutputStream( - new FileOutputStream("SQLTransientConnectionException.ser")); - out.writeObject(e); - ObjectInputStream is = new ObjectInputStream( - new FileInputStream("SQLTransientConnectionException.ser")); - SQLTransientConnectionException ex1 = (SQLTransientConnectionException) is.readObject(); + SQLTransientConnectionException ex1 = + createSerializedException(e, "SQLTransientConnectionException.ser"); assertTrue(reason.equals(ex1.getMessage()) && ex1.getSQLState().equals(state) && cause.equals(ex1.getCause().toString()) --- old/test/java/sql/test/sql/SQLTransientExceptionTests.java 2014-04-21 16:50:11.000000000 -0400 +++ new/test/java/sql/test/sql/SQLTransientExceptionTests.java 2014-04-21 16:50:10.000000000 -0400 @@ -22,49 +22,13 @@ */ package test.sql; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.sql.SQLTransientException; import java.sql.SQLException; +import java.sql.SQLTransientException; import static org.testng.Assert.*; -import org.testng.annotations.AfterClass; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import util.BaseTest; -public class SQLTransientExceptionTests { - - private final String reason = "reason"; - private final String state = "SQLState"; - private final String cause = "java.lang.Throwable: cause"; - private final Throwable t = new Throwable("cause"); - private final Throwable t1 = new Throwable("cause 1"); - private final Throwable t2 = new Throwable("cause 2"); - private final int errorCode = 21; - private final String[] msgs = {"Exception 1", "cause 1", "Exception 2", - "Exception 3", "cause 2"}; - - public SQLTransientExceptionTests() { - } - - @BeforeClass - public static void setUpClass() throws Exception { - } - - @AfterClass - public static void tearDownClass() throws Exception { - } - - @BeforeMethod - public void setUpMethod() throws Exception { - } - - @AfterMethod - public void tearDownMethod() throws Exception { - } +public class SQLTransientExceptionTests extends BaseTest { /** * Create SQLTransientException and setting all objects to null @@ -193,13 +157,8 @@ public void test10() throws Exception { SQLTransientException e = new SQLTransientException(reason, state, errorCode, t); - ObjectOutputStream out - = new ObjectOutputStream( - new FileOutputStream("SQLTransientException.ser")); - out.writeObject(e); - ObjectInputStream is = new ObjectInputStream( - new FileInputStream("SQLTransientException.ser")); - SQLTransientException ex1 = (SQLTransientException) is.readObject(); + SQLTransientException ex1 = createSerializedException(e, + "SQLTransientException.ser"); assertTrue(reason.equals(ex1.getMessage()) && ex1.getSQLState().equals(state) && cause.equals(ex1.getCause().toString()) --- old/test/java/sql/test/sql/SQLWarningTests.java 2014-04-21 16:50:12.000000000 -0400 +++ new/test/java/sql/test/sql/SQLWarningTests.java 2014-04-21 16:50:12.000000000 -0400 @@ -22,52 +22,17 @@ */ package test.sql; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.sql.SQLWarning; import java.sql.SQLException; +import java.sql.SQLWarning; import static org.testng.Assert.*; -import org.testng.annotations.AfterClass; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import util.BaseTest; -public class SQLWarningTests { +public class SQLWarningTests extends BaseTest { - private final String reason = "reason"; - private final String state = "SQLState"; - private final String cause = "java.lang.Throwable: cause"; - private final Throwable t = new Throwable("cause"); - private final Throwable t1 = new Throwable("cause 1"); - private final Throwable t2 = new Throwable("cause 2"); - private final int errorCode = 21; - private final String[] msgs = {"Exception 1", "cause 1", "Exception 2", - "Exception 3", "cause 2"}; private final String[] warnings = {"Warning 1", "cause 1", "Warning 2", "Warning 3", "cause 2"}; - public SQLWarningTests() { - } - - @BeforeClass - public static void setUpClass() throws Exception { - } - - @AfterClass - public static void tearDownClass() throws Exception { - } - - @BeforeMethod - public void setUpMethod() throws Exception { - } - - @AfterMethod - public void tearDownMethod() throws Exception { - } - /** * Create SQLWarning and setting all objects to null */ @@ -193,13 +158,7 @@ @Test public void test10() throws Exception { SQLWarning e = new SQLWarning(reason, state, errorCode, t); - ObjectOutputStream out - = new ObjectOutputStream( - new FileOutputStream("SQLWarning.ser")); - out.writeObject(e); - ObjectInputStream is = new ObjectInputStream( - new FileInputStream("SQLWarning.ser")); - SQLWarning ex1 = (SQLWarning) is.readObject(); + SQLWarning ex1 = createSerializedException(e, "SQLWarning.ser"); assertTrue(reason.equals(ex1.getMessage()) && ex1.getSQLState().equals(state) && cause.equals(ex1.getCause().toString()) --- /dev/null 2014-04-21 16:50:13.000000000 -0400 +++ new/test/java/sql/util/BaseTest.java 2014-04-21 16:50:13.000000000 -0400 @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package util; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.net.URI; +import java.net.URISyntaxException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.sql.SQLException; +import org.testng.annotations.AfterClass; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; + +public class BaseTest { + + protected final String reason = "reason"; + protected final String state = "SQLState"; + protected final String cause = "java.lang.Throwable: cause"; + protected final Throwable t = new Throwable("cause"); + protected final Throwable t1 = new Throwable("cause 1"); + protected final Throwable t2 = new Throwable("cause 2"); + protected final int errorCode = 21; + protected final String[] msgs = {"Exception 1", "cause 1", "Exception 2", + "Exception 3", "cause 2"}; + + @BeforeClass + public static void setUpClass() throws Exception { + } + + @AfterClass + public static void tearDownClass() throws Exception { + } + + @BeforeMethod + public void setUpMethod() throws Exception { + } + + @AfterMethod + public void tearDownMethod() throws Exception { + } + + /** + * Take some form of SQLException, serialize and deserialize it + * + * @param SQLException + * @param ex SQLException + * @param fname name of file + * @return + * @throws IOException + * @throws ClassNotFoundException + */ + @SuppressWarnings("unchecked") + protected T + createSerializedException(T ex, String fname) + throws IOException, ClassNotFoundException, URISyntaxException { + T ex1; + try (ObjectOutputStream out = new ObjectOutputStream( + new FileOutputStream(fname)); + ObjectInputStream is = new ObjectInputStream( + new FileInputStream(fname))) { + out.writeObject(ex); + ex1 = (T) is.readObject(); + } + + File f = new File(fname); + if (!f.delete()) { + System.out.println("path=" + f.getAbsolutePath() + + " could not be deleted"); + } + return ex1; + } + +}