8041331: Cleanup files for jtreg and windows

Reviewed-by: rriggs, smarks, chegar
This commit is contained in:
Lance Andersen 2014-04-22 08:57:01 -04:00
parent e613bf3290
commit 48160e4d08
18 changed files with 183 additions and 787 deletions

View File

@ -24,56 +24,23 @@ package test.sql;
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 class BatchUpdateExceptionTests {
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);
assertTrue(reason.equals(bue.getMessage())
&& bue.getSQLState().equals(state)
&& cause.equals(bue.getCause().toString())
@ -273,6 +235,8 @@ public class BatchUpdateExceptionTests {
&& 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 @@ public class BatchUpdateExceptionTests {
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);
assertTrue(reason.equals(bue.getMessage())
&& bue.getSQLState().equals(state)
&& cause.equals(bue.getCause().toString())

View File

@ -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 @@ public class DataTruncationTests {
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 @@ public class DataTruncationTests {
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 @@ public class DataTruncationTests {
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 @@ public class DataTruncationTests {
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 @@ public class DataTruncationTests {
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 class DataTruncationTests {
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);
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 @@ public class DataTruncationTests {
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 @@ public class DataTruncationTests {
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();

View File

@ -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<String, ClientInfoStatus> 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 class SQLClientInfoExceptionTests {
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);
assertTrue(reason.equals(ex1.getMessage())
&& ex1.getSQLState().equals(state)
&& cause.equals(ex1.getCause().toString())

View File

@ -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 @@ public class SQLDataExceptionTests {
@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);
assertTrue(reason.equals(ex1.getMessage())
&& ex1.getSQLState().equals(state)
&& cause.equals(ex1.getCause().toString())

View File

@ -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 @@ public class SQLExceptionTests {
@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);
assertTrue(reason.equals(ex1.getMessage())
&& ex1.getSQLState().equals(state)
&& cause.equals(ex1.getCause().toString())

View File

@ -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 class SQLFeatureNotSupportedExceptionTests {
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);
assertTrue(reason.equals(ex1.getMessage())
&& ex1.getSQLState().equals(state)
&& cause.equals(ex1.getCause().toString())

View File

@ -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 class SQLIntegrityConstraintViolationExceptionTests {
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);
assertTrue(reason.equals(ex1.getMessage())
&& ex1.getSQLState().equals(state)
&& cause.equals(ex1.getCause().toString())

View File

@ -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 class SQLInvalidAuthorizationSpecExceptionTests {
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);
assertTrue(reason.equals(ex1.getMessage())
&& ex1.getSQLState().equals(state)
&& cause.equals(ex1.getCause().toString())

View File

@ -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
@ -204,14 +168,8 @@ public class SQLNonTransientConnectionExceptionTests {
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"));
SQLNonTransientConnectionException ex1 =
(SQLNonTransientConnectionException) is.readObject();
createSerializedException(e);
assertTrue(reason.equals(ex1.getMessage())
&& ex1.getSQLState().equals(state)
&& cause.equals(ex1.getCause().toString())

View File

@ -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 class SQLNonTransientExceptionTests {
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);
assertTrue(reason.equals(ex1.getMessage())
&& ex1.getSQLState().equals(state)
&& cause.equals(ex1.getCause().toString())

View File

@ -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 class SQLRecoverableExceptionTests {
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);
assertTrue(reason.equals(ex1.getMessage())
&& ex1.getSQLState().equals(state)
&& cause.equals(ex1.getCause().toString())

View File

@ -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 @@ public class SQLSyntaxErrorExceptionTests {
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);
assertTrue(reason.equals(ex1.getMessage())
&& ex1.getSQLState().equals(state)
&& cause.equals(ex1.getCause().toString())

View File

@ -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 class SQLTimeoutExceptionTests {
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);
assertTrue(reason.equals(ex1.getMessage())
&& ex1.getSQLState().equals(state)
&& cause.equals(ex1.getCause().toString())

View File

@ -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 class SQLTransactionRollbackExceptionTests {
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);
assertTrue(reason.equals(ex1.getMessage())
&& ex1.getSQLState().equals(state)
&& cause.equals(ex1.getCause().toString())

View File

@ -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 class SQLTransientConnectionExceptionTests {
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);
assertTrue(reason.equals(ex1.getMessage())
&& ex1.getSQLState().equals(state)
&& cause.equals(ex1.getCause().toString())

View File

@ -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,7 @@ public class SQLTransientExceptionTests {
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);
assertTrue(reason.equals(ex1.getMessage())
&& ex1.getSQLState().equals(state)
&& cause.equals(ex1.getCause().toString())

View File

@ -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 @@ public class SQLWarningTests {
@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);
assertTrue(reason.equals(ex1.getMessage())
&& ex1.getSQLState().equals(state)
&& cause.equals(ex1.getCause().toString())

View File

@ -0,0 +1,89 @@
/*
* 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.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
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 <T> SQLException
* @param ex SQLException
* @return deserialized SQLException
* @throws IOException
* @throws ClassNotFoundException
*/
@SuppressWarnings("unchecked")
protected <T extends SQLException> T
createSerializedException(T ex)
throws IOException, ClassNotFoundException {
T ex1;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try (ObjectOutputStream oos = new ObjectOutputStream(baos) ) {
oos.writeObject(ex);
}
try (ObjectInputStream ois =
new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()))) {
ex1 = (T) ois.readObject();
}
return ex1;
}
}