8376038: Refactor java/sql tests to use JUnit

8376629: Refactor javax/sql tests to use JUnit

Reviewed-by: lancea
This commit is contained in:
Justin Lu 2026-01-30 17:41:50 +00:00
parent 673cd6ed0c
commit ee60eff1ec
108 changed files with 2511 additions and 2133 deletions

View File

@ -1,173 +0,0 @@
/*
* Copyright (c) 2013, 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.
*/
/*
*@test
*@bug 8007520
*@summary Test those bridge methods to/from java.time date/time classes
* @key randomness
*/
import java.util.Random;
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
public class JavatimeTest {
static final int NANOS_PER_SECOND = 1000000000;
public static void main(String[] args) throws Throwable {
int N = 10000;
long t1970 = new java.util.Date(70, 0, 01).getTime();
Random r = new Random();
for (int i = 0; i < N; i++) {
int days = r.nextInt(50) * 365 + r.nextInt(365);
long secs = t1970 + days * 86400 + r.nextInt(86400);
int nanos = r.nextInt(NANOS_PER_SECOND);
int nanos_ms = nanos / 1000000 * 1000000; // millis precision
long millis = secs * 1000 + r.nextInt(1000);
LocalDateTime ldt = LocalDateTime.ofEpochSecond(secs, nanos, ZoneOffset.UTC);
LocalDateTime ldt_ms = LocalDateTime.ofEpochSecond(secs, nanos_ms, ZoneOffset.UTC);
Instant inst = Instant.ofEpochSecond(secs, nanos);
Instant inst_ms = Instant.ofEpochSecond(secs, nanos_ms);
//System.out.printf("ms: %16d ns: %10d ldt:[%s]%n", millis, nanos, ldt);
/////////// Timestamp ////////////////////////////////
Timestamp ta = new Timestamp(millis);
ta.setNanos(nanos);
if (!isEqual(ta.toLocalDateTime(), ta)) {
System.out.printf("ms: %16d ns: %10d ldt:[%s]%n", millis, nanos, ldt);
print(ta.toLocalDateTime(), ta);
throw new RuntimeException("FAILED: j.s.ts -> ldt");
}
if (!isEqual(ldt, Timestamp.valueOf(ldt))) {
System.out.printf("ms: %16d ns: %10d ldt:[%s]%n", millis, nanos, ldt);
print(ldt, Timestamp.valueOf(ldt));
throw new RuntimeException("FAILED: ldt -> j.s.ts");
}
Instant inst0 = ta.toInstant();
if (ta.getTime() != inst0.toEpochMilli() ||
ta.getNanos() != inst0.getNano() ||
!ta.equals(Timestamp.from(inst0))) {
System.out.printf("ms: %16d ns: %10d ldt:[%s]%n", millis, nanos, ldt);
throw new RuntimeException("FAILED: j.s.ts -> instant -> j.s.ts");
}
inst = Instant.ofEpochSecond(secs, nanos);
Timestamp ta0 = Timestamp.from(inst);
if (ta0.getTime() != inst.toEpochMilli() ||
ta0.getNanos() != inst.getNano() ||
!inst.equals(ta0.toInstant())) {
System.out.printf("ms: %16d ns: %10d ldt:[%s]%n", millis, nanos, ldt);
throw new RuntimeException("FAILED: instant -> timestamp -> instant");
}
////////// java.sql.Date /////////////////////////////
// j.s.d/t uses j.u.d.equals() !!!!!!!!
java.sql.Date jsd = new java.sql.Date(millis);
if (!isEqual(jsd.toLocalDate(), jsd)) {
System.out.printf("ms: %16d ns: %10d ldt:[%s]%n", millis, nanos, ldt);
print(jsd.toLocalDate(), jsd);
throw new RuntimeException("FAILED: j.s.d -> ld");
}
LocalDate ld = ldt.toLocalDate();
if (!isEqual(ld, java.sql.Date.valueOf(ld))) {
System.out.printf("ms: %16d ns: %10d ldt:[%s]%n", millis, nanos, ldt);
print(ld, java.sql.Date.valueOf(ld));
throw new RuntimeException("FAILED: ld -> j.s.d");
}
////////// java.sql.Time /////////////////////////////
java.sql.Time jst = new java.sql.Time(millis);
if (!isEqual(jst.toLocalTime(), jst)) {
System.out.printf("ms: %16d ns: %10d ldt:[%s]%n", millis, nanos, ldt);
print(jst.toLocalTime(), jst);
throw new RuntimeException("FAILED: j.s.t -> lt");
}
// millis precision
LocalTime lt = ldt_ms.toLocalTime();
if (!isEqual(lt, java.sql.Time.valueOf(lt))) {
System.out.printf("ms: %16d ns: %10d ldt:[%s]%n", millis, nanos, ldt);
print(lt, java.sql.Time.valueOf(lt));
throw new RuntimeException("FAILED: lt -> j.s.t");
}
}
System.out.println("Passed!");
}
private static boolean isEqual(LocalDateTime ldt, Timestamp ts) {
ZonedDateTime zdt = ZonedDateTime.of(ldt, ZoneId.systemDefault());
return zdt.getYear() == ts.getYear() + 1900 &&
zdt.getMonthValue() == ts.getMonth() + 1 &&
zdt.getDayOfMonth() == ts.getDate() &&
zdt.getHour() == ts.getHours() &&
zdt.getMinute() == ts.getMinutes() &&
zdt.getSecond() == ts.getSeconds() &&
zdt.getNano() == ts.getNanos();
}
private static void print(LocalDateTime ldt, Timestamp ts) {
ZonedDateTime zdt = ZonedDateTime.of(ldt, ZoneId.systemDefault());
System.out.printf("ldt:ts %d/%d, %d/%d, %d/%d, %d/%d, %d/%d, %d/%d, nano:[%d/%d]%n",
zdt.getYear(), ts.getYear() + 1900,
zdt.getMonthValue(), ts.getMonth() + 1,
zdt.getDayOfMonth(), ts.getDate(),
zdt.getHour(), ts.getHours(),
zdt.getMinute(), ts.getMinutes(),
zdt.getSecond(), ts.getSeconds(),
zdt.getNano(), ts.getNanos());
}
private static boolean isEqual(LocalDate ld, java.sql.Date d) {
return ld.getYear() == d.getYear() + 1900 &&
ld.getMonthValue() == d.getMonth() + 1 &&
ld.getDayOfMonth() == d.getDate();
}
private static void print(LocalDate ld, java.sql.Date d) {
System.out.printf("%d/%d, %d/%d, %d/%d%n",
ld.getYear(), d.getYear() + 1900,
ld.getMonthValue(), d.getMonth() + 1,
ld.getDayOfMonth(), d.getDate());
}
private static boolean isEqual(LocalTime lt, java.sql.Time t) {
return lt.getHour() == t.getHours() &&
lt.getMinute() == t.getMinutes() &&
lt.getSecond() == t.getSeconds();
}
private static void print(LocalTime lt, java.sql.Time t) {
System.out.printf("%d/%d, %d/%d, %d/%d%n",
lt.getHour(), t.getHours(),
lt.getMinute(), t.getMinutes(),
lt.getSecond(), t.getSeconds());
}
}

View File

