test/java/sql/test/sql/SQLIntegrityConstraintViolationExceptionTests.java
Print this page
*** 20,73 ****
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
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.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;
! 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 {
! }
/**
* Create SQLIntegrityConstraintViolationException and setting all objects to null
*/
@Test
--- 20,37 ----
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package test.sql;
import java.sql.SQLException;
+ import java.sql.SQLIntegrityConstraintViolationException;
import java.sql.SQLNonTransientException;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
+ import util.BaseTest;
! public class SQLIntegrityConstraintViolationExceptionTests extends BaseTest {
/**
* Create SQLIntegrityConstraintViolationException and setting all objects to null
*/
@Test
*** 202,219 ****
*/
@Test
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();
assertTrue(reason.equals(ex1.getMessage())
&& ex1.getSQLState().equals(state)
&& cause.equals(ex1.getCause().toString())
&& ex1.getErrorCode() == errorCode);
}
--- 166,177 ----
*/
@Test
public void test10() throws Exception {
SQLIntegrityConstraintViolationException e =
new SQLIntegrityConstraintViolationException(reason, state, errorCode, t);
SQLIntegrityConstraintViolationException ex1 =
! createSerializedException(e, "SQLIntegrityConstraintViolationException.ser");
assertTrue(reason.equals(ex1.getMessage())
&& ex1.getSQLState().equals(state)
&& cause.equals(ex1.getCause().toString())
&& ex1.getErrorCode() == errorCode);
}