8041331: Cleanup files for jtreg and windows
Reviewed-by: rriggs, smarks, chegar
This commit is contained in:
parent
e613bf3290
commit
48160e4d08
@ -24,56 +24,23 @@ package test.sql;
|
|||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.ObjectInputStream;
|
import java.io.ObjectInputStream;
|
||||||
import java.io.ObjectOutputStream;
|
|
||||||
import java.sql.BatchUpdateException;
|
import java.sql.BatchUpdateException;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import static org.testng.Assert.*;
|
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 org.testng.annotations.Test;
|
||||||
import util.SerializedBatchUpdateException;
|
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 int[] uc = {1, 2, 3};
|
||||||
private final long[] luc = {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", ".")
|
private final String testSrcDir = System.getProperty("test.src", ".")
|
||||||
+ File.separatorChar;
|
+ 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
|
* Create BatchUpdateException and setting all objects to null
|
||||||
*/
|
*/
|
||||||
@ -258,13 +225,8 @@ public class BatchUpdateExceptionTests {
|
|||||||
public void test12() throws Exception {
|
public void test12() throws Exception {
|
||||||
BatchUpdateException be = new BatchUpdateException(reason, state, errorCode,
|
BatchUpdateException be = new BatchUpdateException(reason, state, errorCode,
|
||||||
uc, t);
|
uc, t);
|
||||||
ObjectOutputStream out
|
BatchUpdateException bue
|
||||||
= new ObjectOutputStream(
|
= createSerializedException(be);
|
||||||
new FileOutputStream("BatchUpdateException_JDBC42.ser"));
|
|
||||||
out.writeObject(be);
|
|
||||||
ObjectInputStream is = new ObjectInputStream(
|
|
||||||
new FileInputStream("BatchUpdateException_JDBC42.ser"));
|
|
||||||
BatchUpdateException bue = (BatchUpdateException) is.readObject();
|
|
||||||
assertTrue(reason.equals(bue.getMessage())
|
assertTrue(reason.equals(bue.getMessage())
|
||||||
&& bue.getSQLState().equals(state)
|
&& bue.getSQLState().equals(state)
|
||||||
&& cause.equals(bue.getCause().toString())
|
&& cause.equals(bue.getCause().toString())
|
||||||
@ -273,6 +235,8 @@ public class BatchUpdateExceptionTests {
|
|||||||
&& Arrays.equals(bue.getUpdateCounts(), uc));
|
&& Arrays.equals(bue.getUpdateCounts(), uc));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* De-Serialize a BatchUpdateException from JDBC 4.0 and make sure you can
|
* De-Serialize a BatchUpdateException from JDBC 4.0 and make sure you can
|
||||||
* read it back properly
|
* read it back properly
|
||||||
@ -308,13 +272,8 @@ public class BatchUpdateExceptionTests {
|
|||||||
long[] luc1 = {Integer.MAX_VALUE, Integer.MAX_VALUE + 1};
|
long[] luc1 = {Integer.MAX_VALUE, Integer.MAX_VALUE + 1};
|
||||||
BatchUpdateException be = new BatchUpdateException(reason, state, errorCode,
|
BatchUpdateException be = new BatchUpdateException(reason, state, errorCode,
|
||||||
luc1, t);
|
luc1, t);
|
||||||
ObjectOutputStream out
|
BatchUpdateException bue
|
||||||
= new ObjectOutputStream(
|
= createSerializedException(be);
|
||||||
new FileOutputStream("BatchUpdateException_MAX_INT.ser"));
|
|
||||||
out.writeObject(be);
|
|
||||||
ObjectInputStream is = new ObjectInputStream(
|
|
||||||
new FileInputStream("BatchUpdateException_MAX_INT.ser"));
|
|
||||||
BatchUpdateException bue = (BatchUpdateException) is.readObject();
|
|
||||||
assertTrue(reason.equals(bue.getMessage())
|
assertTrue(reason.equals(bue.getMessage())
|
||||||
&& bue.getSQLState().equals(state)
|
&& bue.getSQLState().equals(state)
|
||||||
&& cause.equals(bue.getCause().toString())
|
&& cause.equals(bue.getCause().toString())
|
||||||
|
@ -22,56 +22,26 @@
|
|||||||
*/
|
*/
|
||||||
package test.sql;
|
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.DataTruncation;
|
||||||
|
import java.sql.SQLException;
|
||||||
import static org.testng.Assert.*;
|
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 org.testng.annotations.Test;
|
||||||
|
import util.BaseTest;
|
||||||
|
|
||||||
public class DataTruncationTests {
|
public class DataTruncationTests extends BaseTest {
|
||||||
|
|
||||||
private final String READ_TRUNCATION = "01004";
|
private final String READ_TRUNCATION = "01004";
|
||||||
private final String WRITE_TRUNCATION = "22001";
|
private final String WRITE_TRUNCATION = "22001";
|
||||||
private final String reason = "Data truncation";
|
private final String dtReason = "Data truncation";
|
||||||
private final String cause = "java.lang.Throwable: cause";
|
private final int dterrorCode = 0;
|
||||||
private final Throwable t = new Throwable("cause");
|
private final String[] dtmsgs = {dtReason, "cause 1", dtReason,
|
||||||
private final Throwable t1 = new Throwable("cause 1");
|
dtReason, "cause 2"};
|
||||||
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 boolean onRead = false;
|
private boolean onRead = false;
|
||||||
private final boolean parameter = false;
|
private final boolean parameter = false;
|
||||||
private final int index = 21;
|
private final int index = 21;
|
||||||
private final int dataSize = 25;
|
private final int dataSize = 25;
|
||||||
private final int transferSize = 10;
|
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
|
* Create DataTruncation object indicating a truncation on read
|
||||||
*/
|
*/
|
||||||
@ -80,10 +50,10 @@ public class DataTruncationTests {
|
|||||||
onRead = true;
|
onRead = true;
|
||||||
DataTruncation e = new DataTruncation(index, parameter, onRead,
|
DataTruncation e = new DataTruncation(index, parameter, onRead,
|
||||||
dataSize, transferSize);
|
dataSize, transferSize);
|
||||||
assertTrue(e.getMessage().equals(reason)
|
assertTrue(e.getMessage().equals(dtReason)
|
||||||
&& e.getSQLState().equals(READ_TRUNCATION)
|
&& e.getSQLState().equals(READ_TRUNCATION)
|
||||||
&& e.getCause() == null
|
&& e.getCause() == null
|
||||||
&& e.getErrorCode() == errorCode
|
&& e.getErrorCode() == dterrorCode
|
||||||
&& e.getParameter() == parameter
|
&& e.getParameter() == parameter
|
||||||
&& e.getRead() == onRead
|
&& e.getRead() == onRead
|
||||||
&& e.getDataSize() == dataSize
|
&& e.getDataSize() == dataSize
|
||||||
@ -99,10 +69,10 @@ public class DataTruncationTests {
|
|||||||
onRead = false;
|
onRead = false;
|
||||||
DataTruncation e = new DataTruncation(index, parameter, onRead,
|
DataTruncation e = new DataTruncation(index, parameter, onRead,
|
||||||
dataSize, transferSize);
|
dataSize, transferSize);
|
||||||
assertTrue(e.getMessage().equals(reason)
|
assertTrue(e.getMessage().equals(dtReason)
|
||||||
&& e.getSQLState().equals(WRITE_TRUNCATION)
|
&& e.getSQLState().equals(WRITE_TRUNCATION)
|
||||||
&& e.getCause() == null
|
&& e.getCause() == null
|
||||||
&& e.getErrorCode() == errorCode
|
&& e.getErrorCode() == dterrorCode
|
||||||
&& e.getParameter() == parameter
|
&& e.getParameter() == parameter
|
||||||
&& e.getRead() == onRead
|
&& e.getRead() == onRead
|
||||||
&& e.getDataSize() == dataSize
|
&& e.getDataSize() == dataSize
|
||||||
@ -119,10 +89,10 @@ public class DataTruncationTests {
|
|||||||
onRead = true;
|
onRead = true;
|
||||||
DataTruncation e = new DataTruncation(index, parameter, onRead,
|
DataTruncation e = new DataTruncation(index, parameter, onRead,
|
||||||
dataSize, transferSize, t);
|
dataSize, transferSize, t);
|
||||||
assertTrue(e.getMessage().equals(reason)
|
assertTrue(e.getMessage().equals(dtReason)
|
||||||
&& e.getSQLState().equals(READ_TRUNCATION)
|
&& e.getSQLState().equals(READ_TRUNCATION)
|
||||||
&& cause.equals(e.getCause().toString())
|
&& cause.equals(e.getCause().toString())
|
||||||
&& e.getErrorCode() == errorCode
|
&& e.getErrorCode() == dterrorCode
|
||||||
&& e.getParameter() == parameter
|
&& e.getParameter() == parameter
|
||||||
&& e.getRead() == onRead
|
&& e.getRead() == onRead
|
||||||
&& e.getDataSize() == dataSize
|
&& e.getDataSize() == dataSize
|
||||||
@ -139,10 +109,10 @@ public class DataTruncationTests {
|
|||||||
onRead = true;;
|
onRead = true;;
|
||||||
DataTruncation e = new DataTruncation(index, parameter, onRead,
|
DataTruncation e = new DataTruncation(index, parameter, onRead,
|
||||||
dataSize, transferSize, null);
|
dataSize, transferSize, null);
|
||||||
assertTrue(e.getMessage().equals(reason)
|
assertTrue(e.getMessage().equals(dtReason)
|
||||||
&& e.getSQLState().equals(READ_TRUNCATION)
|
&& e.getSQLState().equals(READ_TRUNCATION)
|
||||||
&& e.getCause() == null
|
&& e.getCause() == null
|
||||||
&& e.getErrorCode() == errorCode
|
&& e.getErrorCode() == dterrorCode
|
||||||
&& e.getParameter() == parameter
|
&& e.getParameter() == parameter
|
||||||
&& e.getRead() == onRead
|
&& e.getRead() == onRead
|
||||||
&& e.getDataSize() == dataSize
|
&& e.getDataSize() == dataSize
|
||||||
@ -160,10 +130,10 @@ public class DataTruncationTests {
|
|||||||
int negIndex = -1;
|
int negIndex = -1;
|
||||||
DataTruncation e = new DataTruncation(negIndex, parameter, onRead,
|
DataTruncation e = new DataTruncation(negIndex, parameter, onRead,
|
||||||
dataSize, transferSize);
|
dataSize, transferSize);
|
||||||
assertTrue(e.getMessage().equals(reason)
|
assertTrue(e.getMessage().equals(dtReason)
|
||||||
&& e.getSQLState().equals(READ_TRUNCATION)
|
&& e.getSQLState().equals(READ_TRUNCATION)
|
||||||
&& e.getCause() == null
|
&& e.getCause() == null
|
||||||
&& e.getErrorCode() == errorCode
|
&& e.getErrorCode() == dterrorCode
|
||||||
&& e.getParameter() == parameter
|
&& e.getParameter() == parameter
|
||||||
&& e.getRead() == onRead
|
&& e.getRead() == onRead
|
||||||
&& e.getDataSize() == dataSize
|
&& e.getDataSize() == dataSize
|
||||||
@ -178,17 +148,11 @@ public class DataTruncationTests {
|
|||||||
public void test5() throws Exception {
|
public void test5() throws Exception {
|
||||||
DataTruncation e = new DataTruncation(index, parameter, onRead,
|
DataTruncation e = new DataTruncation(index, parameter, onRead,
|
||||||
dataSize, transferSize);
|
dataSize, transferSize);
|
||||||
ObjectOutputStream out
|
DataTruncation ex1 = createSerializedException(e);
|
||||||
= new ObjectOutputStream(
|
assertTrue(e.getMessage().equals(dtReason)
|
||||||
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)
|
|
||||||
&& e.getSQLState().equals(READ_TRUNCATION)
|
&& e.getSQLState().equals(READ_TRUNCATION)
|
||||||
&& e.getCause() == null
|
&& e.getCause() == null
|
||||||
&& e.getErrorCode() == errorCode
|
&& e.getErrorCode() == dterrorCode
|
||||||
&& e.getParameter() == parameter
|
&& e.getParameter() == parameter
|
||||||
&& e.getRead() == onRead
|
&& e.getRead() == onRead
|
||||||
&& e.getDataSize() == dataSize
|
&& e.getDataSize() == dataSize
|
||||||
@ -212,7 +176,7 @@ public class DataTruncationTests {
|
|||||||
ex.setNextException(ex2);
|
ex.setNextException(ex2);
|
||||||
int num = 0;
|
int num = 0;
|
||||||
for (Throwable e : ex) {
|
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;
|
int num = 0;
|
||||||
SQLException sqe = ex;
|
SQLException sqe = ex;
|
||||||
while (sqe != null) {
|
while (sqe != null) {
|
||||||
assertTrue(msgs[num++].equals(sqe.getMessage()));
|
assertTrue(dtmsgs[num++].equals(sqe.getMessage()));
|
||||||
Throwable c = sqe.getCause();
|
Throwable c = sqe.getCause();
|
||||||
while (c != null) {
|
while (c != null) {
|
||||||
assertTrue(msgs[num++].equals(c.getMessage()));
|
assertTrue(dtmsgs[num++].equals(c.getMessage()));
|
||||||
c = c.getCause();
|
c = c.getCause();
|
||||||
}
|
}
|
||||||
sqe = sqe.getNextException();
|
sqe = sqe.getNextException();
|
||||||
|
@ -22,55 +22,23 @@
|
|||||||
*/
|
*/
|
||||||
package test.sql;
|
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.ClientInfoStatus;
|
||||||
import java.sql.SQLClientInfoException;
|
import java.sql.SQLClientInfoException;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import static org.testng.Assert.*;
|
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 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 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() {
|
public SQLClientInfoExceptionTests() {
|
||||||
map.put("1", ClientInfoStatus.REASON_UNKNOWN_PROPERTY);
|
map.put("1", ClientInfoStatus.REASON_UNKNOWN_PROPERTY);
|
||||||
map.put("21", 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
|
* Create SQLClientInfoException and setting all objects to null
|
||||||
*/
|
*/
|
||||||
@ -201,13 +169,8 @@ public class SQLClientInfoExceptionTests {
|
|||||||
public void test10() throws Exception {
|
public void test10() throws Exception {
|
||||||
SQLClientInfoException e = new SQLClientInfoException(reason, state,
|
SQLClientInfoException e = new SQLClientInfoException(reason, state,
|
||||||
errorCode, map, t);
|
errorCode, map, t);
|
||||||
ObjectOutputStream out
|
SQLClientInfoException ex1 =
|
||||||
= new ObjectOutputStream(
|
createSerializedException(e);
|
||||||
new FileOutputStream("SQLClientInfoException.ser"));
|
|
||||||
out.writeObject(e);
|
|
||||||
ObjectInputStream is = new ObjectInputStream(
|
|
||||||
new FileInputStream("SQLClientInfoException.ser"));
|
|
||||||
SQLClientInfoException ex1 = (SQLClientInfoException) is.readObject();
|
|
||||||
assertTrue(reason.equals(ex1.getMessage())
|
assertTrue(reason.equals(ex1.getMessage())
|
||||||
&& ex1.getSQLState().equals(state)
|
&& ex1.getSQLState().equals(state)
|
||||||
&& cause.equals(ex1.getCause().toString())
|
&& cause.equals(ex1.getCause().toString())
|
||||||
|
@ -22,50 +22,14 @@
|
|||||||
*/
|
*/
|
||||||
package test.sql;
|
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.SQLDataException;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.SQLNonTransientException;
|
import java.sql.SQLNonTransientException;
|
||||||
import static org.testng.Assert.*;
|
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 org.testng.annotations.Test;
|
||||||
|
import util.BaseTest;
|
||||||
|
|
||||||
public class SQLDataExceptionTests {
|
public class SQLDataExceptionTests 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"};
|
|
||||||
|
|
||||||
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 {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create SQLDataException and setting all objects to null
|
* Create SQLDataException and setting all objects to null
|
||||||
@ -191,13 +155,7 @@ public class SQLDataExceptionTests {
|
|||||||
@Test
|
@Test
|
||||||
public void test10() throws Exception {
|
public void test10() throws Exception {
|
||||||
SQLDataException e = new SQLDataException(reason, state, errorCode, t);
|
SQLDataException e = new SQLDataException(reason, state, errorCode, t);
|
||||||
ObjectOutputStream out
|
SQLDataException ex1 = createSerializedException(e);
|
||||||
= new ObjectOutputStream(
|
|
||||||
new FileOutputStream("SQLDataException.ser"));
|
|
||||||
out.writeObject(e);
|
|
||||||
ObjectInputStream is = new ObjectInputStream(
|
|
||||||
new FileInputStream("SQLDataException.ser"));
|
|
||||||
SQLDataException ex1 = (SQLDataException) is.readObject();
|
|
||||||
assertTrue(reason.equals(ex1.getMessage())
|
assertTrue(reason.equals(ex1.getMessage())
|
||||||
&& ex1.getSQLState().equals(state)
|
&& ex1.getSQLState().equals(state)
|
||||||
&& cause.equals(ex1.getCause().toString())
|
&& cause.equals(ex1.getCause().toString())
|
||||||
|
@ -22,48 +22,12 @@
|
|||||||
*/
|
*/
|
||||||
package test.sql;
|
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.SQLException;
|
||||||
import static org.testng.Assert.*;
|
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 org.testng.annotations.Test;
|
||||||
|
import util.BaseTest;
|
||||||
|
|
||||||
public class SQLExceptionTests {
|
public class SQLExceptionTests 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"};
|
|
||||||
|
|
||||||
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 {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create SQLException and setting all objects to null
|
* Create SQLException and setting all objects to null
|
||||||
@ -189,13 +153,7 @@ public class SQLExceptionTests {
|
|||||||
@Test
|
@Test
|
||||||
public void test10() throws Exception {
|
public void test10() throws Exception {
|
||||||
SQLException e = new SQLException(reason, state, errorCode, t);
|
SQLException e = new SQLException(reason, state, errorCode, t);
|
||||||
ObjectOutputStream out
|
SQLException ex1 = createSerializedException(e);
|
||||||
= new ObjectOutputStream(
|
|
||||||
new FileOutputStream("SQLException.ser"));
|
|
||||||
out.writeObject(e);
|
|
||||||
ObjectInputStream is = new ObjectInputStream(
|
|
||||||
new FileInputStream("SQLException.ser"));
|
|
||||||
SQLException ex1 = (SQLException) is.readObject();
|
|
||||||
assertTrue(reason.equals(ex1.getMessage())
|
assertTrue(reason.equals(ex1.getMessage())
|
||||||
&& ex1.getSQLState().equals(state)
|
&& ex1.getSQLState().equals(state)
|
||||||
&& cause.equals(ex1.getCause().toString())
|
&& cause.equals(ex1.getCause().toString())
|
||||||
|
@ -22,50 +22,14 @@
|
|||||||
*/
|
*/
|
||||||
package test.sql;
|
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.SQLException;
|
||||||
|
import java.sql.SQLFeatureNotSupportedException;
|
||||||
import java.sql.SQLNonTransientException;
|
import java.sql.SQLNonTransientException;
|
||||||
import static org.testng.Assert.*;
|
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 org.testng.annotations.Test;
|
||||||
|
import util.BaseTest;
|
||||||
|
|
||||||
public class SQLFeatureNotSupportedExceptionTests {
|
public class SQLFeatureNotSupportedExceptionTests 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"};
|
|
||||||
|
|
||||||
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 {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create SQLFeatureNotSupportedException and setting all objects to null
|
* Create SQLFeatureNotSupportedException and setting all objects to null
|
||||||
@ -201,13 +165,8 @@ public class SQLFeatureNotSupportedExceptionTests {
|
|||||||
public void test10() throws Exception {
|
public void test10() throws Exception {
|
||||||
SQLFeatureNotSupportedException e =
|
SQLFeatureNotSupportedException e =
|
||||||
new SQLFeatureNotSupportedException(reason, state, errorCode, t);
|
new SQLFeatureNotSupportedException(reason, state, errorCode, t);
|
||||||
ObjectOutputStream out
|
SQLFeatureNotSupportedException ex1 =
|
||||||
= new ObjectOutputStream(
|
createSerializedException(e);
|
||||||
new FileOutputStream("SQLFeatureNotSupportedException.ser"));
|
|
||||||
out.writeObject(e);
|
|
||||||
ObjectInputStream is = new ObjectInputStream(
|
|
||||||
new FileInputStream("SQLFeatureNotSupportedException.ser"));
|
|
||||||
SQLFeatureNotSupportedException ex1 = (SQLFeatureNotSupportedException) is.readObject();
|
|
||||||
assertTrue(reason.equals(ex1.getMessage())
|
assertTrue(reason.equals(ex1.getMessage())
|
||||||
&& ex1.getSQLState().equals(state)
|
&& ex1.getSQLState().equals(state)
|
||||||
&& cause.equals(ex1.getCause().toString())
|
&& cause.equals(ex1.getCause().toString())
|
||||||
|
@ -22,50 +22,14 @@
|
|||||||
*/
|
*/
|
||||||
package test.sql;
|
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.SQLException;
|
||||||
|
import java.sql.SQLIntegrityConstraintViolationException;
|
||||||
import java.sql.SQLNonTransientException;
|
import java.sql.SQLNonTransientException;
|
||||||
import static org.testng.Assert.*;
|
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 org.testng.annotations.Test;
|
||||||
|
import util.BaseTest;
|
||||||
|
|
||||||
public class SQLIntegrityConstraintViolationExceptionTests {
|
public class SQLIntegrityConstraintViolationExceptionTests 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"};
|
|
||||||
|
|
||||||
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 {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create SQLIntegrityConstraintViolationException and setting all objects to null
|
* Create SQLIntegrityConstraintViolationException and setting all objects to null
|
||||||
@ -204,14 +168,8 @@ public class SQLIntegrityConstraintViolationExceptionTests {
|
|||||||
public void test10() throws Exception {
|
public void test10() throws Exception {
|
||||||
SQLIntegrityConstraintViolationException e =
|
SQLIntegrityConstraintViolationException e =
|
||||||
new SQLIntegrityConstraintViolationException(reason, state, errorCode, t);
|
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 ex1 =
|
||||||
(SQLIntegrityConstraintViolationException) is.readObject();
|
createSerializedException(e);
|
||||||
assertTrue(reason.equals(ex1.getMessage())
|
assertTrue(reason.equals(ex1.getMessage())
|
||||||
&& ex1.getSQLState().equals(state)
|
&& ex1.getSQLState().equals(state)
|
||||||
&& cause.equals(ex1.getCause().toString())
|
&& cause.equals(ex1.getCause().toString())
|
||||||
|
@ -22,50 +22,14 @@
|
|||||||
*/
|
*/
|
||||||
package test.sql;
|
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.SQLException;
|
||||||
|
import java.sql.SQLInvalidAuthorizationSpecException;
|
||||||
import java.sql.SQLNonTransientException;
|
import java.sql.SQLNonTransientException;
|
||||||
import static org.testng.Assert.*;
|
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 org.testng.annotations.Test;
|
||||||
|
import util.BaseTest;
|
||||||
|
|
||||||
public class SQLInvalidAuthorizationSpecExceptionTests {
|
public class SQLInvalidAuthorizationSpecExceptionTests 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"};
|
|
||||||
|
|
||||||
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 {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create SQLInvalidAuthorizationSpecException and setting all objects to
|
* Create SQLInvalidAuthorizationSpecException and setting all objects to
|
||||||
@ -208,13 +172,8 @@ public class SQLInvalidAuthorizationSpecExceptionTests {
|
|||||||
public void test10() throws Exception {
|
public void test10() throws Exception {
|
||||||
SQLInvalidAuthorizationSpecException e
|
SQLInvalidAuthorizationSpecException e
|
||||||
= new SQLInvalidAuthorizationSpecException(reason, state, errorCode, t);
|
= new SQLInvalidAuthorizationSpecException(reason, state, errorCode, t);
|
||||||
ObjectOutputStream out
|
SQLInvalidAuthorizationSpecException ex1 =
|
||||||
= new ObjectOutputStream(
|
createSerializedException(e);
|
||||||
new FileOutputStream("SQLInvalidAuthorizationSpecException.ser"));
|
|
||||||
out.writeObject(e);
|
|
||||||
ObjectInputStream is = new ObjectInputStream(
|
|
||||||
new FileInputStream("SQLInvalidAuthorizationSpecException.ser"));
|
|
||||||
SQLInvalidAuthorizationSpecException ex1 = (SQLInvalidAuthorizationSpecException) is.readObject();
|
|
||||||
assertTrue(reason.equals(ex1.getMessage())
|
assertTrue(reason.equals(ex1.getMessage())
|
||||||
&& ex1.getSQLState().equals(state)
|
&& ex1.getSQLState().equals(state)
|
||||||
&& cause.equals(ex1.getCause().toString())
|
&& cause.equals(ex1.getCause().toString())
|
||||||
|
@ -22,50 +22,14 @@
|
|||||||
*/
|
*/
|
||||||
package test.sql;
|
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.SQLException;
|
||||||
|
import java.sql.SQLNonTransientConnectionException;
|
||||||
import java.sql.SQLNonTransientException;
|
import java.sql.SQLNonTransientException;
|
||||||
import static org.testng.Assert.*;
|
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 org.testng.annotations.Test;
|
||||||
|
import util.BaseTest;
|
||||||
|
|
||||||
public class SQLNonTransientConnectionExceptionTests {
|
public class SQLNonTransientConnectionExceptionTests 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"};
|
|
||||||
|
|
||||||
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 {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create SQLNonTransientConnectionException and setting all objects to null
|
* Create SQLNonTransientConnectionException and setting all objects to null
|
||||||
@ -204,14 +168,8 @@ public class SQLNonTransientConnectionExceptionTests {
|
|||||||
public void test10() throws Exception {
|
public void test10() throws Exception {
|
||||||
SQLNonTransientConnectionException e =
|
SQLNonTransientConnectionException e =
|
||||||
new SQLNonTransientConnectionException(reason, state, errorCode, t);
|
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 ex1 =
|
||||||
(SQLNonTransientConnectionException) is.readObject();
|
createSerializedException(e);
|
||||||
assertTrue(reason.equals(ex1.getMessage())
|
assertTrue(reason.equals(ex1.getMessage())
|
||||||
&& ex1.getSQLState().equals(state)
|
&& ex1.getSQLState().equals(state)
|
||||||
&& cause.equals(ex1.getCause().toString())
|
&& cause.equals(ex1.getCause().toString())
|
||||||
|
@ -22,49 +22,13 @@
|
|||||||
*/
|
*/
|
||||||
package test.sql;
|
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.SQLException;
|
||||||
import java.sql.SQLNonTransientException;
|
import java.sql.SQLNonTransientException;
|
||||||
import static org.testng.Assert.*;
|
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 org.testng.annotations.Test;
|
||||||
|
import util.BaseTest;
|
||||||
|
|
||||||
public class SQLNonTransientExceptionTests {
|
public class SQLNonTransientExceptionTests 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"};
|
|
||||||
|
|
||||||
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 {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create SQLNonTransientException and setting all objects to null
|
* Create SQLNonTransientException and setting all objects to null
|
||||||
@ -194,13 +158,8 @@ public class SQLNonTransientExceptionTests {
|
|||||||
public void test10() throws Exception {
|
public void test10() throws Exception {
|
||||||
SQLNonTransientException e =
|
SQLNonTransientException e =
|
||||||
new SQLNonTransientException(reason, state, errorCode, t);
|
new SQLNonTransientException(reason, state, errorCode, t);
|
||||||
ObjectOutputStream out
|
SQLNonTransientException ex1 =
|
||||||
= new ObjectOutputStream(
|
createSerializedException(e);
|
||||||
new FileOutputStream("SQLNonTransientException.ser"));
|
|
||||||
out.writeObject(e);
|
|
||||||
ObjectInputStream is = new ObjectInputStream(
|
|
||||||
new FileInputStream("SQLNonTransientException.ser"));
|
|
||||||
SQLNonTransientException ex1 = (SQLNonTransientException) is.readObject();
|
|
||||||
assertTrue(reason.equals(ex1.getMessage())
|
assertTrue(reason.equals(ex1.getMessage())
|
||||||
&& ex1.getSQLState().equals(state)
|
&& ex1.getSQLState().equals(state)
|
||||||
&& cause.equals(ex1.getCause().toString())
|
&& cause.equals(ex1.getCause().toString())
|
||||||
|
@ -22,49 +22,13 @@
|
|||||||
*/
|
*/
|
||||||
package test.sql;
|
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.SQLException;
|
||||||
|
import java.sql.SQLRecoverableException;
|
||||||
import static org.testng.Assert.*;
|
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 org.testng.annotations.Test;
|
||||||
|
import util.BaseTest;
|
||||||
|
|
||||||
public class SQLRecoverableExceptionTests {
|
public class SQLRecoverableExceptionTests 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"};
|
|
||||||
|
|
||||||
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 {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create SQLRecoverableException and setting all objects to null
|
* Create SQLRecoverableException and setting all objects to null
|
||||||
@ -194,13 +158,8 @@ public class SQLRecoverableExceptionTests {
|
|||||||
public void test10() throws Exception {
|
public void test10() throws Exception {
|
||||||
SQLRecoverableException e =
|
SQLRecoverableException e =
|
||||||
new SQLRecoverableException(reason, state, errorCode, t);
|
new SQLRecoverableException(reason, state, errorCode, t);
|
||||||
ObjectOutputStream out
|
SQLRecoverableException ex1 =
|
||||||
= new ObjectOutputStream(
|
createSerializedException(e);
|
||||||
new FileOutputStream("SQLRecoverableException.ser"));
|
|
||||||
out.writeObject(e);
|
|
||||||
ObjectInputStream is = new ObjectInputStream(
|
|
||||||
new FileInputStream("SQLRecoverableException.ser"));
|
|
||||||
SQLRecoverableException ex1 = (SQLRecoverableException) is.readObject();
|
|
||||||
assertTrue(reason.equals(ex1.getMessage())
|
assertTrue(reason.equals(ex1.getMessage())
|
||||||
&& ex1.getSQLState().equals(state)
|
&& ex1.getSQLState().equals(state)
|
||||||
&& cause.equals(ex1.getCause().toString())
|
&& cause.equals(ex1.getCause().toString())
|
||||||
|
@ -22,50 +22,14 @@
|
|||||||
*/
|
*/
|
||||||
package test.sql;
|
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.SQLException;
|
||||||
import java.sql.SQLNonTransientException;
|
import java.sql.SQLNonTransientException;
|
||||||
|
import java.sql.SQLSyntaxErrorException;
|
||||||
import static org.testng.Assert.*;
|
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 org.testng.annotations.Test;
|
||||||
|
import util.BaseTest;
|
||||||
|
|
||||||
public class SQLSyntaxErrorExceptionTests {
|
public class SQLSyntaxErrorExceptionTests 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"};
|
|
||||||
|
|
||||||
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 {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create SQLSyntaxErrorException and setting all objects to null
|
* Create SQLSyntaxErrorException and setting all objects to null
|
||||||
@ -196,13 +160,8 @@ public class SQLSyntaxErrorExceptionTests {
|
|||||||
|
|
||||||
SQLSyntaxErrorException e =
|
SQLSyntaxErrorException e =
|
||||||
new SQLSyntaxErrorException(reason, state, errorCode, t);
|
new SQLSyntaxErrorException(reason, state, errorCode, t);
|
||||||
ObjectOutputStream out
|
SQLSyntaxErrorException ex1 =
|
||||||
= new ObjectOutputStream(
|
createSerializedException(e);
|
||||||
new FileOutputStream("SQLSyntaxErrorException.ser"));
|
|
||||||
out.writeObject(e);
|
|
||||||
ObjectInputStream is = new ObjectInputStream(
|
|
||||||
new FileInputStream("SQLSyntaxErrorException.ser"));
|
|
||||||
SQLSyntaxErrorException ex1 = (SQLSyntaxErrorException) is.readObject();
|
|
||||||
assertTrue(reason.equals(ex1.getMessage())
|
assertTrue(reason.equals(ex1.getMessage())
|
||||||
&& ex1.getSQLState().equals(state)
|
&& ex1.getSQLState().equals(state)
|
||||||
&& cause.equals(ex1.getCause().toString())
|
&& cause.equals(ex1.getCause().toString())
|
||||||
|
@ -22,50 +22,14 @@
|
|||||||
*/
|
*/
|
||||||
package test.sql;
|
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.SQLException;
|
||||||
import java.sql.SQLTimeoutException;
|
import java.sql.SQLTimeoutException;
|
||||||
import java.sql.SQLTransientException;
|
import java.sql.SQLTransientException;
|
||||||
import static org.testng.Assert.*;
|
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 org.testng.annotations.Test;
|
||||||
|
import util.BaseTest;
|
||||||
|
|
||||||
public class SQLTimeoutExceptionTests {
|
public class SQLTimeoutExceptionTests 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"};
|
|
||||||
|
|
||||||
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 {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create SQLTimeoutException and setting all objects to null
|
* Create SQLTimeoutException and setting all objects to null
|
||||||
@ -193,13 +157,8 @@ public class SQLTimeoutExceptionTests {
|
|||||||
public void test10() throws Exception {
|
public void test10() throws Exception {
|
||||||
SQLTimeoutException e =
|
SQLTimeoutException e =
|
||||||
new SQLTimeoutException(reason, state, errorCode, t);
|
new SQLTimeoutException(reason, state, errorCode, t);
|
||||||
ObjectOutputStream out
|
SQLTimeoutException ex1 =
|
||||||
= new ObjectOutputStream(
|
createSerializedException(e);
|
||||||
new FileOutputStream("SQLTimeoutException.ser"));
|
|
||||||
out.writeObject(e);
|
|
||||||
ObjectInputStream is = new ObjectInputStream(
|
|
||||||
new FileInputStream("SQLTimeoutException.ser"));
|
|
||||||
SQLTimeoutException ex1 = (SQLTimeoutException) is.readObject();
|
|
||||||
assertTrue(reason.equals(ex1.getMessage())
|
assertTrue(reason.equals(ex1.getMessage())
|
||||||
&& ex1.getSQLState().equals(state)
|
&& ex1.getSQLState().equals(state)
|
||||||
&& cause.equals(ex1.getCause().toString())
|
&& cause.equals(ex1.getCause().toString())
|
||||||
|
@ -22,50 +22,14 @@
|
|||||||
*/
|
*/
|
||||||
package test.sql;
|
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.SQLException;
|
||||||
import java.sql.SQLTransactionRollbackException;
|
import java.sql.SQLTransactionRollbackException;
|
||||||
import java.sql.SQLTransientException;
|
import java.sql.SQLTransientException;
|
||||||
import static org.testng.Assert.*;
|
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 org.testng.annotations.Test;
|
||||||
|
import util.BaseTest;
|
||||||
|
|
||||||
public class SQLTransactionRollbackExceptionTests {
|
public class SQLTransactionRollbackExceptionTests 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"};
|
|
||||||
|
|
||||||
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 {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create SQLTransactionRollbackException and setting all objects to null
|
* Create SQLTransactionRollbackException and setting all objects to null
|
||||||
@ -202,13 +166,8 @@ public class SQLTransactionRollbackExceptionTests {
|
|||||||
public void test10() throws Exception {
|
public void test10() throws Exception {
|
||||||
SQLTransactionRollbackException e =
|
SQLTransactionRollbackException e =
|
||||||
new SQLTransactionRollbackException(reason, state, errorCode, t);
|
new SQLTransactionRollbackException(reason, state, errorCode, t);
|
||||||
ObjectOutputStream out
|
SQLTransactionRollbackException ex1 =
|
||||||
= new ObjectOutputStream(
|
createSerializedException(e);
|
||||||
new FileOutputStream("SQLTransactionRollbackException.ser"));
|
|
||||||
out.writeObject(e);
|
|
||||||
ObjectInputStream is = new ObjectInputStream(
|
|
||||||
new FileInputStream("SQLTransactionRollbackException.ser"));
|
|
||||||
SQLTransactionRollbackException ex1 = (SQLTransactionRollbackException) is.readObject();
|
|
||||||
assertTrue(reason.equals(ex1.getMessage())
|
assertTrue(reason.equals(ex1.getMessage())
|
||||||
&& ex1.getSQLState().equals(state)
|
&& ex1.getSQLState().equals(state)
|
||||||
&& cause.equals(ex1.getCause().toString())
|
&& cause.equals(ex1.getCause().toString())
|
||||||
|
@ -22,50 +22,14 @@
|
|||||||
*/
|
*/
|
||||||
package test.sql;
|
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.SQLException;
|
||||||
import java.sql.SQLTransientConnectionException;
|
import java.sql.SQLTransientConnectionException;
|
||||||
import java.sql.SQLTransientException;
|
import java.sql.SQLTransientException;
|
||||||
import static org.testng.Assert.*;
|
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 org.testng.annotations.Test;
|
||||||
|
import util.BaseTest;
|
||||||
|
|
||||||
public class SQLTransientConnectionExceptionTests {
|
public class SQLTransientConnectionExceptionTests 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"};
|
|
||||||
|
|
||||||
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 {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create SQLTransientConnectionException and setting all objects to null
|
* Create SQLTransientConnectionException and setting all objects to null
|
||||||
@ -202,13 +166,8 @@ public class SQLTransientConnectionExceptionTests {
|
|||||||
public void test10() throws Exception {
|
public void test10() throws Exception {
|
||||||
SQLTransientConnectionException e =
|
SQLTransientConnectionException e =
|
||||||
new SQLTransientConnectionException(reason, state, errorCode, t);
|
new SQLTransientConnectionException(reason, state, errorCode, t);
|
||||||
ObjectOutputStream out
|
SQLTransientConnectionException ex1 =
|
||||||
= new ObjectOutputStream(
|
createSerializedException(e);
|
||||||
new FileOutputStream("SQLTransientConnectionException.ser"));
|
|
||||||
out.writeObject(e);
|
|
||||||
ObjectInputStream is = new ObjectInputStream(
|
|
||||||
new FileInputStream("SQLTransientConnectionException.ser"));
|
|
||||||
SQLTransientConnectionException ex1 = (SQLTransientConnectionException) is.readObject();
|
|
||||||
assertTrue(reason.equals(ex1.getMessage())
|
assertTrue(reason.equals(ex1.getMessage())
|
||||||
&& ex1.getSQLState().equals(state)
|
&& ex1.getSQLState().equals(state)
|
||||||
&& cause.equals(ex1.getCause().toString())
|
&& cause.equals(ex1.getCause().toString())
|
||||||
|
@ -22,49 +22,13 @@
|
|||||||
*/
|
*/
|
||||||
package test.sql;
|
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.SQLException;
|
||||||
|
import java.sql.SQLTransientException;
|
||||||
import static org.testng.Assert.*;
|
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 org.testng.annotations.Test;
|
||||||
|
import util.BaseTest;
|
||||||
|
|
||||||
public class SQLTransientExceptionTests {
|
public class SQLTransientExceptionTests 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"};
|
|
||||||
|
|
||||||
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 {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create SQLTransientException and setting all objects to null
|
* Create SQLTransientException and setting all objects to null
|
||||||
@ -193,13 +157,7 @@ public class SQLTransientExceptionTests {
|
|||||||
public void test10() throws Exception {
|
public void test10() throws Exception {
|
||||||
SQLTransientException e =
|
SQLTransientException e =
|
||||||
new SQLTransientException(reason, state, errorCode, t);
|
new SQLTransientException(reason, state, errorCode, t);
|
||||||
ObjectOutputStream out
|
SQLTransientException ex1 = createSerializedException(e);
|
||||||
= new ObjectOutputStream(
|
|
||||||
new FileOutputStream("SQLTransientException.ser"));
|
|
||||||
out.writeObject(e);
|
|
||||||
ObjectInputStream is = new ObjectInputStream(
|
|
||||||
new FileInputStream("SQLTransientException.ser"));
|
|
||||||
SQLTransientException ex1 = (SQLTransientException) is.readObject();
|
|
||||||
assertTrue(reason.equals(ex1.getMessage())
|
assertTrue(reason.equals(ex1.getMessage())
|
||||||
&& ex1.getSQLState().equals(state)
|
&& ex1.getSQLState().equals(state)
|
||||||
&& cause.equals(ex1.getCause().toString())
|
&& cause.equals(ex1.getCause().toString())
|
||||||
|
@ -22,52 +22,17 @@
|
|||||||
*/
|
*/
|
||||||
package test.sql;
|
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.SQLException;
|
||||||
|
import java.sql.SQLWarning;
|
||||||
import static org.testng.Assert.*;
|
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 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",
|
private final String[] warnings = {"Warning 1", "cause 1", "Warning 2",
|
||||||
"Warning 3", "cause 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
|
* Create SQLWarning and setting all objects to null
|
||||||
*/
|
*/
|
||||||
@ -193,13 +158,7 @@ public class SQLWarningTests {
|
|||||||
@Test
|
@Test
|
||||||
public void test10() throws Exception {
|
public void test10() throws Exception {
|
||||||
SQLWarning e = new SQLWarning(reason, state, errorCode, t);
|
SQLWarning e = new SQLWarning(reason, state, errorCode, t);
|
||||||
ObjectOutputStream out
|
SQLWarning ex1 = createSerializedException(e);
|
||||||
= new ObjectOutputStream(
|
|
||||||
new FileOutputStream("SQLWarning.ser"));
|
|
||||||
out.writeObject(e);
|
|
||||||
ObjectInputStream is = new ObjectInputStream(
|
|
||||||
new FileInputStream("SQLWarning.ser"));
|
|
||||||
SQLWarning ex1 = (SQLWarning) is.readObject();
|
|
||||||
assertTrue(reason.equals(ex1.getMessage())
|
assertTrue(reason.equals(ex1.getMessage())
|
||||||
&& ex1.getSQLState().equals(state)
|
&& ex1.getSQLState().equals(state)
|
||||||
&& cause.equals(ex1.getCause().toString())
|
&& cause.equals(ex1.getCause().toString())
|
||||||
|
89
jdk/test/java/sql/util/BaseTest.java
Normal file
89
jdk/test/java/sql/util/BaseTest.java
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user