@ -0,0 +1,3 @@
# JDBC unit tests uses JUnit
JUnit.dirs= .
lib.dirs = /java/sql/util

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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
@ -20,7 +20,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package test.sql;
package sql;
import java.io.ByteArrayInputStream;
import java.io.File;
@ -28,8 +28,10 @@ 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 static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import util.SerializedBatchUpdateException;
import util.BaseTest;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2026, 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
@ -20,28 +20,33 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package test.sql;
package sql;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.junit.jupiter.params.provider.ValueSource;
import util.BaseTest;
import util.StubConnection;
import java.sql.CallableStatement;
import java.sql.SQLException;
import static org.testng.Assert.assertEquals;
import org.junit.jupiter.api.AfterEach;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
public class CallableStatementTests extends BaseTest {
private CallableStatement cstmt;
@BeforeMethod
@BeforeEach
public void setUpMethod() throws Exception {
cstmt = new StubConnection().prepareCall("{call SuperHero_Proc(?)}");
}
@AfterMethod
@AfterEach
public void tearDownMethod() throws Exception {
cstmt.close();
}
@ -50,80 +55,84 @@ public class CallableStatementTests extends BaseTest {
* Verify that enquoteLiteral creates a valid literal and converts every
* single quote to two single quotes
*/
@Test(dataProvider = "validEnquotedLiteralValues")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("validEnquotedLiteralValues")
public void test00(String s, String expected) throws SQLException {
assertEquals(cstmt.enquoteLiteral(s), expected);
assertEquals(expected, cstmt.enquoteLiteral(s));
}
/*
* Validate a NullPointerException is thrown if the string passed to
* enquoteLiteral is null
*/
@Test(expectedExceptions = NullPointerException.class)
@Test
public void test01() throws SQLException {
cstmt.enquoteLiteral(null);
assertThrows(NullPointerException.class, () -> cstmt.enquoteLiteral(null));
}
/*
* Validate that enquoteIdentifier returns the expected value
*/
@Test(dataProvider = "validIdentifierValues")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("validEnquotedIdentifierValues")
public void test02(String s, boolean alwaysQuote, String expected) throws SQLException {
assertEquals(cstmt.enquoteIdentifier(s, alwaysQuote), expected);
assertEquals(expected, cstmt.enquoteIdentifier(s, alwaysQuote));
}
/*
* Validate that a SQLException is thrown for values that are not valid
* for a SQL identifier
*/
@Test(dataProvider = "invalidIdentifierValues",
expectedExceptions = SQLException.class)
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("invalidEnquotedIdentifierValues")
public void test03(String s, boolean alwaysQuote) throws SQLException {
cstmt.enquoteIdentifier(s, alwaysQuote);
assertThrows(SQLException.class, () -> cstmt.enquoteIdentifier(s, alwaysQuote));
}
/*
* Validate a NullPointerException is thrown is the string passed to
* enquoteIdentiifer is null
*/
@Test(dataProvider = "trueFalse",
expectedExceptions = NullPointerException.class)
@ParameterizedTest(autoCloseArguments = false)
@ValueSource(booleans = {true, false})
public void test04(boolean alwaysQuote) throws SQLException {
cstmt.enquoteIdentifier(null, alwaysQuote);
assertThrows(NullPointerException.class, () -> cstmt.enquoteIdentifier(null, alwaysQuote));
}
/*
* Validate that isSimpleIdentifier returns the expected value
*/
@Test(dataProvider = "simpleIdentifierValues")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("simpleIdentifierValues")
public void test05(String s, boolean expected) throws SQLException {
assertEquals(cstmt.isSimpleIdentifier(s), expected);
assertEquals(expected, cstmt.isSimpleIdentifier(s));
}
/*
* Validate a NullPointerException is thrown if the string passed to
* isSimpleIdentifier is null
*/
@Test(expectedExceptions = NullPointerException.class)
@Test
public void test06() throws SQLException {
cstmt.isSimpleIdentifier(null);
assertThrows(NullPointerException.class, () -> cstmt.isSimpleIdentifier(null));
}
/*
* Verify that enquoteLiteral creates a valid literal and converts every
* single quote to two single quotes
*/
@Test(dataProvider = "validEnquotedNCharLiteralValues")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("validEnquotedNCharLiteralValues")
public void test07(String s, String expected) throws SQLException {
assertEquals(cstmt.enquoteNCharLiteral(s), expected);
assertEquals(expected, cstmt.enquoteNCharLiteral(s));
}
/*
* Validate a NullPointerException is thrown if the string passed to
* enquoteNCharLiteral is null
*/
@Test(expectedExceptions = NullPointerException.class)
@Test
public void test08() throws SQLException {
cstmt.enquoteNCharLiteral(null);
assertThrows(NullPointerException.class, () -> cstmt.enquoteNCharLiteral(null));
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2025, 2026, 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
@ -20,22 +20,25 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package test.sql;
package sql;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.junit.jupiter.params.provider.ValueSource;
import util.BaseTest;
import util.StubConnection;
import java.sql.SQLException;
import static org.testng.Assert.*;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
public class ConnectionTests extends BaseTest {
protected StubConnection conn;
@BeforeMethod
@BeforeEach
public void setUpMethod() throws Exception {
conn = new StubConnection();
}
@ -44,80 +47,84 @@ public class ConnectionTests extends BaseTest {
* Verify that enquoteLiteral creates a valid literal and converts every
* single quote to two single quotes
*/
@Test(dataProvider = "validEnquotedLiteralValues")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("validEnquotedLiteralValues")
public void test00(String s, String expected) throws SQLException {
assertEquals(conn.enquoteLiteral(s), expected);
assertEquals(expected, conn.enquoteLiteral(s));
}
/*
* Validate a NullPointerException is thrown if the string passed to
* enquoteLiteral is null
*/
@Test(expectedExceptions = NullPointerException.class)
@Test
public void test01() throws SQLException {
conn.enquoteLiteral(null);
assertThrows(NullPointerException.class, () -> conn.enquoteLiteral(null));
}
/*
* Validate that enquoteIdentifier returns the expected value
*/
@Test(dataProvider = "validIdentifierValues")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("validEnquotedIdentifierValues")
public void test02(String s, boolean alwaysQuote, String expected) throws SQLException {
assertEquals(conn.enquoteIdentifier(s, alwaysQuote), expected);
assertEquals(expected, conn.enquoteIdentifier(s, alwaysQuote));
}
/*
* Validate that a SQLException is thrown for values that are not valid
* for a SQL identifier
*/
@Test(dataProvider = "invalidIdentifierValues",
expectedExceptions = SQLException.class)
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("invalidEnquotedIdentifierValues")
public void test03(String s, boolean alwaysQuote) throws SQLException {
conn.enquoteIdentifier(s, alwaysQuote);
assertThrows(SQLException.class, () -> conn.enquoteIdentifier(s, alwaysQuote));
}
/*
* Validate a NullPointerException is thrown is the string passed to
* enquoteIdentiifer is null
*/
@Test(dataProvider = "trueFalse",
expectedExceptions = NullPointerException.class)
@ParameterizedTest(autoCloseArguments = false)
@ValueSource(booleans = {true, false})
public void test04(boolean alwaysQuote) throws SQLException {
conn.enquoteIdentifier(null, alwaysQuote);
assertThrows(NullPointerException.class, () -> conn.enquoteIdentifier(null, alwaysQuote));
}
/*
* Validate that isSimpleIdentifier returns the expected value
*/
@Test(dataProvider = "simpleIdentifierValues")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("simpleIdentifierValues")
public void test05(String s, boolean expected) throws SQLException {
assertEquals(conn.isSimpleIdentifier(s), expected);
assertEquals(expected, conn.isSimpleIdentifier(s));
}
/*
* Validate a NullPointerException is thrown if the string passed to
* isSimpleIdentifier is null
*/
@Test(expectedExceptions = NullPointerException.class)
@Test
public void test06() throws SQLException {
conn.isSimpleIdentifier(null);
assertThrows(NullPointerException.class, () -> conn.isSimpleIdentifier(null));
}
/*
* Verify that enquoteLiteral creates a valid literal and converts every
* single quote to two single quotes
*/
@Test(dataProvider = "validEnquotedNCharLiteralValues")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("validEnquotedNCharLiteralValues")
public void test07(String s, String expected) throws SQLException {
assertEquals(conn.enquoteNCharLiteral(s), expected);
assertEquals(expected, conn.enquoteNCharLiteral(s));
}
/*
* Validate a NullPointerException is thrown if the string passed to
* enquoteNCharLiteral is null
*/
@Test(expectedExceptions = NullPointerException.class)
@Test
public void test08() throws SQLException {
conn.enquoteNCharLiteral(null);
assertThrows(NullPointerException.class, () -> conn.enquoteNCharLiteral(null));
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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
@ -20,12 +20,14 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package test.sql;
package sql;
import java.sql.DataTruncation;
import java.sql.SQLException;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import util.BaseTest;
public class DataTruncationTests extends BaseTest {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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
@ -20,14 +20,18 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package test.sql;
package 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 java.util.stream.Stream;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import util.BaseTest;
public class DateTests extends BaseTest {
@ -35,17 +39,18 @@ public class DateTests extends BaseTest {
/*
* Validate an IllegalArgumentException is thrown for an invalid Date string
*/
@Test(dataProvider = "invalidDateValues",
expectedExceptions = IllegalArgumentException.class)
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("invalidDateValues")
public void test(String d) throws Exception {
Date.valueOf(d);
assertThrows(IllegalArgumentException.class, () -> Date.valueOf(d));
}
/*
* Test that a date created from a date string is equal to the value
* returned from toString()
*/
@Test(dataProvider = "validDateValues")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("validDateValues")
public void test00(String d, String expectedD) {
Date d1 = Date.valueOf(d);
Date d2 = Date.valueOf(expectedD);
@ -207,20 +212,20 @@ public class DateTests extends BaseTest {
/*
* Validate an NPE occurs when a null LocalDate is passed to valueOf
*/
@Test(expectedExceptions = NullPointerException.class)
@Test
public void test15() throws Exception {
LocalDate ld = null;
Date.valueOf(ld);
assertThrows(NullPointerException.class, () -> Date.valueOf(ld));
}
/*
* Validate an UnsupportedOperationException occurs when toInstant() is
* called
*/
@Test(expectedExceptions = UnsupportedOperationException.class)
@Test
public void test16() throws Exception {
Date d = Date.valueOf("1961-08-30");
Instant instant = d.toInstant();
assertThrows(UnsupportedOperationException.class, d::toInstant);
}
/*
@ -271,55 +276,55 @@ public class DateTests extends BaseTest {
/*
* Validate an IllegalArgumentException is thrown for calling getHours
*/
@Test(expectedExceptions = IllegalArgumentException.class)
@Test
public void test21() throws Exception {
Date d = Date.valueOf("1961-08-30");
d.getHours();
assertThrows(IllegalArgumentException.class, d::getHours);
}
/*
* Validate an IllegalArgumentException is thrown for calling getMinutes
*/
@Test(expectedExceptions = IllegalArgumentException.class)
@Test
public void test22() throws Exception {
Date d = Date.valueOf("1961-08-30");
d.getMinutes();
assertThrows(IllegalArgumentException.class, d::getMinutes);
}
/*
* Validate an IllegalArgumentException is thrown for calling getSeconds
*/
@Test(expectedExceptions = IllegalArgumentException.class)
@Test
public void test23() throws Exception {
Date d = Date.valueOf("1961-08-30");
d.getSeconds();
assertThrows(IllegalArgumentException.class, d::getSeconds);
}
/*
* Validate an IllegalArgumentException is thrown for calling setHours
*/
@Test(expectedExceptions = IllegalArgumentException.class)
@Test
public void test24() throws Exception {
Date d = Date.valueOf("1961-08-30");
d.setHours(8);
assertThrows(IllegalArgumentException.class, () -> d.setHours(8));
}
/*
* Validate an IllegalArgumentException is thrown for calling setMinutes
*/
@Test(expectedExceptions = IllegalArgumentException.class)
@Test
public void test25() throws Exception {
Date d = Date.valueOf("1961-08-30");
d.setMinutes(0);
assertThrows(IllegalArgumentException.class, () -> d.setMinutes(0));
}
/*
* Validate an IllegalArgumentException is thrown for calling setSeconds
*/
@Test(expectedExceptions = IllegalArgumentException.class)
@Test
public void test26() throws Exception {
Date d = Date.valueOf("1961-08-30");
d.setSeconds(0);
assertThrows(IllegalArgumentException.class, () -> d.setSeconds(0));
}
/*
@ -327,32 +332,31 @@ public class DateTests extends BaseTest {
* 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"}
};
private Stream<String> invalidDateValues() {
return Stream.of(
"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"
);
}
/*
@ -360,14 +364,12 @@ public class DateTests extends BaseTest {
* 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"}
};
private Stream<Arguments> validDateValues() {
return Stream.of(
Arguments.of("2009-08-30", "2009-08-30"),
Arguments.of("2009-01-8", "2009-01-08"),
Arguments.of("2009-1-01", "2009-01-01"),
Arguments.of("2009-1-1", "2009-01-01")
);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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
@ -20,7 +20,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package test.sql;
package sql;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
@ -39,12 +39,10 @@ import java.util.Collections;
import java.util.Properties;
import java.util.stream.Collectors;
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 static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import util.StubDriver;
public class DriverManagerTests {
@ -58,23 +56,11 @@ public class DriverManagerTests {
public DriverManagerTests() {
}
@BeforeClass
public static void setUpClass() throws Exception {
}
@AfterClass
public static void tearDownClass() throws Exception {
}
@BeforeMethod
@BeforeEach
public void setUpMethod() throws Exception {
removeAllDrivers();
}
@AfterMethod
public void tearDownMethod() throws Exception {
}
/**
* Utility method to remove all registered drivers
*/
@ -113,7 +99,7 @@ public class DriverManagerTests {
int[] vals = {-1, 0, 5};
for (int val : vals) {
DriverManager.setLoginTimeout(val);
assertEquals(val, DriverManager.getLoginTimeout());
assertEquals(DriverManager.getLoginTimeout(), val);
}
}
@ -121,20 +107,22 @@ public class DriverManagerTests {
* Validate that NullPointerException is thrown when null is passed to
* registerDriver
*/
@Test(expectedExceptions = NullPointerException.class)
@Test
public void test1() throws Exception {
Driver d = null;
DriverManager.registerDriver(d);
assertThrows(NullPointerException.class,
() -> DriverManager.registerDriver(d));
}
/**
* Validate that NullPointerException is thrown when null is passed to
* registerDriver
*/
@Test(expectedExceptions = NullPointerException.class)
@Test
public void test2() throws Exception {
Driver d = null;
DriverManager.registerDriver(d, null);
assertThrows(NullPointerException.class, () ->
DriverManager.registerDriver(d, null));
}
/**
@ -150,68 +138,68 @@ public class DriverManagerTests {
* Validate that SQLException is thrown when there is no Driver to service
* the URL
*/
@Test(expectedExceptions = SQLException.class)
@Test
public void test4() throws Exception {
DriverManager.getConnection(InvalidURL);
assertThrows(SQLException.class, () -> DriverManager.getConnection(InvalidURL));
}
/**
* Validate that SQLException is thrown when there is no Driver to service
* the URL
*/
@Test(expectedExceptions = SQLException.class)
@Test
public void test5() throws Exception {
DriverManager.getConnection(InvalidURL, new Properties());
assertThrows(SQLException.class, () -> DriverManager.getConnection(InvalidURL, new Properties()));
}
/**
* Validate that SQLException is thrown when there is no Driver to service
* the URL
*/
@Test(expectedExceptions = SQLException.class)
@Test
public void test6() throws Exception {
DriverManager.getConnection(InvalidURL, "LuckyDog", "tennisanyone");
assertThrows(SQLException.class, () -> DriverManager.getConnection(InvalidURL, "LuckyDog", "tennisanyone"));
}
/**
* Validate that SQLException is thrown when null is passed for the URL
*/
@Test(expectedExceptions = SQLException.class)
@Test
public void test7() throws Exception {
DriverManager.getConnection(null);
assertThrows(SQLException.class, () -> DriverManager.getConnection(null));
}
/**
* Validate that SQLException is thrown when null is passed for the URL
*/
@Test(expectedExceptions = SQLException.class)
@Test
public void test8() throws Exception {
DriverManager.getConnection(null, new Properties());
assertThrows(SQLException.class, () -> DriverManager.getConnection(null, new Properties()));
}
/**
* Validate that SQLException is thrown when null is passed for the URL
*/
@Test(expectedExceptions = SQLException.class)
@Test
public void test9() throws Exception {
DriverManager.getConnection(null, "LuckyDog", "tennisanyone");
assertThrows(SQLException.class, () -> DriverManager.getConnection(null, "LuckyDog", "tennisanyone"));
}
/**
* Validate that SQLException is thrown when there is no Driver to service
* the URL
*/
@Test(expectedExceptions = SQLException.class)
@Test
public void test10() throws Exception {
DriverManager.getDriver(InvalidURL);
assertThrows(SQLException.class, () -> DriverManager.getDriver(InvalidURL));
}
/**
* Validate that SQLException is thrown when null is passed for the URL
*/
@Test(expectedExceptions = SQLException.class)
@Test
public void test11() throws Exception {
DriverManager.getDriver(null);
assertThrows(SQLException.class, () -> DriverManager.getDriver(null));
}
/**
@ -229,10 +217,10 @@ public class DriverManagerTests {
* Validate that SQLException is thrown when the URL is not valid for any of
* the registered drivers
*/
@Test(expectedExceptions = SQLException.class)
@Test
public void test13() throws Exception {
DriverManager.registerDriver(new StubDriver());
DriverManager.getDriver(InvalidURL);
assertThrows(SQLException.class, () -> DriverManager.getDriver(InvalidURL));
}
/**
@ -370,9 +358,9 @@ public class DriverManagerTests {
}
Collection<Driver> expectedDrivers = Collections.list(DriverManager.getDrivers());
assertEquals(expectedDrivers.size(), n);
assertEquals(n, expectedDrivers.size());
Collection<Driver> drivers = DriverManager.drivers().collect(Collectors.toList());
assertEquals(drivers, expectedDrivers);
assertEquals(expectedDrivers, drivers);
}
}

View File

@ -0,0 +1,184 @@
/*
* Copyright (c) 2013, 2026, 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 sql;
/*
* @test
* @bug 8007520
* @summary Test those bridge methods to/from java.time date/time classes
* @key randomness
*/
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.FieldSource;
import java.util.List;
import java.util.Random;
import java.sql.Timestamp;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.util.stream.IntStream;
import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class JavatimeTest {
private static final int NANOS_PER_SECOND = 1000000000;
private static final long t1970 = new java.util.Date(70, 0, 01).getTime();
private static final Random R = new Random();
// Data provider contains 10,000 randomized arguments
// which are used as the dates and times for the tests
private static final List<Arguments> DATE_TIME_ARGS = IntStream.range(0, 10_000)
.mapToObj(i -> {
int days = R.nextInt(50) * 365 + R.nextInt(365);
long secs = t1970 + days * 86400 + R.nextInt(86400);
int nanos = R.nextInt(NANOS_PER_SECOND);
int nanos_ms = nanos / 1000000 * 1000000; // millis precision
long millis = secs * 1000 + R.nextInt(1000);
LocalDateTime ldt = LocalDateTime.ofEpochSecond(secs, nanos, ZoneOffset.UTC);
return Arguments.of(millis, nanos, ldt, secs, nanos_ms);
}).toList();
@ParameterizedTest(autoCloseArguments = false)
@FieldSource("DATE_TIME_ARGS")
void timestampTest(long millis, int nanos, LocalDateTime ldt, long secs) {
Timestamp ta = new Timestamp(millis);
ta.setNanos(nanos);
assertTrue(isEqual(ta.toLocalDateTime(), ta),
errMsg("j.s.ts -> ldt", millis, nanos, ldt, results(ta.toLocalDateTime(), ta)));
assertTrue(isEqual(ldt, Timestamp.valueOf(ldt)),
errMsg("ldt -> j.s.ts", millis, nanos, ldt, results(ldt, Timestamp.valueOf(ldt))));
Instant inst0 = ta.toInstant();
assertAll(errMsg("j.s.ts -> instant -> j.s.ts", millis, nanos, ldt),
() -> assertEquals(ta.getTime(), inst0.toEpochMilli()),
() -> assertEquals(ta.getNanos(), inst0.getNano()),
() -> assertEquals(ta, Timestamp.from(inst0))
);
Instant inst = Instant.ofEpochSecond(secs, nanos);
Timestamp ta0 = Timestamp.from(inst);
assertAll(errMsg("instant -> timestamp -> instant", millis, nanos, ldt),
() -> assertEquals(ta0.getTime(), inst.toEpochMilli()),
() -> assertEquals(ta0.getNanos(), inst.getNano()),
() -> assertEquals(inst, ta0.toInstant())
);
}
@ParameterizedTest(autoCloseArguments = false)
@FieldSource("DATE_TIME_ARGS")
void sqlDateTest(long millis, int nanos, LocalDateTime ldt) {
// j.s.d/t uses j.u.d.equals() !!!!!!!!
java.sql.Date jsd = new java.sql.Date(millis);
assertTrue(isEqual(jsd.toLocalDate(), jsd),
errMsg("j.s.d -> ld", millis, nanos, ldt, results(jsd.toLocalDate(), jsd)));
LocalDate ld = ldt.toLocalDate();
assertTrue(isEqual(ld, java.sql.Date.valueOf(ld)),
errMsg("ld -> j.s.d", millis, nanos, ldt, results(ld, java.sql.Date.valueOf(ld))));
}
@ParameterizedTest(autoCloseArguments = false)
@FieldSource("DATE_TIME_ARGS")
void sqlTimeTest(long millis, int nanos, LocalDateTime ldt, long secs, int nanos_ms) {
java.sql.Time jst = new java.sql.Time(millis);
assertTrue(isEqual(jst.toLocalTime(), jst),
errMsg("j.s.t -> lt", millis, nanos, ldt, results(jst.toLocalTime(), jst)));
// millis precision
LocalDateTime ldt_ms = LocalDateTime.ofEpochSecond(secs, nanos_ms, ZoneOffset.UTC);
LocalTime lt = ldt_ms.toLocalTime();
assertTrue(isEqual(lt, java.sql.Time.valueOf(lt)),
errMsg("lt -> j.s.t", millis, nanos, ldt, results(lt, java.sql.Time.valueOf(lt))));
}
private static boolean isEqual(LocalDateTime ldt, Timestamp ts) {
ZonedDateTime zdt = ZonedDateTime.of(ldt, ZoneId.systemDefault());
return zdt.getYear() == ts.getYear() + 1900 &&
zdt.getMonthValue() == ts.getMonth() + 1 &&
zdt.getDayOfMonth() == ts.getDate() &&
zdt.getHour() == ts.getHours() &&
zdt.getMinute() == ts.getMinutes() &&
zdt.getSecond() == ts.getSeconds() &&
zdt.getNano() == ts.getNanos();
}
private static String results(LocalDateTime ldt, Timestamp ts) {
ZonedDateTime zdt = ZonedDateTime.of(ldt, ZoneId.systemDefault());
return "ldt:ts %d/%d, %d/%d, %d/%d, %d/%d, %d/%d, %d/%d, nano:[%d/%d]%n".formatted(
zdt.getYear(), ts.getYear() + 1900,
zdt.getMonthValue(), ts.getMonth() + 1,
zdt.getDayOfMonth(), ts.getDate(),
zdt.getHour(), ts.getHours(),
zdt.getMinute(), ts.getMinutes(),
zdt.getSecond(), ts.getSeconds(),
zdt.getNano(), ts.getNanos());
}
private static boolean isEqual(LocalDate ld, java.sql.Date d) {
return ld.getYear() == d.getYear() + 1900 &&
ld.getMonthValue() == d.getMonth() + 1 &&
ld.getDayOfMonth() == d.getDate();
}
private static String results(LocalDate ld, java.sql.Date d) {
return "%d/%d, %d/%d, %d/%d%n".formatted(
ld.getYear(), d.getYear() + 1900,
ld.getMonthValue(), d.getMonth() + 1,
ld.getDayOfMonth(), d.getDate());
}
private static boolean isEqual(LocalTime lt, java.sql.Time t) {
return lt.getHour() == t.getHours() &&
lt.getMinute() == t.getMinutes() &&
lt.getSecond() == t.getSeconds();
}
private static String results(LocalTime lt, java.sql.Time t) {
return "%d/%d, %d/%d, %d/%d%n".formatted(
lt.getHour(), t.getHours(),
lt.getMinute(), t.getMinutes(),
lt.getSecond(), t.getSeconds());
}
private static String errMsg(String testCase, long millis, int nanos,
LocalDateTime ldt, String results) {
return "FAILED: %s%n INPUTS: ms: %16d ns: %10d ldt:[%s]%n ACTUAL: %s"
.formatted(testCase, millis, nanos, ldt, results);
}
private static String errMsg(String testCase, long millis, int nanos,
LocalDateTime ldt) {
return "FAILED: %s%n INPUTS: ms: %16d ns: %10d ldt:[%s]%n"
.formatted(testCase, millis, nanos, ldt);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2026, 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
@ -20,29 +20,34 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package test.sql;
package sql;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.junit.jupiter.params.provider.ValueSource;
import util.BaseTest;
import util.StubConnection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import static org.testng.Assert.assertEquals;
import org.junit.jupiter.api.AfterEach;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
public class PreparedStatementTests extends BaseTest {
private PreparedStatement pstmt;
@BeforeMethod
@BeforeEach
public void setUpMethod() throws Exception {
pstmt = new StubConnection().prepareStatement("Select * from foo were bar = ?");
}
@AfterMethod
@AfterEach
public void tearDownMethod() throws Exception {
pstmt.close();
}
@ -51,80 +56,84 @@ public class PreparedStatementTests extends BaseTest {
* Verify that enquoteLiteral creates a valid literal and converts every
* single quote to two single quotes
*/
@Test(dataProvider = "validEnquotedLiteralValues")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("validEnquotedLiteralValues")
public void test00(String s, String expected) throws SQLException {
assertEquals(pstmt.enquoteLiteral(s), expected);
assertEquals(expected, pstmt.enquoteLiteral(s));
}
/*
* Validate a NullPointerException is thrown if the string passed to
* enquoteLiteral is null
*/
@Test(expectedExceptions = NullPointerException.class)
@Test
public void test01() throws SQLException {
pstmt.enquoteLiteral(null);
assertThrows(NullPointerException.class, () -> pstmt.enquoteLiteral(null));
}
/*
* Validate that enquoteIdentifier returns the expected value
*/
@Test(dataProvider = "validIdentifierValues")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("validEnquotedIdentifierValues")
public void test02(String s, boolean alwaysQuote, String expected) throws SQLException {
assertEquals(pstmt.enquoteIdentifier(s, alwaysQuote), expected);
assertEquals(expected, pstmt.enquoteIdentifier(s, alwaysQuote));
}
/*
* Validate that a SQLException is thrown for values that are not valid
* for a SQL identifier
*/
@Test(dataProvider = "invalidIdentifierValues",
expectedExceptions = SQLException.class)
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("invalidEnquotedIdentifierValues")
public void test03(String s, boolean alwaysQuote) throws SQLException {
pstmt.enquoteIdentifier(s, alwaysQuote);
assertThrows(SQLException.class, () -> pstmt.enquoteIdentifier(s, alwaysQuote));
}
/*
* Validate a NullPointerException is thrown is the string passed to
* enquoteIdentiifer is null
*/
@Test(dataProvider = "trueFalse",
expectedExceptions = NullPointerException.class)
@ParameterizedTest(autoCloseArguments = false)
@ValueSource(booleans = {true, false})
public void test04(boolean alwaysQuote) throws SQLException {
pstmt.enquoteIdentifier(null, alwaysQuote);
assertThrows(NullPointerException.class, () -> pstmt.enquoteIdentifier(null, alwaysQuote));
}
/*
* Validate that isSimpleIdentifier returns the expected value
*/
@Test(dataProvider = "simpleIdentifierValues")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("simpleIdentifierValues")
public void test05(String s, boolean expected) throws SQLException {
assertEquals(pstmt.isSimpleIdentifier(s), expected);
assertEquals(expected, pstmt.isSimpleIdentifier(s));
}
/*
* Validate a NullPointerException is thrown if the string passed to
* isSimpleIdentifier is null
*/
@Test(expectedExceptions = NullPointerException.class)
@Test
public void test06() throws SQLException {
pstmt.isSimpleIdentifier(null);
assertThrows(NullPointerException.class, () -> pstmt.isSimpleIdentifier(null));
}
/*
* Verify that enquoteLiteral creates a valid literal and converts every
* single quote to two single quotes
*/
@Test(dataProvider = "validEnquotedNCharLiteralValues")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("validEnquotedNCharLiteralValues")
public void test07(String s, String expected) throws SQLException {
assertEquals(pstmt.enquoteNCharLiteral(s), expected);
assertEquals(expected, pstmt.enquoteNCharLiteral(s));
}
/*
* Validate a NullPointerException is thrown if the string passed to
* enquoteNCharLiteral is null
*/
@Test(expectedExceptions = NullPointerException.class)
@Test
public void test08() throws SQLException {
pstmt.enquoteNCharLiteral(null);
assertThrows(NullPointerException.class, () -> pstmt.enquoteNCharLiteral(null));
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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
@ -20,14 +20,16 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package test.sql;
package 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 static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import util.BaseTest;
public class SQLClientInfoExceptionTests extends BaseTest {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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
@ -20,13 +20,15 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package test.sql;
package sql;
import java.sql.SQLDataException;
import java.sql.SQLException;
import java.sql.SQLNonTransientException;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import util.BaseTest;
public class SQLDataExceptionTests extends BaseTest {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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
@ -20,11 +20,13 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package test.sql;
package sql;
import java.sql.SQLException;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import util.BaseTest;
public class SQLExceptionTests extends BaseTest {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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
@ -20,13 +20,15 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package test.sql;
package sql;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.sql.SQLNonTransientException;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import util.BaseTest;
public class SQLFeatureNotSupportedExceptionTests extends BaseTest {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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
@ -20,13 +20,15 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package test.sql;
package sql;
import java.sql.SQLException;
import java.sql.SQLIntegrityConstraintViolationException;
import java.sql.SQLNonTransientException;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import util.BaseTest;
public class SQLIntegrityConstraintViolationExceptionTests extends BaseTest {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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
@ -20,13 +20,15 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package test.sql;
package sql;
import java.sql.SQLException;
import java.sql.SQLInvalidAuthorizationSpecException;
import java.sql.SQLNonTransientException;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import util.BaseTest;
public class SQLInvalidAuthorizationSpecExceptionTests extends BaseTest {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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
@ -20,13 +20,15 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package test.sql;
package sql;
import java.sql.SQLException;
import java.sql.SQLNonTransientConnectionException;
import java.sql.SQLNonTransientException;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import util.BaseTest;
public class SQLNonTransientConnectionExceptionTests extends BaseTest {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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
@ -20,12 +20,14 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package test.sql;
package sql;
import java.sql.SQLException;
import java.sql.SQLNonTransientException;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import util.BaseTest;
public class SQLNonTransientExceptionTests extends BaseTest {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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
@ -20,12 +20,14 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package test.sql;
package sql;
import java.sql.SQLException;
import java.sql.SQLRecoverableException;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import util.BaseTest;
public class SQLRecoverableExceptionTests extends BaseTest {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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
@ -20,13 +20,15 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package test.sql;
package sql;
import java.sql.SQLException;
import java.sql.SQLNonTransientException;
import java.sql.SQLSyntaxErrorException;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import util.BaseTest;
public class SQLSyntaxErrorExceptionTests extends BaseTest {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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
@ -20,13 +20,15 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package test.sql;
package sql;
import java.sql.SQLException;
import java.sql.SQLTimeoutException;
import java.sql.SQLTransientException;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import util.BaseTest;
public class SQLTimeoutExceptionTests extends BaseTest {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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
@ -20,13 +20,15 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package test.sql;
package sql;
import java.sql.SQLException;
import java.sql.SQLTransactionRollbackException;
import java.sql.SQLTransientException;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import util.BaseTest;
public class SQLTransactionRollbackExceptionTests extends BaseTest {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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
@ -20,13 +20,15 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package test.sql;
package sql;
import java.sql.SQLException;
import java.sql.SQLTransientConnectionException;
import java.sql.SQLTransientException;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import util.BaseTest;
public class SQLTransientConnectionExceptionTests extends BaseTest {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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
@ -20,12 +20,14 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package test.sql;
package sql;
import java.sql.SQLException;
import java.sql.SQLTransientException;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import util.BaseTest;
public class SQLTransientExceptionTests extends BaseTest {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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
@ -20,12 +20,14 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package test.sql;
package sql;
import java.sql.SQLException;
import java.sql.SQLWarning;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import util.BaseTest;
public class SQLWarningTests extends BaseTest {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2026, 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
@ -20,14 +20,21 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package test.sql;
package sql;
import java.sql.SQLException;
import java.sql.Statement;
import static org.testng.Assert.assertEquals;
import org.junit.jupiter.api.AfterEach;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import org.testng.annotations.*;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import org.junit.jupiter.params.provider.ValueSource;
import util.BaseTest;
import util.StubConnection;
@ -35,12 +42,12 @@ public class StatementTests extends BaseTest {
private Statement stmt;
@BeforeMethod
@BeforeEach
public void setUpMethod() throws Exception {
stmt = new StubConnection().createStatement();
}
@AfterMethod
@AfterEach
public void tearDownMethod() throws Exception {
stmt.close();
}
@ -48,80 +55,84 @@ public class StatementTests extends BaseTest {
* Verify that enquoteLiteral creates a valid literal and converts every
* single quote to two single quotes
*/
@Test(dataProvider = "validEnquotedLiteralValues")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("validEnquotedLiteralValues")
public void test00(String s, String expected) throws SQLException {
assertEquals(stmt.enquoteLiteral(s), expected);
assertEquals(expected, stmt.enquoteLiteral(s));
}
/*
* Validate a NullPointerException is thrown if the string passed to
* enquoteLiteral is null
*/
@Test(expectedExceptions = NullPointerException.class)
@Test
public void test01() throws SQLException {
stmt.enquoteLiteral(null);
assertThrows(NullPointerException.class, () -> stmt.enquoteLiteral(null));
}
/*
* Validate that enquoteIdentifier returns the expected value
*/
@Test(dataProvider = "validIdentifierValues")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("validEnquotedIdentifierValues")
public void test02(String s, boolean alwaysQuote, String expected) throws SQLException {
assertEquals(stmt.enquoteIdentifier(s, alwaysQuote), expected);
assertEquals(expected, stmt.enquoteIdentifier(s, alwaysQuote));
}
/*
* Validate that a SQLException is thrown for values that are not valid
* for a SQL identifier
*/
@Test(dataProvider = "invalidIdentifierValues",
expectedExceptions = SQLException.class)
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("invalidEnquotedIdentifierValues")
public void test03(String s, boolean alwaysQuote) throws SQLException {
stmt.enquoteIdentifier(s, alwaysQuote);
assertThrows(SQLException.class, () -> stmt.enquoteIdentifier(s, alwaysQuote));
}
/*
* Validate a NullPointerException is thrown is the string passed to
* enquoteIdentiifer is null
*/
@Test(dataProvider = "trueFalse",
expectedExceptions = NullPointerException.class)
@ParameterizedTest(autoCloseArguments = false)
@ValueSource(booleans = {true, false})
public void test04(boolean alwaysQuote) throws SQLException {
stmt.enquoteIdentifier(null, alwaysQuote);
assertThrows(NullPointerException.class, () -> stmt.enquoteIdentifier(null, alwaysQuote));
}
/*
* Validate that isSimpleIdentifier returns the expected value
*/
@Test(dataProvider = "simpleIdentifierValues")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("simpleIdentifierValues")
public void test05(String s, boolean expected) throws SQLException {
assertEquals(stmt.isSimpleIdentifier(s), expected);
assertEquals(expected, stmt.isSimpleIdentifier(s));
}
/*
* Validate a NullPointerException is thrown if the string passed to
* isSimpleIdentifier is null
*/
@Test(expectedExceptions = NullPointerException.class)
@Test
public void test06() throws SQLException {
stmt.isSimpleIdentifier(null);
assertThrows(NullPointerException.class, () -> stmt.isSimpleIdentifier(null));
}
/*
* Verify that enquoteLiteral creates a valid literal and converts every
* single quote to two single quotes
*/
@Test(dataProvider = "validEnquotedNCharLiteralValues")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("validEnquotedNCharLiteralValues")
public void test07(String s, String expected) throws SQLException {
assertEquals(stmt.enquoteNCharLiteral(s), expected);
assertEquals(expected, stmt.enquoteNCharLiteral(s));
}
/*
* Validate a NullPointerException is thrown if the string passed to
* enquoteNCharLiteral is null
*/
@Test(expectedExceptions = NullPointerException.class)
@Test
public void test08() throws SQLException {
stmt.enquoteNCharLiteral(null);
assertThrows(NullPointerException.class, () -> stmt.enquoteNCharLiteral(null));
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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
@ -20,13 +20,18 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package test.sql;
package sql;
import java.sql.Time;
import java.time.LocalTime;
import static org.testng.Assert.*;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.util.stream.Stream;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import util.BaseTest;
public class TimeTests extends BaseTest {
@ -34,73 +39,73 @@ public class TimeTests extends BaseTest {
/*
* Validate an IllegalArgumentException is thrown for calling getYear
*/
@Test(expectedExceptions = IllegalArgumentException.class)
@Test
public void test01() {
Time t = Time.valueOf("08:30:59");
t.getYear();
assertThrows(IllegalArgumentException.class, t::getYear);
}
/*
* Validate an IllegalArgumentException is thrown for calling getMonth
*/
@Test(expectedExceptions = IllegalArgumentException.class)
@Test
public void test02() {
Time t = Time.valueOf("08:30:59");
t.getMonth();
assertThrows(IllegalArgumentException.class, t::getMonth);
}
/*
* Validate an IllegalArgumentException is thrown for calling getDay
*/
@Test(expectedExceptions = IllegalArgumentException.class)
@Test
public void test03() {
Time t = Time.valueOf("08:30:59");
t.getDay();
assertThrows(IllegalArgumentException.class, t::getDay);
}
/**
* Validate an IllegalArgumentException is thrown for calling getDate
*/
@Test(expectedExceptions = IllegalArgumentException.class)
@Test
public void test04() {
Time t = Time.valueOf("08:30:59");
t.getDate();
assertThrows(IllegalArgumentException.class, t::getDate);
}
/*
* Validate an IllegalArgumentException is thrown for calling setYear
*/
@Test(expectedExceptions = IllegalArgumentException.class)
@Test
public void test05() {
Time t = Time.valueOf("08:30:59");
t.setYear(8);
assertThrows(IllegalArgumentException.class, () -> t.setYear(8));
}
/*
* Validate an IllegalArgumentException is thrown for calling setMonth
*/
@Test(expectedExceptions = IllegalArgumentException.class)
@Test
public void test06() {
Time t = Time.valueOf("08:30:59");
t.setMonth(8);
assertThrows(IllegalArgumentException.class, () -> t.setMonth(8));
}
/*
* Validate an IllegalArgumentException is thrown for calling setDate
*/
@Test(expectedExceptions = IllegalArgumentException.class)
@Test
public void test07() {
Time t = Time.valueOf("08:30:59");
t.setDate(30);
assertThrows(IllegalArgumentException.class, () -> t.setDate(30));
}
/*
* Validate an IllegalArgumentException is thrown for calling getDate
*/
@Test(expectedExceptions = IllegalArgumentException.class)
@Test
public void test08() {
Time t = Time.valueOf("08:30:59");
t.getDate();
assertThrows(IllegalArgumentException.class, t::getDate);
}
/*
@ -128,20 +133,20 @@ public class TimeTests extends BaseTest {
/*
* Validate an NPE occurs when a null LocalDate is passed to valueOf
*/
@Test(expectedExceptions = NullPointerException.class)
@Test
public void test11() throws Exception {
LocalTime ld = null;
Time.valueOf(ld);
assertThrows(NullPointerException.class, () -> Time.valueOf(ld));
}
/*
* Validate an UnsupportedOperationException occurs when toInstant() is
* called
*/
@Test(expectedExceptions = UnsupportedOperationException.class)
@Test
public void test12() throws Exception {
Time t = new Time(System.currentTimeMillis());
t.toInstant();
assertThrows(UnsupportedOperationException.class, t::toInstant);
}
/*
@ -149,7 +154,8 @@ public class TimeTests extends BaseTest {
* toString() of the other and that the correct value is returned from
* toString()
*/
@Test(dataProvider = "validTimeValues")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("validTimeValues")
public void test13(String time, String expected) {
Time t1 = Time.valueOf(time);
Time t2 = Time.valueOf(t1.toString());
@ -182,10 +188,10 @@ public class TimeTests extends BaseTest {
/*
* Validate an IllegalArgumentException is thrown for an invalid Time string
*/
@Test(dataProvider = "invalidTimeValues",
expectedExceptions = IllegalArgumentException.class)
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("invalidTimeValues")
public void test16(String time) throws Exception {
Time.valueOf(time);
assertThrows(IllegalArgumentException.class, () -> Time.valueOf(time));
}
/*
@ -299,29 +305,28 @@ public class TimeTests extends BaseTest {
* to validate that an IllegalArgumentException will be thrown from the
* valueOf method
*/
@DataProvider(name = "invalidTimeValues")
private Object[][] invalidTimeValues() {
return new Object[][]{
{"2009-11-01 10:50:01"},
{"1961-08-30 10:50:01.1"},
{"1961-08-30"},
{"00:00:00."},
{"10:50:0.1"},
{":00:00"},
{"00::00"},
{"00:00:"},
{"::"},
{" : : "},
{"0a:00:00"},
{"00:bb:00"},
{"00:01:cc"},
{"08:10:Batman"},
{"08:10:10:10"},
{"08:10"},
{"a:b:c"},
{null},
{"8:"}
};
private Stream<String> invalidTimeValues() {
return Stream.of(
"2009-11-01 10:50:01",
"1961-08-30 10:50:01.1",
"1961-08-30",
"00:00:00.",
"10:50:0.1",
":00:00",
"00::00",
"00:00:",
"::",
" : : ",
"0a:00:00",
"00:bb:00",
"00:01:cc",
"08:10:Batman",
"08:10:10:10",
"08:10",
"a:b:c",
null,
"8:"
);
}
/*
@ -330,19 +335,18 @@ public class TimeTests extends BaseTest {
* valueOf method. It also contains the expected return value from
* toString()
*/
@DataProvider(name = "validTimeValues")
private Object[][] validTimeValues() {
return new Object[][]{
{"10:50:01", "10:50:01"},
{"01:1:1", "01:01:01"},
{"01:01:1", "01:01:01"},
{"1:01:1", "01:01:01"},
{"2:02:02", "02:02:02"},
{"2:02:2", "02:02:02"},
{"10:50:1", "10:50:01"},
{"00:00:00", "00:00:00"},
{"08:30:59", "08:30:59"},
{"9:0:1", "09:00:01"}
};
private Stream<Arguments> validTimeValues() {
return Stream.of(
Arguments.of("10:50:01", "10:50:01"),
Arguments.of("01:1:1", "01:01:01"),
Arguments.of("01:01:1", "01:01:01"),
Arguments.of("1:01:1", "01:01:01"),
Arguments.of("2:02:02", "02:02:02"),
Arguments.of("2:02:2", "02:02:02"),
Arguments.of("10:50:1", "10:50:01"),
Arguments.of("00:00:00", "00:00:00"),
Arguments.of("08:30:59", "08:30:59"),
Arguments.of("9:0:1", "09:00:01")
);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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
@ -20,7 +20,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package test.sql;
package sql;
import java.sql.Date;
import java.sql.Time;
@ -30,11 +30,16 @@ import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Calendar;
import java.util.TimeZone;
import static org.testng.Assert.*;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.util.stream.Stream;
import org.junit.jupiter.api.AfterAll;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import util.BaseTest;
public class TimestampTests extends BaseTest {
@ -45,7 +50,7 @@ public class TimestampTests extends BaseTest {
* Need to set and use a custom TimeZone which does not
* observe daylight savings time for this test.
*/
@BeforeClass
@BeforeAll
public static void setUpClass() throws Exception {
defaultTimeZone = TimeZone.getDefault();
TimeZone tzone = TimeZone.getTimeZone("GMT+01");
@ -56,7 +61,7 @@ public class TimestampTests extends BaseTest {
/*
* Conservatively reset the default time zone after test.
*/
@AfterClass
@AfterAll
public static void tearDownClass() throws Exception {
TimeZone.setDefault(defaultTimeZone);
}
@ -64,10 +69,10 @@ public class TimestampTests extends BaseTest {
/*
* Validate an IllegalArgumentException is thrown for an invalid Timestamp
*/
@Test(dataProvider = "invalidTimestampValues",
expectedExceptions = IllegalArgumentException.class)
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("invalidTimestampValues")
public void test(String ts) throws Exception {
Timestamp.valueOf(ts);
assertThrows(IllegalArgumentException.class, () -> Timestamp.valueOf(ts));
}
/*
@ -80,7 +85,7 @@ public class TimestampTests extends BaseTest {
String ExpectedTS = "2009-01-01 10:50:0";
Timestamp ts = Timestamp.valueOf(testTS);
Timestamp ts2 = Timestamp.valueOf(ExpectedTS);
assertEquals(ts, ts2, "Error ts1 != ts2");
assertEquals(ts2, ts, "Error ts1 != ts2");
}
/*
@ -91,7 +96,7 @@ public class TimestampTests extends BaseTest {
String testTS = "2009-01-01 10:50:0";
Timestamp ts = Timestamp.valueOf(testTS);
Timestamp ts2 = Timestamp.valueOf(testTS);
assertEquals(ts, ts2, "Error ts1 != ts2");
assertEquals(ts2, ts, "Error ts1 != ts2");
}
/*
@ -104,7 +109,7 @@ public class TimestampTests extends BaseTest {
String ExpectedTS = "2009-01-01 10:50:0";
Timestamp ts = Timestamp.valueOf(testTS);
Timestamp ts2 = Timestamp.valueOf(ExpectedTS);
assertEquals(ts, ts2, "Error ts1 != ts2");
assertEquals(ts2, ts, "Error ts1 != ts2");
}
/*
@ -117,7 +122,7 @@ public class TimestampTests extends BaseTest {
String ExpectedTS = "2009-01-01 10:50:0";
Timestamp ts = Timestamp.valueOf(testTS);
Timestamp ts2 = Timestamp.valueOf(ExpectedTS);
assertEquals(ts, ts2, "Error ts1 != ts2");
assertEquals(ts2, ts, "Error ts1 != ts2");
}
/*
@ -130,7 +135,7 @@ public class TimestampTests extends BaseTest {
String ExpectedTS = "2009-01-01 10:50:0";
Timestamp ts = Timestamp.valueOf(testTS);
Timestamp ts2 = Timestamp.valueOf(ExpectedTS);
assertEquals(ts, ts2, "Error ts1 != ts2");
assertEquals(ts2, ts, "Error ts1 != ts2");
}
/*
@ -142,7 +147,7 @@ public class TimestampTests extends BaseTest {
String ExpectedTS = "2005-01-01 10:20:50.00";
Timestamp ts = Timestamp.valueOf(testTS);
Timestamp ts2 = Timestamp.valueOf(ExpectedTS);
assertEquals(ts, ts2, "Error ts1 != ts2");
assertEquals(ts2, ts, "Error ts1 != ts2");
}
/*
@ -219,7 +224,8 @@ public class TimestampTests extends BaseTest {
* Validate that two Timestamps are equal when one is created from the
* toString() of the other
*/
@Test(dataProvider = "validTimestampValues")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("validTimestampValues")
public void test13(String ts, String expectedTS) {
Timestamp ts1 = Timestamp.valueOf(ts);
Timestamp ts2 = Timestamp.valueOf(ts1.toString());
@ -263,10 +269,10 @@ public class TimestampTests extends BaseTest {
* Validate that a NullPointerException is thrown if a null is passed to
* the before method
*/
@Test(expectedExceptions = NullPointerException.class)
@Test
public void test17() throws Exception {
Timestamp ts1 = Timestamp.valueOf("1996-12-13 14:15:25.745634");
ts1.before(null);
assertThrows(NullPointerException.class, () -> ts1.before(null));
}
/*
@ -316,10 +322,10 @@ public class TimestampTests extends BaseTest {
* Validate that a NullPointerException is thrown if a null is passed to the
* after method
*/
@Test(expectedExceptions = NullPointerException.class)
@Test
public void test22() throws Exception {
Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
ts1.after(null);
assertThrows(NullPointerException.class, () -> ts1.after(null));
}
/*
@ -476,21 +482,21 @@ public class TimestampTests extends BaseTest {
/*
* Validate an IllegalArgumentException is thrown for an invalid nanos value
*/
@Test(expectedExceptions = IllegalArgumentException.class)
@Test
public void test38() throws Exception {
Timestamp ts1 = Timestamp.valueOf("1961-08-30 00:00:00");
ts1.setNanos(-1);
assertThrows(IllegalArgumentException.class, () -> ts1.setNanos(-1));
}
/*
* Validate an IllegalArgumentException is thrown for an invalid nanos value
*/
@Test(expectedExceptions = IllegalArgumentException.class)
@Test
public void test39() throws Exception {
int nanos = 999999999;
Timestamp ts1 = Timestamp.valueOf("1961-08-30 00:00:00");
ts1.setNanos(nanos + 1);
assertThrows(IllegalArgumentException.class, () -> ts1.setNanos(nanos + 1));
}
/*
@ -541,10 +547,10 @@ public class TimestampTests extends BaseTest {
/*
* Validate an NPE occurs when a null LocalDateTime is passed to valueOF
*/
@Test(expectedExceptions = NullPointerException.class)
@Test
public void test44() throws Exception {
LocalDateTime ldt = null;
Timestamp.valueOf(ldt);
assertThrows(NullPointerException.class, () -> Timestamp.valueOf(ldt));
}
/*
@ -572,10 +578,10 @@ public class TimestampTests extends BaseTest {
/*
* Validate an NPE occurs when a null instant is passed to from
*/
@Test(expectedExceptions = NullPointerException.class)
@Test
public void test47() throws Exception {
Instant instant = null;
Timestamp.from(instant);
assertThrows(NullPointerException.class, () -> Timestamp.from(instant));
}
// Added SQE tests
@ -628,7 +634,8 @@ public class TimestampTests extends BaseTest {
* Validate that two Timestamps are equal when one is created from the
* toString() of the other
*/
@Test(dataProvider = "validateNanos")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("validateNanos")
public void test51(String ts, int nanos) {
Timestamp ts1 = Timestamp.valueOf(ts);
Timestamp ts2 = Timestamp.valueOf(ts1.toString());
@ -636,35 +643,36 @@ public class TimestampTests extends BaseTest {
"Error with Nanos");
}
@Test(dataProvider = "validTimestampLongValues")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("validTimestampLongValues")
public void test52(long value, String ts) {
Timestamp ts1 = new Timestamp(value);
assertEquals(ts1.toString(), ts, "ts1.toString() != ts");
assertEquals(ts, ts1.toString(), "ts1.toString() != ts");
}
@Test
public void test53() {
// The latest Instant that can be converted to a Timestamp.
Instant instant1 = Instant.ofEpochSecond(Long.MAX_VALUE / 1000, 999_999_999);
assertEquals(Timestamp.from(instant1).toInstant(), instant1);
assertEquals(instant1, Timestamp.from(instant1).toInstant());
// One nanosecond more, and converting it gets an overflow.
Instant instant2 = instant1.plusNanos(1);
expectThrows(IllegalArgumentException.class, () -> Timestamp.from(instant2));
assertThrows(IllegalArgumentException.class, () -> Timestamp.from(instant2));
// The earliest Instant that can be converted to a Timestamp.
Instant instant3 = Instant.ofEpochSecond(Long.MIN_VALUE / 1000, 0);
assertEquals(Timestamp.from(instant3).toInstant(), instant3);
assertEquals(instant3, Timestamp.from(instant3).toInstant());
// One nanosecond less, and converting it gets an overflow.
Instant instant4 = instant3.minusNanos(1);
expectThrows(IllegalArgumentException.class, () -> Timestamp.from(instant4));
assertThrows(IllegalArgumentException.class, () -> Timestamp.from(instant4));
// The latest possible Instant will certainly overflow.
expectThrows(IllegalArgumentException.class, () -> Timestamp.from(Instant.MAX));
assertThrows(IllegalArgumentException.class, () -> Timestamp.from(Instant.MAX));
// The earliest possible Instant will certainly overflow.
expectThrows(IllegalArgumentException.class, () -> Timestamp.from(Instant.MIN));
assertThrows(IllegalArgumentException.class, () -> Timestamp.from(Instant.MIN));
}
/*
@ -683,7 +691,7 @@ public class TimestampTests extends BaseTest {
assertTrue(ts1.equals(ts2));
// As the Timestamp values, including the nanos are the same, the hashCode's
// should be equal
assertEquals(ts1.hashCode(), ts2.hashCode());
assertEquals(ts2.hashCode(), ts1.hashCode());
}
/*
@ -702,7 +710,7 @@ public class TimestampTests extends BaseTest {
assertTrue(ts2.equals(ts2));
assertFalse(ts1.equals(ts2));
// As the nanos differ, the hashCode values should differ
assertNotEquals(ts1.hashCode(), ts2.hashCode());
assertNotEquals(ts2.hashCode(), ts1.hashCode());
}
/*
@ -710,33 +718,32 @@ public class TimestampTests extends BaseTest {
* to validate that an IllegalArgumentException will be thrown from the
* valueOf method
*/
@DataProvider(name = "invalidTimestampValues")
private Object[][] invalidTimestampValues() {
return new Object[][]{
{"2009-11-01-01 10:50:01"},
{"aaaa-11-01-01 10:50"},
{"aaaa-11-01 10:50"},
{"1961--30 00:00:00"},
{"--30 00:00:00"},
{"-- 00:00:00"},
{"1961-1- 00:00:00"},
{"2009-11-01"},
{"10:50:01"},
{"1961-a-30 00:00:00"},
{"1961-01-bb 00:00:00"},
{"1961-08-30 00:00:00."},
{"1961-08-30 :00:00"},
{"1961-08-30 00::00"},
{"1961-08-30 00:00:"},
{"1961-08-30 ::"},
{"1961-08-30 0a:00:00"},
{"1961-08-30 00:bb:00"},
{"1961-08-30 00:01:cc"},
{"1961-08-30 00:00:00.01a"},
{"1961-08-30 00:00:00.a"},
{"1996-12-10 12:26:19.1234567890"},
{null}
};
private Stream<String> invalidTimestampValues() {
return Stream.of(
"2009-11-01-01 10:50:01",
"aaaa-11-01-01 10:50",
"aaaa-11-01 10:50",
"1961--30 00:00:00",
"--30 00:00:00",
"-- 00:00:00",
"1961-1- 00:00:00",
"2009-11-01",
"10:50:01",
"1961-a-30 00:00:00",
"1961-01-bb 00:00:00",
"1961-08-30 00:00:00.",
"1961-08-30 :00:00",
"1961-08-30 00::00",
"1961-08-30 00:00:",
"1961-08-30 ::",
"1961-08-30 0a:00:00",
"1961-08-30 00:bb:00",
"1961-08-30 00:01:cc",
"1961-08-30 00:00:00.01a",
"1961-08-30 00:00:00.a",
"1996-12-10 12:26:19.1234567890",
null
);
}
/*
@ -744,67 +751,65 @@ public class TimestampTests extends BaseTest {
* to validate that an IllegalArgumentException will not be thrown from the
* valueOf method and the corect value from toString() is returned
*/
@DataProvider(name = "validTimestampValues")
private Object[][] validTimestampValues() {
return new Object[][]{
{"1961-08-30 00:00:00", "1961-08-30 00:00:00.0"},
{"1961-08-30 11:22:33", "1961-08-30 11:22:33.0"},
{"1961-8-30 00:00:00", "1961-08-30 00:00:00.0"},
{"1966-08-1 00:00:00", "1966-08-01 00:00:00.0"},
{"1996-12-10 12:26:19.1", "1996-12-10 12:26:19.1"},
{"1996-12-10 12:26:19.12", "1996-12-10 12:26:19.12"},
{"1996-12-10 12:26:19.123", "1996-12-10 12:26:19.123"},
{"1996-12-10 12:26:19.1234", "1996-12-10 12:26:19.1234"},
{"1996-12-10 12:26:19.12345", "1996-12-10 12:26:19.12345"},
{"1996-12-10 12:26:19.123456", "1996-12-10 12:26:19.123456"},
{"1996-12-10 12:26:19.1234567", "1996-12-10 12:26:19.1234567"},
{"1996-12-10 12:26:19.12345678", "1996-12-10 12:26:19.12345678"},
{"1996-12-10 12:26:19.123456789", "1996-12-10 12:26:19.123456789"},
{"1996-12-10 12:26:19.000000001", "1996-12-10 12:26:19.000000001"},
{"1996-12-10 12:26:19.000000012", "1996-12-10 12:26:19.000000012"},
{"1996-12-10 12:26:19.000000123", "1996-12-10 12:26:19.000000123"},
{"1996-12-10 12:26:19.000001234", "1996-12-10 12:26:19.000001234"},
{"1996-12-10 12:26:19.000012345", "1996-12-10 12:26:19.000012345"},
{"1996-12-10 12:26:19.000123456", "1996-12-10 12:26:19.000123456"},
{"1996-12-10 12:26:19.001234567", "1996-12-10 12:26:19.001234567"},
{"1996-12-10 12:26:19.12345678", "1996-12-10 12:26:19.12345678"},
{"1996-12-10 12:26:19.0", "1996-12-10 12:26:19.0"},
{"1996-12-10 12:26:19.01230", "1996-12-10 12:26:19.0123"}
};
private Stream<Arguments> validTimestampValues() {
return Stream.of(
Arguments.of("1961-08-30 00:00:00", "1961-08-30 00:00:00.0"),
Arguments.of("1961-08-30 11:22:33", "1961-08-30 11:22:33.0"),
Arguments.of("1961-8-30 00:00:00", "1961-08-30 00:00:00.0"),
Arguments.of("1966-08-1 00:00:00", "1966-08-01 00:00:00.0"),
Arguments.of("1996-12-10 12:26:19.1", "1996-12-10 12:26:19.1"),
Arguments.of("1996-12-10 12:26:19.12", "1996-12-10 12:26:19.12"),
Arguments.of("1996-12-10 12:26:19.123", "1996-12-10 12:26:19.123"),
Arguments.of("1996-12-10 12:26:19.1234", "1996-12-10 12:26:19.1234"),
Arguments.of("1996-12-10 12:26:19.12345", "1996-12-10 12:26:19.12345"),
Arguments.of("1996-12-10 12:26:19.123456", "1996-12-10 12:26:19.123456"),
Arguments.of("1996-12-10 12:26:19.1234567", "1996-12-10 12:26:19.1234567"),
Arguments.of("1996-12-10 12:26:19.12345678", "1996-12-10 12:26:19.12345678"),
Arguments.of("1996-12-10 12:26:19.123456789", "1996-12-10 12:26:19.123456789"),
Arguments.of("1996-12-10 12:26:19.000000001", "1996-12-10 12:26:19.000000001"),
Arguments.of("1996-12-10 12:26:19.000000012", "1996-12-10 12:26:19.000000012"),
Arguments.of("1996-12-10 12:26:19.000000123", "1996-12-10 12:26:19.000000123"),
Arguments.of("1996-12-10 12:26:19.000001234", "1996-12-10 12:26:19.000001234"),
Arguments.of("1996-12-10 12:26:19.000012345", "1996-12-10 12:26:19.000012345"),
Arguments.of("1996-12-10 12:26:19.000123456", "1996-12-10 12:26:19.000123456"),
Arguments.of("1996-12-10 12:26:19.001234567", "1996-12-10 12:26:19.001234567"),
Arguments.of("1996-12-10 12:26:19.12345678", "1996-12-10 12:26:19.12345678"),
Arguments.of("1996-12-10 12:26:19.0", "1996-12-10 12:26:19.0"),
Arguments.of("1996-12-10 12:26:19.01230", "1996-12-10 12:26:19.0123")
);
}
@DataProvider(name = "validTimestampLongValues")
private Object[][] validTimestampLongValues() {
return new Object[][]{
{1L, "1970-01-01 01:00:00.001"},
{-3600*1000L - 1, "1969-12-31 23:59:59.999"},
{-(20000L*365*24*60*60*1000), "18018-08-28 01:00:00.0"},
{Timestamp.valueOf("1961-08-30 11:22:33").getTime(), "1961-08-30 11:22:33.0"},
{Timestamp.valueOf("1961-08-30 11:22:33.54321000").getTime(), "1961-08-30 11:22:33.543"}, // nanoprecision lost
{new Timestamp(114, 10, 10, 10, 10, 10, 100000000).getTime(), "2014-11-10 10:10:10.1"},
{new Timestamp(0, 10, 10, 10, 10, 10, 100000).getTime(), "1900-11-10 10:10:10.0"}, // nanoprecision lost
{new Date(114, 10, 10).getTime(), "2014-11-10 00:00:00.0"},
{new Date(0, 10, 10).getTime(), "1900-11-10 00:00:00.0"},
{LocalDateTime.of(1960, 10, 10, 10, 10, 10, 50000).atZone(ZoneId.of("America/Los_Angeles"))
.toInstant().toEpochMilli(), "1960-10-10 19:10:10.0"},
private Stream<Arguments> validTimestampLongValues() {
return Stream.of(
Arguments.of(1L, "1970-01-01 01:00:00.001"),
Arguments.of(-3600*1000L - 1, "1969-12-31 23:59:59.999"),
Arguments.of(-(20000L*365*24*60*60*1000), "18018-08-28 01:00:00.0"),
Arguments.of(Timestamp.valueOf("1961-08-30 11:22:33").getTime(), "1961-08-30 11:22:33.0"),
Arguments.of(Timestamp.valueOf("1961-08-30 11:22:33.54321000").getTime(), "1961-08-30 11:22:33.543"), // nanoprecision lost
Arguments.of(new Timestamp(114, 10, 10, 10, 10, 10, 100000000).getTime(), "2014-11-10 10:10:10.1"),
Arguments.of(new Timestamp(0, 10, 10, 10, 10, 10, 100000).getTime(), "1900-11-10 10:10:10.0"), // nanoprecision lost
Arguments.of(new Date(114, 10, 10).getTime(), "2014-11-10 00:00:00.0"),
Arguments.of(new Date(0, 10, 10).getTime(), "1900-11-10 00:00:00.0"),
Arguments.of(LocalDateTime.of(1960, 10, 10, 10, 10, 10, 50000).atZone(ZoneId.of("America/Los_Angeles"))
.toInstant().toEpochMilli(), "1960-10-10 19:10:10.0"),
// millisecond timestamps wraps around at year 1, so Long.MIN_VALUE looks similar
// Long.MAX_VALUE, while actually representing 292278994 BCE
{Long.MIN_VALUE, "292278994-08-17 08:12:55.192"},
{Long.MAX_VALUE + 1, "292278994-08-17 08:12:55.192"},
{Long.MAX_VALUE, "292278994-08-17 08:12:55.807"},
{Long.MIN_VALUE - 1, "292278994-08-17 08:12:55.807"},
Arguments.of(Long.MIN_VALUE, "292278994-08-17 08:12:55.192"),
Arguments.of(Long.MAX_VALUE + 1, "292278994-08-17 08:12:55.192"),
Arguments.of(Long.MAX_VALUE, "292278994-08-17 08:12:55.807"),
Arguments.of(Long.MIN_VALUE - 1, "292278994-08-17 08:12:55.807"),
// wrap around point near 0001-01-01, test that we never get a negative year:
{-(1970L*365*24*60*60*1000), "0001-04-25 01:00:00.0"},
{-(1970L*365*24*60*60*1000 + 115*24*60*60*1000L), "0001-12-31 01:00:00.0"},
{-(1970L*365*24*60*60*1000 + 115*24*60*60*1000L - 23*60*60*1000L), "0001-01-01 00:00:00.0"},
Arguments.of(-(1970L*365*24*60*60*1000), "0001-04-25 01:00:00.0"),
Arguments.of(-(1970L*365*24*60*60*1000 + 115*24*60*60*1000L), "0001-12-31 01:00:00.0"),
Arguments.of(-(1970L*365*24*60*60*1000 + 115*24*60*60*1000L - 23*60*60*1000L), "0001-01-01 00:00:00.0"),
{LocalDateTime.of(0, 1, 1, 10, 10, 10, 50000).atZone(ZoneId.of("America/Los_Angeles"))
.toInstant().toEpochMilli() - 2*24*60*60*1000L, "0001-01-01 19:03:08.0"}, // 1 BCE
{LocalDateTime.of(0, 1, 1, 10, 10, 10, 50000).atZone(ZoneId.of("America/Los_Angeles"))
.toInstant().toEpochMilli() - 3*24*60*60*1000L, "0002-12-31 19:03:08.0"} // 2 BCE
};
Arguments.of(LocalDateTime.of(0, 1, 1, 10, 10, 10, 50000).atZone(ZoneId.of("America/Los_Angeles"))
.toInstant().toEpochMilli() - 2*24*60*60*1000L, "0001-01-01 19:03:08.0"), // 1 BCE
Arguments.of(LocalDateTime.of(0, 1, 1, 10, 10, 10, 50000).atZone(ZoneId.of("America/Los_Angeles"))
.toInstant().toEpochMilli() - 3*24*60*60*1000L, "0002-12-31 19:03:08.0") // 2 BCE
);
}
/*
@ -812,29 +817,28 @@ public class TimestampTests extends BaseTest {
* validate that the correct Nanos value is generated from the specified
* Timestamp
*/
@DataProvider(name = "validateNanos")
private Object[][] validateNanos() {
return new Object[][]{
{"1961-08-30 00:00:00", 0},
{"1996-12-10 12:26:19.1", 100000000},
{"1996-12-10 12:26:19.12", 120000000},
{"1996-12-10 12:26:19.123", 123000000},
{"1996-12-10 12:26:19.1234", 123400000},
{"1996-12-10 12:26:19.12345", 123450000},
{"1996-12-10 12:26:19.123456", 123456000},
{"1996-12-10 12:26:19.1234567", 123456700},
{"1996-12-10 12:26:19.12345678", 123456780},
{"1996-12-10 12:26:19.123456789", 123456789},
{"1996-12-10 12:26:19.000000001", 1},
{"1996-12-10 12:26:19.000000012", 12},
{"1996-12-10 12:26:19.000000123", 123},
{"1996-12-10 12:26:19.000001234", 1234},
{"1996-12-10 12:26:19.000012345", 12345},
{"1996-12-10 12:26:19.000123456", 123456},
{"1996-12-10 12:26:19.001234567", 1234567},
{"1996-12-10 12:26:19.012345678", 12345678},
{"1996-12-10 12:26:19.0", 0},
{"1996-12-10 12:26:19.01230", 12300000}
};
private Stream<Arguments> validateNanos() {
return Stream.of(
Arguments.of("1961-08-30 00:00:00", 0),
Arguments.of("1996-12-10 12:26:19.1", 100000000),
Arguments.of("1996-12-10 12:26:19.12", 120000000),
Arguments.of("1996-12-10 12:26:19.123", 123000000),
Arguments.of("1996-12-10 12:26:19.1234", 123400000),
Arguments.of("1996-12-10 12:26:19.12345", 123450000),
Arguments.of("1996-12-10 12:26:19.123456", 123456000),
Arguments.of("1996-12-10 12:26:19.1234567", 123456700),
Arguments.of("1996-12-10 12:26:19.12345678", 123456780),
Arguments.of("1996-12-10 12:26:19.123456789", 123456789),
Arguments.of("1996-12-10 12:26:19.000000001", 1),
Arguments.of("1996-12-10 12:26:19.000000012", 12),
Arguments.of("1996-12-10 12:26:19.000000123", 123),
Arguments.of("1996-12-10 12:26:19.000001234", 1234),
Arguments.of("1996-12-10 12:26:19.000012345", 12345),
Arguments.of("1996-12-10 12:26:19.000123456", 123456),
Arguments.of("1996-12-10 12:26:19.001234567", 1234567),
Arguments.of("1996-12-10 12:26:19.012345678", 12345678),
Arguments.of("1996-12-10 12:26:19.0", 0),
Arguments.of("1996-12-10 12:26:19.01230", 12300000)
);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2026, 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
@ -20,7 +20,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package test.sql.othervm;
package sql.drivermanager;
import java.io.BufferedReader;
import java.io.CharArrayReader;
@ -33,8 +33,8 @@ import java.util.Enumeration;
import java.util.logging.Level;
import java.util.logging.Logger;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
public class DriverManagerInitTests {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2026, 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
@ -20,23 +20,19 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package sql.drivermanager;
import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.SQLException;
import static org.testng.Assert.*;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
/*
* @test
* @library /java/sql/modules
* @build luckydogdriver/* mystubdriver/*
* @run testng/othervm DriverManagerModuleTests
* @summary Tests that a JDBC Driver that is a module can be loaded
* via the service-provider loading mechanism.
*/
@ -46,28 +42,12 @@ public class DriverManagerModuleTests {
private static final String STUBDRIVERURL = "jdbc:stub:myDB";
private static final String CONNECTION_CLASS_NAME = "com.luckydogtennis.StubConnection";
@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 {
}
/**
* Validate JDBC drivers as modules will be accessible. One driver will be
* loaded and registered via the service-provider loading mechanism. The
* other driver will need to be explictly loaded
*
* @throws java.lang.Exception
* @throws Exception
*/
@Test
public void test() throws Exception {
@ -101,7 +81,7 @@ public class DriverManagerModuleTests {
* Validate that a Connection can be obtained from a JDBC driver which is a
* module and loaded via the service-provider loading mechanism.
*
* @throws java.lang.Exception
* @throws Exception
*/
@Test
public void test00() throws Exception {

View File

@ -0,0 +1,4 @@
# drivermanager tests are run in othervm
othervm.dirs = .
# Required by DriverManagerModuleTests.java
lib.dirs = /java/sql/modules

View File

@ -1,4 +0,0 @@
# JDBC unit tests uses TestNG
TestNG.dirs = .
othervm.dirs = test/sql/othervm

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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
@ -29,9 +29,12 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.sql.JDBCType;
import java.sql.SQLException;
import java.util.stream.Stream;
import org.testng.annotations.DataProvider;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.params.provider.Arguments;
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class BaseTest {
protected final String reason = "reason";
@ -73,29 +76,11 @@ public class BaseTest {
return o1;
}
/*
* 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;
protected Stream<Integer> jdbcTypes() {
return Stream.of(JDBCType.values()).map(JDBCType::getVendorTypeNumber);
}
/*
@ -103,15 +88,14 @@ public class BaseTest {
* that enquoteLiteral converts a string to a literal and every instance of
* a single quote will be converted into two single quotes in the literal.
*/
@DataProvider(name = "validEnquotedLiteralValues")
protected Object[][] validEnquotedLiteralValues() {
return new Object[][]{
{"Hello", "'Hello'"},
{"G'Day", "'G''Day'"},
{"'G''Day'", "'''G''''Day'''"},
{"I'''M", "'I''''''M'"},
{"The Dark Knight", "'The Dark Knight'"},
};
protected Stream<Arguments> validEnquotedLiteralValues() {
return Stream.of(
Arguments.of("Hello", "'Hello'"),
Arguments.of("G'Day", "'G''Day'"),
Arguments.of("'G''Day'", "'''G''''Day'''"),
Arguments.of("I'''M", "'I''''''M'"),
Arguments.of("The Dark Knight", "'The Dark Knight'")
);
}
/*
@ -119,37 +103,37 @@ public class BaseTest {
* that enqouteIdentifier returns a simple SQL Identifier or a
* quoted identifier
*/
@DataProvider(name = "validIdentifierValues")
protected Object[][] validEnquotedIdentifierValues() {
return new Object[][]{
{"b", false, "b"},
{"b", true, "\"b\""},
{MAX_LENGTH_IDENTIFIER, false, MAX_LENGTH_IDENTIFIER},
{MAX_LENGTH_IDENTIFIER, true, "\"" + MAX_LENGTH_IDENTIFIER + "\""},
{"Hello", false, "Hello"},
{"Hello", true, "\"Hello\""},
{"G'Day", false, "\"G'Day\""},
{"G'Day", true, "\"G'Day\""},
{"Bruce Wayne", false, "\"Bruce Wayne\""},
{"Bruce Wayne", true, "\"Bruce Wayne\""},
{"select", false, "\"select\""},
{"table", true, "\"table\""},
{"GoodDay$", false, "\"GoodDay$\""},
{"GoodDay$", true, "\"GoodDay$\""},};
protected Stream<Arguments> validEnquotedIdentifierValues() {
return Stream.of(
Arguments.of("b", false, "b"),
Arguments.of("b", true, "\"b\""),
Arguments.of(MAX_LENGTH_IDENTIFIER, false, MAX_LENGTH_IDENTIFIER),
Arguments.of(MAX_LENGTH_IDENTIFIER, true, "\"" + MAX_LENGTH_IDENTIFIER + "\""),
Arguments.of("Hello", false, "Hello"),
Arguments.of("Hello", true, "\"Hello\""),
Arguments.of("G'Day", false, "\"G'Day\""),
Arguments.of("G'Day", true, "\"G'Day\""),
Arguments.of("Bruce Wayne", false, "\"Bruce Wayne\""),
Arguments.of("Bruce Wayne", true, "\"Bruce Wayne\""),
Arguments.of("select", false, "\"select\""),
Arguments.of("table", true, "\"table\""),
Arguments.of("GoodDay$", false, "\"GoodDay$\""),
Arguments.of("GoodDay$", true, "\"GoodDay$\"")
);
}
/*
* DataProvider used to provide strings are invalid for enquoteIdentifier
* resulting in a SQLException being thrown
*/
@DataProvider(name = "invalidIdentifierValues")
protected Object[][] invalidEnquotedIdentifierValues() {
return new Object[][]{
{"Hel\"lo", false},
{"\"Hel\"lo\"", true},
{"Hello" + '\0', false},
{"", false},
{MAX_LENGTH_IDENTIFIER + 'a', false},};
protected Stream<Arguments> invalidEnquotedIdentifierValues() {
return Stream.of(
Arguments.of("Hel\"lo", false),
Arguments.of("\"Hel\"lo\"", true),
Arguments.of("Hello" + '\0', false),
Arguments.of("", false),
Arguments.of(MAX_LENGTH_IDENTIFIER + 'a', false)
);
}
/*
@ -157,22 +141,21 @@ public class BaseTest {
* that isSimpleIdentifier returns the correct value based on the
* identifier specified.
*/
@DataProvider(name = "simpleIdentifierValues")
protected Object[][] simpleIdentifierValues() {
return new Object[][]{
{"b", true},
{"Hello", true},
{"\"Gotham\"", false},
{"G'Day", false},
{"Bruce Wayne", false},
{"GoodDay$", false},
{"Dick_Grayson", true},
{"Batmobile1966", true},
{MAX_LENGTH_IDENTIFIER, true},
{MAX_LENGTH_IDENTIFIER + 'a', false},
{"", false},
{"select", false}
};
protected Stream<Arguments> simpleIdentifierValues() {
return Stream.of(
Arguments.of("b", true),
Arguments.of("Hello", true),
Arguments.of("\"Gotham\"", false),
Arguments.of("G'Day", false),
Arguments.of("Bruce Wayne", false),
Arguments.of("GoodDay$", false),
Arguments.of("Dick_Grayson", true),
Arguments.of("Batmobile1966", true),
Arguments.of(MAX_LENGTH_IDENTIFIER, true),
Arguments.of(MAX_LENGTH_IDENTIFIER + 'a', false),
Arguments.of("", false),
Arguments.of("select", false)
);
}
/*
@ -181,15 +164,14 @@ public class BaseTest {
* literal and every instance of
* a single quote will be converted into two single quotes in the literal.
*/
@DataProvider(name = "validEnquotedNCharLiteralValues")
protected Object[][] validEnquotedNCharLiteralValues() {
return new Object[][]{
{"Hello", "N'Hello'"},
{"G'Day", "N'G''Day'"},
{"'G''Day'", "N'''G''''Day'''"},
{"I'''M", "N'I''''''M'"},
{"N'Hello'", "N'N''Hello'''"},
{"The Dark Knight", "N'The Dark Knight'"}
};
protected Stream<Arguments> validEnquotedNCharLiteralValues() {
return Stream.of(
Arguments.of("Hello", "N'Hello'"),
Arguments.of("G'Day", "N'G''Day'"),
Arguments.of("'G''Day'", "N'''G''''Day'''"),
Arguments.of("I'''M", "N'I''''''M'"),
Arguments.of("N'Hello'", "N'N''Hello'''"),
Arguments.of("The Dark Knight", "N'The Dark Knight'")
);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2026, 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

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2025, 2026, 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

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2026, 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

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2026, 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

View File

@ -1,7 +1,7 @@
# JDBC unit tests uses TestNG
TestNG.dirs= .
# JDBC unit tests uses JUnit
JUnit.dirs= .
othervm.dirs= .
lib.dirs = /java/sql/testng
lib.dirs = /java/sql/util
modules = java.sql.rowset/com.sun.rowset \
java.sql.rowset/com.sun.rowset.internal \
java.sql.rowset/com.sun.rowset.providers

View File

@ -1 +0,0 @@
modules = java.sql.rowset

View File

@ -1,42 +0,0 @@
/*
* Copyright (c) 2011, 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.
*/
import javax.sql.rowset.serial.SerialBlob;
import javax.sql.rowset.serial.SerialException;
/**
* @test
* @bug 7077451
* @summary tests if the correct exception is thrown when calling method setBinaryStream() on SerialBlob
*/
public class SetBinaryStream {
public static void main(String[] args) throws Exception {
SerialBlob blob = new SerialBlob(new byte[0]);
try {
blob.setBinaryStream(0);
} catch (SerialException e) {
System.out.println("Test PASSED");
}
}
}

View File

@ -1,42 +0,0 @@
/*
* Copyright (c) 2011, 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.
*/
import javax.sql.rowset.serial.SerialClob;
import javax.sql.rowset.serial.SerialException;
/**
* @test
* @bug 7077451
* @summary tests if the correct exception is thrown when calling method setAsciiStream() on SerialClob
*/
public class SetAsciiStream {
public static void main(String[] args) throws Exception {
SerialClob clob = new SerialClob(new char[0]);
try {
clob.setAsciiStream(0);
} catch (SerialException e) {
System.out.println("Test PASSED");
}
}
}

View File

@ -1,42 +0,0 @@
/*
* Copyright (c) 2011, 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.
*/
import javax.sql.rowset.serial.SerialClob;
import javax.sql.rowset.serial.SerialException;
/**
* @test
* @bug 7077451
* @summary tests if the correct exception is thrown when calling method setCharacterStream() on SerialClob
*/
public class SetCharacterStream {
public static void main(String[] args) throws Exception {
SerialClob clob = new SerialClob(new char[0]);
try {
clob.setCharacterStream(0);
} catch (SerialException e) {
System.out.println("Test PASSED");
}
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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
@ -40,14 +40,19 @@ import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.Calendar;
import java.util.stream.Stream;
import javax.sql.RowSet;
import javax.sql.rowset.serial.SerialArray;
import javax.sql.rowset.serial.SerialBlob;
import javax.sql.rowset.serial.SerialClob;
import javax.sql.rowset.serial.SerialRef;
import static org.testng.Assert.*;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import util.StubArray;
import util.StubBaseRowSet;
import util.StubBlob;
@ -67,7 +72,8 @@ public class BaseRowSetTests extends CommonRowSetTests {
/*
* Create a RowSetListener and validate that notifyCursorMoved is called
*/
@Test(dataProvider = "rowSetType")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("rowSetType")
public void baseRowSetTest0000(StubBaseRowSet rs) throws Exception {
TestRowSetListener rsl = new TestRowSetListener();
rs.addRowSetListener(rsl);
@ -78,7 +84,8 @@ public class BaseRowSetTests extends CommonRowSetTests {
/*
* Create a RowSetListener and validate that notifyRowChanged is called
*/
@Test(dataProvider = "rowSetType")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("rowSetType")
public void baseRowSetTest0001(StubBaseRowSet rs) throws Exception {
TestRowSetListener rsl = new TestRowSetListener();
rs.addRowSetListener(rsl);
@ -89,7 +96,8 @@ public class BaseRowSetTests extends CommonRowSetTests {
/*
* Create a RowSetListener and validate that notifyRowSetChanged is called
*/
@Test(dataProvider = "rowSetType")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("rowSetType")
public void baseRowSetTest0002(StubBaseRowSet rs) throws Exception {
TestRowSetListener rsl = new TestRowSetListener();
rs.addRowSetListener(rsl);
@ -101,7 +109,8 @@ public class BaseRowSetTests extends CommonRowSetTests {
* Create multiple RowSetListeners and validate that notifyRowSetChanged
* is called on all listeners
*/
@Test(dataProvider = "rowSetType")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("rowSetType")
public void baseRowSetTest0003(StubBaseRowSet rs) throws Exception {
TestRowSetListener rsl = new TestRowSetListener();
TestRowSetListener rsl2 = new TestRowSetListener();
@ -116,7 +125,8 @@ public class BaseRowSetTests extends CommonRowSetTests {
* Create multiple RowSetListeners and validate that notifyRowChanged
* is called on all listeners
*/
@Test(dataProvider = "rowSetType")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("rowSetType")
public void baseRowSetTest0004(StubBaseRowSet rs) throws Exception {
TestRowSetListener rsl = new TestRowSetListener();
TestRowSetListener rsl2 = new TestRowSetListener();
@ -131,7 +141,8 @@ public class BaseRowSetTests extends CommonRowSetTests {
* Create multiple RowSetListeners and validate that notifyCursorMoved
* is called on all listeners
*/
@Test(dataProvider = "rowSetType")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("rowSetType")
public void baseRowSetTest0005(StubBaseRowSet rs) throws Exception {
TestRowSetListener rsl = new TestRowSetListener();
TestRowSetListener rsl2 = new TestRowSetListener();
@ -146,7 +157,8 @@ public class BaseRowSetTests extends CommonRowSetTests {
* Create a RowSetListener and validate that notifyRowSetChanged,
* notifyRowChanged() and notifyCursorMoved are called
*/
@Test(dataProvider = "rowSetType")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("rowSetType")
public void baseRowSetTest0006(StubBaseRowSet rs) throws Exception {
TestRowSetListener rsl = new TestRowSetListener();
rs.addRowSetListener(rsl);
@ -163,7 +175,8 @@ public class BaseRowSetTests extends CommonRowSetTests {
* Create multiple RowSetListeners and validate that notifyRowSetChanged,
* notifyRowChanged() and notifyCursorMoved are called on all listeners
*/
@Test(dataProvider = "rowSetType")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("rowSetType")
public void baseRowSetTest0007(StubBaseRowSet rs) throws Exception {
TestRowSetListener rsl = new TestRowSetListener();
TestRowSetListener rsl2 = new TestRowSetListener();
@ -185,7 +198,8 @@ public class BaseRowSetTests extends CommonRowSetTests {
* remove the listener, invoke notifyRowSetChanged again and verify the
* listner is not called
*/
@Test(dataProvider = "rowSetType")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("rowSetType")
public void baseRowSetTest0008(StubBaseRowSet rs) throws Exception {
TestRowSetListener rsl = new TestRowSetListener();
rs.addRowSetListener(rsl);
@ -202,7 +216,8 @@ public class BaseRowSetTests extends CommonRowSetTests {
* Set the base parameters and validate that the value set is
* the correct type and value
*/
@Test(dataProvider = "testBaseParameters")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("testBaseParameters")
public void baseRowSetTest0009(int pos, Object o) throws Exception {
assertTrue(getParam(pos, o).getClass().isInstance(o));
assertTrue(o.equals(getParam(pos, o)));
@ -212,7 +227,8 @@ public class BaseRowSetTests extends CommonRowSetTests {
* Set the complex parameters and validate that the value set is
* the correct type
*/
@Test(dataProvider = "testAdvancedParameters")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("testAdvancedParameters")
public void baseRowSetTest0010(int pos, Object o) throws Exception {
assertTrue(getParam(pos, o).getClass().isInstance(o));
}
@ -220,7 +236,8 @@ public class BaseRowSetTests extends CommonRowSetTests {
/*
* Validate setNull specifying the supported type values
*/
@Test(dataProvider = "jdbcTypes")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("jdbcTypes")
public void baseRowSetTest0011(Integer type) throws Exception {
brs = new StubBaseRowSet();
brs.setNull(1, type);
@ -231,7 +248,8 @@ public class BaseRowSetTests extends CommonRowSetTests {
* Validate setNull specifying the supported type values and that
* typeName is set internally
*/
@Test(dataProvider = "jdbcTypes")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("jdbcTypes")
public void baseRowSetTest0012(Integer type) throws Exception {
brs = new StubBaseRowSet();
brs.setNull(1, type, "SUPERHERO");
@ -274,7 +292,8 @@ public class BaseRowSetTests extends CommonRowSetTests {
/*
* Validate that initParams() initializes the parameters
*/
@Test(dataProvider = "rowSetType")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("rowSetType")
public void baseRowSetTest0016(StubBaseRowSet rs) throws Exception {
rs.setInt(1, 1);
rs.initParams();
@ -285,8 +304,7 @@ public class BaseRowSetTests extends CommonRowSetTests {
/*
* DataProvider used to set parameters for basic types that are supported
*/
@DataProvider(name = "testBaseParameters")
private Object[][] testBaseParameters() throws SQLException {
private Stream<Arguments> testBaseParameters() throws SQLException {
Integer aInt = 1;
Long aLong = Long.MAX_VALUE;
Short aShort = Short.MIN_VALUE;
@ -320,34 +338,32 @@ public class BaseRowSetTests extends CommonRowSetTests {
brs.setObject(17, query, Types.CHAR);
brs.setObject(18, query, Types.CHAR, 0);
return new Object[][]{
{1, aInt},
{2, query},
{3, aLong},
{4, aBoolean},
{5, aShort},
{6, aDouble},
{7, bd},
{8, aFloat},
{9, aByte},
{10, aDate},
{11, aTime},
{12, aTimeStamp},
{13, aDate},
{14, aTime},
{15, aTimeStamp},
{16, query},
{17, query},
{18, query}
};
return Stream.of(
Arguments.of(1, aInt),
Arguments.of(2, query),
Arguments.of(3, aLong),
Arguments.of(4, aBoolean),
Arguments.of(5, aShort),
Arguments.of(6, aDouble),
Arguments.of(7, bd),
Arguments.of(8, aFloat),
Arguments.of(9, aByte),
Arguments.of(10, aDate),
Arguments.of(11, aTime),
Arguments.of(12, aTimeStamp),
Arguments.of(13, aDate),
Arguments.of(14, aTime),
Arguments.of(15, aTimeStamp),
Arguments.of(16, query),
Arguments.of(17, query),
Arguments.of(18, query)
);
}
/*
* DataProvider used to set advanced parameters for types that are supported
*/
@DataProvider(name = "testAdvancedParameters")
private Object[][] testAdvancedParameters() throws SQLException {
private Stream<Arguments> testAdvancedParameters() throws SQLException {
byte[] bytes = new byte[10];
Ref aRef = new SerialRef(new StubRef("INTEGER", query));
@ -367,17 +383,17 @@ public class BaseRowSetTests extends CommonRowSetTests {
brs.setUnicodeStream(8, is, query.length());
brs.setCharacterStream(9, rdr, query.length());
return new Object[][]{
{1, bytes},
{2, is},
{3, aRef},
{4, aArray},
{5, aBlob},
{6, aClob},
{7, is},
{8, is},
{9, rdr}
};
return Stream.of(
Arguments.of(1, bytes),
Arguments.of(2, is),
Arguments.of(3, aRef),
Arguments.of(4, aArray),
Arguments.of(5, aBlob),
Arguments.of(6, aClob),
Arguments.of(7, is),
Arguments.of(8, is),
Arguments.of(9, rdr)
);
}
/*

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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
@ -23,11 +23,15 @@
package test.rowset;
import java.sql.SQLException;
import java.util.stream.Stream;
import javax.sql.rowset.RowSetFactory;
import javax.sql.rowset.RowSetProvider;
import static org.testng.Assert.*;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import util.BaseTest;
public class RowSetFactoryTests extends BaseTest {
@ -50,7 +54,8 @@ public class RowSetFactoryTests extends BaseTest {
* Validate that the RowSetFactory returned by RowSetProvider.newFactory()
* returns the correct RowSet implementations
*/
@Test(dataProvider = "RowSetValues", enabled = true)
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("RowSetValues")
public void test(RowSetFactory rsf, String impl) throws SQLException {
validateRowSetImpl(rsf, impl);
}
@ -98,22 +103,20 @@ public class RowSetFactoryTests extends BaseTest {
* DataProvider used to provide the RowSetFactory and the RowSet
* implementation that should be returned
*/
@DataProvider(name = "RowSetValues")
private Object[][] RowSetValues() throws SQLException {
private Stream<Arguments> RowSetValues() throws SQLException {
RowSetFactory rsf = RowSetProvider.newFactory();
RowSetFactory rsf1 = RowSetProvider.newFactory(STUB_FACTORY_CLASSNAME, null);
return new Object[][]{
{rsf, DEFAULT_CACHEDROWSET_CLASSNAME},
{rsf, DEFAULT_FILTEREDROWSET_CLASSNAME},
{rsf, DEFAULT_JDBCROWSET_CLASSNAME},
{rsf, DEFAULT_JOINROWSET_CLASSNAME},
{rsf, DEFAULT_WEBROWSET_CLASSNAME},
{rsf1, STUB_CACHEDROWSET_CLASSNAME},
{rsf1, STUB_FILTEREDROWSET_CLASSNAME},
{rsf1, STUB_JDBCROWSET_CLASSNAME},
{rsf1, STUB_JOINROWSET_CLASSNAME},
{rsf1, STUB_WEBROWSET_CLASSNAME}
};
return Stream.of(
Arguments.of(rsf, DEFAULT_CACHEDROWSET_CLASSNAME),
Arguments.of(rsf, DEFAULT_FILTEREDROWSET_CLASSNAME),
Arguments.of(rsf, DEFAULT_JDBCROWSET_CLASSNAME),
Arguments.of(rsf, DEFAULT_JOINROWSET_CLASSNAME),
Arguments.of(rsf, DEFAULT_WEBROWSET_CLASSNAME),
Arguments.of(rsf1, STUB_CACHEDROWSET_CLASSNAME),
Arguments.of(rsf1, STUB_FILTEREDROWSET_CLASSNAME),
Arguments.of(rsf1, STUB_JDBCROWSET_CLASSNAME),
Arguments.of(rsf1, STUB_JOINROWSET_CLASSNAME),
Arguments.of(rsf1, STUB_WEBROWSET_CLASSNAME)
);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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
@ -25,12 +25,19 @@ package test.rowset;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Types;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import javax.sql.RowSetMetaData;
import javax.sql.rowset.RowSetMetaDataImpl;
import static org.testng.Assert.*;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.junit.jupiter.params.provider.ValueSource;
import util.BaseTest;
public class RowSetMetaDataTests extends BaseTest {
@ -40,7 +47,7 @@ public class RowSetMetaDataTests extends BaseTest {
// Instance to be used within the tests
private RowSetMetaDataImpl rsmd;
@BeforeMethod
@BeforeEach
public void setUpMethod() throws Exception {
rsmd = new RowSetMetaDataImpl();
rsmd.setColumnCount(MAX_COLUMNS);
@ -49,325 +56,325 @@ public class RowSetMetaDataTests extends BaseTest {
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("invalidColumnRanges")
public void test(Integer col) throws Exception {
rsmd.getCatalogName(col);
assertThrows(SQLException.class, () -> rsmd.getCatalogName(col));
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("invalidColumnRanges")
public void test01(Integer col) throws Exception {
rsmd.getColumnClassName(col);
assertThrows(SQLException.class, () -> rsmd.getColumnClassName(col));
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("invalidColumnRanges")
public void test02(Integer col) throws Exception {
rsmd.getColumnDisplaySize(col);
assertThrows(SQLException.class, () -> rsmd.getColumnDisplaySize(col));
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("invalidColumnRanges")
public void test03(Integer col) throws Exception {
rsmd.getColumnLabel(col);
assertThrows(SQLException.class, () -> rsmd.getColumnLabel(col));
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("invalidColumnRanges")
public void test04(Integer col) throws Exception {
rsmd.getColumnName(col);
assertThrows(SQLException.class, () -> rsmd.getColumnName(col));
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("invalidColumnRanges")
public void test05(Integer col) throws Exception {
rsmd.getColumnType(col);
assertThrows(SQLException.class, () -> rsmd.getColumnType(col));
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("invalidColumnRanges")
public void test06(Integer col) throws Exception {
rsmd.getColumnTypeName(col);
assertThrows(SQLException.class, () -> rsmd.getColumnTypeName(col));
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("invalidColumnRanges")
public void test07(Integer col) throws Exception {
rsmd.getPrecision(col);
assertThrows(SQLException.class, () -> rsmd.getPrecision(col));
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("invalidColumnRanges")
public void test08(Integer col) throws Exception {
rsmd.getScale(col);
assertThrows(SQLException.class, () -> rsmd.getScale(col));
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("invalidColumnRanges")
public void test09(Integer col) throws Exception {
rsmd.getSchemaName(col);
assertThrows(SQLException.class, () -> rsmd.getSchemaName(col));
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("invalidColumnRanges")
public void test10(Integer col) throws Exception {
rsmd.getTableName(col);
assertThrows(SQLException.class, () -> rsmd.getTableName(col));
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("invalidColumnRanges")
public void test11(Integer col) throws Exception {
rsmd.isAutoIncrement(col);
assertThrows(SQLException.class, () -> rsmd.isAutoIncrement(col));
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("invalidColumnRanges")
public void test12(Integer col) throws Exception {
rsmd.isCaseSensitive(col);
assertThrows(SQLException.class, () -> rsmd.isCaseSensitive(col));
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("invalidColumnRanges")
public void test13(Integer col) throws Exception {
rsmd.isCurrency(col);
assertThrows(SQLException.class, () -> rsmd.isCurrency(col));
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("invalidColumnRanges")
public void test14(Integer col) throws Exception {
rsmd.isDefinitelyWritable(col);
assertThrows(SQLException.class, () -> rsmd.isDefinitelyWritable(col));
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("invalidColumnRanges")
public void test15(Integer col) throws Exception {
rsmd.isNullable(col);
assertThrows(SQLException.class, () -> rsmd.isNullable(col));
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("invalidColumnRanges")
public void test16(Integer col) throws Exception {
rsmd.isReadOnly(col);
assertThrows(SQLException.class, () -> rsmd.isReadOnly(col));
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("invalidColumnRanges")
public void test17(Integer col) throws Exception {
rsmd.isSearchable(col);
assertThrows(SQLException.class, () -> rsmd.isSearchable(col));
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("invalidColumnRanges")
public void test18(Integer col) throws Exception {
rsmd.isSigned(col);
assertThrows(SQLException.class, () -> rsmd.isSigned(col));
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("invalidColumnRanges")
public void test19(Integer col) throws Exception {
rsmd.isWritable(col);
assertThrows(SQLException.class, () -> rsmd.isWritable(col));
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("invalidColumnRanges")
public void test20(Integer col) throws Exception {
rsmd.setAutoIncrement(col, true);
assertThrows(SQLException.class, () -> rsmd.setAutoIncrement(col, true));
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("invalidColumnRanges")
public void test21(Integer col) throws Exception {
rsmd.setCaseSensitive(col, true);
assertThrows(SQLException.class, () -> rsmd.setCaseSensitive(col, true));
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("invalidColumnRanges")
public void test22(Integer col) throws Exception {
rsmd.setCatalogName(col, null);
assertThrows(SQLException.class, () -> rsmd.setCatalogName(col, null));
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("invalidColumnRanges")
public void test23(Integer col) throws Exception {
rsmd.setColumnDisplaySize(col, 5);
assertThrows(SQLException.class, () -> rsmd.setColumnDisplaySize(col, 5));
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("invalidColumnRanges")
public void test24(Integer col) throws Exception {
rsmd.setColumnLabel(col, "label");
assertThrows(SQLException.class, () -> rsmd.setColumnLabel(col, "label"));
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("invalidColumnRanges")
public void test25(Integer col) throws Exception {
rsmd.setColumnName(col, "F1");
assertThrows(SQLException.class, () -> rsmd.setColumnName(col, "F1"));
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("invalidColumnRanges")
public void test26(Integer col) throws Exception {
rsmd.setColumnType(col, Types.CHAR);
assertThrows(SQLException.class, () -> rsmd.setColumnType(col, Types.CHAR));
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("invalidColumnRanges")
public void test27(Integer col) throws Exception {
rsmd.setColumnTypeName(col, "F1");
assertThrows(SQLException.class, () -> rsmd.setColumnTypeName(col, "F1"));
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("invalidColumnRanges")
public void test28(Integer col) throws Exception {
rsmd.setCurrency(col, true);
assertThrows(SQLException.class, () -> rsmd.setCurrency(col, true));
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("invalidColumnRanges")
public void test29(Integer col) throws Exception {
rsmd.setNullable(col, ResultSetMetaData.columnNoNulls);
assertThrows(SQLException.class, () -> rsmd.setNullable(col, ResultSetMetaData.columnNoNulls));
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("invalidColumnRanges")
public void test30(Integer col) throws Exception {
rsmd.setPrecision(col, 2);
assertThrows(SQLException.class, () -> rsmd.setPrecision(col, 2));
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("invalidColumnRanges")
public void test31(Integer col) throws Exception {
rsmd.setScale(col, 2);
assertThrows(SQLException.class, () -> rsmd.setScale(col, 2));
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("invalidColumnRanges")
public void test32(Integer col) throws Exception {
rsmd.setSchemaName(col, "Gotham");
assertThrows(SQLException.class, () -> rsmd.setSchemaName(col, "Gotham"));
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("invalidColumnRanges")
public void test33(Integer col) throws Exception {
rsmd.setSearchable(col, false);
assertThrows(SQLException.class, () -> rsmd.setSearchable(col, false));
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("invalidColumnRanges")
public void test34(Integer col) throws Exception {
rsmd.setSigned(col, false);
assertThrows(SQLException.class, () -> rsmd.setSigned(col, false));
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("invalidColumnRanges")
public void test35(Integer col) throws Exception {
rsmd.setTableName(col, "SUPERHEROS");
assertThrows(SQLException.class, () -> rsmd.setTableName(col, "SUPERHEROS"));
}
/*
@ -375,7 +382,8 @@ public class RowSetMetaDataTests extends BaseTest {
* Note: Once setColumnClassName is added to RowSetMetaData, this
* method will need to change.
*/
@Test(dataProvider = "columnClassNames")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("columnClassNames")
public void test36(Integer type, String name) throws Exception {
rsmd.setColumnType(1, type);
assertTrue(rsmd.getColumnClassName(1).equals(name));
@ -385,7 +393,8 @@ public class RowSetMetaDataTests extends BaseTest {
* Validate that all of the methods are accessible and the correct value
* is returned for each column
*/
@Test(dataProvider = "columnRanges")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("columnRanges")
public void test37(Integer col) throws Exception {
rsmd.setAutoIncrement(col, true);
assertTrue(rsmd.isAutoIncrement(col));
@ -429,7 +438,8 @@ public class RowSetMetaDataTests extends BaseTest {
/*
* Validate that the proper values are accepted by setNullable
*/
@Test(dataProvider = "validSetNullableValues")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("validSetNullableValues")
public void test38(Integer val) throws Exception {
rsmd.setNullable(1, val);
}
@ -437,7 +447,8 @@ public class RowSetMetaDataTests extends BaseTest {
/*
* Validate that the correct type is returned for the column
*/
@Test(dataProvider = "jdbcTypes")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("jdbcTypes")
public void test39(Integer type) throws Exception {
rsmd.setColumnType(1, type);
assertTrue(type == rsmd.getColumnType(1));
@ -446,7 +457,8 @@ public class RowSetMetaDataTests extends BaseTest {
/*
* Validate that the correct value is returned from the isXXX methods
*/
@Test(dataProvider = "trueFalse")
@ParameterizedTest(autoCloseArguments = false)
@ValueSource(booleans = {true, false})
public void test40(Boolean b) throws Exception {
rsmd.setAutoIncrement(1, b);
rsmd.setCaseSensitive(1, b);
@ -483,73 +495,62 @@ public class RowSetMetaDataTests extends BaseTest {
* to validate that an IllegalArgumentException will be thrown from the
* valueOf method
*/
@DataProvider(name = "validSetNullableValues")
private Object[][] validSetNullableValues() {
return new Object[][]{
{ResultSetMetaData.columnNoNulls},
{ResultSetMetaData.columnNullable},
{ResultSetMetaData.columnNullableUnknown}
};
private Stream<Integer> validSetNullableValues() {
return Stream.of(
ResultSetMetaData.columnNoNulls,
ResultSetMetaData.columnNullable,
ResultSetMetaData.columnNullableUnknown
);
}
/*
* DataProvider used to provide column indexes that are out of range so that
* SQLException is thrown
*/
@DataProvider(name = "invalidColumnRanges")
private Object[][] invalidColumnRanges() {
return new Object[][]{
{-1},
{0},
{MAX_COLUMNS + 1}
};
private Stream<Integer> invalidColumnRanges() {
return Stream.of(
-1,
0,
MAX_COLUMNS + 1
);
}
/*
* DataProvider used to provide the valid column ranges for the
* RowSetMetaDataImpl object
*/
@DataProvider(name = "columnRanges")
private Object[][] columnRanges() {
Object[][] o = new Object[MAX_COLUMNS][1];
for (int i = 1; i <= MAX_COLUMNS; i++) {
o[i - 1][0] = i;
}
return o;
private Stream<Integer> columnRanges() {
return IntStream.rangeClosed(1, MAX_COLUMNS).boxed();
}
/*
* DataProvider used to specify the value to set via setColumnType and
* the expected value to be returned from getColumnClassName
*/
@DataProvider(name = "columnClassNames")
private Object[][] columnClassNames() {
return new Object[][]{
{Types.CHAR, "java.lang.String"},
{Types.NCHAR, "java.lang.String"},
{Types.VARCHAR, "java.lang.String"},
{Types.NVARCHAR, "java.lang.String"},
{Types.LONGVARCHAR, "java.lang.String"},
{Types.LONGNVARCHAR, "java.lang.String"},
{Types.NUMERIC, "java.math.BigDecimal"},
{Types.DECIMAL, "java.math.BigDecimal"},
{Types.BIT, "java.lang.Boolean"},
{Types.TINYINT, "java.lang.Byte"},
{Types.SMALLINT, "java.lang.Short"},
{Types.INTEGER, "java.lang.Integer"},
{Types.FLOAT, "java.lang.Double"},
{Types.DOUBLE, "java.lang.Double"},
{Types.BINARY, "byte[]"},
{Types.VARBINARY, "byte[]"},
{Types.LONGVARBINARY, "byte[]"},
{Types.DATE, "java.sql.Date"},
{Types.TIME, "java.sql.Time"},
{Types.TIMESTAMP, "java.sql.Timestamp"},
{Types.CLOB, "java.sql.Clob"},
{Types.BLOB, "java.sql.Blob"}
};
private Stream<Arguments> columnClassNames() {
return Stream.of(
Arguments.of(Types.CHAR, "java.lang.String"),
Arguments.of(Types.NCHAR, "java.lang.String"),
Arguments.of(Types.VARCHAR, "java.lang.String"),
Arguments.of(Types.NVARCHAR, "java.lang.String"),
Arguments.of(Types.LONGVARCHAR, "java.lang.String"),
Arguments.of(Types.LONGNVARCHAR, "java.lang.String"),
Arguments.of(Types.NUMERIC, "java.math.BigDecimal"),
Arguments.of(Types.DECIMAL, "java.math.BigDecimal"),
Arguments.of(Types.BIT, "java.lang.Boolean"),
Arguments.of(Types.TINYINT, "java.lang.Byte"),
Arguments.of(Types.SMALLINT, "java.lang.Short"),
Arguments.of(Types.INTEGER, "java.lang.Integer"),
Arguments.of(Types.FLOAT, "java.lang.Double"),
Arguments.of(Types.DOUBLE, "java.lang.Double"),
Arguments.of(Types.BINARY, "byte[]"),
Arguments.of(Types.VARBINARY, "byte[]"),
Arguments.of(Types.LONGVARBINARY, "byte[]"),
Arguments.of(Types.DATE, "java.sql.Date"),
Arguments.of(Types.TIME, "java.sql.Time"),
Arguments.of(Types.TIMESTAMP, "java.sql.Timestamp"),
Arguments.of(Types.CLOB, "java.sql.Clob"),
Arguments.of(Types.BLOB, "java.sql.Blob")
);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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
@ -27,14 +27,19 @@ import java.io.File;
import java.net.URL;
import java.net.URLClassLoader;
import java.sql.SQLException;
import java.util.stream.Stream;
import javax.sql.rowset.RowSetFactory;
import javax.sql.rowset.RowSetProvider;
import static org.testng.Assert.*;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import util.BaseTest;
import util.StubRowSetFactory;
@ -57,7 +62,7 @@ public class RowSetProviderTests extends BaseTest {
* Save off the original property value for javax.sql.rowset.RowSetFactory,
* original classloader and define the path to the jars directory
*/
@BeforeClass
@BeforeAll
public static void setUpClass() throws Exception {
origFactoryProperty = System.getProperty("javax.sql.rowset.RowSetFactory");
cl = Thread.currentThread().getContextClassLoader();
@ -68,7 +73,7 @@ public class RowSetProviderTests extends BaseTest {
/*
* Install the original javax.sql.rowset.RowSetFactory property value
*/
@AfterClass
@AfterAll
public static void tearDownClass() throws Exception {
if (origFactoryProperty != null) {
System.setProperty("javax.sql.rowset.RowSetFactory",
@ -80,7 +85,7 @@ public class RowSetProviderTests extends BaseTest {
* Clear the javax.sql.rowset.RowSetFactory property value and
* reset the classloader to its original value
*/
@AfterMethod
@AfterEach
public void tearDownMethod() throws Exception {
System.clearProperty("javax.sql.rowset.RowSetFactory");
Thread.currentThread().setContextClassLoader(cl);
@ -89,7 +94,8 @@ public class RowSetProviderTests extends BaseTest {
/*
* Validate that the correct RowSetFactory is returned by newFactory().
*/
@Test(dataProvider = "RowSetFactoryValues")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("RowSetFactoryValues")
public void test(RowSetFactory rsf, String impl) throws SQLException {
validateProvider(rsf, impl);
}
@ -109,7 +115,7 @@ public class RowSetProviderTests extends BaseTest {
* Validate that the correct RowSetFactory is returned by newFactory()
* when specified by the javax.sql.rowset.RowSetFactory property.
*/
@Test(enabled = true)
@Test
public void test02() throws SQLException {
System.setProperty("javax.sql.rowset.RowSetFactory", STUB_FACTORY_CLASSNAME);
validateProvider(RowSetProvider.newFactory(), STUB_FACTORY_CLASSNAME);
@ -120,11 +126,13 @@ public class RowSetProviderTests extends BaseTest {
* when specified RowSetFactory specified by the
* javax.sql.rowset.RowSetFactory property is not valid.
*/
@Test(expectedExceptions = SQLException.class)
@Test
public void test03() throws SQLException {
System.setProperty("javax.sql.rowset.RowSetFactory",
"invalid.RowSetFactoryImpl");
RowSetFactory rsf = RowSetProvider.newFactory();
assertThrows(SQLException.class, () -> {
System.setProperty("javax.sql.rowset.RowSetFactory",
"invalid.RowSetFactoryImpl");
RowSetFactory rsf = RowSetProvider.newFactory();
});
}
/*
@ -144,13 +152,15 @@ public class RowSetProviderTests extends BaseTest {
* Validate that a SQLException is thrown by newFactory() if the default
* RowSetFactory specified by the ServiceLoader API is not valid
*/
@Test(expectedExceptions = SQLException.class)
@Test
public void test05() throws Exception {
File f = new File(jarPath + "badFactory");
URLClassLoader loader = new URLClassLoader(new URL[]{
new URL(f.toURI().toString())}, getClass().getClassLoader());
Thread.currentThread().setContextClassLoader(loader);
RowSetProvider.newFactory();
assertThrows(SQLException.class, () -> {
File f = new File(jarPath + "badFactory");
URLClassLoader loader = new URLClassLoader(new URL[]{
new URL(f.toURI().toString())}, getClass().getClassLoader());
Thread.currentThread().setContextClassLoader(loader);
RowSetProvider.newFactory();
});
}
/*
@ -174,16 +184,15 @@ public class RowSetProviderTests extends BaseTest {
* DataProvider used to provide a RowSetFactory and the expected
* RowSetFactory implementation that should be returned
*/
@DataProvider(name = "RowSetFactoryValues")
private Object[][] RowSetFactoryValues() throws SQLException {
private Stream<Arguments> RowSetFactoryValues() throws SQLException {
RowSetFactory rsf = RowSetProvider.newFactory();
RowSetFactory rsf1 = RowSetProvider.newFactory(STUB_FACTORY_CLASSNAME, null);
RowSetFactory rsf2 = RowSetProvider.newFactory(DEFFAULT_FACTORY_CLASSNAME, null);
return new Object[][]{
{rsf, NO_VALADATE_IMPL},
{rsf, DEFFAULT_FACTORY_CLASSNAME},
{rsf1, STUB_FACTORY_CLASSNAME},
{rsf2, DEFFAULT_FACTORY_CLASSNAME}
};
return Stream.of(
Arguments.of(rsf, NO_VALADATE_IMPL),
Arguments.of(rsf, DEFFAULT_FACTORY_CLASSNAME),
Arguments.of(rsf1, STUB_FACTORY_CLASSNAME),
Arguments.of(rsf2, DEFFAULT_FACTORY_CLASSNAME)
);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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
@ -24,8 +24,10 @@ package test.rowset;
import java.sql.SQLException;
import javax.sql.rowset.RowSetWarning;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import util.BaseTest;
public class RowSetWarningTests extends BaseTest {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2026, 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

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2026, 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

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2026, 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
@ -26,24 +26,30 @@ import java.sql.SQLException;
import javax.sql.RowSet;
import javax.sql.rowset.FilteredRowSet;
import javax.sql.rowset.Predicate;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.junit.jupiter.api.AfterEach;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import test.rowset.webrowset.CommonWebRowSetTests;
public class FilteredRowSetTests extends CommonWebRowSetTests {
private FilteredRowSet frs;
@BeforeMethod
@BeforeEach
public void setUpMethod() throws Exception {
frs = createCoffeeHousesRowSet();
}
@AfterMethod
@AfterEach
public void tearDownMethod() throws Exception {
frs.close();
}
@ -83,7 +89,7 @@ public class FilteredRowSetTests extends CommonWebRowSetTests {
10023, 10040, 10042, 10024, 10039, 10041, 10035, 10037, 10034
};
frs.setFilter(new PrimaryKeyFilter(10000, 10999, 1));
assertEquals(getPrimaryKeys(frs), expectedKeys);
assertArrayEquals(expectedKeys, getPrimaryKeys(frs));
}
/*
@ -96,7 +102,7 @@ public class FilteredRowSetTests extends CommonWebRowSetTests {
10023, 10040, 10042, 10024, 10039, 10041, 10035, 10037, 10034
};
frs.setFilter(new PrimaryKeyFilter(10000, 10999, "STORE_ID"));
assertEquals(getPrimaryKeys(frs), expectedKeys);
assertArrayEquals(expectedKeys, getPrimaryKeys(frs));
}
@ -111,7 +117,7 @@ public class FilteredRowSetTests extends CommonWebRowSetTests {
};
String[] cityArray = {"SF", "LA"};
frs.setFilter(new CityFilter(cityArray, 2));
assertEquals(getPrimaryKeys(frs), expectedKeys);
assertArrayEquals(expectedKeys, getPrimaryKeys(frs));
}
/*
@ -125,14 +131,16 @@ public class FilteredRowSetTests extends CommonWebRowSetTests {
};
String[] cityArray = {"SF", "LA"};
frs.setFilter(new CityFilter(cityArray, "CITY"));
assertEquals(getPrimaryKeys(frs), expectedKeys);
assertArrayEquals(expectedKeys, getPrimaryKeys(frs));
}
// Tests that are common but need to be disabled due to an implementation bug
@Test(dataProvider = "rowSetType", enabled = false)
@Disabled
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("rowSetType")
public void commonCachedRowSetTest0043(RowSet rs) throws Exception {
// Need to fix bug in FilteredRowSets
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2026, 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

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2026, 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
@ -28,7 +28,9 @@ import java.sql.SQLException;
import javax.sql.rowset.JdbcRowSet;
import javax.sql.rowset.RowSetFactory;
import javax.sql.rowset.RowSetProvider;
import org.testng.annotations.Test;
import org.junit.jupiter.api.Test;
import util.BaseTest;
import util.StubDriver;
@ -41,7 +43,7 @@ public class JdbcRowSetDriverManagerTest extends BaseTest {
* Validate that JDBCRowSetImpl can connect to a JDBC driver that is
* register by DriverManager.
*/
@Test(enabled = true)
@Test
public void test0000() throws SQLException {
DriverManager.registerDriver(new StubDriver());

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2026, 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
@ -26,16 +26,22 @@ import java.sql.SQLException;
import java.sql.Types;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;
import javax.sql.RowSet;
import javax.sql.rowset.CachedRowSet;
import javax.sql.rowset.JoinRowSet;
import javax.sql.rowset.RowSetMetaDataImpl;
import javax.sql.rowset.WebRowSet;
import static org.testng.Assert.assertEquals;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import test.rowset.webrowset.CommonWebRowSetTests;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
public class JoinRowSetTests extends CommonWebRowSetTests {
private final String SUPPLIERS_TABLE = "SUPPLIERS";
@ -150,8 +156,7 @@ public class JoinRowSetTests extends CommonWebRowSetTests {
/*
* DataProvider used to set parameters for basic types that are supported
*/
@DataProvider(name = "createCachedRowSetsToUse")
private Object[][] createCachedRowSetsToUse() throws SQLException {
private Stream<Arguments> createCachedRowSetsToUse() throws SQLException {
CachedRowSet crs = rsf.createCachedRowSet();
initCoffeesMetaData(crs);
createCoffeesRows(crs);
@ -162,9 +167,7 @@ public class JoinRowSetTests extends CommonWebRowSetTests {
createSuppiersRows(crs1);
// Make sure you are not on the insertRow
crs1.moveToCurrentRow();
return new Object[][]{
{crs, crs1}
};
return Stream.of(Arguments.of(crs, crs1));
}
/*
@ -178,13 +181,14 @@ public class JoinRowSetTests extends CommonWebRowSetTests {
results.add(jrs.getInt("COF_ID"));
}
}
assertEquals(results.toArray(), EXPECTED);
assertArrayEquals(EXPECTED, results.toArray());
}
/*
* Join two CachedRowSets specifying a column name to join against
*/
@Test(dataProvider = "createCachedRowSetsToUse")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("createCachedRowSetsToUse")
public void joinRowSetTests0000(CachedRowSet crs, CachedRowSet crs1)
throws Exception {
@ -200,7 +204,8 @@ public class JoinRowSetTests extends CommonWebRowSetTests {
/*
* Join two CachedRowSets specifying a column index to join against
*/
@Test(dataProvider = "createCachedRowSetsToUse")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("createCachedRowSetsToUse")
public void joinRowSetTests0001(CachedRowSet crs, CachedRowSet crs1)
throws Exception {
@ -216,7 +221,8 @@ public class JoinRowSetTests extends CommonWebRowSetTests {
/*
* Join two CachedRowSets specifying a column name to join against
*/
@Test(dataProvider = "createCachedRowSetsToUse")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("createCachedRowSetsToUse")
public void joinRowSetTests0002(CachedRowSet crs, CachedRowSet crs1)
throws Exception {
@ -233,7 +239,8 @@ public class JoinRowSetTests extends CommonWebRowSetTests {
/*
* Join two CachedRowSets specifying a column index to join against
*/
@Test(dataProvider = "createCachedRowSetsToUse")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("createCachedRowSetsToUse")
public void joinRowSetTests0003(CachedRowSet crs, CachedRowSet crs1)
throws Exception {
@ -251,7 +258,8 @@ public class JoinRowSetTests extends CommonWebRowSetTests {
/*
* Join two CachedRowSets specifying a column name to join against
*/
@Test(dataProvider = "createCachedRowSetsToUse")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("createCachedRowSetsToUse")
public void joinRowSetTests0005(CachedRowSet crs, CachedRowSet crs1)
throws Exception {
@ -269,7 +277,8 @@ public class JoinRowSetTests extends CommonWebRowSetTests {
/*
* Join two CachedRowSets specifying a column index to join against
*/
@Test(dataProvider = "createCachedRowSetsToUse")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("createCachedRowSetsToUse")
public void joinRowSetTests0006(CachedRowSet crs, CachedRowSet crs1)
throws Exception {
@ -286,39 +295,56 @@ public class JoinRowSetTests extends CommonWebRowSetTests {
}
// Disabled tests due to bugs in JoinRowSet
@Test(dataProvider = "rowSetType", enabled = false)
@Disabled
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("rowSetType")
public void commonCachedRowSetTest0004(CachedRowSet rs) throws Exception {
}
@Test(dataProvider = "rowSetType", enabled = false)
@Disabled
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("rowSetType")
public void commonCachedRowSetTest0005(CachedRowSet rs) throws Exception {
}
@Test(dataProvider = "rowSetType", enabled = false)
@Disabled
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("rowSetType")
public void commonCachedRowSetTest0008(CachedRowSet rs) throws Exception {
}
@Test(dataProvider = "rowSetType", enabled = false)
@Disabled
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("rowSetType")
public void commonCachedRowSetTest0026(CachedRowSet rs) throws Exception {
}
@Test(dataProvider = "rowSetType", enabled = false)
@Disabled
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("rowSetType")
public void commonCachedRowSetTest0027(CachedRowSet rs) throws Exception {
}
@Test(dataProvider = "rowSetType", enabled = false)
@Disabled
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("rowSetType")
public void commonCachedRowSetTest0053(CachedRowSet rs) throws Exception {
}
@Test(dataProvider = "rowSetType", enabled = false)
@Disabled
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("rowSetType")
public void commonCachedRowSetTest0054(CachedRowSet rs) throws Exception {
}
@Test(dataProvider = "rowSetType", enabled = false)
@Disabled
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("rowSetType")
public void commonCachedRowSetTest0055(CachedRowSet rs) throws Exception {
}
@Test(dataProvider = "rowSetType")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("rowSetType")
public void WebRowSetTest0009(WebRowSet wrs1) throws Exception {
}
}

View File

@ -0,0 +1,2 @@
# Enabled for ValidateGetBundle.java
modules = java.sql.rowset/com.sun.rowset:+open

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2026, 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
@ -20,6 +20,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package test.rowset.resourcebundle;
import com.sun.rowset.JdbcRowSetResourceBundle;
@ -35,8 +36,6 @@ import org.junit.jupiter.params.provider.Arguments;
* @test
* @bug 8294989
* @summary Check JDBC RowSet resource bundle access
* @modules java.sql.rowset/com.sun.rowset:+open
* @run junit/othervm ValidateGetBundle
*/
public class ValidateGetBundle{

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2026, 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
@ -20,21 +20,21 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package test.rowset;
package test.rowset.resourcebundle;
import java.util.Locale;
import java.sql.SQLException;
import javax.sql.rowset.RowSetProvider;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeClass;
import static org.testng.Assert.*;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
/**
* @test
* @bug 8294989
* @summary Check that the resource bundle can be accessed
* @throws SQLException if an unexpected error occurs
* @run testng/othervm
*/
public class ValidateResourceBundleAccess{
// Expected JDBCResourceBundle message, jdbcrowsetimpl.invalstate
@ -43,8 +43,8 @@ public class ValidateResourceBundleAccess{
private static final String RSREADERERROR = "Internal Error in RowSetReader: no connection or command";
// Checking against English messages, set to US Locale
@BeforeClass
public void setEnglishEnvironment() {
@BeforeAll
public static void setEnglishEnvironment() {
Locale.setDefault(Locale.US);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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
@ -33,9 +33,11 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import javax.sql.rowset.serial.SQLInputImpl;
import static org.testng.Assert.*;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import util.BaseTest;
import util.StubArray;
import util.StubBlob;
@ -54,7 +56,7 @@ public class SQLInputImplTests extends BaseTest {
private SuperHero hero;
private final String sqlType = "SUPERHERO";
@BeforeMethod
@BeforeEach
public void setUpMethod() throws Exception {
map = new HashMap<>();
impl = new TestSQLDataImpl("TestSQLData");
@ -68,18 +70,22 @@ public class SQLInputImplTests extends BaseTest {
* Validate that a SQLException is thrown if the attribute value is
* null
*/
@Test(expectedExceptions = SQLException.class)
@Test
public void test() throws Exception {
SQLInputImpl x = new SQLInputImpl(null, map);
assertThrows(SQLException.class, () -> {
SQLInputImpl x = new SQLInputImpl(null, map);
});
}
/*
* Validate that a SQLException is thrown if the map value is
* null
*/
@Test(expectedExceptions = SQLException.class)
@Test
public void test02() throws Exception {
SQLInputImpl x = new SQLInputImpl(typeValues, null);
assertThrows(SQLException.class, () -> {
SQLInputImpl x = new SQLInputImpl(typeValues, null);
});
}
/*
@ -124,7 +130,7 @@ public class SQLInputImplTests extends BaseTest {
/*
* Validate a Array can be read
*/
@Test(enabled = true)
@Test
public void test06() throws Exception {
Object[] coffees = new Object[]{"Espresso", "Colombian", "French Roast",
"Cappuccino"};
@ -139,7 +145,7 @@ public class SQLInputImplTests extends BaseTest {
/*
* Validate a Blob can be read
*/
@Test(enabled = true)
@Test
public void test07() throws Exception {
Blob b = new StubBlob();
Object[] values = {b};
@ -153,7 +159,7 @@ public class SQLInputImplTests extends BaseTest {
/*
* Validate a Clob can be read
*/
@Test(enabled = true)
@Test
public void test08() throws Exception {
Clob c = new StubClob();
Object[] values = {c};
@ -166,7 +172,7 @@ public class SQLInputImplTests extends BaseTest {
/*
* Validate a Ref can be read
*/
@Test(enabled = true)
@Test
public void test09() throws Exception {
Ref ref = new StubRef(sqlType, hero);
Object[] values = {ref};
@ -179,7 +185,7 @@ public class SQLInputImplTests extends BaseTest {
/*
* Validate a URL can be read
*/
@Test(enabled = true)
@Test
public void test10() throws Exception {
URL u = new URL("http://www.oracle.com/");
Object[] values = {u};

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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
@ -41,9 +41,11 @@ import javax.sql.rowset.serial.SerialClob;
import javax.sql.rowset.serial.SerialDatalink;
import javax.sql.rowset.serial.SerialRef;
import javax.sql.rowset.serial.SerialStruct;
import static org.testng.Assert.*;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import util.BaseTest;
import util.StubArray;
import util.StubBlob;
@ -64,7 +66,7 @@ public class SQLOutputImplTests extends BaseTest {
private SuperHero hero;
private SQLOutputImpl outImpl;
@BeforeMethod
@BeforeEach
public void setUpMethod() throws Exception {
results = new Vector();
impl = new TestSQLDataImpl("TestSQLData");
@ -78,18 +80,22 @@ public class SQLOutputImplTests extends BaseTest {
* Validate that a SQLException is thrown if the attribute value is
* null
*/
@Test(expectedExceptions = SQLException.class)
@Test
public void test() throws Exception {
SQLOutputImpl x = new SQLOutputImpl(null, map);
assertThrows(SQLException.class, () -> {
SQLOutputImpl x = new SQLOutputImpl(null, map);
});
}
/*
* Validate that a SQLException is thrown if the map value is
* null
*/
@Test(expectedExceptions = SQLException.class)
@Test
public void test02() throws Exception {
SQLOutputImpl x = new SQLOutputImpl(results, null);
assertThrows(SQLException.class, () -> {
SQLOutputImpl x = new SQLOutputImpl(results, null);
});
}
/*
@ -109,7 +115,7 @@ public class SQLOutputImplTests extends BaseTest {
/*
* Validate a Array can be written and returned
*/
@Test(enabled = true)
@Test
public void test04() throws Exception {
Object[] coffees = new Object[]{"Espresso", "Colombian", "French Roast",
"Cappuccino"};
@ -123,7 +129,7 @@ public class SQLOutputImplTests extends BaseTest {
/*
* Validate a Blob can be written and returned
*/
@Test(enabled = true)
@Test
public void test05() throws Exception {
Blob b = new StubBlob();
outImpl.writeBlob(b);
@ -136,7 +142,7 @@ public class SQLOutputImplTests extends BaseTest {
/*
* Validate a Clob can be written and returned
*/
@Test(enabled = true)
@Test
public void test06() throws Exception {
Clob c = new StubClob();
outImpl.writeClob(c);
@ -148,7 +154,7 @@ public class SQLOutputImplTests extends BaseTest {
/*
* Validate a Ref can be written and returned
*/
@Test(enabled = true)
@Test
public void test07() throws Exception {
Ref ref = new StubRef(sqlType, hero);
outImpl.writeRef(ref);
@ -159,7 +165,7 @@ public class SQLOutputImplTests extends BaseTest {
/*
* Validate a Struct can be written and returned
*/
@Test(enabled = true)
@Test
public void test08() throws Exception {
Object[] attributes = new Object[]{"Bruce", "Wayne", 1939,
"Batman"};
@ -173,7 +179,7 @@ public class SQLOutputImplTests extends BaseTest {
/*
* Validate a DataLink can be written and returned
*/
@Test(enabled = true)
@Test
public void test09() throws Exception {
URL u = new URL("http://www.oracle.com/");
outImpl.writeURL(u);
@ -186,7 +192,7 @@ public class SQLOutputImplTests extends BaseTest {
/*
* Validate an Object implementing SQLData can be written and returned
*/
@Test(enabled = true)
@Test
public void test10() throws Exception {
Object[] attributes = new Object[]{"Bruce", "Wayne", 1939,
"Batman"};

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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
@ -29,9 +29,11 @@ import java.util.HashMap;
import java.util.Map;
import javax.sql.rowset.serial.SerialArray;
import javax.sql.rowset.serial.SerialException;
import static org.testng.Assert.*;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import util.BaseTest;
import util.StubArray;
@ -42,7 +44,7 @@ public class SerialArrayTests extends BaseTest {
private Array a;
private Map<String, Class<?>> map;
@BeforeMethod
@BeforeEach
public void setUpMethod() throws Exception {
coffees = new Object[]{"Espresso", "Colombian", "French Roast",
"Cappuccino"};
@ -61,111 +63,133 @@ public class SerialArrayTests extends BaseTest {
/*
* Validate a SQLException is thrown if the map is null
*/
@Test(expectedExceptions = SQLException.class)
@Test
public void test02() throws Exception {
SerialArray sa = new SerialArray(a, null);
assertThrows(SQLException.class, () -> {
SerialArray sa = new SerialArray(a, null);
});
}
/*
* Validate a SerialException is thrown when getResultSet() is called
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test03() throws Exception {
SerialArray sa = new SerialArray(a);
sa.getResultSet();
assertThrows(SerialException.class, () -> {
SerialArray sa = new SerialArray(a);
sa.getResultSet();
});
}
/*
* Validate a SerialException is thrown when getResultSet() is called
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test04() throws Exception {
SerialArray sa = new SerialArray(a);
sa.getResultSet(null);
assertThrows(SerialException.class, () -> {
SerialArray sa = new SerialArray(a);
sa.getResultSet(null);
});
}
/*
* Validate a SerialException is thrown when getResultSet() is called
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test05() throws Exception {
SerialArray sa = new SerialArray(a);
sa.getResultSet(1, 1);
assertThrows(SerialException.class, () -> {
SerialArray sa = new SerialArray(a);
sa.getResultSet(1, 1);
});
}
/*
* Validate a SerialException is thrown when getResultSet() is called
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test06() throws Exception {
SerialArray sa = new SerialArray(a);
sa.getResultSet(1, 1, null);
assertThrows(SerialException.class, () -> {
SerialArray sa = new SerialArray(a);
sa.getResultSet(1, 1, null);
});
}
/*
* Validate a SerialException is thrown when getArray() is invoked after
* free() is called
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test07() throws Exception {
SerialArray sa = new SerialArray(a);
sa.free();
sa.getArray();
assertThrows(SerialException.class, () -> {
SerialArray sa = new SerialArray(a);
sa.free();
sa.getArray();
});
}
/*
* Validate a SerialException is thrown when getArray() is invoked after
* free() is called
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test08() throws Exception {
SerialArray sa = new SerialArray(a);
sa.free();
sa.getArray(map);
assertThrows(SerialException.class, () -> {
SerialArray sa = new SerialArray(a);
sa.free();
sa.getArray(map);
});
}
/*
* Validate a SerialException is thrown when getArray() is invoked after
* free() is called
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test09() throws Exception {
SerialArray sa = new SerialArray(a);
sa.free();
sa.getArray(1, 1, map);
assertThrows(SerialException.class, () -> {
SerialArray sa = new SerialArray(a);
sa.free();
sa.getArray(1, 1, map);
});
}
/*
* Validate a SerialException is thrown when getArray() is invoked after
* free() is called
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test10() throws Exception {
SerialArray sa = new SerialArray(a);
sa.free();
sa.getArray(1, 1);
assertThrows(SerialException.class, () -> {
SerialArray sa = new SerialArray(a);
sa.free();
sa.getArray(1, 1);
});
}
/*
* Validate a SerialException is thrown when getBaseType() is invoked after
* free() is called
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test11() throws Exception {
SerialArray sa = new SerialArray(a);
sa.free();
sa.getBaseType();
assertThrows(SerialException.class, () -> {
SerialArray sa = new SerialArray(a);
sa.free();
sa.getBaseType();
});
}
/*
* Validate a SerialException is thrown when getBaseTypeName() is invoked after
* free() is called
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test12() throws Exception {
SerialArray sa = new SerialArray(a);
sa.free();
sa.getBaseTypeName();
assertThrows(SerialException.class, () -> {
SerialArray sa = new SerialArray(a);
sa.free();
sa.getBaseTypeName();
});
}
/*

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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
@ -24,11 +24,14 @@ package test.rowset.serial;
import java.io.InputStream;
import java.io.OutputStream;
import java.sql.SQLException;
import java.util.Arrays;
import javax.sql.rowset.serial.SerialBlob;
import javax.sql.rowset.serial.SerialException;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import util.BaseTest;
import util.StubBlob;
@ -37,6 +40,16 @@ public class SerialBlobTests extends BaseTest {
// byte[] used to populate SerialBlob
private byte[] bytes = new byte[]{1, 2, 3, 4, 5};
/*
* Validate calling setBinaryStream() on a SerialBlob constructed from a
* byte array throws SerialException. Bug 7077451.
*/
@Test
void setBinaryStreamExceptionTest() throws SQLException {
SerialBlob blob = new SerialBlob(new byte[0]);
assertThrows(SerialException.class, () -> blob.setBinaryStream(0));
}
/*
* Validate calling free() does not throw an Exception
*/
@ -50,110 +63,130 @@ public class SerialBlobTests extends BaseTest {
* Validate calling getBinaryStream() after calling free() throws an
* SerialException
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test01() throws Exception {
SerialBlob sb = new SerialBlob(new StubBlob());
sb.free();
sb.getBinaryStream();
assertThrows(SerialException.class, () -> {
SerialBlob sb = new SerialBlob(new StubBlob());
sb.free();
sb.getBinaryStream();
});
}
/*
* Validate calling getBinaryStream() after calling free() throws an
* SerialException
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test02() throws Exception {
SerialBlob sb = new SerialBlob(new StubBlob());
sb.free();
sb.getBinaryStream(1, 5);
assertThrows(SerialException.class, () -> {
SerialBlob sb = new SerialBlob(new StubBlob());
sb.free();
sb.getBinaryStream(1, 5);
});
}
/*
* Validate calling getBytes() after calling free() throws an
* SerialException
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test03() throws Exception {
SerialBlob sb = new SerialBlob(new StubBlob());
sb.free();
sb.getBytes(1, 1);
assertThrows(SerialException.class, () -> {
SerialBlob sb = new SerialBlob(new StubBlob());
sb.free();
sb.getBytes(1, 1);
});
}
/*
* Validate calling getLength() after calling free() throws an
* SerialException
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test04() throws Exception {
SerialBlob sb = new SerialBlob(new StubBlob());
sb.free();
sb.length();
assertThrows(SerialException.class, () -> {
SerialBlob sb = new SerialBlob(new StubBlob());
sb.free();
sb.length();
});
}
/*
* Validate calling position() after calling free() throws an
* SerialException
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test05() throws Exception {
SerialBlob sb = new SerialBlob(new StubBlob());
sb.free();
sb.position(new byte[5], 1);
assertThrows(SerialException.class, () -> {
SerialBlob sb = new SerialBlob(new StubBlob());
sb.free();
sb.position(new byte[5], 1);
});
}
/*
* Validate calling position() after calling free() throws an
* SerialException
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test06() throws Exception {
SerialBlob sb = new SerialBlob(new StubBlob());
sb.free();
sb.position(new StubBlob(), 1);
assertThrows(SerialException.class, () -> {
SerialBlob sb = new SerialBlob(new StubBlob());
sb.free();
sb.position(new StubBlob(), 1);
});
}
/*
* Validate calling free() after calling setBinaryStream() throws an
* SerialException
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test07() throws Exception {
SerialBlob sb = new SerialBlob(new StubBlob());
sb.free();
sb.setBinaryStream(5);
assertThrows(SerialException.class, () -> {
SerialBlob sb = new SerialBlob(new StubBlob());
sb.free();
sb.setBinaryStream(5);
});
}
/*
* Validate calling free() after calling setBytes() throws an
* SerialException
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test08() throws Exception {
SerialBlob sb = new SerialBlob(new StubBlob());
sb.free();
sb.setBytes(1, new byte[5]);
assertThrows(SerialException.class, () -> {
SerialBlob sb = new SerialBlob(new StubBlob());
sb.free();
sb.setBytes(1, new byte[5]);
});
}
/*
* Validate calling setBytes() after calling free() throws an
* SerialException
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test09() throws Exception {
SerialBlob sb = new SerialBlob(new StubBlob());
sb.free();
sb.setBytes(1, new byte[10], 0, 5);
assertThrows(SerialException.class, () -> {
SerialBlob sb = new SerialBlob(new StubBlob());
sb.free();
sb.setBytes(1, new byte[10], 0, 5);
});
}
/*
* Validate calling truncate() after calling free() throws an
* SerialException
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test10() throws Exception {
SerialBlob sb = new SerialBlob(new StubBlob());
sb.free();
sb.truncate(1);
assertThrows(SerialException.class, () -> {
SerialBlob sb = new SerialBlob(new StubBlob());
sb.free();
sb.truncate(1);
});
}
/*
@ -173,56 +206,68 @@ public class SerialBlobTests extends BaseTest {
/*
* Validate a SerialException is thrown if pos < 0 for getBinaryStream
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test12() throws Exception {
SerialBlob sb = new SerialBlob(bytes);
InputStream is = sb.getBinaryStream(-1, 3);
assertThrows(SerialException.class, () -> {
SerialBlob sb = new SerialBlob(bytes);
InputStream is = sb.getBinaryStream(-1, 3);
});
}
/*
* Validate a SerialException is thrown if pos = 0 for getBinaryStream
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test13() throws Exception {
SerialBlob sb = new SerialBlob(bytes);
InputStream is = sb.getBinaryStream(0, 3);
assertThrows(SerialException.class, () -> {
SerialBlob sb = new SerialBlob(bytes);
InputStream is = sb.getBinaryStream(0, 3);
});
}
/*
* Validate a SerialException is thrown if len > the length of the stream
* for getBinaryStream
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test14() throws Exception {
SerialBlob sb = new SerialBlob(bytes);
InputStream is = sb.getBinaryStream(0, 3);
assertThrows(SerialException.class, () -> {
SerialBlob sb = new SerialBlob(bytes);
InputStream is = sb.getBinaryStream(0, 3);
});
}
/*
* Validate a SerialException is thrown if length < 1
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test15() throws Exception {
SerialBlob sb = new SerialBlob(bytes);
InputStream is = sb.getBinaryStream(1, 0);
assertThrows(SerialException.class, () -> {
SerialBlob sb = new SerialBlob(bytes);
InputStream is = sb.getBinaryStream(1, 0);
});
}
/*
* Validate a SerialException is thrown if length > byte array length
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test16() throws Exception {
SerialBlob sb = new SerialBlob(bytes);
InputStream is = sb.getBinaryStream(1, 6);
assertThrows(SerialException.class, () -> {
SerialBlob sb = new SerialBlob(bytes);
InputStream is = sb.getBinaryStream(1, 6);
});
}
/*
* Validate a SerialException is thrown if pos > byte array length
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test17() throws Exception {
SerialBlob sb = new SerialBlob(bytes);
InputStream is = sb.getBinaryStream(bytes.length + 2, 6);
assertThrows(SerialException.class, () -> {
SerialBlob sb = new SerialBlob(bytes);
InputStream is = sb.getBinaryStream(bytes.length + 2, 6);
});
}
/*
@ -241,12 +286,14 @@ public class SerialBlobTests extends BaseTest {
/*
* Test clone after free has been called that the clone is not accessible
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test19() throws Exception {
SerialBlob sb = new SerialBlob(bytes);
sb.free();
SerialBlob sb2 = (SerialBlob) sb.clone();
InputStream is = sb2.getBinaryStream(1, 3);
assertThrows(SerialException.class, () -> {
SerialBlob sb = new SerialBlob(bytes);
sb.free();
SerialBlob sb2 = (SerialBlob) sb.clone();
InputStream is = sb2.getBinaryStream(1, 3);
});
}
/*
@ -264,10 +311,12 @@ public class SerialBlobTests extends BaseTest {
* Validate a SerialException is thrown if byte[] is used to
* create the SeriablBlob and setBinaryStream is called
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test21() throws Exception {
SerialBlob sb = new SerialBlob(bytes);
sb.setBinaryStream(3);
assertThrows(SerialException.class, () -> {
SerialBlob sb = new SerialBlob(bytes);
sb.setBinaryStream(3);
});
}
/*
@ -281,7 +330,7 @@ public class SerialBlobTests extends BaseTest {
byte[] expected = new byte[]{1, 7, 8, 9, 5};
SerialBlob sb = new SerialBlob(bytes);
int written = sb.setBytes(2, diff);
assertEquals(written, diff.length);
assertEquals(diff.length, written);
assertTrue(
Arrays.equals(sb.getBytes(1, (int) sb.length()),
expected),
@ -300,7 +349,7 @@ public class SerialBlobTests extends BaseTest {
byte[] expected = new byte[]{1, 8, 9, 0, 5};
SerialBlob sb = new SerialBlob(bytes);
int written = sb.setBytes(2, diff, 1, bytesToWrite);
assertEquals(written, bytesToWrite);
assertEquals(bytesToWrite, written);
assertTrue(
Arrays.equals(sb.getBytes(1, (int) sb.length()),
expected),
@ -355,7 +404,7 @@ public class SerialBlobTests extends BaseTest {
byte[] pattern = new byte[]{3, 4};
SerialBlob sb = new SerialBlob(bytes);
long pos = sb.position(pattern, 1);
assertEquals(pos, expectedPos);
assertEquals(expectedPos, pos);
}
/*
@ -368,7 +417,7 @@ public class SerialBlobTests extends BaseTest {
byte[] pattern = new byte[]{3, 4, 5};
SerialBlob sb = new SerialBlob(bytes);
long pos = sb.position(pattern, 2);
assertEquals(pos, expectedPos);
assertEquals(expectedPos, pos);
}
/*
@ -381,7 +430,7 @@ public class SerialBlobTests extends BaseTest {
byte[] pattern = new byte[]{4, 6};
SerialBlob sb = new SerialBlob(new StubBlob());
long pos = sb.position(pattern, 1);
assertEquals(pos, expectedPos);
assertEquals(expectedPos, pos);
}
/*
@ -394,7 +443,7 @@ public class SerialBlobTests extends BaseTest {
byte[] pattern = new byte[]{6, 8};
SerialBlob sb = new SerialBlob(new StubBlob());
long pos = sb.position(pattern, 2);
assertEquals(pos, expectedPos);
assertEquals(expectedPos, pos);
}
/*
@ -411,8 +460,8 @@ public class SerialBlobTests extends BaseTest {
byte[] expected = new byte[]{1, 2, 3, 4, 7};
SerialBlob sb = new SerialBlob(bytes);
int written = sb.setBytes(writePos, diff, 0, bytesToWrite);
assertEquals(written, bytesToWrite);
assertEquals(sb.getBytes(1, (int) sb.length()), expected);
assertEquals(bytesToWrite, written);
assertArrayEquals(expected, sb.getBytes(1, (int) sb.length()));
}
/*
@ -428,8 +477,8 @@ public class SerialBlobTests extends BaseTest {
byte[] expected = new byte[]{1, 2, 3, 4, 8, 9};
SerialBlob sb = new SerialBlob(bytes);
int written = sb.setBytes(writePos, diff, 1, bytesToWrite);
assertEquals(written, bytesToWrite);
assertEquals(sb.getBytes(1, (int) sb.length()), expected);
assertEquals(bytesToWrite, written);
assertArrayEquals(expected, sb.getBytes(1, (int) sb.length()));
}
/*
@ -445,29 +494,33 @@ public class SerialBlobTests extends BaseTest {
byte[] expected = new byte[]{1, 2, 3, 4, 5, 8, 9, 0};
SerialBlob sb = new SerialBlob(bytes);
int written = sb.setBytes(writePos, diff, 1, bytesToWrite);
assertEquals(written, bytesToWrite);
assertEquals(sb.getBytes(1, (int) sb.length()), expected);
assertEquals(bytesToWrite, written);
assertArrayEquals(expected, sb.getBytes(1, (int) sb.length()));
}
/*
* Validate a SerialException is thrown if length < 0 for setBytes
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test34() throws Exception {
int length = -1;
SerialBlob sb = new SerialBlob(bytes);
int written = sb.setBytes(1, new byte[]{1}, 1, length);
assertThrows(SerialException.class, () -> {
int length = -1;
SerialBlob sb = new SerialBlob(bytes);
int written = sb.setBytes(1, new byte[]{1}, 1, length);
});
}
/*
* Validate a SerialException is thrown if length + offset >
* Integer.MAX_VALUE for setBytes
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test35() throws Exception {
int offset = 1;
int length = Integer.MAX_VALUE;
SerialBlob sb = new SerialBlob(bytes);
int written = sb.setBytes(1, new byte[]{1, 2, 3}, offset, length);
assertThrows(SerialException.class, () -> {
int offset = 1;
int length = Integer.MAX_VALUE;
SerialBlob sb = new SerialBlob(bytes);
int written = sb.setBytes(1, new byte[]{1, 2, 3}, offset, length);
});
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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
@ -26,10 +26,14 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
import java.io.Writer;
import java.sql.SQLException;
import javax.sql.rowset.serial.SerialClob;
import javax.sql.rowset.serial.SerialException;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import util.BaseTest;
import util.StubClob;
@ -43,6 +47,26 @@ public class SerialClobTests extends BaseTest {
'o', 'r', 'l', 'd'};
}
/*
* Validate calling setAsciiStream() on a SerialClob constructed from a
* char array throws SerialException. Bug 7077451.
*/
@Test
void setAsciiStreamExceptionTest() throws SQLException {
SerialClob clob = new SerialClob(new char[0]);
assertThrows(SerialException.class, () -> clob.setAsciiStream(0));
}
/*
* Validate calling setCharacterStream() on a SerialClob constructed from a
* char array throws SerialException. Bug 7077451.
*/
@Test
void setCharacterStreamExceptionTest() throws SQLException {
SerialClob clob = new SerialClob(new char[0]);
assertThrows(SerialException.class, () -> clob.setCharacterStream(0));
}
/*
* Validate calling free() does not throw an Exception
*/
@ -56,192 +80,228 @@ public class SerialClobTests extends BaseTest {
* Validate calling getCharacterStream() after calling free() throws an
* SerialException
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test01() throws Exception {
SerialClob sc = new SerialClob(new StubClob());
sc.free();
sc.getCharacterStream();
assertThrows(SerialException.class, () -> {
SerialClob sc = new SerialClob(new StubClob());
sc.free();
sc.getCharacterStream();
});
}
/*
* Validate calling getCharacterStream() after calling free() throws an
* SerialException
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test02() throws Exception {
SerialClob sc = new SerialClob(chars);
sc.free();
sc.getCharacterStream();
assertThrows(SerialException.class, () -> {
SerialClob sc = new SerialClob(chars);
sc.free();
sc.getCharacterStream();
});
}
/*
* Validate calling getCharacterStream() after calling free() throws an
* SerialException
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test03() throws Exception {
SerialClob sc = new SerialClob(new StubClob());
sc.free();
sc.getCharacterStream(1, 5);
assertThrows(SerialException.class, () -> {
SerialClob sc = new SerialClob(new StubClob());
sc.free();
sc.getCharacterStream(1, 5);
});
}
/*
* Validate calling getSubString() after calling free() throws an
* SerialException
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test04() throws Exception {
SerialClob sc = new SerialClob(new StubClob());
sc.free();
sc.getSubString(1, 1);
assertThrows(SerialException.class, () -> {
SerialClob sc = new SerialClob(new StubClob());
sc.free();
sc.getSubString(1, 1);
});
}
/*
* Validate calling truncate() after calling free() throws an
* SerialException
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test05() throws Exception {
SerialClob sc = new SerialClob(new StubClob());
sc.free();
sc.truncate(1);
assertThrows(SerialException.class, () -> {
SerialClob sc = new SerialClob(new StubClob());
sc.free();
sc.truncate(1);
});
}
/*
* Validate calling getAsciiStream() after calling free() throws an
* SerialException
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test06() throws Exception {
SerialClob sc = new SerialClob(new StubClob());
sc.free();
sc.getAsciiStream();
assertThrows(SerialException.class, () -> {
SerialClob sc = new SerialClob(new StubClob());
sc.free();
sc.getAsciiStream();
});
}
/*
* Validate calling length() after calling free() throws an SerialException
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test07() throws Exception {
SerialClob sc = new SerialClob(new StubClob());
sc.free();
sc.length();
assertThrows(SerialException.class, () -> {
SerialClob sc = new SerialClob(new StubClob());
sc.free();
sc.length();
});
}
/*
* Validate calling position() after calling free() throws an
* SerialException
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test08() throws Exception {
SerialClob sc = new SerialClob(new StubClob());
sc.free();
sc.position("hello", 1);
assertThrows(SerialException.class, () -> {
SerialClob sc = new SerialClob(new StubClob());
sc.free();
sc.position("hello", 1);
});
}
/*
* Validate calling position() after calling free() throws an
* SerialException
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test09() throws Exception {
SerialClob sc = new SerialClob(new StubClob());
sc.free();
sc.position(new StubClob(), 1);
assertThrows(SerialException.class, () -> {
SerialClob sc = new SerialClob(new StubClob());
sc.free();
sc.position(new StubClob(), 1);
});
}
/*
* Validate calling setAsciiStream() after calling free() throws an
* SerialException
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test10() throws Exception {
SerialClob sc = new SerialClob(new StubClob());
sc.free();
sc.setAsciiStream(5);
assertThrows(SerialException.class, () -> {
SerialClob sc = new SerialClob(new StubClob());
sc.free();
sc.setAsciiStream(5);
});
}
/*
* Validate calling setCharacterStream() after calling free() throws an
* SerialException
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test11() throws Exception {
SerialClob sc = new SerialClob(new StubClob());
sc.free();
sc.setCharacterStream(5);
assertThrows(SerialException.class, () -> {
SerialClob sc = new SerialClob(new StubClob());
sc.free();
sc.setCharacterStream(5);
});
}
/*
* Validate calling setString() after calling free() throws an
* SerialException
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test12() throws Exception {
SerialClob sc = new SerialClob(new StubClob());
sc.free();
sc.setString(1, "hello");
assertThrows(SerialException.class, () -> {
SerialClob sc = new SerialClob(new StubClob());
sc.free();
sc.setString(1, "hello");
});
}
/*
* Validate calling setString() after calling free() throws an
* SerialException
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test13() throws Exception {
SerialClob sc = new SerialClob(new StubClob());
sc.free();
sc.setString(1, "hello", 0, 5);
assertThrows(SerialException.class, () -> {
SerialClob sc = new SerialClob(new StubClob());
sc.free();
sc.setString(1, "hello", 0, 5);
});
}
/*
* Test that SerialException is thrown if pos < 0 on a call to
* getCharacterStream
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test14() throws Exception {
SerialClob sc = new SerialClob(chars);
sc.getCharacterStream(-1, 5);
assertThrows(SerialException.class, () -> {
SerialClob sc = new SerialClob(chars);
sc.getCharacterStream(-1, 5);
});
}
/*
* Test that SerialException is thrown if pos = 0 on a call to
* getCharacterStream
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test15() throws Exception {
SerialClob sc = new SerialClob(chars);
sc.getCharacterStream(0, 5);
assertThrows(SerialException.class, () -> {
SerialClob sc = new SerialClob(chars);
sc.getCharacterStream(0, 5);
});
}
/*
* Test that SerialException is thrown if pos = 0 on a call to
* getCharacterStream
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test16() throws Exception {
SerialClob sc = new SerialClob(chars);
sc.getCharacterStream(1, 100);
assertThrows(SerialException.class, () -> {
SerialClob sc = new SerialClob(chars);
sc.getCharacterStream(1, 100);
});
}
/*
* Test that SerialException is thrown if length = 0 on a call to
* getCharacterStream
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test17() throws Exception {
SerialClob sc = new SerialClob(chars);
sc.getCharacterStream(1, 0);
assertThrows(SerialException.class, () -> {
SerialClob sc = new SerialClob(chars);
sc.getCharacterStream(1, 0);
});
}
/*
* Test that SerialException is thrown if pos > length on a call to
* getCharacterStream
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test18() throws Exception {
SerialClob sc = new SerialClob(chars);
sc.getCharacterStream(100, 5);
assertThrows(SerialException.class, () -> {
SerialClob sc = new SerialClob(chars);
sc.getCharacterStream(100, 5);
});
}
/*
@ -401,7 +461,7 @@ public class SerialClobTests extends BaseTest {
String expected = "Hello, I am the Batman!";
SerialClob sc = new SerialClob(val.toCharArray());
int written = sc.setString(13, val1);
assertEquals(val1.length(), written);
assertEquals(written, val1.length());
assertTrue(expected.equals(sc.getSubString(1, (int) sc.length())));
}
@ -420,8 +480,8 @@ public class SerialClobTests extends BaseTest {
String expected = "Hi, I am the Joker!!!!!";
SerialClob sc = new SerialClob(val.toCharArray());
int written = sc.setString(writePos, val1, offset, expectedWritten);
assertEquals(written, expectedWritten);
assertEquals(sc.getSubString(1, (int) sc.length()), expected);
assertEquals(expectedWritten, written);
assertEquals(expected, sc.getSubString(1, (int) sc.length()));
}
/*
@ -478,7 +538,8 @@ public class SerialClobTests extends BaseTest {
* Check that getCharacterStream() returns a Reader and that the char[] that
* was specified to create the SerialClob can be returned via the Reader
*/
@Test(enabled = false)
@Test
@Disabled
public void test37() throws Exception {
SerialClob sc = new SerialClob(chars);
String expected = "ello w";
@ -504,12 +565,14 @@ public class SerialClobTests extends BaseTest {
* Check calling setString() with offset > val1.length() throws a
* SerialException
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test39() throws Exception {
String val1 = "hello";
int offset = val1.length() + 1;
SerialClob sc = new SerialClob(chars);
sc.setString(1, val1, offset, 0);
assertThrows(SerialException.class, () -> {
String val1 = "hello";
int offset = val1.length() + 1;
SerialClob sc = new SerialClob(chars);
sc.setString(1, val1, offset, 0);
});
}
/*
@ -526,8 +589,8 @@ public class SerialClobTests extends BaseTest {
String expected = "Hello, I am the Joker, who are you?!";
SerialClob sc = new SerialClob(val.toCharArray());
int written = sc.setString(writePos, val1, offset, expectedWritten);
assertEquals(written, expectedWritten);
assertEquals(sc.getSubString(1, (int) sc.length()), expected);
assertEquals(expectedWritten, written);
assertEquals(expected, sc.getSubString(1, (int) sc.length()));
}
/*
@ -544,29 +607,33 @@ public class SerialClobTests extends BaseTest {
String expected = "Hi, I am the Joker!";
SerialClob sc = new SerialClob(val.toCharArray());
int written = sc.setString(writePos, val1, offset, expectedWritten);
assertEquals(written, expectedWritten);
assertEquals(sc.getSubString(1, (int) sc.length()), expected);
assertEquals(expectedWritten, written);
assertEquals(expected, sc.getSubString(1, (int) sc.length()));
}
/*
* Validate a SerialException is thrown if length < 0 for setString
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test42() throws Exception {
int length = -1;
SerialClob sc = new SerialClob(chars);
int written = sc.setString(1, "hello", 1, length);
assertThrows(SerialException.class, () -> {
int length = -1;
SerialClob sc = new SerialClob(chars);
int written = sc.setString(1, "hello", 1, length);
});
}
/*
* Validate a SerialException is thrown if length + offset >
* Integer.MAX_VALUE for setString
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test43() throws Exception {
int offset = 1;
int length = Integer.MAX_VALUE;
SerialClob sc = new SerialClob(chars);
int written = sc.setString(1, "hello", offset, length);
assertThrows(SerialException.class, () -> {
int offset = 1;
int length = Integer.MAX_VALUE;
SerialClob sc = new SerialClob(chars);
int written = sc.setString(1, "hello", offset, length);
});
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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
@ -25,9 +25,11 @@ package test.rowset.serial;
import java.net.URL;
import javax.sql.rowset.serial.SerialDatalink;
import javax.sql.rowset.serial.SerialException;
import static org.testng.Assert.*;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import util.BaseTest;
public class SerialDataLinkTests extends BaseTest {
@ -36,7 +38,7 @@ public class SerialDataLinkTests extends BaseTest {
private URL u1;
private SerialDatalink dl;
@BeforeMethod
@BeforeEach
public void setUpMethod() throws Exception {
u = new URL("http://www.oracle.com/");
u1 = new URL("http://www.usatoday.com/");
@ -46,9 +48,11 @@ public class SerialDataLinkTests extends BaseTest {
/*
* Validate that a SerialException is thrown if the URL is null
*/
@Test(expectedExceptions = SerialException.class)
@Test
public void test() throws Exception {
SerialDatalink dl1 = new SerialDatalink(null);
assertThrows(SerialException.class, () -> {
SerialDatalink dl1 = new SerialDatalink(null);
});
}
/*

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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
@ -24,8 +24,10 @@ package test.rowset.serial;
import java.sql.SQLException;
import javax.sql.rowset.serial.SerialException;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import util.BaseTest;
public class SerialExceptionTests extends BaseTest {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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
@ -27,8 +27,11 @@ import java.util.Arrays;
import javax.sql.rowset.RowSetMetaDataImpl;
import javax.sql.rowset.serial.SerialException;
import javax.sql.rowset.serial.SerialJavaObject;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import util.BaseTest;
public class SerialJavaObjectTests extends BaseTest {
@ -37,18 +40,23 @@ public class SerialJavaObjectTests extends BaseTest {
* Validate that an NPE is thrown when null is specified to create
* the SerialJavaObject
*/
@Test(expectedExceptions = NullPointerException.class)
@Test
public void test() throws Exception {
SerialJavaObject sjo = new SerialJavaObject(null);
assertThrows(NullPointerException.class, () -> {
SerialJavaObject sjo = new SerialJavaObject(null);
});
}
/*
* Validate that a SerialException is thrown when the object specified
* contains public static fields
*/
@Test(expectedExceptions = SerialException.class, enabled = false)
@Test
@Disabled
public void test01() throws Exception {
SerialJavaObject sjo = new SerialJavaObject(new RowSetMetaDataImpl());
assertThrows(SerialException.class, () -> {
SerialJavaObject sjo = new SerialJavaObject(new RowSetMetaDataImpl());
});
}
/*

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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
@ -27,9 +27,12 @@ import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import javax.sql.rowset.serial.SerialRef;
import static org.testng.Assert.*;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import util.BaseTest;
import util.StubRef;
import util.SuperHero;
@ -41,7 +44,7 @@ public class SerialRefTests extends BaseTest {
private final String sqlType = "SUPERHERO";
private SuperHero hero;
@BeforeMethod
@BeforeEach
public void setUpMethod() throws Exception {
map.put(sqlType, Class.forName("util.SuperHero"));
hero = new SuperHero(sqlType, "Bruce", "Wayne", 1939, "Batman");
@ -51,18 +54,22 @@ public class SerialRefTests extends BaseTest {
/*
* Validate that a SQLException() is thrown if the Ref is null
*/
@Test(expectedExceptions = SQLException.class)
@Test
public void test01() throws Exception {
SerialRef sr = new SerialRef(null);
assertThrows(SQLException.class, () -> {
SerialRef sr = new SerialRef(null);
});
}
/*
* Validate that a SQLException() is thrown if the typeName is null in the
* Ref used to create the SerialRef
*/
@Test(expectedExceptions = SQLException.class)
@Test
public void test02() throws Exception {
SerialRef sr = new SerialRef(new StubRef(null, hero));
assertThrows(SQLException.class, () -> {
SerialRef sr = new SerialRef(new StubRef(null, hero));
});
}
/*
@ -72,7 +79,7 @@ public class SerialRefTests extends BaseTest {
@Test
public void test03() throws Exception {
SerialRef sr = new SerialRef(ref);
assertEquals(sr.getBaseTypeName(), sqlType);
assertEquals(sqlType, sr.getBaseTypeName());
}
/*
@ -87,7 +94,8 @@ public class SerialRefTests extends BaseTest {
/*
* Validate that getObject() returns the same object used to create the Ref
*/
@Test(enabled = false)
@Test
@Disabled
public void test05() throws Exception {
SerialRef sr = new SerialRef(ref);
assertTrue(hero.equals(sr.getObject(map)));

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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
@ -27,9 +27,11 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import javax.sql.rowset.serial.SerialStruct;
import static org.testng.Assert.*;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import util.BaseTest;
import util.StubStruct;
import util.SuperHero;
@ -42,7 +44,7 @@ public class SerialStructTests extends BaseTest {
private final String sqlType = "SUPERHERO";
private SuperHero hero;
@BeforeMethod
@BeforeEach
public void setUpMethod() throws Exception {
attributes = new Object[]{"Bruce", "Wayne", 1939,
"Batman"};
@ -58,7 +60,7 @@ public class SerialStructTests extends BaseTest {
@Test
public void test01() throws Exception {
SerialStruct ss = new SerialStruct(struct, map);
assertEquals(ss.getSQLTypeName(), sqlType);
assertEquals(sqlType, ss.getSQLTypeName());
}
/*
@ -68,7 +70,7 @@ public class SerialStructTests extends BaseTest {
@Test
public void test02() throws Exception {
SerialStruct ss = new SerialStruct(hero, map);
assertEquals(ss.getSQLTypeName(), sqlType);
assertEquals(sqlType, ss.getSQLTypeName());
}
/*

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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
@ -24,8 +24,10 @@ package test.rowset.spi;
import java.sql.SQLException;
import javax.sql.rowset.spi.SyncFactoryException;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import util.BaseTest;
public class SyncFactoryExceptionTests extends BaseTest {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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
@ -33,9 +33,11 @@ import javax.naming.Context;
import javax.sql.rowset.spi.SyncFactory;
import javax.sql.rowset.spi.SyncFactoryException;
import javax.sql.rowset.spi.SyncProvider;
import static org.testng.Assert.*;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import util.PropertyStubProvider;
import util.StubSyncProvider;
import util.StubContext;
@ -67,7 +69,7 @@ public class SyncFactoryTests {
ctx = new StubContext();
}
@BeforeMethod
@BeforeEach
public void setUpMethod() throws Exception {
// Make sure the provider provider that is registered is removed
// before each run
@ -120,17 +122,21 @@ public class SyncFactoryTests {
/*
* Validate that a SyncFactoryException is thrown if the ProviderID is null
*/
@Test(expectedExceptions = SyncFactoryException.class)
@Test
public void test03() throws SyncFactoryException {
SyncProvider p = SyncFactory.getInstance(null);
assertThrows(SyncFactoryException.class, () -> {
SyncProvider p = SyncFactory.getInstance(null);
});
}
/*
* Validate that a SyncFactoryException is thrown if the Logger is null
*/
@Test(expectedExceptions = SyncFactoryException.class,enabled=true)
@Test
public void test04() throws SyncFactoryException {
Logger l = SyncFactory.getLogger();
assertThrows(SyncFactoryException.class, () -> {
Logger l = SyncFactory.getLogger();
});
}
/*
@ -179,15 +185,15 @@ public class SyncFactoryTests {
* Validate that setJNDIContext throws a SyncFactoryException if the
* context is null
*/
@Test(expectedExceptions = SyncFactoryException.class, enabled=true)
@Test
public void test08() throws Exception {
SyncFactory.setJNDIContext(null);
assertThrows(SyncFactoryException.class, () -> SyncFactory.setJNDIContext(null));
}
/*
* Validate that setJNDIContext succeeds
*/
@Test(enabled=true)
@Test
public void test09() throws Exception {
SyncFactory.setJNDIContext(ctx);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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
@ -27,11 +27,12 @@ import java.sql.SQLException;
import javax.sql.rowset.spi.SyncProviderException;
import javax.sql.rowset.spi.SyncResolver;
import static org.testng.Assert.*;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.junit.jupiter.api.AfterAll;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import util.BaseTest;
import util.StubSyncResolver;
@ -40,16 +41,16 @@ public class SyncProviderExceptionTests extends BaseTest {
// Used by SyncProviderException::getSyncResolver tests
private SyncResolver resolver;
@BeforeClass
@BeforeAll
public static void setUpClass() throws Exception {
System.out.println(System.getProperty("java.naming.factory.initial"));
}
@AfterClass
@AfterAll
public static void tearDownClass() throws Exception {
}
@BeforeMethod
@BeforeEach
public void setupTest() {
resolver = new SyncProviderException().getSyncResolver();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2026, 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
@ -35,11 +35,15 @@ import java.math.BigDecimal;
import java.sql.ResultSet;
import java.util.Arrays;
import javax.sql.rowset.WebRowSet;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertEqualsNoOrder;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
import org.testng.annotations.Test;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import test.rowset.cachedrowset.CommonCachedRowSetTests;
public abstract class CommonWebRowSetTests extends CommonCachedRowSetTests {
@ -131,10 +135,11 @@ public abstract class CommonWebRowSetTests extends CommonCachedRowSetTests {
/*
* Validate the expected Rows are contained within the RowSet
*/
@Test(dataProvider = "rowsetUsingCoffees")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("rowsetUsingCoffees")
public void WebRowSetTest0000(WebRowSet wrs) throws Exception {
assertEquals(getPrimaryKeys(wrs), COFFEES_PRIMARY_KEYS);
assertEquals(wrs.size(), COFFEES_ROWS);
assertArrayEquals(COFFEES_PRIMARY_KEYS, getPrimaryKeys(wrs));
assertEquals(COFFEES_ROWS, wrs.size());
wrs.close();
}
@ -142,14 +147,15 @@ public abstract class CommonWebRowSetTests extends CommonCachedRowSetTests {
* Validate the expected Rows are contained within the RowSet
* populated by readXML(Reader)
*/
@Test(dataProvider = "rowSetType")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("rowSetType")
public void WebRowSetTest0001(WebRowSet wrs1) throws Exception {
try (FileReader fr = new FileReader(COFFEE_ROWS_XML)) {
wrs1.readXml(fr);
}
assertEquals(getPrimaryKeys(wrs1), COFFEES_PRIMARY_KEYS);
assertEquals(wrs1.size(), COFFEES_ROWS);
assertArrayEquals(COFFEES_PRIMARY_KEYS, getPrimaryKeys(wrs1));
assertEquals(COFFEES_ROWS, wrs1.size());
wrs1.close();
}
@ -158,13 +164,14 @@ public abstract class CommonWebRowSetTests extends CommonCachedRowSetTests {
* Validate the expected Rows are contained within the RowSet
* populated by readXML(InputStream)
*/
@Test(dataProvider = "rowSetType")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("rowSetType")
public void WebRowSetTest0002(WebRowSet wrs1) throws Exception {
try (FileInputStream fis = new FileInputStream(COFFEE_ROWS_XML)) {
wrs1.readXml(fis);
}
assertEquals(getPrimaryKeys(wrs1), COFFEES_PRIMARY_KEYS);
assertEquals(wrs1.size(), COFFEES_ROWS);
assertArrayEquals(COFFEES_PRIMARY_KEYS, getPrimaryKeys(wrs1));
assertEquals(COFFEES_ROWS, wrs1.size());
wrs1.close();
}
@ -173,12 +180,13 @@ public abstract class CommonWebRowSetTests extends CommonCachedRowSetTests {
* back via readXML(InputStream) and validate the primary keys
* are the same
*/
@Test(dataProvider = "rowsetUsingCoffees")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("rowsetUsingCoffees")
public void WebRowSetTest0003(WebRowSet wrs) throws Exception {
ByteArrayOutputStream baos = writeWebRowSetWithOutputStream(wrs);
try (WebRowSet wrs1 = readWebRowSetWithOInputStream(baos)) {
assertEquals(getPrimaryKeys(wrs1), COFFEES_PRIMARY_KEYS);
assertEquals(wrs1.size(), COFFEES_ROWS);
assertArrayEquals(COFFEES_PRIMARY_KEYS, getPrimaryKeys(wrs1));
assertEquals(COFFEES_ROWS, wrs1.size());
}
}
@ -187,14 +195,15 @@ public abstract class CommonWebRowSetTests extends CommonCachedRowSetTests {
* back via readXML(InputStream) and validate the primary keys
* are the same
*/
@Test(dataProvider = "rowsetUsingCoffees")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("rowsetUsingCoffees")
public void WebRowSetTest0004(WebRowSet wrs) throws Exception {
ResultSet rs = wrs;
rs.beforeFirst();
ByteArrayOutputStream baos = writeWebRowSetWithOutputStream(rs);
try (WebRowSet wrs1 = readWebRowSetWithOInputStream(baos)) {
assertEquals(getPrimaryKeys(wrs1), COFFEES_PRIMARY_KEYS);
assertEquals(wrs1.size(), COFFEES_ROWS);
assertArrayEquals(COFFEES_PRIMARY_KEYS, getPrimaryKeys(wrs1));
assertEquals(COFFEES_ROWS, wrs1.size());
}
}
@ -203,12 +212,13 @@ public abstract class CommonWebRowSetTests extends CommonCachedRowSetTests {
* back via readXML(Reader) and validate the primary keys
* are the same
*/
@Test(dataProvider = "rowsetUsingCoffees")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("rowsetUsingCoffees")
public void WebRowSetTest0005(WebRowSet wrs) throws Exception {
ByteArrayOutputStream baos = writeWebRowSetWithOutputStreamWithWriter(wrs);
try (WebRowSet wrs1 = readWebRowSetWithOInputStreamWithReader(baos)) {
assertEquals(getPrimaryKeys(wrs1), COFFEES_PRIMARY_KEYS);
assertEquals(wrs1.size(), COFFEES_ROWS);
assertArrayEquals(COFFEES_PRIMARY_KEYS, getPrimaryKeys(wrs1));
assertEquals(COFFEES_ROWS, wrs1.size());
}
}
@ -217,14 +227,15 @@ public abstract class CommonWebRowSetTests extends CommonCachedRowSetTests {
* back via readXML(Reader) and validate the primary keys
* are the same
*/
@Test(dataProvider = "rowsetUsingCoffees")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("rowsetUsingCoffees")
public void WebRowSetTest0006(WebRowSet wrs) throws Exception {
ResultSet rs = wrs;
rs.beforeFirst();
ByteArrayOutputStream baos = writeWebRowSetWithOutputStreamWithWriter(rs);
try (WebRowSet wrs1 = readWebRowSetWithOInputStreamWithReader(baos)) {
assertEquals(getPrimaryKeys(wrs1), COFFEES_PRIMARY_KEYS);
assertEquals(wrs1.size(), COFFEES_ROWS);
assertArrayEquals(COFFEES_PRIMARY_KEYS, getPrimaryKeys(wrs1));
assertEquals(COFFEES_ROWS, wrs1.size());
}
}
@ -232,11 +243,13 @@ public abstract class CommonWebRowSetTests extends CommonCachedRowSetTests {
* Validate the expected Rows are contained within the RowSet
* after deleting the specified rows
*/
@Test(dataProvider = "rowsetUsingCoffees", enabled = false)
@Disabled
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("rowsetUsingCoffees")
public void WebRowSetTest0007(WebRowSet wrs) throws Exception {
assertEquals(getPrimaryKeys(wrs), COFFEES_PRIMARY_KEYS);
assertArrayEquals(COFFEES_PRIMARY_KEYS, getPrimaryKeys(wrs));
int[] rowsToDelete = {2, 4};
assertEquals(getPrimaryKeys(wrs), COFFEES_PRIMARY_KEYS);
assertArrayEquals(COFFEES_PRIMARY_KEYS, getPrimaryKeys(wrs));
for (int row : rowsToDelete) {
assertTrue(deleteRowByPrimaryKey(wrs, row, 1));
}
@ -262,12 +275,13 @@ public abstract class CommonWebRowSetTests extends CommonCachedRowSetTests {
* that was populated by reading an xml file with all rows
* marked as a currentRow
*/
@Test(dataProvider = "rowSetType")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("rowSetType")
public void WebRowSetTest0008(WebRowSet wrs1) throws Exception {
FileInputStream fis = new FileInputStream(COFFEE_ROWS_XML);
wrs1.readXml(fis);
assertTrue(wrs1.size() == COFFEES_ROWS);
assertEquals(getPrimaryKeys(wrs1), COFFEES_PRIMARY_KEYS);
assertArrayEquals(COFFEES_PRIMARY_KEYS, getPrimaryKeys(wrs1));
// Validate that the rows are not marked as deleted, inserted or updated
wrs1.beforeFirst();
while (wrs1.next()) {
@ -284,14 +298,15 @@ public abstract class CommonWebRowSetTests extends CommonCachedRowSetTests {
* Also validate that they are or are not visible based on the
* setShowDeleted value
*/
@Test(dataProvider = "rowSetType")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("rowSetType")
public void WebRowSetTest0009(WebRowSet wrs1) throws Exception {
int[] rowsToDelete = {2, 4};
Object[] expectedRows = {1, 3, 5};
FileInputStream fis = new FileInputStream(DELETED_COFFEE_ROWS_XML);
wrs1.readXml(fis);
assertTrue(wrs1.size() == COFFEES_ROWS);
assertEquals(getPrimaryKeys(wrs1), expectedRows);
assertArrayEquals(expectedRows, getPrimaryKeys(wrs1));
// With setShowDeleted(false) which is the default,
// the deleted row should not be visible
for (int row : rowsToDelete) {
@ -302,7 +317,7 @@ public abstract class CommonWebRowSetTests extends CommonCachedRowSetTests {
for (int row : rowsToDelete) {
assertTrue(findRowByPrimaryKey(wrs1, row, 1));
}
assertEquals(getPrimaryKeys(wrs1), COFFEES_PRIMARY_KEYS);
assertArrayEquals(COFFEES_PRIMARY_KEYS, getPrimaryKeys(wrs1));
wrs1.close();
}
@ -311,12 +326,13 @@ public abstract class CommonWebRowSetTests extends CommonCachedRowSetTests {
* Validate that the correct row in the WebRowSet that had been created
* from an xml file is marked as updated and contains the correct values
*/
@Test(dataProvider = "rowSetType")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("rowSetType")
public void WebRowSetTest0010(WebRowSet wrs1) throws Exception {
FileInputStream fis = new FileInputStream(UPDATED_COFFEE_ROWS_XML);
wrs1.readXml(fis);
assertTrue(wrs1.size() == COFFEES_ROWS);
assertEquals(getPrimaryKeys(wrs1), COFFEES_PRIMARY_KEYS);
assertArrayEquals(COFFEES_PRIMARY_KEYS, getPrimaryKeys(wrs1));
wrs1.beforeFirst();
while (wrs1.next()) {
if (wrs1.getInt(1) == 3) {
@ -337,7 +353,8 @@ public abstract class CommonWebRowSetTests extends CommonCachedRowSetTests {
* Validate the correct row is marked as inserted in a WebRowSet
* that is read from an xml file
*/
@Test(dataProvider = "rowSetType")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("rowSetType")
public void WebRowSetTest0011(WebRowSet wrs1) throws Exception {
int expectedSize = COFFEES_ROWS + 2;
int addedRowPK = 15;
@ -348,7 +365,10 @@ public abstract class CommonWebRowSetTests extends CommonCachedRowSetTests {
FileInputStream fis = new FileInputStream(INSERTED_COFFEE_ROWS_XML);
wrs1.readXml(fis);
assertTrue(wrs1.size() == expectedSize);
assertEqualsNoOrder(getPrimaryKeys(wrs1), expected);
var actual = getPrimaryKeys(wrs1);
Arrays.sort(actual);
Arrays.sort(expected);
assertArrayEquals(expected, actual);
wrs1.beforeFirst();
while (wrs1.next()) {
if (wrs1.getInt(1) == 15 || wrs1.getInt(1) == 20) {
@ -367,7 +387,8 @@ public abstract class CommonWebRowSetTests extends CommonCachedRowSetTests {
/*
* Read an xml file which contains a row that was inserted and updated
*/
@Test(dataProvider = "rowSetType")
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("rowSetType")
public void WebRowSetTest0012(WebRowSet wrs1) throws Exception {
int expectedSize = COFFEES_ROWS + 1;
int addedRowPK = 100;
@ -376,7 +397,7 @@ public abstract class CommonWebRowSetTests extends CommonCachedRowSetTests {
FileInputStream fis = new FileInputStream(UPDATED_INSERTED_COFFEE_ROWS_XML);
wrs1.readXml(fis);
assertTrue(wrs1.size() == expectedSize);
assertEquals(getPrimaryKeys(wrs1), expected);
assertArrayEquals(expected, getPrimaryKeys(wrs1));
wrs1.beforeFirst();
while (wrs1.next()) {
if (wrs1.getInt(1) == addedRowPK) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2026, 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

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, 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

Some files were not shown because too many files have changed in this diff Show More