提交 7beb1017 编写于 作者: K kshefov

8081479: Backport JDBC tests from JDK 9 from test/java/sql and test/javax/sql to JDK 8u.

Reviewed-by: lancea
Contributed-by: maxim.soloviev@oracle.com
上级 7185d192
# JDBC unit tests uses TestNG
TestNG.dirs = .
/*
* 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 test.sql;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.ObjectInputStream;
import java.sql.BatchUpdateException;
import java.sql.SQLException;
import java.util.Arrays;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
import util.SerializedBatchUpdateException;
import util.BaseTest;
public class BatchUpdateExceptionTests extends BaseTest {
private final int[] uc = {1, 2, 3};
private final long[] luc = {1, 2, 3};
private final String testSrcDir = System.getProperty("test.src", ".")
+ File.separatorChar;
/**
* Create BatchUpdateException and setting all objects to null
*/
@Test
public void test() {
BatchUpdateException be = new BatchUpdateException(null,
null, errorCode, (int[]) null, null);
assertTrue(be.getMessage() == null && be.getSQLState() == null
&& be.getUpdateCounts() == null && be.getCause() == null
&& be.getLargeUpdateCounts() == null
&& be.getErrorCode() == errorCode);
}
/**
* Create BatchUpdateException with no-arg constructor
*/
@Test
public void test1() {
BatchUpdateException ex = new BatchUpdateException();
assertTrue(ex.getMessage() == null
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0
&& ex.getUpdateCounts() == null
&& ex.getLargeUpdateCounts() == null);
}
/**
* Create BatchUpdateException with null Throwable
*/
@Test
public void test2() {
BatchUpdateException ex = new BatchUpdateException((Throwable) null);
assertTrue(ex.getMessage() == null
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0
&& ex.getUpdateCounts() == null
&& ex.getLargeUpdateCounts() == null);
}
/**
* Create BatchUpdateException with message and update counts
*/
@Test
public void test3() {
BatchUpdateException ex = new BatchUpdateException(reason, uc);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0
&& Arrays.equals(ex.getUpdateCounts(), uc)
&& Arrays.equals(ex.getLargeUpdateCounts(), luc)
);
}
/**
* Create BatchUpdateException with update counts
*/
@Test
public void test4() {
BatchUpdateException ex = new BatchUpdateException(uc);
assertTrue(ex.getMessage() == null
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0
&& Arrays.equals(ex.getUpdateCounts(), uc)
&& Arrays.equals(ex.getLargeUpdateCounts(), luc)
);
}
/**
* Create BatchUpdateException with Throwable and update counts
*/
@Test
public void test5() {
BatchUpdateException ex = new BatchUpdateException(uc, t);
assertTrue(ex.getMessage().equals(cause)
&& ex.getSQLState() == null
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0
&& Arrays.equals(ex.getUpdateCounts(), uc)
&& Arrays.equals(ex.getLargeUpdateCounts(), luc)
);
}
/**
* Create BatchUpdateException with message, Throwable, and update counts
*/
@Test
public void test6() {
BatchUpdateException ex = new BatchUpdateException(reason, uc, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState() == null
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0
&& Arrays.equals(ex.getUpdateCounts(), uc)
&& Arrays.equals(ex.getLargeUpdateCounts(), luc)
);
}
/**
* Create BatchUpdateException with message, SQLState, Throwable, and update
* counts
*/
@Test
public void test7() {
BatchUpdateException ex = new BatchUpdateException(reason, state, uc, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0
&& Arrays.equals(ex.getUpdateCounts(), uc)
&& Arrays.equals(ex.getLargeUpdateCounts(), luc)
);
}
/**
* Create BatchUpdateException with message, SQLState, errorCode code
* Throwable, and update counts
*/
@Test
public void test8() {
BatchUpdateException ex = new BatchUpdateException(reason, state, errorCode,
uc, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == errorCode
&& Arrays.equals(ex.getUpdateCounts(), uc)
&& Arrays.equals(ex.getLargeUpdateCounts(), luc)
);
}
/**
* Create BatchUpdateException with message, SQLState, errorCode code
* Throwable, and long [] update counts
*/
@Test
public void test9() {
BatchUpdateException ex = new BatchUpdateException(reason, state, errorCode,
luc, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == errorCode
&& Arrays.equals(ex.getUpdateCounts(), uc)
&& Arrays.equals(ex.getLargeUpdateCounts(), luc)
);
}
/**
* Validate that a copy of the update counts array is made
*/
@Test
public void test10() {
int[] uc1 = {1, 2};
BatchUpdateException ex = new BatchUpdateException(uc1);
assertTrue(Arrays.equals(ex.getUpdateCounts(), uc1));
uc1[0] = 6689;
assertFalse(Arrays.equals(ex.getUpdateCounts(), uc1));
}
/**
* Validate that if null is specified for the update count, it is returned
* as null
*/
@Test
public void test11() {
BatchUpdateException ex = new BatchUpdateException((int[]) null);
assertTrue(ex.getMessage() == null && ex.getSQLState() == null
&& ex.getErrorCode() == 0 && ex.getUpdateCounts() == null
&& ex.getLargeUpdateCounts() == null);
}
/**
* Serialize a BatchUpdateException and make sure you can read it back
* properly
*/
@Test
public void test12() throws Exception {
BatchUpdateException be = new BatchUpdateException(reason, state, errorCode,
uc, t);
BatchUpdateException bue
= createSerializedException(be);
assertTrue(reason.equals(bue.getMessage())
&& bue.getSQLState().equals(state)
&& cause.equals(bue.getCause().toString())
&& bue.getErrorCode() == errorCode
&& Arrays.equals(bue.getLargeUpdateCounts(), luc)
&& Arrays.equals(bue.getUpdateCounts(), uc));
}
/**
* De-Serialize a BatchUpdateException from JDBC 4.0 and make sure you can
* read it back properly
*/
@Test
public void test13() throws Exception {
String reason1 = "This was the error msg";
String state1 = "user defined sqlState";
String cause1 = "java.lang.Throwable: throw 1";
int errorCode1 = 99999;
Throwable t = new Throwable("throw 1");
int[] uc1 = {1, 2, 21};
long[] luc1 = {1, 2, 21};
ObjectInputStream ois = new ObjectInputStream(
new ByteArrayInputStream(SerializedBatchUpdateException.DATA));
BatchUpdateException bue = (BatchUpdateException) ois.readObject();
assertTrue(reason1.equals(bue.getMessage())
&& bue.getSQLState().equals(state1)
&& bue.getErrorCode() == errorCode1
&& cause1.equals(bue.getCause().toString())
&& Arrays.equals(bue.getLargeUpdateCounts(), luc1)
&& Arrays.equals(bue.getUpdateCounts(), uc1));
}
/**
* Serialize a BatchUpdateException with an Integer.MAX_VALUE + 1 and
* validate you can read it back properly
*/
@Test
public void test14() throws Exception {
int[] uc1 = {Integer.MAX_VALUE, Integer.MAX_VALUE + 1};
long[] luc1 = {Integer.MAX_VALUE, Integer.MAX_VALUE + 1};
BatchUpdateException be = new BatchUpdateException(reason, state, errorCode,
luc1, t);
BatchUpdateException bue
= createSerializedException(be);
assertTrue(reason.equals(bue.getMessage())
&& bue.getSQLState().equals(state)
&& cause.equals(bue.getCause().toString())
&& bue.getErrorCode() == errorCode
&& Arrays.equals(bue.getLargeUpdateCounts(), luc1)
&& Arrays.equals(bue.getUpdateCounts(), uc1));
}
/**
* Validate that the ordering of the returned Exceptions is correct
* using for-each loop
*/
@Test
public void test15() {
BatchUpdateException ex = new BatchUpdateException("Exception 1", uc, t1);
BatchUpdateException ex1 = new BatchUpdateException("Exception 2", uc);
BatchUpdateException ex2 = new BatchUpdateException("Exception 3", uc, t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
for (Throwable e : ex) {
assertTrue(msgs[num++].equals(e.getMessage()));
}
}
/**
* Validate that the ordering of the returned Exceptions is correct
* using traditional while loop
*/
@Test
public void test16() {
BatchUpdateException ex = new BatchUpdateException("Exception 1", uc, t1);
BatchUpdateException ex1 = new BatchUpdateException("Exception 2", uc);
BatchUpdateException ex2 = new BatchUpdateException("Exception 3", uc, t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
SQLException sqe = ex;
int num = 0;
while (sqe != null) {
assertTrue(msgs[num++].equals(sqe.getMessage()));
Throwable c = sqe.getCause();
while (c != null) {
assertTrue(msgs[num++].equals(c.getMessage()));
c = c.getCause();
}
sqe = sqe.getNextException();
}
}
}
/*
* 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 test.sql;
import java.sql.DataTruncation;
import java.sql.SQLException;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
import util.BaseTest;
public class DataTruncationTests extends BaseTest {
private final String READ_TRUNCATION = "01004";
private final String WRITE_TRUNCATION = "22001";
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;
/**
* Create DataTruncation object indicating a truncation on read
*/
@Test
public void test() {
onRead = true;
DataTruncation e = new DataTruncation(index, parameter, onRead,
dataSize, transferSize);
assertTrue(e.getMessage().equals(dtReason)
&& e.getSQLState().equals(READ_TRUNCATION)
&& e.getCause() == null
&& e.getErrorCode() == dterrorCode
&& e.getParameter() == parameter
&& e.getRead() == onRead
&& e.getDataSize() == dataSize
&& e.getTransferSize() == transferSize
&& e.getIndex() == index);
}
/**
* Create DataTruncation object indicating a truncation on write
*/
@Test
public void test1() {
onRead = false;
DataTruncation e = new DataTruncation(index, parameter, onRead,
dataSize, transferSize);
assertTrue(e.getMessage().equals(dtReason)
&& e.getSQLState().equals(WRITE_TRUNCATION)
&& e.getCause() == null
&& e.getErrorCode() == dterrorCode
&& e.getParameter() == parameter
&& e.getRead() == onRead
&& e.getDataSize() == dataSize
&& e.getTransferSize() == transferSize
&& e.getIndex() == index);
}
/**
* Create DataTruncation object indicating a truncation on read with a
* Throwable
*/
@Test
public void test2() {
onRead = true;
DataTruncation e = new DataTruncation(index, parameter, onRead,
dataSize, transferSize, t);
assertTrue(e.getMessage().equals(dtReason)
&& e.getSQLState().equals(READ_TRUNCATION)
&& cause.equals(e.getCause().toString())
&& e.getErrorCode() == dterrorCode
&& e.getParameter() == parameter
&& e.getRead() == onRead
&& e.getDataSize() == dataSize
&& e.getTransferSize() == transferSize
&& e.getIndex() == index);
}
/**
* Create DataTruncation object indicating a truncation on read with null
* specified for the Throwable
*/
@Test
public void test3() {
onRead = true;;
DataTruncation e = new DataTruncation(index, parameter, onRead,
dataSize, transferSize, null);
assertTrue(e.getMessage().equals(dtReason)
&& e.getSQLState().equals(READ_TRUNCATION)
&& e.getCause() == null
&& e.getErrorCode() == dterrorCode
&& e.getParameter() == parameter
&& e.getRead() == onRead
&& e.getDataSize() == dataSize
&& e.getTransferSize() == transferSize
&& e.getIndex() == index);
}
/**
* Create DataTruncation object indicating a truncation on read and you can
* pass a -1 for the index
*/
@Test
public void test4() {
onRead = true;
int negIndex = -1;
DataTruncation e = new DataTruncation(negIndex, parameter, onRead,
dataSize, transferSize);
assertTrue(e.getMessage().equals(dtReason)
&& e.getSQLState().equals(READ_TRUNCATION)
&& e.getCause() == null
&& e.getErrorCode() == dterrorCode
&& e.getParameter() == parameter
&& e.getRead() == onRead
&& e.getDataSize() == dataSize
&& e.getTransferSize() == transferSize
&& e.getIndex() == negIndex);
}
/**
* Serialize a DataTruncation and make sure you can read it back properly
*/
@Test
public void test5() throws Exception {
DataTruncation e = new DataTruncation(index, parameter, onRead,
dataSize, transferSize);
DataTruncation ex1 = createSerializedException(e);
assertTrue(e.getMessage().equals(dtReason)
&& e.getSQLState().equals(READ_TRUNCATION)
&& e.getCause() == null
&& e.getErrorCode() == dterrorCode
&& e.getParameter() == parameter
&& e.getRead() == onRead
&& e.getDataSize() == dataSize
&& e.getTransferSize() == transferSize
&& e.getIndex() == index);
}
/**
* Validate that the ordering of the returned Exceptions is correct using
* for-each loop
*/
@Test
public void test11() {
DataTruncation ex = new DataTruncation(index, parameter, onRead,
dataSize, transferSize, t1);
DataTruncation ex1 = new DataTruncation(index, parameter, onRead,
dataSize, transferSize);
DataTruncation ex2 = new DataTruncation(index, parameter, onRead,
dataSize, transferSize, t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
for (Throwable e : ex) {
assertTrue(dtmsgs[num++].equals(e.getMessage()));
}
}
/**
* Validate that the ordering of the returned Exceptions is correct using
* traditional while loop
*/
@Test
public void test12() {
DataTruncation ex = new DataTruncation(index, parameter, onRead,
dataSize, transferSize, t1);
DataTruncation ex1 = new DataTruncation(index, parameter, onRead,
dataSize, transferSize);
DataTruncation ex2 = new DataTruncation(index, parameter, onRead,
dataSize, transferSize, t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
SQLException sqe = ex;
while (sqe != null) {
assertTrue(dtmsgs[num++].equals(sqe.getMessage()));
Throwable c = sqe.getCause();
while (c != null) {
assertTrue(dtmsgs[num++].equals(c.getMessage()));
c = c.getCause();
}
sqe = sqe.getNextException();
}
}
}
/*
* 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 test.sql;
import java.sql.Date;
import java.time.Instant;
import java.time.LocalDate;
import static org.testng.Assert.*;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import util.BaseTest;
public class DateTests extends BaseTest {
/*
* Validate an IllegalArgumentException is thrown for an invalid Date string
*/
@Test(dataProvider = "invalidDateValues",
expectedExceptions = IllegalArgumentException.class)
public void test(String d) throws Exception {
Date.valueOf(d);
}
/*
* Test that a date created from a date string is equal to the value
* returned from toString()
*/
@Test(dataProvider = "validDateValues")
public void test00(String d, String expectedD) {
Date d1 = Date.valueOf(d);
Date d2 = Date.valueOf(expectedD);
assertTrue(d1.equals(d2) && d2.equals(d1)
&& d1.toString().equals(expectedD), "Error d1 != d2");
}
/*
* Validate that a Date.after() returns false when same date is compared
*/
@Test
public void test01() {
Date d = Date.valueOf("1961-08-30");
assertFalse(d.after(d), "Error d.after(d) = true");
}
/*
* Validate that a Date.after() returns true when later date is compared to
* earlier date
*/
@Test
public void test2() {
Date d = Date.valueOf("1961-08-30");
Date d2 = new Date(System.currentTimeMillis());
assertTrue(d2.after(d), "Error d2.after(d) = false");
}
/*
* Validate that a Date.after() returns false when earlier date is compared
* to later date
*/
@Test
public void test3() {
Date d = Date.valueOf("1961-08-30");
Date d2 = new Date(d.getTime());
assertFalse(d.after(d2), "Error d.after(d2) = true");
}
/*
* Validate that a Date.after() returns false when date compared to another
* date created from the original date
*/
@Test
public void test4() {
Date d = Date.valueOf("1961-08-30");
Date d2 = new Date(d.getTime());
assertFalse(d.after(d2), "Error d.after(d2) = true");
assertFalse(d2.after(d), "Error d2.after(d) = true");
}
/*
* Validate that a Date.before() returns false when same date is compared
*/
@Test
public void test5() {
Date d = Date.valueOf("1961-08-30");
assertFalse(d.before(d), "Error d.before(d) = true");
}
/*
* Validate that a Date.before() returns true when earlier date is compared
* to later date
*/
@Test
public void test6() {
Date d = Date.valueOf("1961-08-30");
Date d2 = new Date(System.currentTimeMillis());
assertTrue(d.before(d2), "Error d.before(d2) = false");
}
/*
* Validate that a Date.before() returns false when later date is compared
* to earlier date
*/
@Test
public void test7() {
Date d = Date.valueOf("1961-08-30");
Date d2 = new Date(d.getTime());
assertFalse(d2.before(d), "Error d2.before(d) = true");
}
/*
* Validate that a Date.before() returns false when date compared to another
* date created from the original date
*/
@Test
public void test8() {
Date d = Date.valueOf("1961-08-30");
Date d2 = new Date(d.getTime());
assertFalse(d.before(d2), "Error d.before(d2) = true");
assertFalse(d2.before(d), "Error d2.before(d) = true");
}
/*
* Validate that a Date.compareTo returns 0 when both Date objects are the
* same
*/
@Test
public void test9() {
Date d = Date.valueOf("1961-08-30");
assertTrue(d.compareTo(d) == 0, "Error d.compareTo(d) !=0");
}
/*
* Validate that a Date.compareTo returns 0 when both Date objects represent
* the same date
*/
@Test
public void test10() {
Date d = Date.valueOf("1961-08-30");
Date d2 = new Date(d.getTime());
assertTrue(d.compareTo(d2) == 0, "Error d.compareTo(d2) !=0");
}
/*
* Validate that a Date.compareTo returns -1 when comparing a date to a
* later date
*/
@Test
public void test11() {
Date d = Date.valueOf("1961-08-30");
Date d2 = new Date(System.currentTimeMillis());
assertTrue(d.compareTo(d2) == -1, "Error d.compareTo(d2) != -1");
}
/*
* Validate that a Date.compareTo returns 1 when comparing a date to an
* earlier date
*/
@Test
public void test12() {
Date d = Date.valueOf("1961-08-30");
Date d2 = new Date(System.currentTimeMillis());
assertTrue(d2.compareTo(d) == 1, "Error d.compareTo(d2) != 1");
}
/*
* Validate that a Date made from a LocalDate are equal
*/
@Test
public void test13() {
Date d = Date.valueOf("1961-08-30");
LocalDate ldt = d.toLocalDate();
Date d2 = Date.valueOf(ldt);
assertTrue(d.equals(d2), "Error d != d2");
}
/*
* Validate that a Date LocalDate value, made from a LocalDate are equal
*/
@Test
public void test14() {
LocalDate ldt = LocalDate.now();
Date d = Date.valueOf(ldt);
assertTrue(ldt.equals(d.toLocalDate()),
"Error LocalDate values are not equal");
}
/*
* Validate an NPE occurs when a null LocalDate is passed to valueOf
*/
@Test(expectedExceptions = NullPointerException.class)
public void test15() throws Exception {
LocalDate ld = null;
Date.valueOf(ld);
}
/*
* Validate an UnsupportedOperationException occurs when toInstant() is
* called
*/
@Test(expectedExceptions = UnsupportedOperationException.class)
public void test16() throws Exception {
Date d = Date.valueOf("1961-08-30");
Instant instant = d.toInstant();
}
/*
* Validate that two Date objects are equal when one is created from the
* toString() of the other
*/
@Test
public void test17() {
Date d = Date.valueOf("1961-08-30");
Date d2 = Date.valueOf(d.toString());
assertTrue(d.equals(d2) && d2.equals(d), "Error d != d2");
}
/*
* Validate that two Date values one created using valueOf and another via a
* constructor are equal
*/
@Test
public void test18() {
Date d = Date.valueOf("1961-08-30");
Date d2 = new Date(61, 7, 30);
assertTrue(d.equals(d2), "Error d != d2");
}
/*
* Validate that two Date values one created using getTime() of the other
* are equal
*/
@Test
public void test19() {
Date d = Date.valueOf("1961-08-30");
Date d2 = new Date(d.getTime());
assertTrue(d.equals(d2), "Error d != d2");
}
/*
* Validate that a Date value is equal to itself
*/
@Test
public void test20() {
Date d = Date.valueOf("1961-08-30");
assertTrue(d.equals(d), "Error d != d");
}
/*
* Validate an IllegalArgumentException is thrown for calling getHours
*/
@Test(expectedExceptions = IllegalArgumentException.class)
public void test21() throws Exception {
Date d = Date.valueOf("1961-08-30");
d.getHours();
}
/*
* Validate an IllegalArgumentException is thrown for calling getMinutes
*/
@Test(expectedExceptions = IllegalArgumentException.class)
public void test22() throws Exception {
Date d = Date.valueOf("1961-08-30");
d.getMinutes();
}
/*
* Validate an IllegalArgumentException is thrown for calling getSeconds
*/
@Test(expectedExceptions = IllegalArgumentException.class)
public void test23() throws Exception {
Date d = Date.valueOf("1961-08-30");
d.getSeconds();
}
/*
* Validate an IllegalArgumentException is thrown for calling setHours
*/
@Test(expectedExceptions = IllegalArgumentException.class)
public void test24() throws Exception {
Date d = Date.valueOf("1961-08-30");
d.setHours(8);
}
/*
* Validate an IllegalArgumentException is thrown for calling setMinutes
*/
@Test(expectedExceptions = IllegalArgumentException.class)
public void test25() throws Exception {
Date d = Date.valueOf("1961-08-30");
d.setMinutes(0);
}
/*
* Validate an IllegalArgumentException is thrown for calling setSeconds
*/
@Test(expectedExceptions = IllegalArgumentException.class)
public void test26() throws Exception {
Date d = Date.valueOf("1961-08-30");
d.setSeconds(0);
}
/*
* DataProvider used to provide Date which are not valid and are used
* to validate that an IllegalArgumentException will be thrown from the
* valueOf method
*/
@DataProvider(name = "invalidDateValues")
private Object[][] invalidDateValues() {
return new Object[][]{
{"20009-11-01"},
{"09-11-01"},
{"-11-01"},
{"2009-111-01"},
{"2009--01"},
{"2009-13-01"},
{"2009-11-011"},
{"2009-11-"},
{"2009-11-00"},
{"2009-11-33"},
{"--"},
{""},
{null},
{"-"},
{"2009"},
{"2009-01"},
{"---"},
{"2009-13--1"},
{"1900-1-0"},
{"2009-01-01 10:50:01"},
{"1996-12-10 12:26:19.1"},
{"10:50:01"}
};
}
/*
* DataProvider used to provide Dates which are valid and are used
* to validate that an IllegalArgumentException will not be thrown from the
* valueOf method and the corect value from toString() is returned
*/
@DataProvider(name = "validDateValues")
private Object[][] validDateValues() {
return new Object[][]{
{"2009-08-30", "2009-08-30"},
{"2009-01-8", "2009-01-08"},
{"2009-1-01", "2009-01-01"},
{"2009-1-1", "2009-01-01"}
};
}
}
/*
* 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 test.sql;
import java.security.AccessControlException;
import java.security.Policy;
import java.sql.DriverManager;
import java.sql.SQLException;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import util.BaseTest;
import util.StubDriver;
import util.TestPolicy;
public class DriverManagerPermissionsTests extends BaseTest {
private static Policy policy;
private static SecurityManager sm;
/*
* Install a SecurityManager along with a base Policy to allow testNG to run
*/
@BeforeClass
public static void setUpClass() throws Exception {
setPolicy(new TestPolicy());
System.setSecurityManager(new SecurityManager());
}
/*
* Install the original Policy and SecurityManager
*/
@AfterClass
public static void tearDownClass() throws Exception {
System.setSecurityManager(sm);
setPolicy(policy);
}
/*
* Save off the original Policy and SecurityManager
*/
public DriverManagerPermissionsTests() {
policy = Policy.getPolicy();
sm = System.getSecurityManager();
}
/*
* Validate that AccessControlException is thrown if SQLPermission("setLog")
* has not been granted
*/
@Test(expectedExceptions = AccessControlException.class)
public void test() {
setPolicy(new TestPolicy());
DriverManager.setLogStream(null);
}
/*
* Validate that setLogStream succeeds if SQLPermission("setLog") has been
* granted
*/
@Test
public void test1() {
Policy.setPolicy(new TestPolicy("setLog"));
DriverManager.setLogStream(null);
}
/*
* Validate that setLogStream succeeds if AllPermissions has been granted
*/
@Test
public void test2() {
setPolicy(new TestPolicy("all"));
DriverManager.setLogStream(null);
}
/*
* Validate that AccessControlException is thrown if SQLPermission("setLog")
* has not been granted
*/
@Test(expectedExceptions = AccessControlException.class)
public void test4() {
setPolicy(new TestPolicy());
DriverManager.setLogWriter(null);
}
/*
* Validate that setLogWriter succeeds if SQLPermission("setLog") has been
* granted
*/
@Test
public void test5() {
setPolicy(new TestPolicy("setLog"));
DriverManager.setLogWriter(null);
}
/*
* Validate that setLogWriter succeeds if AllPermissions has been granted
*/
@Test
public void test6() {
setPolicy(new TestPolicy("all"));
DriverManager.setLogWriter(null);
}
/*
* Validate that AccessControlException is thrown if
* SQLPermission("deregisterDriver") has not been granted
*/
@Test(expectedExceptions = AccessControlException.class)
public void test7() throws SQLException {
setPolicy(new TestPolicy());
DriverManager.deregisterDriver(new StubDriver());
}
/*
* Validate that deregisterDriver succeeds if
* SQLPermission("deregisterDriver") has been granted
*/
@Test
public void test8() throws SQLException {
setPolicy(new TestPolicy("deregisterDriver"));
DriverManager.deregisterDriver(new StubDriver());
}
/*
* Validate that deregisterDriver succeeds if AllPermissions has been
* granted
*/
@Test
public void test9() throws SQLException {
setPolicy(new TestPolicy("all"));
DriverManager.deregisterDriver(new StubDriver());
}
}
/*
* 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 test.sql;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.CharArrayReader;
import java.io.CharArrayWriter;
import java.io.File;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;
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.StubDriver;
public class DriverManagerTests {
private final String StubDriverURL = "jdbc:tennis:boy";
private final String StubDriverDAURL = "jdbc:luckydog:tennis";
private final String InvalidURL = "jdbc:cardio:tennis";
private String[] results = {"output", "more output", "and more", "the end"};
private String noOutput = "should not find this";
public DriverManagerTests() {
}
@BeforeClass
public static void setUpClass() throws Exception {
}
@AfterClass
public static void tearDownClass() throws Exception {
}
@BeforeMethod
public void setUpMethod() throws Exception {
removeAllDrivers();
}
@AfterMethod
public void tearDownMethod() throws Exception {
}
/**
* Utility method to remove all registered drivers
*/
private static void removeAllDrivers() {
java.util.Enumeration e = DriverManager.getDrivers();
while (e.hasMoreElements()) {
try {
DriverManager.deregisterDriver((Driver) (e.nextElement()));
} catch (SQLException ex) {
System.out.print(ex.getMessage());
}
}
}
/**
* Utility method to see if a driver is registered
*/
private boolean isDriverRegistered(Driver d) {
boolean foundDriver = false;
java.util.Enumeration e = DriverManager.getDrivers();
while (e.hasMoreElements()) {
if (d == (Driver) e.nextElement()) {
foundDriver = true;
break;
}
}
return foundDriver;
}
/**
* Validate that values set using setLoginTimeout will be returned by
* getLoginTimeout
*/
@Test
public void test() {
int[] vals = {-1, 0, 5};
for (int val : vals) {
DriverManager.setLoginTimeout(val);
assertEquals(val, DriverManager.getLoginTimeout());
}
}
/**
* Validate that NullPointerException is thrown when null is passed to
* registerDriver
*/
@Test(expectedExceptions = NullPointerException.class)
public void test1() throws Exception {
Driver d = null;
DriverManager.registerDriver(d);
}
/**
* Validate that NullPointerException is thrown when null is passed to
* registerDriver
*/
@Test(expectedExceptions = NullPointerException.class)
public void test2() throws Exception {
Driver d = null;
DriverManager.registerDriver(d, null);
}
/**
* Validate that a null value allows for deRegisterDriver to return
*/
@Test
public void test3() throws Exception {
DriverManager.deregisterDriver(null);
}
/**
* Validate that SQLException is thrown when there is no Driver to service
* the URL
*/
@Test(expectedExceptions = SQLException.class)
public void test4() throws Exception {
DriverManager.getConnection(InvalidURL);
}
/**
* Validate that SQLException is thrown when there is no Driver to service
* the URL
*/
@Test(expectedExceptions = SQLException.class)
public void test5() throws Exception {
DriverManager.getConnection(InvalidURL, new Properties());
}
/**
* Validate that SQLException is thrown when there is no Driver to service
* the URL
*/
@Test(expectedExceptions = SQLException.class)
public void test6() throws Exception {
DriverManager.getConnection(InvalidURL, "LuckyDog", "tennisanyone");
}
/**
* Validate that SQLException is thrown when null is passed for the URL
*/
@Test(expectedExceptions = SQLException.class)
public void test7() throws Exception {
DriverManager.getConnection(null);
}
/**
* Validate that SQLException is thrown when null is passed for the URL
*/
@Test(expectedExceptions = SQLException.class)
public void test8() throws Exception {
DriverManager.getConnection(null, new Properties());
}
/**
* Validate that SQLException is thrown when null is passed for the URL
*/
@Test(expectedExceptions = SQLException.class)
public void test9() throws Exception {
DriverManager.getConnection(null, "LuckyDog", "tennisanyone");
}
/**
* Validate that SQLException is thrown when there is no Driver to service
* the URL
*/
@Test(expectedExceptions = SQLException.class)
public void test10() throws Exception {
DriverManager.getDriver(InvalidURL);
}
/**
* Validate that SQLException is thrown when null is passed for the URL
*/
@Test(expectedExceptions = SQLException.class)
public void test11() throws Exception {
DriverManager.getDriver(null);
}
/**
* Validate that a non-null Driver is returned by getDriver when a valid URL
* is specified
*/
@Test
public void test12() throws Exception {
DriverManager.registerDriver(new StubDriver());
assertTrue(DriverManager.getDriver(StubDriverURL) != null);
}
/**
* Validate that SQLException is thrown when the URL is not valid for any of
* the registered drivers
*/
@Test(expectedExceptions = SQLException.class)
public void test13() throws Exception {
DriverManager.registerDriver(new StubDriver());
DriverManager.getDriver(InvalidURL);
}
/**
* Validate that a Connection object is returned when a valid URL is
* specified to getConnection
*
*/
@Test
public void test14() throws Exception {
DriverManager.registerDriver(new StubDriver());
assertTrue(
DriverManager.getConnection(StubDriverURL) != null);
assertTrue(DriverManager.getConnection(StubDriverURL,
"LuckyDog", "tennisanyone") != null);
Properties props = new Properties();
props.put("user", "LuckyDog");
props.put("password", "tennisanyone");
assertTrue(
DriverManager.getConnection(StubDriverURL,
props) != null);
}
/**
* Register a driver and make sure you find it via its URL. Deregister the
* driver and validate it is not longer registered
*
* @throws Exception
*/
@Test()
public void test15() throws Exception {
DriverManager.registerDriver(new StubDriver());
Driver d = DriverManager.getDriver(StubDriverURL);
assertTrue(d != null);
assertTrue(isDriverRegistered(d));
DriverManager.deregisterDriver(d);
assertFalse(isDriverRegistered(d));
}
/**
* Validate that DriverAction.release is called when a driver is registered
* via registerDriver(Driver, DriverAction)
*
* @throws Exception
*/
@Test
public void test16() throws Exception {
File file = new File(util.StubDriverDA.DriverActionCalled);
file.delete();
assertFalse(file.exists());
Driver d = null;
Class.forName("util.StubDriverDA");
d = DriverManager.getDriver(StubDriverDAURL);
DriverManager.deregisterDriver(d);
assertFalse(isDriverRegistered(d), "Driver is registered");
assertTrue(file.exists());
}
/**
* Create a PrintStream and use to send output via DriverManager.println
* Validate that if you disable the stream, the output sent is not present
*/
@Test
public void tests17() throws Exception {
ByteArrayOutputStream os = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(os);
DriverManager.setLogStream(ps);
assertTrue(DriverManager.getLogStream() == ps);
DriverManager.println(results[0]);
DriverManager.setLogStream((PrintStream) null);
assertTrue(DriverManager.getLogStream() == null);
DriverManager.println(noOutput);
DriverManager.setLogStream(ps);
DriverManager.println(results[1]);
DriverManager.println(results[2]);
DriverManager.println(results[3]);
DriverManager.setLogStream((PrintStream) null);
DriverManager.println(noOutput);
/*
* Check we do not get the output when the stream is disabled
*/
InputStreamReader is
= new InputStreamReader(new ByteArrayInputStream(os.toByteArray()));
BufferedReader reader = new BufferedReader(is);
for (String result : results) {
assertTrue(result.equals(reader.readLine()));
}
}
/**
* Create a PrintWriter and use to to send output via DriverManager.println
* Validate that if you disable the writer, the output sent is not present
*/
@Test
public void tests18() throws Exception {
CharArrayWriter cw = new CharArrayWriter();
PrintWriter pw = new PrintWriter(cw);
DriverManager.setLogWriter(pw);
assertTrue(DriverManager.getLogWriter() == pw);
DriverManager.println(results[0]);
DriverManager.setLogWriter(null);
assertTrue(DriverManager.getLogWriter() == null);
DriverManager.println(noOutput);
DriverManager.setLogWriter(pw);
DriverManager.println(results[1]);
DriverManager.println(results[2]);
DriverManager.println(results[3]);
DriverManager.setLogWriter(null);
DriverManager.println(noOutput);
/*
* Check we do not get the output when the stream is disabled
*/
BufferedReader reader
= new BufferedReader(new CharArrayReader(cw.toCharArray()));
for (String result : results) {
assertTrue(result.equals(reader.readLine()));
}
}
}
/*
* 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 test.sql;
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.Test;
import util.BaseTest;
public class SQLClientInfoExceptionTests extends BaseTest {
private final HashMap<String, ClientInfoStatus> map = new HashMap<>();
public SQLClientInfoExceptionTests() {
map.put("1", ClientInfoStatus.REASON_UNKNOWN_PROPERTY);
map.put("21", ClientInfoStatus.REASON_UNKNOWN_PROPERTY);
}
/**
* Create SQLClientInfoException and setting all objects to null
*/
@Test
public void test() {
SQLClientInfoException e = new SQLClientInfoException(null);
assertTrue(e.getMessage() == null && e.getSQLState() == null
&& e.getCause() == null && e.getErrorCode() == 0
&& e.getFailedProperties() == null);
}
/**
* Create SQLClientInfoException with no-arg constructor
*/
@Test
public void test1() {
SQLClientInfoException ex = new SQLClientInfoException();
assertTrue(ex.getMessage() == null
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0
&& ex.getFailedProperties() == null);
}
/**
* Create SQLClientInfoException with null Throwable
*/
@Test
public void test2() {
SQLClientInfoException ex = new SQLClientInfoException(map, null);
assertTrue(ex.getMessage() == null
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0
&& ex.getFailedProperties().equals(map));
}
/**
* Create SQLClientInfoException with message
*/
@Test
public void test3() {
SQLClientInfoException ex = new SQLClientInfoException(reason, map);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0
&& ex.getFailedProperties().equals(map));
}
/**
* Create SQLClientInfoException with null Throwable
*/
@Test
public void test4() {
SQLClientInfoException ex = new SQLClientInfoException(reason, map, null);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0
&& ex.getFailedProperties().equals(map));
}
/**
* Create SQLClientInfoException with message, and SQLState
*/
@Test
public void test5() {
SQLClientInfoException ex = new SQLClientInfoException(reason, state,
map);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& ex.getCause() == null
&& ex.getErrorCode() == 0
&& ex.getFailedProperties().equals(map));
}
/**
* Create SQLClientInfoException with message, and SQLState
*/
@Test
public void test6() {
SQLClientInfoException ex = new SQLClientInfoException(reason, state,
map, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0
&& ex.getFailedProperties().equals(map));
}
/**
* Create SQLClientInfoException with message, SQLState, errorCode, and
* Throwable
*/
@Test
public void test7() {
SQLClientInfoException ex = new SQLClientInfoException(reason, state,
errorCode, map);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& ex.getCause() == null
&& ex.getErrorCode() == errorCode
&& ex.getFailedProperties().equals(map));
}
/**
* Create SQLClientInfoException with message, SQLState, and error code
*/
@Test
public void test8() {
SQLClientInfoException ex = new SQLClientInfoException(reason, state,
errorCode, map, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == errorCode
&& ex.getFailedProperties().equals(map));
}
/**
* Serialize a SQLClientInfoException and make sure you can read it back
* properly
*/
@Test
public void test10() throws Exception {
SQLClientInfoException e = new SQLClientInfoException(reason, state,
errorCode, map, t);
SQLClientInfoException ex1 =
createSerializedException(e);
assertTrue(reason.equals(ex1.getMessage())
&& ex1.getSQLState().equals(state)
&& cause.equals(ex1.getCause().toString())
&& ex1.getErrorCode() == errorCode
&& ex1.getFailedProperties().equals(map));
}
/**
* Validate that the ordering of the returned Exceptions is correct using
* for-each loop
*/
@Test
public void test11() {
SQLClientInfoException ex = new SQLClientInfoException("Exception 1",
map, t1);
SQLClientInfoException ex1 = new SQLClientInfoException("Exception 2",
map);
SQLClientInfoException ex2 = new SQLClientInfoException("Exception 3",
map, t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
for (Throwable e : ex) {
assertTrue(msgs[num++].equals(e.getMessage()));
}
}
/**
* Validate that the ordering of the returned Exceptions is correct using
* traditional while loop
*/
@Test
public void test12() {
SQLClientInfoException ex = new SQLClientInfoException("Exception 1",
map, t1);
SQLClientInfoException ex1 = new SQLClientInfoException("Exception 2",
map);
SQLClientInfoException ex2 = new SQLClientInfoException("Exception 3",
map, t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
SQLException sqe = ex;
while (sqe != null) {
assertTrue(msgs[num++].equals(sqe.getMessage()));
Throwable c = sqe.getCause();
while (c != null) {
assertTrue(msgs[num++].equals(c.getMessage()));
c = c.getCause();
}
sqe = sqe.getNextException();
}
}
}
/*
* 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 test.sql;
import java.sql.SQLDataException;
import java.sql.SQLException;
import java.sql.SQLNonTransientException;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
import util.BaseTest;
public class SQLDataExceptionTests extends BaseTest {
/**
* Create SQLDataException and setting all objects to null
*/
@Test
public void test() {
SQLDataException e = new SQLDataException(null, null, errorCode, null);
assertTrue(e.getMessage() == null && e.getSQLState() == null
&& e.getCause() == null && e.getErrorCode() == errorCode);
}
/**
* Create SQLDataException with no-arg constructor
*/
@Test
public void test1() {
SQLDataException ex = new SQLDataException();
assertTrue(ex.getMessage() == null
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLDataException with message
*/
@Test
public void test2() {
SQLDataException ex = new SQLDataException(reason);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLDataException with message, and SQLState
*/
@Test
public void test3() {
SQLDataException ex = new SQLDataException(reason, state);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLDataException with message, SQLState, and error code
*/
@Test
public void test4() {
SQLDataException ex = new SQLDataException(reason, state, errorCode);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& ex.getCause() == null
&& ex.getErrorCode() == errorCode);
}
/**
* Create SQLDataException with message, SQLState, errorCode, and Throwable
*/
@Test
public void test5() {
SQLDataException ex = new SQLDataException(reason, state, errorCode, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == errorCode);
}
/**
* Create SQLDataException with message, SQLState, and Throwable
*/
@Test
public void test6() {
SQLDataException ex = new SQLDataException(reason, state, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
/**
* Create SQLDataException with message, and Throwable
*/
@Test
public void test7() {
SQLDataException ex = new SQLDataException(reason, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState() == null
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
/**
* Create SQLDataException with null Throwable
*/
@Test
public void test8() {
SQLDataException ex = new SQLDataException((Throwable)null);
assertTrue(ex.getMessage() == null
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLDataException with Throwable
*/
@Test
public void test9() {
SQLDataException ex = new SQLDataException(t);
assertTrue(ex.getMessage().equals(cause)
&& ex.getSQLState() == null
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
/**
* Serialize a SQLDataException and make sure you can read it back properly
*/
@Test
public void test10() throws Exception {
SQLDataException e = new SQLDataException(reason, state, errorCode, t);
SQLDataException ex1 = createSerializedException(e);
assertTrue(reason.equals(ex1.getMessage())
&& ex1.getSQLState().equals(state)
&& cause.equals(ex1.getCause().toString())
&& ex1.getErrorCode() == errorCode);
}
/**
* Validate that the ordering of the returned Exceptions is correct
* using for-each loop
*/
@Test
public void test11() {
SQLDataException ex = new SQLDataException("Exception 1", t1);
SQLDataException ex1 = new SQLDataException("Exception 2");
SQLDataException ex2 = new SQLDataException("Exception 3", t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
for (Throwable e : ex) {
assertTrue(msgs[num++].equals(e.getMessage()));
}
}
/**
* Validate that the ordering of the returned Exceptions is correct
* using traditional while loop
*/
@Test
public void test12() {
SQLDataException ex = new SQLDataException("Exception 1", t1);
SQLDataException ex1 = new SQLDataException("Exception 2");
SQLDataException ex2 = new SQLDataException("Exception 3", t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
SQLException sqe = ex;
while (sqe != null) {
assertTrue(msgs[num++].equals(sqe.getMessage()));
Throwable c = sqe.getCause();
while (c != null) {
assertTrue(msgs[num++].equals(c.getMessage()));
c = c.getCause();
}
sqe = sqe.getNextException();
}
}
/**
* Create SQLDataException and validate it is an instance of
* SQLNonTransientException
*/
@Test
public void test13() {
Exception ex = new SQLDataException();
assertTrue(ex instanceof SQLNonTransientException);
}
}
/*
* 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 test.sql;
import java.sql.SQLException;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
import util.BaseTest;
public class SQLExceptionTests extends BaseTest {
/**
* Create SQLException and setting all objects to null
*/
@Test
public void test() {
SQLException e = new SQLException(null, null, errorCode, null);
assertTrue(e.getMessage() == null && e.getSQLState() == null
&& e.getCause() == null && e.getErrorCode() == errorCode);
}
/**
* Create SQLException with no-arg constructor
*/
@Test
public void test1() {
SQLException ex = new SQLException();
assertTrue(ex.getMessage() == null
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLException with message
*/
@Test
public void test2() {
SQLException ex = new SQLException(reason);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLException with message, and SQLState
*/
@Test
public void test3() {
SQLException ex = new SQLException(reason, state);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLException with message, SQLState, and error code
*/
@Test
public void test4() {
SQLException ex = new SQLException(reason, state, errorCode);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& ex.getCause() == null
&& ex.getErrorCode() == errorCode);
}
/**
* Create SQLException with message, SQLState, errorCode, and Throwable
*/
@Test
public void test5() {
SQLException ex = new SQLException(reason, state, errorCode, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == errorCode);
}
/**
* Create SQLException with message, SQLState, and Throwable
*/
@Test
public void test6() {
SQLException ex = new SQLException(reason, state, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
/**
* Create SQLException with message, and Throwable
*/
@Test
public void test7() {
SQLException ex = new SQLException(reason, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState() == null
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
/**
* Create SQLException with null Throwable
*/
@Test
public void test8() {
SQLException ex = new SQLException((Throwable)null);
assertTrue(ex.getMessage() == null
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLException with Throwable
*/
@Test
public void test9() {
SQLException ex = new SQLException(t);
assertTrue(ex.getMessage().equals(cause)
&& ex.getSQLState() == null
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
/**
* Serialize a SQLException and make sure you can read it back properly
*/
@Test
public void test10() throws Exception {
SQLException e = new SQLException(reason, state, errorCode, t);
SQLException ex1 = createSerializedException(e);
assertTrue(reason.equals(ex1.getMessage())
&& ex1.getSQLState().equals(state)
&& cause.equals(ex1.getCause().toString())
&& ex1.getErrorCode() == errorCode);
}
/**
* Validate that the ordering of the returned Exceptions is correct
* using for-each loop
*/
@Test
public void test11() {
SQLException ex = new SQLException("Exception 1", t1);
SQLException ex1 = new SQLException("Exception 2");
SQLException ex2 = new SQLException("Exception 3", t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
for (Throwable e : ex) {
assertTrue(msgs[num++].equals(e.getMessage()));
}
}
/**
* Validate that the ordering of the returned Exceptions is correct
* using traditional while loop
*/
@Test
public void test12() {
SQLException ex = new SQLException("Exception 1", t1);
SQLException ex1 = new SQLException("Exception 2");
SQLException ex2 = new SQLException("Exception 3", t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
while (ex != null) {
assertTrue(msgs[num++].equals(ex.getMessage()));
Throwable c = ex.getCause();
while (c != null) {
assertTrue(msgs[num++].equals(c.getMessage()));
c = c.getCause();
}
ex = ex.getNextException();
}
}
}
/*
* 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 test.sql;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.sql.SQLNonTransientException;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
import util.BaseTest;
public class SQLFeatureNotSupportedExceptionTests extends BaseTest {
/**
* Create SQLFeatureNotSupportedException and setting all objects to null
*/
@Test
public void test() {
SQLFeatureNotSupportedException e =
new SQLFeatureNotSupportedException(null, null, errorCode, null);
assertTrue(e.getMessage() == null && e.getSQLState() == null
&& e.getCause() == null && e.getErrorCode() == errorCode);
}
/**
* Create SQLFeatureNotSupportedException with no-arg constructor
*/
@Test
public void test1() {
SQLFeatureNotSupportedException ex = new SQLFeatureNotSupportedException();
assertTrue(ex.getMessage() == null
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLFeatureNotSupportedException with message
*/
@Test
public void test2() {
SQLFeatureNotSupportedException ex =
new SQLFeatureNotSupportedException(reason);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLFeatureNotSupportedException with message, and SQLState
*/
@Test
public void test3() {
SQLFeatureNotSupportedException ex =
new SQLFeatureNotSupportedException(reason, state);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLFeatureNotSupportedException with message, SQLState, and error code
*/
@Test
public void test4() {
SQLFeatureNotSupportedException ex =
new SQLFeatureNotSupportedException(reason, state, errorCode);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& ex.getCause() == null
&& ex.getErrorCode() == errorCode);
}
/**
* Create SQLFeatureNotSupportedException with message, SQLState, errorCode, and Throwable
*/
@Test
public void test5() {
SQLFeatureNotSupportedException ex =
new SQLFeatureNotSupportedException(reason, state, errorCode, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == errorCode);
}
/**
* Create SQLFeatureNotSupportedException with message, SQLState, and Throwable
*/
@Test
public void test6() {
SQLFeatureNotSupportedException ex =
new SQLFeatureNotSupportedException(reason, state, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
/**
* Create SQLFeatureNotSupportedException with message, and Throwable
*/
@Test
public void test7() {
SQLFeatureNotSupportedException ex =
new SQLFeatureNotSupportedException(reason, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState() == null
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
/**
* Create SQLFeatureNotSupportedException with null Throwable
*/
@Test
public void test8() {
SQLFeatureNotSupportedException ex =
new SQLFeatureNotSupportedException((Throwable) null);
assertTrue(ex.getMessage() == null
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLFeatureNotSupportedException with Throwable
*/
@Test
public void test9() {
SQLFeatureNotSupportedException ex =
new SQLFeatureNotSupportedException(t);
assertTrue(ex.getMessage().equals(cause)
&& ex.getSQLState() == null
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
/**
* Serialize a SQLFeatureNotSupportedException and make sure you can read it back properly
*/
@Test
public void test10() throws Exception {
SQLFeatureNotSupportedException e =
new SQLFeatureNotSupportedException(reason, state, errorCode, t);
SQLFeatureNotSupportedException ex1 =
createSerializedException(e);
assertTrue(reason.equals(ex1.getMessage())
&& ex1.getSQLState().equals(state)
&& cause.equals(ex1.getCause().toString())
&& ex1.getErrorCode() == errorCode);
}
/**
* Validate that the ordering of the returned Exceptions is correct
* using for-each loop
*/
@Test
public void test11() {
SQLFeatureNotSupportedException ex =
new SQLFeatureNotSupportedException("Exception 1", t1);
SQLFeatureNotSupportedException ex1 =
new SQLFeatureNotSupportedException("Exception 2");
SQLFeatureNotSupportedException ex2 =
new SQLFeatureNotSupportedException("Exception 3", t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
for (Throwable e : ex) {
assertTrue(msgs[num++].equals(e.getMessage()));
}
}
/**
* Validate that the ordering of the returned Exceptions is correct
* using traditional while loop
*/
@Test
public void test12() {
SQLFeatureNotSupportedException ex =
new SQLFeatureNotSupportedException("Exception 1", t1);
SQLFeatureNotSupportedException ex1 =
new SQLFeatureNotSupportedException("Exception 2");
SQLFeatureNotSupportedException ex2 =
new SQLFeatureNotSupportedException("Exception 3", t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
SQLException sqe = ex;
while (sqe != null) {
assertTrue(msgs[num++].equals(sqe.getMessage()));
Throwable c = sqe.getCause();
while (c != null) {
assertTrue(msgs[num++].equals(c.getMessage()));
c = c.getCause();
}
sqe = sqe.getNextException();
}
}
/**
* Create SQLFeatureNotSupportedException and validate it is an instance of
* SQLNonTransientException
*/
@Test
public void test13() {
Exception ex = new SQLFeatureNotSupportedException();
assertTrue(ex instanceof SQLNonTransientException);
}
}
/*
* 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 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
public void test() {
SQLIntegrityConstraintViolationException e =
new SQLIntegrityConstraintViolationException(null,
null, errorCode, null);
assertTrue(e.getMessage() == null && e.getSQLState() == null
&& e.getCause() == null && e.getErrorCode() == errorCode);
}
/**
* Create SQLIntegrityConstraintViolationException with no-arg constructor
*/
@Test
public void test1() {
SQLIntegrityConstraintViolationException ex =
new SQLIntegrityConstraintViolationException();
assertTrue(ex.getMessage() == null
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLIntegrityConstraintViolationException with message
*/
@Test
public void test2() {
SQLIntegrityConstraintViolationException ex =
new SQLIntegrityConstraintViolationException(reason);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLIntegrityConstraintViolationException with message, and SQLState
*/
@Test
public void test3() {
SQLIntegrityConstraintViolationException ex =
new SQLIntegrityConstraintViolationException(reason, state);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLIntegrityConstraintViolationException with message, SQLState, and error code
*/
@Test
public void test4() {
SQLIntegrityConstraintViolationException ex =
new SQLIntegrityConstraintViolationException(reason, state, errorCode);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& ex.getCause() == null
&& ex.getErrorCode() == errorCode);
}
/**
* Create SQLIntegrityConstraintViolationException with message, SQLState, errorCode, and Throwable
*/
@Test
public void test5() {
SQLIntegrityConstraintViolationException ex =
new SQLIntegrityConstraintViolationException(reason, state, errorCode, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == errorCode);
}
/**
* Create SQLIntegrityConstraintViolationException with message, SQLState, and Throwable
*/
@Test
public void test6() {
SQLIntegrityConstraintViolationException ex =
new SQLIntegrityConstraintViolationException(reason, state, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
/**
* Create SQLIntegrityConstraintViolationException with message, and Throwable
*/
@Test
public void test7() {
SQLIntegrityConstraintViolationException ex =
new SQLIntegrityConstraintViolationException(reason, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState() == null
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
/**
* Create SQLIntegrityConstraintViolationException with null Throwable
*/
@Test
public void test8() {
SQLIntegrityConstraintViolationException ex =
new SQLIntegrityConstraintViolationException((Throwable)null);
assertTrue(ex.getMessage() == null
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLIntegrityConstraintViolationException with Throwable
*/
@Test
public void test9() {
SQLIntegrityConstraintViolationException ex =
new SQLIntegrityConstraintViolationException(t);
assertTrue(ex.getMessage().equals(cause)
&& ex.getSQLState() == null
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
/**
* Serialize a SQLIntegrityConstraintViolationException and make sure
* you can read it back properly
*/
@Test
public void test10() throws Exception {
SQLIntegrityConstraintViolationException e =
new SQLIntegrityConstraintViolationException(reason, state, errorCode, t);
SQLIntegrityConstraintViolationException ex1 =
createSerializedException(e);
assertTrue(reason.equals(ex1.getMessage())
&& ex1.getSQLState().equals(state)
&& cause.equals(ex1.getCause().toString())
&& ex1.getErrorCode() == errorCode);
}
/**
* Validate that the ordering of the returned Exceptions is correct
* using for-each loop
*/
@Test
public void test11() {
SQLIntegrityConstraintViolationException ex =
new SQLIntegrityConstraintViolationException("Exception 1", t1);
SQLIntegrityConstraintViolationException ex1 =
new SQLIntegrityConstraintViolationException("Exception 2");
SQLIntegrityConstraintViolationException ex2 =
new SQLIntegrityConstraintViolationException("Exception 3", t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
for (Throwable e : ex) {
assertTrue(msgs[num++].equals(e.getMessage()));
}
}
/**
* Validate that the ordering of the returned Exceptions is correct
* using traditional while loop
*/
@Test
public void test12() {
SQLIntegrityConstraintViolationException ex =
new SQLIntegrityConstraintViolationException("Exception 1", t1);
SQLIntegrityConstraintViolationException ex1 =
new SQLIntegrityConstraintViolationException("Exception 2");
SQLIntegrityConstraintViolationException ex2 =
new SQLIntegrityConstraintViolationException("Exception 3", t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
SQLException sqe = ex;
while (sqe != null) {
assertTrue(msgs[num++].equals(sqe.getMessage()));
Throwable c = sqe.getCause();
while (c != null) {
assertTrue(msgs[num++].equals(c.getMessage()));
c = c.getCause();
}
sqe = sqe.getNextException();
}
}
/**
* Create SQLIntegrityConstraintViolationException and validate it is an instance of
* SQLNonTransientException
*/
@Test
public void test13() {
Exception ex = new SQLIntegrityConstraintViolationException();
assertTrue(ex instanceof SQLNonTransientException);
}
}
/*
* 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 test.sql;
import java.sql.SQLException;
import java.sql.SQLInvalidAuthorizationSpecException;
import java.sql.SQLNonTransientException;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
import util.BaseTest;
public class SQLInvalidAuthorizationSpecExceptionTests extends BaseTest {
/**
* Create SQLInvalidAuthorizationSpecException and setting all objects to
* null
*/
@Test
public void test() {
SQLInvalidAuthorizationSpecException e
= new SQLInvalidAuthorizationSpecException(null,
null, errorCode, null);
assertTrue(e.getMessage() == null && e.getSQLState() == null
&& e.getCause() == null && e.getErrorCode() == errorCode);
}
/**
* Create SQLInvalidAuthorizationSpecException with no-arg constructor
*/
@Test
public void test1() {
SQLInvalidAuthorizationSpecException ex
= new SQLInvalidAuthorizationSpecException();
assertTrue(ex.getMessage() == null
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLInvalidAuthorizationSpecException with message
*/
@Test
public void test2() {
SQLInvalidAuthorizationSpecException ex
= new SQLInvalidAuthorizationSpecException(reason);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLInvalidAuthorizationSpecException with message, and SQLState
*/
@Test
public void test3() {
SQLInvalidAuthorizationSpecException ex
= new SQLInvalidAuthorizationSpecException(reason, state);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLInvalidAuthorizationSpecException with message, SQLState, and
* error code
*/
@Test
public void test4() {
SQLInvalidAuthorizationSpecException ex
= new SQLInvalidAuthorizationSpecException(reason, state, errorCode);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& ex.getCause() == null
&& ex.getErrorCode() == errorCode);
}
/**
* Create SQLInvalidAuthorizationSpecException with message, SQLState,
* errorCode, and Throwable
*/
@Test
public void test5() {
SQLInvalidAuthorizationSpecException ex
= new SQLInvalidAuthorizationSpecException(reason, state, errorCode, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == errorCode);
}
/**
* Create SQLInvalidAuthorizationSpecException with message, SQLState, and
* Throwable
*/
@Test
public void test6() {
SQLInvalidAuthorizationSpecException ex
= new SQLInvalidAuthorizationSpecException(reason, state, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
/**
* Create SQLInvalidAuthorizationSpecException with message, and Throwable
*/
@Test
public void test7() {
SQLInvalidAuthorizationSpecException ex
= new SQLInvalidAuthorizationSpecException(reason, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState() == null
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
/**
* Create SQLInvalidAuthorizationSpecException with null Throwable
*/
@Test
public void test8() {
SQLInvalidAuthorizationSpecException ex
= new SQLInvalidAuthorizationSpecException((Throwable) null);
assertTrue(ex.getMessage() == null
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLInvalidAuthorizationSpecException with Throwable
*/
@Test
public void test9() {
SQLInvalidAuthorizationSpecException ex
= new SQLInvalidAuthorizationSpecException(t);
assertTrue(ex.getMessage().equals(cause)
&& ex.getSQLState() == null
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
/**
* Serialize a SQLInvalidAuthorizationSpecException and make sure you can
* read it back properly
*/
@Test
public void test10() throws Exception {
SQLInvalidAuthorizationSpecException e
= new SQLInvalidAuthorizationSpecException(reason, state, errorCode, t);
SQLInvalidAuthorizationSpecException ex1 =
createSerializedException(e);
assertTrue(reason.equals(ex1.getMessage())
&& ex1.getSQLState().equals(state)
&& cause.equals(ex1.getCause().toString())
&& ex1.getErrorCode() == errorCode);
}
/**
* Validate that the ordering of the returned Exceptions is correct using
* for-each loop
*/
@Test
public void test11() {
SQLInvalidAuthorizationSpecException ex
= new SQLInvalidAuthorizationSpecException("Exception 1", t1);
SQLInvalidAuthorizationSpecException ex1
= new SQLInvalidAuthorizationSpecException("Exception 2");
SQLInvalidAuthorizationSpecException ex2
= new SQLInvalidAuthorizationSpecException("Exception 3", t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
for (Throwable e : ex) {
assertTrue(msgs[num++].equals(e.getMessage()));
}
}
/**
* Validate that the ordering of the returned Exceptions is correct using
* traditional while loop
*/
@Test
public void test12() {
SQLInvalidAuthorizationSpecException ex
= new SQLInvalidAuthorizationSpecException("Exception 1", t1);
SQLInvalidAuthorizationSpecException ex1
= new SQLInvalidAuthorizationSpecException("Exception 2");
SQLInvalidAuthorizationSpecException ex2
= new SQLInvalidAuthorizationSpecException("Exception 3", t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
SQLException sqe = ex;
while (sqe != null) {
assertTrue(msgs[num++].equals(sqe.getMessage()));
Throwable c = sqe.getCause();
while (c != null) {
assertTrue(msgs[num++].equals(c.getMessage()));
c = c.getCause();
}
sqe = sqe.getNextException();
}
}
/**
* Create SQLInvalidAuthorizationSpecException and validate it is an
* instance of SQLNonTransientException
*/
@Test
public void test13() {
Exception ex = new SQLInvalidAuthorizationSpecException();
assertTrue(ex instanceof SQLNonTransientException);
}
}
/*
* 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 test.sql;
import java.sql.SQLException;
import java.sql.SQLNonTransientConnectionException;
import java.sql.SQLNonTransientException;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
import util.BaseTest;
public class SQLNonTransientConnectionExceptionTests extends BaseTest {
/**
* Create SQLNonTransientConnectionException and setting all objects to null
*/
@Test
public void test() {
SQLNonTransientConnectionException e =
new SQLNonTransientConnectionException(null,
null, errorCode, null);
assertTrue(e.getMessage() == null && e.getSQLState() == null
&& e.getCause() == null && e.getErrorCode() == errorCode);
}
/**
* Create SQLNonTransientConnectionException with no-arg constructor
*/
@Test
public void test1() {
SQLNonTransientConnectionException ex =
new SQLNonTransientConnectionException();
assertTrue(ex.getMessage() == null
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLNonTransientConnectionException with message
*/
@Test
public void test2() {
SQLNonTransientConnectionException ex =
new SQLNonTransientConnectionException(reason);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLNonTransientConnectionException with message, and SQLState
*/
@Test
public void test3() {
SQLNonTransientConnectionException ex =
new SQLNonTransientConnectionException(reason, state);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLNonTransientConnectionException with message, SQLState, and error code
*/
@Test
public void test4() {
SQLNonTransientConnectionException ex =
new SQLNonTransientConnectionException(reason, state, errorCode);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& ex.getCause() == null
&& ex.getErrorCode() == errorCode);
}
/**
* Create SQLNonTransientConnectionException with message, SQLState, errorCode, and Throwable
*/
@Test
public void test5() {
SQLNonTransientConnectionException ex =
new SQLNonTransientConnectionException(reason, state, errorCode, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == errorCode);
}
/**
* Create SQLNonTransientConnectionException with message, SQLState, and Throwable
*/
@Test
public void test6() {
SQLNonTransientConnectionException ex =
new SQLNonTransientConnectionException(reason, state, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
/**
* Create SQLNonTransientConnectionException with message, and Throwable
*/
@Test
public void test7() {
SQLNonTransientConnectionException ex =
new SQLNonTransientConnectionException(reason, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState() == null
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
/**
* Create SQLNonTransientConnectionException with null Throwable
*/
@Test
public void test8() {
SQLNonTransientConnectionException ex =
new SQLNonTransientConnectionException((Throwable)null);
assertTrue(ex.getMessage() == null
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLNonTransientConnectionException with Throwable
*/
@Test
public void test9() {
SQLNonTransientConnectionException ex =
new SQLNonTransientConnectionException(t);
assertTrue(ex.getMessage().equals(cause)
&& ex.getSQLState() == null
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
/**
* Serialize a SQLNonTransientConnectionException and make sure you can
* read it back properly
*/
@Test
public void test10() throws Exception {
SQLNonTransientConnectionException e =
new SQLNonTransientConnectionException(reason, state, errorCode, t);
SQLNonTransientConnectionException ex1 =
createSerializedException(e);
assertTrue(reason.equals(ex1.getMessage())
&& ex1.getSQLState().equals(state)
&& cause.equals(ex1.getCause().toString())
&& ex1.getErrorCode() == errorCode);
}
/**
* Validate that the ordering of the returned Exceptions is correct
* using for-each loop
*/
@Test
public void test11() {
SQLNonTransientConnectionException ex =
new SQLNonTransientConnectionException("Exception 1", t1);
SQLNonTransientConnectionException ex1 =
new SQLNonTransientConnectionException("Exception 2");
SQLNonTransientConnectionException ex2 =
new SQLNonTransientConnectionException("Exception 3", t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
for (Throwable e : ex) {
assertTrue(msgs[num++].equals(e.getMessage()));
}
}
/**
* Validate that the ordering of the returned Exceptions is correct
* using traditional while loop
*/
@Test
public void test12() {
SQLNonTransientConnectionException ex =
new SQLNonTransientConnectionException("Exception 1", t1);
SQLNonTransientConnectionException ex1 =
new SQLNonTransientConnectionException("Exception 2");
SQLNonTransientConnectionException ex2 =
new SQLNonTransientConnectionException("Exception 3", t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
SQLException sqe = ex;
while (sqe != null) {
assertTrue(msgs[num++].equals(sqe.getMessage()));
Throwable c = sqe.getCause();
while (c != null) {
assertTrue(msgs[num++].equals(c.getMessage()));
c = c.getCause();
}
sqe = sqe.getNextException();
}
}
/**
* Create SQLNonTransientConnectionException and validate it is an instance of
* SQLNonTransientException
*/
@Test
public void test13() {
Exception ex = new SQLNonTransientConnectionException();
assertTrue(ex instanceof SQLNonTransientException);
}
}
/*
* 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 test.sql;
import java.sql.SQLException;
import java.sql.SQLNonTransientException;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
import util.BaseTest;
public class SQLNonTransientExceptionTests extends BaseTest {
/**
* Create SQLNonTransientException and setting all objects to null
*/
@Test
public void test() {
SQLNonTransientException e = new SQLNonTransientException(null,
null, errorCode, null);
assertTrue(e.getMessage() == null && e.getSQLState() == null
&& e.getCause() == null && e.getErrorCode() == errorCode);
}
/**
* Create SQLNonTransientException with no-arg constructor
*/
@Test
public void test1() {
SQLNonTransientException ex = new SQLNonTransientException();
assertTrue(ex.getMessage() == null
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLNonTransientException with message
*/
@Test
public void test2() {
SQLNonTransientException ex = new SQLNonTransientException(reason);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLNonTransientException with message, and SQLState
*/
@Test
public void test3() {
SQLNonTransientException ex = new SQLNonTransientException(reason, state);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLNonTransientException with message, SQLState, and error code
*/
@Test
public void test4() {;
SQLNonTransientException ex =
new SQLNonTransientException(reason, state, errorCode);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& ex.getCause() == null
&& ex.getErrorCode() == errorCode);
}
/**
* Create SQLNonTransientException with message, SQLState, errorCode, and Throwable
*/
@Test
public void test5() {
SQLNonTransientException ex =
new SQLNonTransientException(reason, state, errorCode, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == errorCode);
}
/**
* Create SQLNonTransientException with message, SQLState, and Throwable
*/
@Test
public void test6() {
SQLNonTransientException ex = new SQLNonTransientException(reason, state, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
/**
* Create SQLNonTransientException with message, and Throwable
*/
@Test
public void test7() {
SQLNonTransientException ex = new SQLNonTransientException(reason, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState() == null
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
/**
* Create SQLNonTransientException with null Throwable
*/
@Test
public void test8() {
SQLNonTransientException ex = new SQLNonTransientException((Throwable)null);
assertTrue(ex.getMessage() == null
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLNonTransientException with Throwable
*/
@Test
public void test9() {
SQLNonTransientException ex = new SQLNonTransientException(t);
assertTrue(ex.getMessage().equals(cause)
&& ex.getSQLState() == null
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
/**
* Serialize a SQLNonTransientException and make sure you can read it back properly
*/
@Test
public void test10() throws Exception {
SQLNonTransientException e =
new SQLNonTransientException(reason, state, errorCode, t);
SQLNonTransientException ex1 =
createSerializedException(e);
assertTrue(reason.equals(ex1.getMessage())
&& ex1.getSQLState().equals(state)
&& cause.equals(ex1.getCause().toString())
&& ex1.getErrorCode() == errorCode);
}
/**
* Validate that the ordering of the returned Exceptions is correct
* using for-each loop
*/
@Test
public void test11() {
SQLNonTransientException ex = new SQLNonTransientException("Exception 1", t1);
SQLNonTransientException ex1 = new SQLNonTransientException("Exception 2");
SQLNonTransientException ex2 = new SQLNonTransientException("Exception 3", t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
for (Throwable e : ex) {
assertTrue(msgs[num++].equals(e.getMessage()));
}
}
/**
* Validate that the ordering of the returned Exceptions is correct
* using traditional while loop
*/
@Test
public void test12() {
SQLNonTransientException ex = new SQLNonTransientException("Exception 1", t1);
SQLNonTransientException ex1 = new SQLNonTransientException("Exception 2");
SQLNonTransientException ex2 = new SQLNonTransientException("Exception 3", t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
SQLException sqe = ex;
while (sqe != null) {
assertTrue(msgs[num++].equals(sqe.getMessage()));
Throwable c = sqe.getCause();
while (c != null) {
assertTrue(msgs[num++].equals(c.getMessage()));
c = c.getCause();
}
sqe = sqe.getNextException();
}
}
}
/*
* 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 test.sql;
import java.sql.SQLException;
import java.sql.SQLRecoverableException;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
import util.BaseTest;
public class SQLRecoverableExceptionTests extends BaseTest {
/**
* Create SQLRecoverableException and setting all objects to null
*/
@Test
public void test() {
SQLRecoverableException e = new SQLRecoverableException(null,
null, errorCode, null);
assertTrue(e.getMessage() == null && e.getSQLState() == null
&& e.getCause() == null && e.getErrorCode() == errorCode);
}
/**
* Create SQLRecoverableException with no-arg constructor
*/
@Test
public void test1() {
SQLRecoverableException ex = new SQLRecoverableException();
assertTrue(ex.getMessage() == null
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLRecoverableException with message
*/
@Test
public void test2() {
SQLRecoverableException ex = new SQLRecoverableException(reason);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLRecoverableException with message, and SQLState
*/
@Test
public void test3() {
SQLRecoverableException ex = new SQLRecoverableException(reason, state);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLRecoverableException with message, SQLState, and error code
*/
@Test
public void test4() {
SQLRecoverableException ex =
new SQLRecoverableException(reason, state, errorCode);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& ex.getCause() == null
&& ex.getErrorCode() == errorCode);
}
/**
* Create SQLRecoverableException with message, SQLState, errorCode, and Throwable
*/
@Test
public void test5() {
SQLRecoverableException ex =
new SQLRecoverableException(reason, state, errorCode, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == errorCode);
}
/**
* Create SQLRecoverableException with message, SQLState, and Throwable
*/
@Test
public void test6() {
SQLRecoverableException ex = new SQLRecoverableException(reason, state, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
/**
* Create SQLRecoverableException with message, and Throwable
*/
@Test
public void test7() {
SQLRecoverableException ex = new SQLRecoverableException(reason, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState() == null
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
/**
* Create SQLRecoverableException with null Throwable
*/
@Test
public void test8() {
SQLRecoverableException ex = new SQLRecoverableException((Throwable)null);
assertTrue(ex.getMessage() == null
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLRecoverableException with Throwable
*/
@Test
public void test9() {
SQLRecoverableException ex = new SQLRecoverableException(t);
assertTrue(ex.getMessage().equals(cause)
&& ex.getSQLState() == null
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
/**
* Serialize a SQLRecoverableException and make sure you can read it back properly
*/
@Test
public void test10() throws Exception {
SQLRecoverableException e =
new SQLRecoverableException(reason, state, errorCode, t);
SQLRecoverableException ex1 =
createSerializedException(e);
assertTrue(reason.equals(ex1.getMessage())
&& ex1.getSQLState().equals(state)
&& cause.equals(ex1.getCause().toString())
&& ex1.getErrorCode() == errorCode);
}
/**
* Validate that the ordering of the returned Exceptions is correct
* using for-each loop
*/
@Test
public void test11() {
SQLRecoverableException ex = new SQLRecoverableException("Exception 1", t1);
SQLRecoverableException ex1 = new SQLRecoverableException("Exception 2");
SQLRecoverableException ex2 = new SQLRecoverableException("Exception 3", t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
for (Throwable e : ex) {
assertTrue(msgs[num++].equals(e.getMessage()));
}
}
/**
* Validate that the ordering of the returned Exceptions is correct
* using traditional while loop
*/
@Test
public void test12() {
SQLRecoverableException ex = new SQLRecoverableException("Exception 1", t1);
SQLRecoverableException ex1 = new SQLRecoverableException("Exception 2");
SQLRecoverableException ex2 = new SQLRecoverableException("Exception 3", t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
SQLException sqe = ex;
while (sqe != null) {
assertTrue(msgs[num++].equals(sqe.getMessage()));
Throwable c = sqe.getCause();
while (c != null) {
assertTrue(msgs[num++].equals(c.getMessage()));
c = c.getCause();
}
sqe = sqe.getNextException();
}
}
}
/*
* 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 test.sql;
import java.sql.SQLException;
import java.sql.SQLNonTransientException;
import java.sql.SQLSyntaxErrorException;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
import util.BaseTest;
public class SQLSyntaxErrorExceptionTests extends BaseTest {
/**
* Create SQLSyntaxErrorException and setting all objects to null
*/
@Test
public void test() {
SQLSyntaxErrorException e = new SQLSyntaxErrorException(null,
null, errorCode, null);
assertTrue(e.getMessage() == null && e.getSQLState() == null
&& e.getCause() == null && e.getErrorCode() == errorCode);
}
/**
* Create SQLSyntaxErrorException with no-arg constructor
*/
@Test
public void test1() {
SQLSyntaxErrorException ex = new SQLSyntaxErrorException();
assertTrue(ex.getMessage() == null
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLSyntaxErrorException with message
*/
@Test
public void test2() {
SQLSyntaxErrorException ex = new SQLSyntaxErrorException(reason);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLSyntaxErrorException with message, and SQLState
*/
@Test
public void test3() {
SQLSyntaxErrorException ex = new SQLSyntaxErrorException(reason, state);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLSyntaxErrorException with message, SQLState, and error code
*/
@Test
public void test4() {
SQLSyntaxErrorException ex =
new SQLSyntaxErrorException(reason, state, errorCode);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& ex.getCause() == null
&& ex.getErrorCode() == errorCode);
}
/**
* Create SQLSyntaxErrorException with message, SQLState, errorCode, and Throwable
*/
@Test
public void test5() {
SQLSyntaxErrorException ex =
new SQLSyntaxErrorException(reason, state, errorCode, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == errorCode);
}
/**
* Create SQLSyntaxErrorException with message, SQLState, and Throwable
*/
@Test
public void test6() {
SQLSyntaxErrorException ex = new SQLSyntaxErrorException(reason, state, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
/**
* Create SQLSyntaxErrorException with message, and Throwable
*/
@Test
public void test7() {
SQLSyntaxErrorException ex = new SQLSyntaxErrorException(reason, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState() == null
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
/**
* Create SQLSyntaxErrorException with null Throwable
*/
@Test
public void test8() {
SQLSyntaxErrorException ex = new SQLSyntaxErrorException((Throwable)null);
assertTrue(ex.getMessage() == null
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLSyntaxErrorException with Throwable
*/
@Test
public void test9() {
SQLSyntaxErrorException ex = new SQLSyntaxErrorException(t);
assertTrue(ex.getMessage().equals(cause)
&& ex.getSQLState() == null
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
/**
* Serialize a SQLSyntaxErrorException and make sure you can read it back properly
*/
@Test
public void test10() throws Exception {
SQLSyntaxErrorException e =
new SQLSyntaxErrorException(reason, state, errorCode, t);
SQLSyntaxErrorException ex1 =
createSerializedException(e);
assertTrue(reason.equals(ex1.getMessage())
&& ex1.getSQLState().equals(state)
&& cause.equals(ex1.getCause().toString())
&& ex1.getErrorCode() == errorCode);
}
/**
* Validate that the ordering of the returned Exceptions is correct
* using for-each loop
*/
@Test
public void test11() {
SQLSyntaxErrorException ex = new SQLSyntaxErrorException("Exception 1", t1);
SQLSyntaxErrorException ex1 = new SQLSyntaxErrorException("Exception 2");
SQLSyntaxErrorException ex2 = new SQLSyntaxErrorException("Exception 3", t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
for (Throwable e : ex) {
assertTrue(msgs[num++].equals(e.getMessage()));
}
}
/**
* Validate that the ordering of the returned Exceptions is correct
* using traditional while loop
*/
@Test
public void test12() {
SQLSyntaxErrorException ex = new SQLSyntaxErrorException("Exception 1", t1);
SQLSyntaxErrorException ex1 = new SQLSyntaxErrorException("Exception 2");
SQLSyntaxErrorException ex2 = new SQLSyntaxErrorException("Exception 3", t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
SQLException sqe = ex;
while (sqe != null) {
assertTrue(msgs[num++].equals(sqe.getMessage()));
Throwable c = sqe.getCause();
while (c != null) {
assertTrue(msgs[num++].equals(c.getMessage()));
c = c.getCause();
}
sqe = sqe.getNextException();
}
}
/**
* Create SQLSyntaxErrorException and validate it is an instance of
* SQLNonTransientException
*/
@Test
public void test13() {
Exception ex = new SQLSyntaxErrorException();
assertTrue(ex instanceof SQLNonTransientException);
}
}
/*
* 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 test.sql;
import java.sql.SQLException;
import java.sql.SQLTimeoutException;
import java.sql.SQLTransientException;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
import util.BaseTest;
public class SQLTimeoutExceptionTests extends BaseTest {
/**
* Create SQLTimeoutException and setting all objects to null
*/
@Test
public void test() {
SQLTimeoutException e = new SQLTimeoutException(null,
null, errorCode, null);
assertTrue(e.getMessage() == null && e.getSQLState() == null
&& e.getCause() == null && e.getErrorCode() == errorCode);
}
/**
* Create SQLTimeoutException with no-arg constructor
*/
@Test
public void test1() {
SQLTimeoutException ex = new SQLTimeoutException();
assertTrue(ex.getMessage() == null
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLTimeoutException with message
*/
@Test
public void test2() {
SQLTimeoutException ex = new SQLTimeoutException(reason);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLTimeoutException with message, and SQLState
*/
@Test
public void test3() {
SQLTimeoutException ex = new SQLTimeoutException(reason, state);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLTimeoutException with message, SQLState, and error code
*/
@Test
public void test4() {
SQLTimeoutException ex = new SQLTimeoutException(reason, state, errorCode);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& ex.getCause() == null
&& ex.getErrorCode() == errorCode);
}
/**
* Create SQLTimeoutException with message, SQLState, errorCode, and Throwable
*/
@Test
public void test5() {
SQLTimeoutException ex = new SQLTimeoutException(reason, state, errorCode, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == errorCode);
}
/**
* Create SQLTimeoutException with message, SQLState, and Throwable
*/
@Test
public void test6() {
SQLTimeoutException ex = new SQLTimeoutException(reason, state, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
/**
* Create SQLTimeoutException with message, and Throwable
*/
@Test
public void test7() {
SQLTimeoutException ex = new SQLTimeoutException(reason, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState() == null
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
/**
* Create SQLTimeoutException with null Throwable
*/
@Test
public void test8() {
SQLTimeoutException ex = new SQLTimeoutException((Throwable)null);
assertTrue(ex.getMessage() == null
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLTimeoutException with Throwable
*/
@Test
public void test9() {
SQLTimeoutException ex = new SQLTimeoutException(t);
assertTrue(ex.getMessage().equals(cause)
&& ex.getSQLState() == null
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
/**
* Serialize a SQLTimeoutException and make sure you can read it back properly
*/
@Test
public void test10() throws Exception {
SQLTimeoutException e =
new SQLTimeoutException(reason, state, errorCode, t);
SQLTimeoutException ex1 =
createSerializedException(e);
assertTrue(reason.equals(ex1.getMessage())
&& ex1.getSQLState().equals(state)
&& cause.equals(ex1.getCause().toString())
&& ex1.getErrorCode() == errorCode);
}
/**
* Validate that the ordering of the returned Exceptions is correct
* using for-each loop
*/
@Test
public void test11() {
SQLTimeoutException ex = new SQLTimeoutException("Exception 1", t1);
SQLTimeoutException ex1 = new SQLTimeoutException("Exception 2");
SQLTimeoutException ex2 = new SQLTimeoutException("Exception 3", t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
for (Throwable e : ex) {
assertTrue(msgs[num++].equals(e.getMessage()));
}
}
/**
* Validate that the ordering of the returned Exceptions is correct
* using traditional while loop
*/
@Test
public void test12() {
SQLTimeoutException ex = new SQLTimeoutException("Exception 1", t1);
SQLTimeoutException ex1 = new SQLTimeoutException("Exception 2");
SQLTimeoutException ex2 = new SQLTimeoutException("Exception 3", t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
SQLException sqe = ex;
while (sqe != null) {
assertTrue(msgs[num++].equals(sqe.getMessage()));
Throwable c = sqe.getCause();
while (c != null) {
assertTrue(msgs[num++].equals(c.getMessage()));
c = c.getCause();
}
sqe = sqe.getNextException();
}
}
/**
* Create SQLTimeoutException and validate it is an instance of
* SQLNonTransientException
*/
@Test
public void test13() {
Exception ex = new SQLTimeoutException();
assertTrue(ex instanceof SQLTransientException);
}
}
/*
* 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 test.sql;
import java.sql.SQLException;
import java.sql.SQLTransactionRollbackException;
import java.sql.SQLTransientException;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
import util.BaseTest;
public class SQLTransactionRollbackExceptionTests extends BaseTest {
/**
* Create SQLTransactionRollbackException and setting all objects to null
*/
@Test
public void test() {
SQLTransactionRollbackException e =
new SQLTransactionRollbackException(null,
null, errorCode, null);
assertTrue(e.getMessage() == null && e.getSQLState() == null
&& e.getCause() == null && e.getErrorCode() == errorCode);
}
/**
* Create SQLTransactionRollbackException with no-arg constructor
*/
@Test
public void test1() {
SQLTransactionRollbackException ex = new SQLTransactionRollbackException();
assertTrue(ex.getMessage() == null
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLTransactionRollbackException with message
*/
@Test
public void test2() {
SQLTransactionRollbackException ex =
new SQLTransactionRollbackException(reason);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLTransactionRollbackException with message, and SQLState
*/
@Test
public void test3() {
SQLTransactionRollbackException ex =
new SQLTransactionRollbackException(reason, state);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLTransactionRollbackException with message, SQLState, and error code
*/
@Test
public void test4() {
SQLTransactionRollbackException ex =
new SQLTransactionRollbackException(reason, state, errorCode);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& ex.getCause() == null
&& ex.getErrorCode() == errorCode);
}
/**
* Create SQLTransactionRollbackException with message, SQLState, errorCode, and Throwable
*/
@Test
public void test5() {
SQLTransactionRollbackException ex =
new SQLTransactionRollbackException(reason, state, errorCode, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == errorCode);
}
/**
* Create SQLTransactionRollbackException with message, SQLState, and Throwable
*/
@Test
public void test6() {
SQLTransactionRollbackException ex =
new SQLTransactionRollbackException(reason, state, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
/**
* Create SQLTransactionRollbackException with message, and Throwable
*/
@Test
public void test7() {
SQLTransactionRollbackException ex =
new SQLTransactionRollbackException(reason, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState() == null
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
/**
* Create SQLTransactionRollbackException with null Throwable
*/
@Test
public void test8() {
SQLTransactionRollbackException ex =
new SQLTransactionRollbackException((Throwable)null);
assertTrue(ex.getMessage() == null
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLTransactionRollbackException with Throwable
*/
@Test
public void test9() {
SQLTransactionRollbackException ex =
new SQLTransactionRollbackException(t);
assertTrue(ex.getMessage().equals(cause)
&& ex.getSQLState() == null
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
/**
* Serialize a SQLTransactionRollbackException and make sure you can read it back properly
*/
@Test
public void test10() throws Exception {
SQLTransactionRollbackException e =
new SQLTransactionRollbackException(reason, state, errorCode, t);
SQLTransactionRollbackException ex1 =
createSerializedException(e);
assertTrue(reason.equals(ex1.getMessage())
&& ex1.getSQLState().equals(state)
&& cause.equals(ex1.getCause().toString())
&& ex1.getErrorCode() == errorCode);
}
/**
* Validate that the ordering of the returned Exceptions is correct
* using for-each loop
*/
@Test
public void test11() {
SQLTransactionRollbackException ex =
new SQLTransactionRollbackException("Exception 1", t1);
SQLTransactionRollbackException ex1 =
new SQLTransactionRollbackException("Exception 2");
SQLTransactionRollbackException ex2 =
new SQLTransactionRollbackException("Exception 3", t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
for (Throwable e : ex) {
assertTrue(msgs[num++].equals(e.getMessage()));
}
}
/**
* Validate that the ordering of the returned Exceptions is correct
* using traditional while loop
*/
@Test
public void test12() {
SQLTransactionRollbackException ex =
new SQLTransactionRollbackException("Exception 1", t1);
SQLTransactionRollbackException ex1 =
new SQLTransactionRollbackException("Exception 2");
SQLTransactionRollbackException ex2 =
new SQLTransactionRollbackException("Exception 3", t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
SQLException sqe = ex;
while (sqe != null) {
assertTrue(msgs[num++].equals(sqe.getMessage()));
Throwable c = sqe.getCause();
while (c != null) {
assertTrue(msgs[num++].equals(c.getMessage()));
c = c.getCause();
}
sqe = sqe.getNextException();
}
}
/**
* Create SQLTransactionRollbackException and validate it is an instance of
* SQLNonTransientException
*/
@Test
public void test13() {
Exception ex = new SQLTransactionRollbackException();
assertTrue(ex instanceof SQLTransientException);
}
}
/*
* 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 test.sql;
import java.sql.SQLException;
import java.sql.SQLTransientConnectionException;
import java.sql.SQLTransientException;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
import util.BaseTest;
public class SQLTransientConnectionExceptionTests extends BaseTest {
/**
* Create SQLTransientConnectionException and setting all objects to null
*/
@Test
public void test() {
SQLTransientConnectionException e =
new SQLTransientConnectionException( null,
null, errorCode, null);
assertTrue(e.getMessage() == null && e.getSQLState() == null
&& e.getCause() == null && e.getErrorCode() == errorCode);
}
/**
* Create SQLTransientConnectionException with no-arg constructor
*/
@Test
public void test1() {
SQLTransientConnectionException ex = new SQLTransientConnectionException();
assertTrue(ex.getMessage() == null
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLTransientConnectionException with message
*/
@Test
public void test2() {
SQLTransientConnectionException ex =
new SQLTransientConnectionException(reason);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLTransientConnectionException with message, and SQLState
*/
@Test
public void test3() {
SQLTransientConnectionException ex =
new SQLTransientConnectionException(reason, state);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLTransientConnectionException with message, SQLState, and error code
*/
@Test
public void test4() {;
SQLTransientConnectionException ex =
new SQLTransientConnectionException(reason, state, errorCode);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& ex.getCause() == null
&& ex.getErrorCode() == errorCode);
}
/**
* Create SQLTransientConnectionException with message, SQLState, errorCode, and Throwable
*/
@Test
public void test5() {
SQLTransientConnectionException ex =
new SQLTransientConnectionException(reason, state, errorCode, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == errorCode);
}
/**
* Create SQLTransientConnectionException with message, SQLState, and Throwable
*/
@Test
public void test6() {
SQLTransientConnectionException ex =
new SQLTransientConnectionException(reason, state, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
/**
* Create SQLTransientConnectionException with message, and Throwable
*/
@Test
public void test7() {
SQLTransientConnectionException ex =
new SQLTransientConnectionException(reason, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState() == null
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
/**
* Create SQLTransientConnectionException with null Throwable
*/
@Test
public void test8() {
SQLTransientConnectionException ex =
new SQLTransientConnectionException((Throwable)null);
assertTrue(ex.getMessage() == null
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLTransientConnectionException with Throwable
*/
@Test
public void test9() {
SQLTransientConnectionException ex =
new SQLTransientConnectionException(t);
assertTrue(ex.getMessage().equals(cause)
&& ex.getSQLState() == null
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
/**
* Serialize a SQLTransientConnectionException and make sure you can read it back properly
*/
@Test
public void test10() throws Exception {
SQLTransientConnectionException e =
new SQLTransientConnectionException(reason, state, errorCode, t);
SQLTransientConnectionException ex1 =
createSerializedException(e);
assertTrue(reason.equals(ex1.getMessage())
&& ex1.getSQLState().equals(state)
&& cause.equals(ex1.getCause().toString())
&& ex1.getErrorCode() == errorCode);
}
/**
* Validate that the ordering of the returned Exceptions is correct
* using for-each loop
*/
@Test
public void test11() {
SQLTransientConnectionException ex =
new SQLTransientConnectionException("Exception 1", t1);
SQLTransientConnectionException ex1 =
new SQLTransientConnectionException("Exception 2");
SQLTransientConnectionException ex2 =
new SQLTransientConnectionException("Exception 3", t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
for (Throwable e : ex) {
assertTrue(msgs[num++].equals(e.getMessage()));
}
}
/**
* Validate that the ordering of the returned Exceptions is correct
* using traditional while loop
*/
@Test
public void test12() {
SQLTransientConnectionException ex =
new SQLTransientConnectionException("Exception 1", t1);
SQLTransientConnectionException ex1 =
new SQLTransientConnectionException("Exception 2");
SQLTransientConnectionException ex2 =
new SQLTransientConnectionException("Exception 3", t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
SQLException sqe = ex;
while (sqe != null) {
assertTrue(msgs[num++].equals(sqe.getMessage()));
Throwable c = sqe.getCause();
while (c != null) {
assertTrue(msgs[num++].equals(c.getMessage()));
c = c.getCause();
}
sqe = sqe.getNextException();
}
}
/**
* Create SQLTransientConnectionException and validate it is an instance of
* SQLNonTransientException
*/
@Test
public void test13() {
Exception ex = new SQLTransientConnectionException();
assertTrue(ex instanceof SQLTransientException);
}
}
/*
* 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 test.sql;
import java.sql.SQLException;
import java.sql.SQLTransientException;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
import util.BaseTest;
public class SQLTransientExceptionTests extends BaseTest {
/**
* Create SQLTransientException and setting all objects to null
*/
@Test
public void test() {
SQLTransientException e = new SQLTransientException(null,
null, errorCode, null);
assertTrue(e.getMessage() == null && e.getSQLState() == null
&& e.getCause() == null && e.getErrorCode() == errorCode);
}
/**
* Create SQLTransientException with no-arg constructor
*/
@Test
public void test1() {
SQLTransientException ex = new SQLTransientException();
assertTrue(ex.getMessage() == null
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLTransientException with message
*/
@Test
public void test2() {
SQLTransientException ex = new SQLTransientException(reason);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLTransientException with message, and SQLState
*/
@Test
public void test3() {
SQLTransientException ex = new SQLTransientException(reason, state);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLTransientException with message, SQLState, and error code
*/
@Test
public void test4() {
SQLTransientException ex = new SQLTransientException(reason, state, errorCode);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& ex.getCause() == null
&& ex.getErrorCode() == errorCode);
}
/**
* Create SQLTransientException with message, SQLState, errorCode, and Throwable
*/
@Test
public void test5() {
SQLTransientException ex =
new SQLTransientException(reason, state, errorCode, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == errorCode);
}
/**
* Create SQLTransientException with message, SQLState, and Throwable
*/
@Test
public void test6() {
SQLTransientException ex = new SQLTransientException(reason, state, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
/**
* Create SQLTransientException with message, and Throwable
*/
@Test
public void test7() {
SQLTransientException ex = new SQLTransientException(reason, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState() == null
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
/**
* Create SQLTransientException with null Throwable
*/
@Test
public void test8() {
SQLTransientException ex = new SQLTransientException((Throwable)null);
assertTrue(ex.getMessage() == null
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLTransientException with Throwable
*/
@Test
public void test9() {
SQLTransientException ex = new SQLTransientException(t);
assertTrue(ex.getMessage().equals(cause)
&& ex.getSQLState() == null
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
/**
* Serialize a SQLTransientException and make sure you can read it back properly
*/
@Test
public void test10() throws Exception {
SQLTransientException e =
new SQLTransientException(reason, state, errorCode, t);
SQLTransientException ex1 = createSerializedException(e);
assertTrue(reason.equals(ex1.getMessage())
&& ex1.getSQLState().equals(state)
&& cause.equals(ex1.getCause().toString())
&& ex1.getErrorCode() == errorCode);
}
/**
* Validate that the ordering of the returned Exceptions is correct
* using for-each loop
*/
@Test
public void test11() {
SQLTransientException ex = new SQLTransientException("Exception 1", t1);
SQLTransientException ex1 = new SQLTransientException("Exception 2");
SQLTransientException ex2 = new SQLTransientException("Exception 3", t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
for (Throwable e : ex) {
assertTrue(msgs[num++].equals(e.getMessage()));
}
}
/**
* Validate that the ordering of the returned Exceptions is correct
* using traditional while loop
*/
@Test
public void test12() {
SQLTransientException ex = new SQLTransientException("Exception 1", t1);
SQLTransientException ex1 = new SQLTransientException("Exception 2");
SQLTransientException ex2 = new SQLTransientException("Exception 3", t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
SQLException sqe = ex;
while (sqe != null) {
assertTrue(msgs[num++].equals(sqe.getMessage()));
Throwable c = sqe.getCause();
while (c != null) {
assertTrue(msgs[num++].equals(c.getMessage()));
c = c.getCause();
}
sqe = sqe.getNextException();
}
}
}
/*
* 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 test.sql;
import java.sql.SQLException;
import java.sql.SQLWarning;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
import util.BaseTest;
public class SQLWarningTests extends BaseTest {
private final String[] warnings = {"Warning 1", "cause 1", "Warning 2",
"Warning 3", "cause 2"};
/**
* Create SQLWarning and setting all objects to null
*/
@Test
public void test() {
SQLWarning e = new SQLWarning(null, null, errorCode, null);
assertTrue(e.getMessage() == null && e.getSQLState() == null
&& e.getCause() == null && e.getErrorCode() == errorCode);
}
/**
* Create SQLWarning with no-arg constructor
*/
@Test
public void test1() {
SQLWarning ex = new SQLWarning();
assertTrue(ex.getMessage() == null
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLWarning with message
*/
@Test
public void test2() {
SQLWarning ex = new SQLWarning(reason);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLWarning with message, and SQLState
*/
@Test
public void test3() {
SQLWarning ex = new SQLWarning(reason, state);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLWarning with message, SQLState, and error code
*/
@Test
public void test4() {
SQLWarning ex = new SQLWarning(reason, state, errorCode);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& ex.getCause() == null
&& ex.getErrorCode() == errorCode);
}
/**
* Create SQLWarning with message, SQLState, errorCode, and Throwable
*/
@Test
public void test5() {
SQLWarning ex = new SQLWarning(reason, state, errorCode, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == errorCode);
}
/**
* Create SQLWarning with message, SQLState, and Throwable
*/
@Test
public void test6() {
SQLWarning ex = new SQLWarning(reason, state, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
/**
* Create SQLWarning with message, and Throwable
*/
@Test
public void test7() {
SQLWarning ex = new SQLWarning(reason, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState() == null
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
/**
* Create SQLWarning with null Throwable
*/
@Test
public void test8() {
SQLWarning ex = new SQLWarning((Throwable) null);
assertTrue(ex.getMessage() == null
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLWarning with Throwable
*/
@Test
public void test9() {
SQLWarning ex = new SQLWarning(t);
assertTrue(ex.getMessage().equals(cause)
&& ex.getSQLState() == null
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
/**
* Serialize a SQLWarning and make sure you can read it back properly
*/
@Test
public void test10() throws Exception {
SQLWarning e = new SQLWarning(reason, state, errorCode, t);
SQLWarning ex1 = createSerializedException(e);
assertTrue(reason.equals(ex1.getMessage())
&& ex1.getSQLState().equals(state)
&& cause.equals(ex1.getCause().toString())
&& ex1.getErrorCode() == errorCode);
}
/**
* Validate that the ordering of the returned Exceptions is correct using
* for-each loop
*/
@Test
public void test11() {
SQLWarning ex = new SQLWarning("Exception 1", t1);
SQLWarning ex1 = new SQLWarning("Exception 2");
SQLWarning ex2 = new SQLWarning("Exception 3", t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
for (Throwable e : ex) {
assertTrue(msgs[num++].equals(e.getMessage()));
}
}
/**
* Validate that the ordering of the returned Exceptions is correct using
* traditional while loop
*/
@Test
public void test12() {
SQLWarning ex = new SQLWarning("Exception 1", t1);
SQLWarning ex1 = new SQLWarning("Exception 2");
SQLWarning ex2 = new SQLWarning("Exception 3", t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
SQLException sqe = ex;
while (sqe != null) {
assertTrue(msgs[num++].equals(sqe.getMessage()));
Throwable c = sqe.getCause();
while (c != null) {
assertTrue(msgs[num++].equals(c.getMessage()));
c = c.getCause();
}
sqe = sqe.getNextException();
}
}
/**
* Validate that the ordering of the returned SQLWarning is correct using
* for-each loop
*/
@Test
public void test13() {
SQLWarning ex = new SQLWarning("Warning 1", t1);
SQLWarning ex1 = new SQLWarning("Warning 2");
SQLWarning ex2 = new SQLWarning("Warning 3", t2);
ex.setNextWarning(ex1);
ex.setNextWarning(ex2);
int num = 0;
for (Throwable e : ex) {
assertTrue(warnings[num++].equals(e.getMessage()));
}
}
/**
* Validate that the ordering of the returned SQLWarning is correct using
* traditional while loop
*/
@Test
public void test14() {
SQLWarning ex = new SQLWarning("Warning 1", t1);
SQLWarning ex1 = new SQLWarning("Warning 2");
SQLWarning ex2 = new SQLWarning("Warning 3", t2);
ex.setNextWarning(ex1);
ex.setNextWarning(ex2);
int num = 0;
SQLWarning sqe = ex;
while (sqe != null) {
assertTrue(warnings[num++].equals(sqe.getMessage()));
Throwable c = sqe.getCause();
while (c != null) {
assertTrue(msgs[num++].equals(c.getMessage()));
c = c.getCause();
}
sqe = sqe.getNextWarning();
}
}
}
此差异已折叠。
此差异已折叠。
/*
* 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.security.Policy;
import java.sql.JDBCType;
import java.sql.SQLException;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
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
*/
@SuppressWarnings("unchecked")
protected <T extends SQLException> T
createSerializedException(T ex)
throws IOException, ClassNotFoundException {
return (T) serializeDeserializeObject(ex);
}
/*
* Utility method to serialize and deserialize an object
*/
@SuppressWarnings("unchecked")
protected <T> T serializeDeserializeObject(T o)
throws IOException, ClassNotFoundException {
T o1;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try (ObjectOutputStream oos = new ObjectOutputStream(baos)) {
oos.writeObject(o);
}
try (ObjectInputStream ois
= new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()))) {
o1 = (T) ois.readObject();
}
return o1;
}
/*
* Utility Method used to set the current Policy
*/
protected static void setPolicy(Policy p) {
Policy.setPolicy(p);
}
/*
* DataProvider used to specify the value to set and check for
* methods using boolean values
*/
@DataProvider(name = "trueFalse")
protected Object[][] trueFalse() {
return new Object[][]{
{true},
{false}
};
}
/*
* DataProvider used to specify the standard JDBC Types
*/
@DataProvider(name = "jdbcTypes")
protected Object[][] jdbcTypes() {
Object[][] o = new Object[JDBCType.values().length][1];
int pos = 0;
for (JDBCType c : JDBCType.values()) {
o[pos++][0] = c.getVendorTypeNumber();
}
return o;
}
}
/*
* 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.sql.DriverAction;
/**
* Simple implementation of DriverAction which calls back into the Driver when
* release is called.
*/
class DriverActionImpl implements DriverAction {
public DriverActionImpl(StubDriverDA d) {
driver = d;
}
private final StubDriverDA driver;
@Override
public void deregister() {
driver.release();
}
}
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
# JDBC unit tests uses TestNG
TestNG.dirs= .
othervm.dirs= .
lib.dirs = /java/sql/testng
modules = java.sql.rowset/com.sun.rowset \
java.sql.rowset/com.sun.rowset.internal \
java.sql.rowset/com.sun.rowset.providers
此差异已折叠。
/*
* Copyright (c) 2015, 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 test.rowset.cachedrowset;
import java.sql.SQLException;
import javax.sql.rowset.CachedRowSet;
public class CachedRowSetTests extends CommonCachedRowSetTests {
@Override
protected CachedRowSet newInstance() throws SQLException {
return rsf.createCachedRowSet();
}
}
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册