From ee60eff1ec9eddcdedc12c1707fbcca0025e71d6 Mon Sep 17 00:00:00 2001 From: Justin Lu Date: Fri, 30 Jan 2026 17:41:50 +0000 Subject: [PATCH] 8376038: Refactor java/sql tests to use JUnit 8376629: Refactor javax/sql tests to use JUnit Reviewed-by: lancea --- test/jdk/java/sql/JavatimeTest.java | 173 ----- test/jdk/java/sql/test/TEST.properties | 3 + .../test/sql/BatchUpdateExceptionTests.java | 10 +- .../test/sql/CallableStatementTests.java | 65 +- .../test/sql/ConnectionTests.java | 59 +- .../test/sql/DataTruncationTests.java | 10 +- .../sql/{testng => }/test/sql/DateTests.java | 124 ++-- .../test/sql/DriverManagerTests.java | 80 +-- test/jdk/java/sql/test/sql/JavatimeTest.java | 184 +++++ .../test/sql/PreparedStatementTests.java | 65 +- .../test/sql/SQLClientInfoExceptionTests.java | 10 +- .../test/sql/SQLDataExceptionTests.java | 10 +- .../test/sql/SQLExceptionTests.java | 10 +- .../SQLFeatureNotSupportedExceptionTests.java | 10 +- ...rityConstraintViolationExceptionTests.java | 10 +- ...nvalidAuthorizationSpecExceptionTests.java | 10 +- ...LNonTransientConnectionExceptionTests.java | 10 +- .../sql/SQLNonTransientExceptionTests.java | 10 +- .../sql/SQLRecoverableExceptionTests.java | 10 +- .../sql/SQLSyntaxErrorExceptionTests.java | 10 +- .../test/sql/SQLTimeoutExceptionTests.java | 10 +- .../SQLTransactionRollbackExceptionTests.java | 10 +- .../SQLTransientConnectionExceptionTests.java | 10 +- .../test/sql/SQLTransientExceptionTests.java | 10 +- .../test/sql/SQLWarningTests.java | 10 +- .../{testng => }/test/sql/StatementTests.java | 63 +- .../sql/{testng => }/test/sql/TimeTests.java | 136 ++-- .../{testng => }/test/sql/TimestampTests.java | 296 ++++---- .../DriverManagerInitTests.java | 8 +- .../DriverManagerModuleTests.java | 34 +- .../test/sql/drivermanager/TEST.properties | 4 + test/jdk/java/sql/testng/TEST.properties | 4 - .../java/sql/{testng => }/util/BaseTest.java | 146 ++-- .../{testng => }/util/DriverActionImpl.java | 2 +- .../util/SerializedBatchUpdateException.java | 2 +- .../util/StubCallableStatement.java | 2 +- .../sql/{testng => }/util/StubConnection.java | 2 +- .../util/StubDatabaseMetaData.java | 2 +- .../sql/{testng => }/util/StubDriver.java | 2 +- .../sql/{testng => }/util/StubDriverDA.java | 2 +- .../util/StubPreparedStatement.java | 2 +- .../sql/{testng => }/util/StubStatement.java | 2 +- .../javax/sql/{testng => }/TEST.properties | 6 +- .../services/javax.sql.rowset.RowSetFactory | 0 .../services/javax.sql.rowset.RowSetFactory | 0 test/jdk/javax/sql/rowset/TEST.properties | 1 - .../serial/SerialBlob/SetBinaryStream.java | 42 -- .../serial/SerialClob/SetAsciiStream.java | 42 -- .../serial/SerialClob/SetCharacterStream.java | 42 -- .../test/rowset/BaseRowSetTests.java | 124 ++-- .../test/rowset/CommonRowSetTests.java | 637 ++++++++++-------- .../test/rowset/RowSetFactoryTests.java | 43 +- .../test/rowset/RowSetMetaDataTests.java | 339 +++++----- .../test/rowset/RowSetProviderTests.java | 69 +- .../test/rowset/RowSetWarningTests.java | 8 +- .../cachedrowset/CachedRowSetTests.java | 2 +- .../cachedrowset/CommonCachedRowSetTests.java | 544 +++++++++------ .../rowset/filteredrowset/CityFilter.java | 2 +- .../filteredrowset/FilteredRowSetTests.java | 36 +- .../filteredrowset/PrimaryKeyFilter.java | 2 +- .../JdbcRowSetDriverManagerTest.java | 8 +- .../rowset/joinrowset/JoinRowSetTests.java | 76 ++- .../rowset/resourcebundle/TEST.properties | 2 + .../resourcebundle}/ValidateGetBundle.java | 5 +- .../ValidateResourceBundleAccess.java | 16 +- .../test/rowset/serial/SQLInputImplTests.java | 34 +- .../rowset/serial/SQLOutputImplTests.java | 38 +- .../test/rowset/serial/SerialArrayTests.java | 110 +-- .../test/rowset/serial/SerialBlobTests.java | 233 ++++--- .../test/rowset/serial/SerialClobTests.java | 251 ++++--- .../rowset/serial/SerialDataLinkTests.java | 18 +- .../rowset/serial/SerialExceptionTests.java | 8 +- .../rowset/serial/SerialJavaObjectTests.java | 22 +- .../test/rowset/serial/SerialRefTests.java | 30 +- .../test/rowset/serial/SerialStructTests.java | 16 +- .../rowset/spi/SyncFactoryExceptionTests.java | 8 +- .../test/rowset/spi/SyncFactoryTests.java | 30 +- .../spi/SyncProviderExceptionTests.java | 19 +- .../webrowset/CommonWebRowSetTests.java | 103 +-- .../test/rowset/webrowset/WebRowSetTests.java | 2 +- .../util/PropertyStubProvider.java | 2 +- .../sql/{testng => }/util/StubArray.java | 2 +- .../sql/{testng => }/util/StubBaseRowSet.java | 2 +- .../javax/sql/{testng => }/util/StubBlob.java | 2 +- .../util/StubCachedRowSetImpl.java | 2 +- .../javax/sql/{testng => }/util/StubClob.java | 2 +- .../sql/{testng => }/util/StubContext.java | 2 +- .../util/StubFilteredRowSetImpl.java | 2 +- .../{testng => }/util/StubJdbcRowSetImpl.java | 2 +- .../{testng => }/util/StubJoinRowSetImpl.java | 2 +- .../sql/{testng => }/util/StubNClob.java | 2 +- .../javax/sql/{testng => }/util/StubRef.java | 2 +- .../sql/{testng => }/util/StubRowId.java | 2 +- .../{testng => }/util/StubRowSetFactory.java | 2 +- .../sql/{testng => }/util/StubSQLXML.java | 2 +- .../sql/{testng => }/util/StubStruct.java | 2 +- .../{testng => }/util/StubSyncProvider.java | 2 +- .../{testng => }/util/StubSyncResolver.java | 2 +- .../{testng => }/util/StubWebRowSetImpl.java | 2 +- .../sql/{testng => }/util/SuperHero.java | 2 +- .../{testng => }/util/TestRowSetListener.java | 2 +- .../{testng => }/util/TestSQLDataImpl.java | 2 +- .../sql/{testng => }/xml/COFFEE_ROWS.xml | 0 .../{testng => }/xml/DELETED_COFFEE_ROWS.xml | 0 .../{testng => }/xml/INSERTED_COFFEE_ROWS.xml | 0 .../xml/MODFIED_DELETED_COFFEE_ROWS.xml | 0 .../{testng => }/xml/UPDATED_COFFEE_ROWS.xml | 0 .../xml/UPDATED_INSERTED_COFFEE_ROWS.xml | 0 108 files changed, 2511 insertions(+), 2133 deletions(-) delete mode 100644 test/jdk/java/sql/JavatimeTest.java create mode 100644 test/jdk/java/sql/test/TEST.properties rename test/jdk/java/sql/{testng => }/test/sql/BatchUpdateExceptionTests.java (98%) rename test/jdk/java/sql/{testng => }/test/sql/CallableStatementTests.java (62%) rename test/jdk/java/sql/{testng => }/test/sql/ConnectionTests.java (63%) rename test/jdk/java/sql/{testng => }/test/sql/DataTruncationTests.java (97%) rename test/jdk/java/sql/{testng => }/test/sql/DateTests.java (80%) rename test/jdk/java/sql/{testng => }/test/sql/DriverManagerTests.java (84%) create mode 100644 test/jdk/java/sql/test/sql/JavatimeTest.java rename test/jdk/java/sql/{testng => }/test/sql/PreparedStatementTests.java (62%) rename test/jdk/java/sql/{testng => }/test/sql/SQLClientInfoExceptionTests.java (97%) rename test/jdk/java/sql/{testng => }/test/sql/SQLDataExceptionTests.java (97%) rename test/jdk/java/sql/{testng => }/test/sql/SQLExceptionTests.java (97%) rename test/jdk/java/sql/{testng => }/test/sql/SQLFeatureNotSupportedExceptionTests.java (97%) rename test/jdk/java/sql/{testng => }/test/sql/SQLIntegrityConstraintViolationExceptionTests.java (97%) rename test/jdk/java/sql/{testng => }/test/sql/SQLInvalidAuthorizationSpecExceptionTests.java (97%) rename test/jdk/java/sql/{testng => }/test/sql/SQLNonTransientConnectionExceptionTests.java (97%) rename test/jdk/java/sql/{testng => }/test/sql/SQLNonTransientExceptionTests.java (97%) rename test/jdk/java/sql/{testng => }/test/sql/SQLRecoverableExceptionTests.java (97%) rename test/jdk/java/sql/{testng => }/test/sql/SQLSyntaxErrorExceptionTests.java (97%) rename test/jdk/java/sql/{testng => }/test/sql/SQLTimeoutExceptionTests.java (97%) rename test/jdk/java/sql/{testng => }/test/sql/SQLTransactionRollbackExceptionTests.java (97%) rename test/jdk/java/sql/{testng => }/test/sql/SQLTransientConnectionExceptionTests.java (97%) rename test/jdk/java/sql/{testng => }/test/sql/SQLTransientExceptionTests.java (97%) rename test/jdk/java/sql/{testng => }/test/sql/SQLWarningTests.java (97%) rename test/jdk/java/sql/{testng => }/test/sql/StatementTests.java (62%) rename test/jdk/java/sql/{testng => }/test/sql/TimeTests.java (76%) rename test/jdk/java/sql/{testng => }/test/sql/TimestampTests.java (73%) rename test/jdk/java/sql/{testng/test/sql/othervm => test/sql/drivermanager}/DriverManagerInitTests.java (93%) rename test/jdk/java/sql/{driverModuleTests => test/sql/drivermanager}/DriverManagerModuleTests.java (84%) create mode 100644 test/jdk/java/sql/test/sql/drivermanager/TEST.properties delete mode 100644 test/jdk/java/sql/testng/TEST.properties rename test/jdk/java/sql/{testng => }/util/BaseTest.java (54%) rename test/jdk/java/sql/{testng => }/util/DriverActionImpl.java (94%) rename test/jdk/java/sql/{testng => }/util/SerializedBatchUpdateException.java (99%) rename test/jdk/java/sql/{testng => }/util/StubCallableStatement.java (99%) rename test/jdk/java/sql/{testng => }/util/StubConnection.java (99%) rename test/jdk/java/sql/{testng => }/util/StubDatabaseMetaData.java (99%) rename test/jdk/java/sql/{testng => }/util/StubDriver.java (96%) rename test/jdk/java/sql/{testng => }/util/StubDriverDA.java (96%) rename test/jdk/java/sql/{testng => }/util/StubPreparedStatement.java (99%) rename test/jdk/java/sql/{testng => }/util/StubStatement.java (99%) rename test/jdk/javax/sql/{testng => }/TEST.properties (68%) rename test/jdk/javax/sql/{testng => }/jars/badFactory/META-INF/services/javax.sql.rowset.RowSetFactory (100%) rename test/jdk/javax/sql/{testng => }/jars/goodFactory/META-INF/services/javax.sql.rowset.RowSetFactory (100%) delete mode 100644 test/jdk/javax/sql/rowset/TEST.properties delete mode 100644 test/jdk/javax/sql/rowset/serial/SerialBlob/SetBinaryStream.java delete mode 100644 test/jdk/javax/sql/rowset/serial/SerialClob/SetAsciiStream.java delete mode 100644 test/jdk/javax/sql/rowset/serial/SerialClob/SetCharacterStream.java rename test/jdk/javax/sql/{testng => }/test/rowset/BaseRowSetTests.java (83%) rename test/jdk/javax/sql/{testng => }/test/rowset/CommonRowSetTests.java (67%) rename test/jdk/javax/sql/{testng => }/test/rowset/RowSetFactoryTests.java (80%) rename test/jdk/javax/sql/{testng => }/test/rowset/RowSetMetaDataTests.java (55%) rename test/jdk/javax/sql/{testng => }/test/rowset/RowSetProviderTests.java (79%) rename test/jdk/javax/sql/{testng => }/test/rowset/RowSetWarningTests.java (97%) rename test/jdk/javax/sql/{testng => }/test/rowset/cachedrowset/CachedRowSetTests.java (94%) rename test/jdk/javax/sql/{testng => }/test/rowset/cachedrowset/CommonCachedRowSetTests.java (79%) rename test/jdk/javax/sql/{testng => }/test/rowset/filteredrowset/CityFilter.java (97%) rename test/jdk/javax/sql/{testng => }/test/rowset/filteredrowset/FilteredRowSetTests.java (81%) rename test/jdk/javax/sql/{testng => }/test/rowset/filteredrowset/PrimaryKeyFilter.java (97%) rename test/jdk/javax/sql/{testng => }/test/rowset/jdbcrowset/JdbcRowSetDriverManagerTest.java (95%) rename test/jdk/javax/sql/{testng => }/test/rowset/joinrowset/JoinRowSetTests.java (83%) create mode 100644 test/jdk/javax/sql/test/rowset/resourcebundle/TEST.properties rename test/jdk/javax/sql/{resourceBundleTests => test/rowset/resourcebundle}/ValidateGetBundle.java (94%) rename test/jdk/javax/sql/{testng/test/rowset => test/rowset/resourcebundle}/ValidateResourceBundleAccess.java (89%) rename test/jdk/javax/sql/{testng => }/test/rowset/serial/SQLInputImplTests.java (92%) rename test/jdk/javax/sql/{testng => }/test/rowset/serial/SQLOutputImplTests.java (91%) rename test/jdk/javax/sql/{testng => }/test/rowset/serial/SerialArrayTests.java (72%) rename test/jdk/javax/sql/{testng => }/test/rowset/serial/SerialBlobTests.java (69%) rename test/jdk/javax/sql/{testng => }/test/rowset/serial/SerialClobTests.java (72%) rename test/jdk/javax/sql/{testng => }/test/rowset/serial/SerialDataLinkTests.java (90%) rename test/jdk/javax/sql/{testng => }/test/rowset/serial/SerialExceptionTests.java (95%) rename test/jdk/javax/sql/{testng => }/test/rowset/serial/SerialJavaObjectTests.java (86%) rename test/jdk/javax/sql/{testng => }/test/rowset/serial/SerialRefTests.java (86%) rename test/jdk/javax/sql/{testng => }/test/rowset/serial/SerialStructTests.java (92%) rename test/jdk/javax/sql/{testng => }/test/rowset/spi/SyncFactoryExceptionTests.java (95%) rename test/jdk/javax/sql/{testng => }/test/rowset/spi/SyncFactoryTests.java (92%) rename test/jdk/javax/sql/{testng => }/test/rowset/spi/SyncProviderExceptionTests.java (96%) rename test/jdk/javax/sql/{testng => }/test/rowset/webrowset/CommonWebRowSetTests.java (81%) rename test/jdk/javax/sql/{testng => }/test/rowset/webrowset/WebRowSetTests.java (94%) rename test/jdk/javax/sql/{testng => }/util/PropertyStubProvider.java (92%) rename test/jdk/javax/sql/{testng => }/util/StubArray.java (97%) rename test/jdk/javax/sql/{testng => }/util/StubBaseRowSet.java (99%) rename test/jdk/javax/sql/{testng => }/util/StubBlob.java (97%) rename test/jdk/javax/sql/{testng => }/util/StubCachedRowSetImpl.java (99%) rename test/jdk/javax/sql/{testng => }/util/StubClob.java (97%) rename test/jdk/javax/sql/{testng => }/util/StubContext.java (98%) rename test/jdk/javax/sql/{testng => }/util/StubFilteredRowSetImpl.java (99%) rename test/jdk/javax/sql/{testng => }/util/StubJdbcRowSetImpl.java (99%) rename test/jdk/javax/sql/{testng => }/util/StubJoinRowSetImpl.java (99%) rename test/jdk/javax/sql/{testng => }/util/StubNClob.java (93%) rename test/jdk/javax/sql/{testng => }/util/StubRef.java (95%) rename test/jdk/javax/sql/{testng => }/util/StubRowId.java (93%) rename test/jdk/javax/sql/{testng => }/util/StubRowSetFactory.java (96%) rename test/jdk/javax/sql/{testng => }/util/StubSQLXML.java (97%) rename test/jdk/javax/sql/{testng => }/util/StubStruct.java (95%) rename test/jdk/javax/sql/{testng => }/util/StubSyncProvider.java (97%) rename test/jdk/javax/sql/{testng => }/util/StubSyncResolver.java (99%) rename test/jdk/javax/sql/{testng => }/util/StubWebRowSetImpl.java (99%) rename test/jdk/javax/sql/{testng => }/util/SuperHero.java (97%) rename test/jdk/javax/sql/{testng => }/util/TestRowSetListener.java (96%) rename test/jdk/javax/sql/{testng => }/util/TestSQLDataImpl.java (98%) rename test/jdk/javax/sql/{testng => }/xml/COFFEE_ROWS.xml (100%) rename test/jdk/javax/sql/{testng => }/xml/DELETED_COFFEE_ROWS.xml (100%) rename test/jdk/javax/sql/{testng => }/xml/INSERTED_COFFEE_ROWS.xml (100%) rename test/jdk/javax/sql/{testng => }/xml/MODFIED_DELETED_COFFEE_ROWS.xml (100%) rename test/jdk/javax/sql/{testng => }/xml/UPDATED_COFFEE_ROWS.xml (100%) rename test/jdk/javax/sql/{testng => }/xml/UPDATED_INSERTED_COFFEE_ROWS.xml (100%) diff --git a/test/jdk/java/sql/JavatimeTest.java b/test/jdk/java/sql/JavatimeTest.java deleted file mode 100644 index 89344d7cdc6..00000000000 --- a/test/jdk/java/sql/JavatimeTest.java +++ /dev/null @@ -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()); - } -} diff --git a/test/jdk/java/sql/test/TEST.properties b/test/jdk/java/sql/test/TEST.properties new file mode 100644 index 00000000000..97c9e7bbe18 --- /dev/null +++ b/test/jdk/java/sql/test/TEST.properties @@ -0,0 +1,3 @@ +# JDBC unit tests uses JUnit +JUnit.dirs= . +lib.dirs = /java/sql/util diff --git a/test/jdk/java/sql/testng/test/sql/BatchUpdateExceptionTests.java b/test/jdk/java/sql/test/sql/BatchUpdateExceptionTests.java similarity index 98% rename from test/jdk/java/sql/testng/test/sql/BatchUpdateExceptionTests.java rename to test/jdk/java/sql/test/sql/BatchUpdateExceptionTests.java index 2b1111b7526..2d010b50e41 100644 --- a/test/jdk/java/sql/testng/test/sql/BatchUpdateExceptionTests.java +++ b/test/jdk/java/sql/test/sql/BatchUpdateExceptionTests.java @@ -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; diff --git a/test/jdk/java/sql/testng/test/sql/CallableStatementTests.java b/test/jdk/java/sql/test/sql/CallableStatementTests.java similarity index 62% rename from test/jdk/java/sql/testng/test/sql/CallableStatementTests.java rename to test/jdk/java/sql/test/sql/CallableStatementTests.java index 7a4fe15ecac..dc5c347ef50 100644 --- a/test/jdk/java/sql/testng/test/sql/CallableStatementTests.java +++ b/test/jdk/java/sql/test/sql/CallableStatementTests.java @@ -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)); } } diff --git a/test/jdk/java/sql/testng/test/sql/ConnectionTests.java b/test/jdk/java/sql/test/sql/ConnectionTests.java similarity index 63% rename from test/jdk/java/sql/testng/test/sql/ConnectionTests.java rename to test/jdk/java/sql/test/sql/ConnectionTests.java index f40c2784e4a..534b5d7d96a 100644 --- a/test/jdk/java/sql/testng/test/sql/ConnectionTests.java +++ b/test/jdk/java/sql/test/sql/ConnectionTests.java @@ -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)); } } diff --git a/test/jdk/java/sql/testng/test/sql/DataTruncationTests.java b/test/jdk/java/sql/test/sql/DataTruncationTests.java similarity index 97% rename from test/jdk/java/sql/testng/test/sql/DataTruncationTests.java rename to test/jdk/java/sql/test/sql/DataTruncationTests.java index fbf7eebe90a..9d221b4a037 100644 --- a/test/jdk/java/sql/testng/test/sql/DataTruncationTests.java +++ b/test/jdk/java/sql/test/sql/DataTruncationTests.java @@ -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 { diff --git a/test/jdk/java/sql/testng/test/sql/DateTests.java b/test/jdk/java/sql/test/sql/DateTests.java similarity index 80% rename from test/jdk/java/sql/testng/test/sql/DateTests.java rename to test/jdk/java/sql/test/sql/DateTests.java index ae6c276c4f6..0c66dd15c98 100644 --- a/test/jdk/java/sql/testng/test/sql/DateTests.java +++ b/test/jdk/java/sql/test/sql/DateTests.java @@ -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 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 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") + ); } } diff --git a/test/jdk/java/sql/testng/test/sql/DriverManagerTests.java b/test/jdk/java/sql/test/sql/DriverManagerTests.java similarity index 84% rename from test/jdk/java/sql/testng/test/sql/DriverManagerTests.java rename to test/jdk/java/sql/test/sql/DriverManagerTests.java index 6b6e8386835..3797b625d21 100644 --- a/test/jdk/java/sql/testng/test/sql/DriverManagerTests.java +++ b/test/jdk/java/sql/test/sql/DriverManagerTests.java @@ -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 expectedDrivers = Collections.list(DriverManager.getDrivers()); - assertEquals(expectedDrivers.size(), n); + assertEquals(n, expectedDrivers.size()); Collection drivers = DriverManager.drivers().collect(Collectors.toList()); - assertEquals(drivers, expectedDrivers); + assertEquals(expectedDrivers, drivers); } } diff --git a/test/jdk/java/sql/test/sql/JavatimeTest.java b/test/jdk/java/sql/test/sql/JavatimeTest.java new file mode 100644 index 00000000000..acc0ac3e841 --- /dev/null +++ b/test/jdk/java/sql/test/sql/JavatimeTest.java @@ -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 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); + } +} \ No newline at end of file diff --git a/test/jdk/java/sql/testng/test/sql/PreparedStatementTests.java b/test/jdk/java/sql/test/sql/PreparedStatementTests.java similarity index 62% rename from test/jdk/java/sql/testng/test/sql/PreparedStatementTests.java rename to test/jdk/java/sql/test/sql/PreparedStatementTests.java index 7813038361d..574b0369b4e 100644 --- a/test/jdk/java/sql/testng/test/sql/PreparedStatementTests.java +++ b/test/jdk/java/sql/test/sql/PreparedStatementTests.java @@ -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)); } } diff --git a/test/jdk/java/sql/testng/test/sql/SQLClientInfoExceptionTests.java b/test/jdk/java/sql/test/sql/SQLClientInfoExceptionTests.java similarity index 97% rename from test/jdk/java/sql/testng/test/sql/SQLClientInfoExceptionTests.java rename to test/jdk/java/sql/test/sql/SQLClientInfoExceptionTests.java index 84230b86758..bea35d95c1c 100644 --- a/test/jdk/java/sql/testng/test/sql/SQLClientInfoExceptionTests.java +++ b/test/jdk/java/sql/test/sql/SQLClientInfoExceptionTests.java @@ -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 { diff --git a/test/jdk/java/sql/testng/test/sql/SQLDataExceptionTests.java b/test/jdk/java/sql/test/sql/SQLDataExceptionTests.java similarity index 97% rename from test/jdk/java/sql/testng/test/sql/SQLDataExceptionTests.java rename to test/jdk/java/sql/test/sql/SQLDataExceptionTests.java index 8a5f8d1a2c1..a18f6406e66 100644 --- a/test/jdk/java/sql/testng/test/sql/SQLDataExceptionTests.java +++ b/test/jdk/java/sql/test/sql/SQLDataExceptionTests.java @@ -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 { diff --git a/test/jdk/java/sql/testng/test/sql/SQLExceptionTests.java b/test/jdk/java/sql/test/sql/SQLExceptionTests.java similarity index 97% rename from test/jdk/java/sql/testng/test/sql/SQLExceptionTests.java rename to test/jdk/java/sql/test/sql/SQLExceptionTests.java index e3643ef119c..8a7850d8fd9 100644 --- a/test/jdk/java/sql/testng/test/sql/SQLExceptionTests.java +++ b/test/jdk/java/sql/test/sql/SQLExceptionTests.java @@ -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 { diff --git a/test/jdk/java/sql/testng/test/sql/SQLFeatureNotSupportedExceptionTests.java b/test/jdk/java/sql/test/sql/SQLFeatureNotSupportedExceptionTests.java similarity index 97% rename from test/jdk/java/sql/testng/test/sql/SQLFeatureNotSupportedExceptionTests.java rename to test/jdk/java/sql/test/sql/SQLFeatureNotSupportedExceptionTests.java index 5b95894412c..24049addfa1 100644 --- a/test/jdk/java/sql/testng/test/sql/SQLFeatureNotSupportedExceptionTests.java +++ b/test/jdk/java/sql/test/sql/SQLFeatureNotSupportedExceptionTests.java @@ -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 { diff --git a/test/jdk/java/sql/testng/test/sql/SQLIntegrityConstraintViolationExceptionTests.java b/test/jdk/java/sql/test/sql/SQLIntegrityConstraintViolationExceptionTests.java similarity index 97% rename from test/jdk/java/sql/testng/test/sql/SQLIntegrityConstraintViolationExceptionTests.java rename to test/jdk/java/sql/test/sql/SQLIntegrityConstraintViolationExceptionTests.java index 082e0af15c8..c8c0958e3f3 100644 --- a/test/jdk/java/sql/testng/test/sql/SQLIntegrityConstraintViolationExceptionTests.java +++ b/test/jdk/java/sql/test/sql/SQLIntegrityConstraintViolationExceptionTests.java @@ -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 { diff --git a/test/jdk/java/sql/testng/test/sql/SQLInvalidAuthorizationSpecExceptionTests.java b/test/jdk/java/sql/test/sql/SQLInvalidAuthorizationSpecExceptionTests.java similarity index 97% rename from test/jdk/java/sql/testng/test/sql/SQLInvalidAuthorizationSpecExceptionTests.java rename to test/jdk/java/sql/test/sql/SQLInvalidAuthorizationSpecExceptionTests.java index 6e4eaa567ee..82a9a345a0e 100644 --- a/test/jdk/java/sql/testng/test/sql/SQLInvalidAuthorizationSpecExceptionTests.java +++ b/test/jdk/java/sql/test/sql/SQLInvalidAuthorizationSpecExceptionTests.java @@ -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 { diff --git a/test/jdk/java/sql/testng/test/sql/SQLNonTransientConnectionExceptionTests.java b/test/jdk/java/sql/test/sql/SQLNonTransientConnectionExceptionTests.java similarity index 97% rename from test/jdk/java/sql/testng/test/sql/SQLNonTransientConnectionExceptionTests.java rename to test/jdk/java/sql/test/sql/SQLNonTransientConnectionExceptionTests.java index dbd8b685844..fa4c75ed672 100644 --- a/test/jdk/java/sql/testng/test/sql/SQLNonTransientConnectionExceptionTests.java +++ b/test/jdk/java/sql/test/sql/SQLNonTransientConnectionExceptionTests.java @@ -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 { diff --git a/test/jdk/java/sql/testng/test/sql/SQLNonTransientExceptionTests.java b/test/jdk/java/sql/test/sql/SQLNonTransientExceptionTests.java similarity index 97% rename from test/jdk/java/sql/testng/test/sql/SQLNonTransientExceptionTests.java rename to test/jdk/java/sql/test/sql/SQLNonTransientExceptionTests.java index 061ffe20840..0f37f905fa7 100644 --- a/test/jdk/java/sql/testng/test/sql/SQLNonTransientExceptionTests.java +++ b/test/jdk/java/sql/test/sql/SQLNonTransientExceptionTests.java @@ -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 { diff --git a/test/jdk/java/sql/testng/test/sql/SQLRecoverableExceptionTests.java b/test/jdk/java/sql/test/sql/SQLRecoverableExceptionTests.java similarity index 97% rename from test/jdk/java/sql/testng/test/sql/SQLRecoverableExceptionTests.java rename to test/jdk/java/sql/test/sql/SQLRecoverableExceptionTests.java index d23a131dbcd..d447e08593c 100644 --- a/test/jdk/java/sql/testng/test/sql/SQLRecoverableExceptionTests.java +++ b/test/jdk/java/sql/test/sql/SQLRecoverableExceptionTests.java @@ -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 { diff --git a/test/jdk/java/sql/testng/test/sql/SQLSyntaxErrorExceptionTests.java b/test/jdk/java/sql/test/sql/SQLSyntaxErrorExceptionTests.java similarity index 97% rename from test/jdk/java/sql/testng/test/sql/SQLSyntaxErrorExceptionTests.java rename to test/jdk/java/sql/test/sql/SQLSyntaxErrorExceptionTests.java index 863213cfcb8..c859f5aa0d2 100644 --- a/test/jdk/java/sql/testng/test/sql/SQLSyntaxErrorExceptionTests.java +++ b/test/jdk/java/sql/test/sql/SQLSyntaxErrorExceptionTests.java @@ -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 { diff --git a/test/jdk/java/sql/testng/test/sql/SQLTimeoutExceptionTests.java b/test/jdk/java/sql/test/sql/SQLTimeoutExceptionTests.java similarity index 97% rename from test/jdk/java/sql/testng/test/sql/SQLTimeoutExceptionTests.java rename to test/jdk/java/sql/test/sql/SQLTimeoutExceptionTests.java index dfe341545e4..a4e249658d9 100644 --- a/test/jdk/java/sql/testng/test/sql/SQLTimeoutExceptionTests.java +++ b/test/jdk/java/sql/test/sql/SQLTimeoutExceptionTests.java @@ -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 { diff --git a/test/jdk/java/sql/testng/test/sql/SQLTransactionRollbackExceptionTests.java b/test/jdk/java/sql/test/sql/SQLTransactionRollbackExceptionTests.java similarity index 97% rename from test/jdk/java/sql/testng/test/sql/SQLTransactionRollbackExceptionTests.java rename to test/jdk/java/sql/test/sql/SQLTransactionRollbackExceptionTests.java index 8453ebe1364..7a7d94cd060 100644 --- a/test/jdk/java/sql/testng/test/sql/SQLTransactionRollbackExceptionTests.java +++ b/test/jdk/java/sql/test/sql/SQLTransactionRollbackExceptionTests.java @@ -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 { diff --git a/test/jdk/java/sql/testng/test/sql/SQLTransientConnectionExceptionTests.java b/test/jdk/java/sql/test/sql/SQLTransientConnectionExceptionTests.java similarity index 97% rename from test/jdk/java/sql/testng/test/sql/SQLTransientConnectionExceptionTests.java rename to test/jdk/java/sql/test/sql/SQLTransientConnectionExceptionTests.java index 7999253b1fa..8ac6ef98222 100644 --- a/test/jdk/java/sql/testng/test/sql/SQLTransientConnectionExceptionTests.java +++ b/test/jdk/java/sql/test/sql/SQLTransientConnectionExceptionTests.java @@ -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 { diff --git a/test/jdk/java/sql/testng/test/sql/SQLTransientExceptionTests.java b/test/jdk/java/sql/test/sql/SQLTransientExceptionTests.java similarity index 97% rename from test/jdk/java/sql/testng/test/sql/SQLTransientExceptionTests.java rename to test/jdk/java/sql/test/sql/SQLTransientExceptionTests.java index d86f86b8fc6..4c43b6c693e 100644 --- a/test/jdk/java/sql/testng/test/sql/SQLTransientExceptionTests.java +++ b/test/jdk/java/sql/test/sql/SQLTransientExceptionTests.java @@ -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 { diff --git a/test/jdk/java/sql/testng/test/sql/SQLWarningTests.java b/test/jdk/java/sql/test/sql/SQLWarningTests.java similarity index 97% rename from test/jdk/java/sql/testng/test/sql/SQLWarningTests.java rename to test/jdk/java/sql/test/sql/SQLWarningTests.java index 2856742dc5c..ab15a877dbd 100644 --- a/test/jdk/java/sql/testng/test/sql/SQLWarningTests.java +++ b/test/jdk/java/sql/test/sql/SQLWarningTests.java @@ -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 { diff --git a/test/jdk/java/sql/testng/test/sql/StatementTests.java b/test/jdk/java/sql/test/sql/StatementTests.java similarity index 62% rename from test/jdk/java/sql/testng/test/sql/StatementTests.java rename to test/jdk/java/sql/test/sql/StatementTests.java index f2bfe712eb5..42e971cc971 100644 --- a/test/jdk/java/sql/testng/test/sql/StatementTests.java +++ b/test/jdk/java/sql/test/sql/StatementTests.java @@ -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)); } } diff --git a/test/jdk/java/sql/testng/test/sql/TimeTests.java b/test/jdk/java/sql/test/sql/TimeTests.java similarity index 76% rename from test/jdk/java/sql/testng/test/sql/TimeTests.java rename to test/jdk/java/sql/test/sql/TimeTests.java index 7b99679754b..71208f03222 100644 --- a/test/jdk/java/sql/testng/test/sql/TimeTests.java +++ b/test/jdk/java/sql/test/sql/TimeTests.java @@ -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 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 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") + ); } } diff --git a/test/jdk/java/sql/testng/test/sql/TimestampTests.java b/test/jdk/java/sql/test/sql/TimestampTests.java similarity index 73% rename from test/jdk/java/sql/testng/test/sql/TimestampTests.java rename to test/jdk/java/sql/test/sql/TimestampTests.java index 6baea9fa26f..33a58c8d857 100644 --- a/test/jdk/java/sql/testng/test/sql/TimestampTests.java +++ b/test/jdk/java/sql/test/sql/TimestampTests.java @@ -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 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 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 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 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) + ); } } diff --git a/test/jdk/java/sql/testng/test/sql/othervm/DriverManagerInitTests.java b/test/jdk/java/sql/test/sql/drivermanager/DriverManagerInitTests.java similarity index 93% rename from test/jdk/java/sql/testng/test/sql/othervm/DriverManagerInitTests.java rename to test/jdk/java/sql/test/sql/drivermanager/DriverManagerInitTests.java index d2570993533..f77fde4b166 100644 --- a/test/jdk/java/sql/testng/test/sql/othervm/DriverManagerInitTests.java +++ b/test/jdk/java/sql/test/sql/drivermanager/DriverManagerInitTests.java @@ -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 { diff --git a/test/jdk/java/sql/driverModuleTests/DriverManagerModuleTests.java b/test/jdk/java/sql/test/sql/drivermanager/DriverManagerModuleTests.java similarity index 84% rename from test/jdk/java/sql/driverModuleTests/DriverManagerModuleTests.java rename to test/jdk/java/sql/test/sql/drivermanager/DriverManagerModuleTests.java index aad39cdb1dd..083153ac38f 100644 --- a/test/jdk/java/sql/driverModuleTests/DriverManagerModuleTests.java +++ b/test/jdk/java/sql/test/sql/drivermanager/DriverManagerModuleTests.java @@ -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 { diff --git a/test/jdk/java/sql/test/sql/drivermanager/TEST.properties b/test/jdk/java/sql/test/sql/drivermanager/TEST.properties new file mode 100644 index 00000000000..0fed686adad --- /dev/null +++ b/test/jdk/java/sql/test/sql/drivermanager/TEST.properties @@ -0,0 +1,4 @@ +# drivermanager tests are run in othervm +othervm.dirs = . +# Required by DriverManagerModuleTests.java +lib.dirs = /java/sql/modules diff --git a/test/jdk/java/sql/testng/TEST.properties b/test/jdk/java/sql/testng/TEST.properties deleted file mode 100644 index 66b1566374a..00000000000 --- a/test/jdk/java/sql/testng/TEST.properties +++ /dev/null @@ -1,4 +0,0 @@ -# JDBC unit tests uses TestNG -TestNG.dirs = . -othervm.dirs = test/sql/othervm - diff --git a/test/jdk/java/sql/testng/util/BaseTest.java b/test/jdk/java/sql/util/BaseTest.java similarity index 54% rename from test/jdk/java/sql/testng/util/BaseTest.java rename to test/jdk/java/sql/util/BaseTest.java index 8751183726d..1a1b14e795a 100644 --- a/test/jdk/java/sql/testng/util/BaseTest.java +++ b/test/jdk/java/sql/util/BaseTest.java @@ -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 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 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 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 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 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 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'") + ); } } diff --git a/test/jdk/java/sql/testng/util/DriverActionImpl.java b/test/jdk/java/sql/util/DriverActionImpl.java similarity index 94% rename from test/jdk/java/sql/testng/util/DriverActionImpl.java rename to test/jdk/java/sql/util/DriverActionImpl.java index 4a286ad8f3c..48fed8086a7 100644 --- a/test/jdk/java/sql/testng/util/DriverActionImpl.java +++ b/test/jdk/java/sql/util/DriverActionImpl.java @@ -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 diff --git a/test/jdk/java/sql/testng/util/SerializedBatchUpdateException.java b/test/jdk/java/sql/util/SerializedBatchUpdateException.java similarity index 99% rename from test/jdk/java/sql/testng/util/SerializedBatchUpdateException.java rename to test/jdk/java/sql/util/SerializedBatchUpdateException.java index 00efc5275a7..08473e6a184 100644 --- a/test/jdk/java/sql/testng/util/SerializedBatchUpdateException.java +++ b/test/jdk/java/sql/util/SerializedBatchUpdateException.java @@ -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 diff --git a/test/jdk/java/sql/testng/util/StubCallableStatement.java b/test/jdk/java/sql/util/StubCallableStatement.java similarity index 99% rename from test/jdk/java/sql/testng/util/StubCallableStatement.java rename to test/jdk/java/sql/util/StubCallableStatement.java index 4a7c27314bb..4700699c4ba 100644 --- a/test/jdk/java/sql/testng/util/StubCallableStatement.java +++ b/test/jdk/java/sql/util/StubCallableStatement.java @@ -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 diff --git a/test/jdk/java/sql/testng/util/StubConnection.java b/test/jdk/java/sql/util/StubConnection.java similarity index 99% rename from test/jdk/java/sql/testng/util/StubConnection.java rename to test/jdk/java/sql/util/StubConnection.java index cd013572adc..e1a60efc323 100644 --- a/test/jdk/java/sql/testng/util/StubConnection.java +++ b/test/jdk/java/sql/util/StubConnection.java @@ -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 diff --git a/test/jdk/java/sql/testng/util/StubDatabaseMetaData.java b/test/jdk/java/sql/util/StubDatabaseMetaData.java similarity index 99% rename from test/jdk/java/sql/testng/util/StubDatabaseMetaData.java rename to test/jdk/java/sql/util/StubDatabaseMetaData.java index 3bf70afaa8f..3c95ac94793 100644 --- a/test/jdk/java/sql/testng/util/StubDatabaseMetaData.java +++ b/test/jdk/java/sql/util/StubDatabaseMetaData.java @@ -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 diff --git a/test/jdk/java/sql/testng/util/StubDriver.java b/test/jdk/java/sql/util/StubDriver.java similarity index 96% rename from test/jdk/java/sql/testng/util/StubDriver.java rename to test/jdk/java/sql/util/StubDriver.java index 12253080377..c45b9ec9919 100644 --- a/test/jdk/java/sql/testng/util/StubDriver.java +++ b/test/jdk/java/sql/util/StubDriver.java @@ -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 diff --git a/test/jdk/java/sql/testng/util/StubDriverDA.java b/test/jdk/java/sql/util/StubDriverDA.java similarity index 96% rename from test/jdk/java/sql/testng/util/StubDriverDA.java rename to test/jdk/java/sql/util/StubDriverDA.java index 5b23f0846d8..f134a9d28cf 100644 --- a/test/jdk/java/sql/testng/util/StubDriverDA.java +++ b/test/jdk/java/sql/util/StubDriverDA.java @@ -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 diff --git a/test/jdk/java/sql/testng/util/StubPreparedStatement.java b/test/jdk/java/sql/util/StubPreparedStatement.java similarity index 99% rename from test/jdk/java/sql/testng/util/StubPreparedStatement.java rename to test/jdk/java/sql/util/StubPreparedStatement.java index a3b95a65f4e..fdb90df4797 100644 --- a/test/jdk/java/sql/testng/util/StubPreparedStatement.java +++ b/test/jdk/java/sql/util/StubPreparedStatement.java @@ -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 diff --git a/test/jdk/java/sql/testng/util/StubStatement.java b/test/jdk/java/sql/util/StubStatement.java similarity index 99% rename from test/jdk/java/sql/testng/util/StubStatement.java rename to test/jdk/java/sql/util/StubStatement.java index c8f6a3ac071..00ed6268856 100644 --- a/test/jdk/java/sql/testng/util/StubStatement.java +++ b/test/jdk/java/sql/util/StubStatement.java @@ -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 diff --git a/test/jdk/javax/sql/testng/TEST.properties b/test/jdk/javax/sql/TEST.properties similarity index 68% rename from test/jdk/javax/sql/testng/TEST.properties rename to test/jdk/javax/sql/TEST.properties index cb97c160507..d9ed805344a 100644 --- a/test/jdk/javax/sql/testng/TEST.properties +++ b/test/jdk/javax/sql/TEST.properties @@ -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 diff --git a/test/jdk/javax/sql/testng/jars/badFactory/META-INF/services/javax.sql.rowset.RowSetFactory b/test/jdk/javax/sql/jars/badFactory/META-INF/services/javax.sql.rowset.RowSetFactory similarity index 100% rename from test/jdk/javax/sql/testng/jars/badFactory/META-INF/services/javax.sql.rowset.RowSetFactory rename to test/jdk/javax/sql/jars/badFactory/META-INF/services/javax.sql.rowset.RowSetFactory diff --git a/test/jdk/javax/sql/testng/jars/goodFactory/META-INF/services/javax.sql.rowset.RowSetFactory b/test/jdk/javax/sql/jars/goodFactory/META-INF/services/javax.sql.rowset.RowSetFactory similarity index 100% rename from test/jdk/javax/sql/testng/jars/goodFactory/META-INF/services/javax.sql.rowset.RowSetFactory rename to test/jdk/javax/sql/jars/goodFactory/META-INF/services/javax.sql.rowset.RowSetFactory diff --git a/test/jdk/javax/sql/rowset/TEST.properties b/test/jdk/javax/sql/rowset/TEST.properties deleted file mode 100644 index 6c5a2c7aceb..00000000000 --- a/test/jdk/javax/sql/rowset/TEST.properties +++ /dev/null @@ -1 +0,0 @@ -modules = java.sql.rowset diff --git a/test/jdk/javax/sql/rowset/serial/SerialBlob/SetBinaryStream.java b/test/jdk/javax/sql/rowset/serial/SerialBlob/SetBinaryStream.java deleted file mode 100644 index a2d7ea2f8cb..00000000000 --- a/test/jdk/javax/sql/rowset/serial/SerialBlob/SetBinaryStream.java +++ /dev/null @@ -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"); - } - } - -} diff --git a/test/jdk/javax/sql/rowset/serial/SerialClob/SetAsciiStream.java b/test/jdk/javax/sql/rowset/serial/SerialClob/SetAsciiStream.java deleted file mode 100644 index 10deaf523e9..00000000000 --- a/test/jdk/javax/sql/rowset/serial/SerialClob/SetAsciiStream.java +++ /dev/null @@ -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"); - } - } - -} diff --git a/test/jdk/javax/sql/rowset/serial/SerialClob/SetCharacterStream.java b/test/jdk/javax/sql/rowset/serial/SerialClob/SetCharacterStream.java deleted file mode 100644 index be861e43723..00000000000 --- a/test/jdk/javax/sql/rowset/serial/SerialClob/SetCharacterStream.java +++ /dev/null @@ -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"); - } - } - -} diff --git a/test/jdk/javax/sql/testng/test/rowset/BaseRowSetTests.java b/test/jdk/javax/sql/test/rowset/BaseRowSetTests.java similarity index 83% rename from test/jdk/javax/sql/testng/test/rowset/BaseRowSetTests.java rename to test/jdk/javax/sql/test/rowset/BaseRowSetTests.java index c1d2d9a2ed0..8c47415db39 100644 --- a/test/jdk/javax/sql/testng/test/rowset/BaseRowSetTests.java +++ b/test/jdk/javax/sql/test/rowset/BaseRowSetTests.java @@ -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 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 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) + ); } /* diff --git a/test/jdk/javax/sql/testng/test/rowset/CommonRowSetTests.java b/test/jdk/javax/sql/test/rowset/CommonRowSetTests.java similarity index 67% rename from test/jdk/javax/sql/testng/test/rowset/CommonRowSetTests.java rename to test/jdk/javax/sql/test/rowset/CommonRowSetTests.java index 89492aefed5..5e8163fbf05 100644 --- a/test/jdk/javax/sql/testng/test/rowset/CommonRowSetTests.java +++ b/test/jdk/javax/sql/test/rowset/CommonRowSetTests.java @@ -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 @@ -43,17 +43,23 @@ import java.util.Calendar; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Stream; import javax.sql.RowSet; import javax.sql.rowset.BaseRowSet; import javax.sql.rowset.CachedRowSet; import javax.sql.rowset.RowSetFactory; import javax.sql.rowset.RowSetMetaDataImpl; import javax.sql.rowset.RowSetProvider; -import org.testng.Assert; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; + +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + +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.StubBlob; import util.StubClob; @@ -98,7 +104,7 @@ public abstract class CommonRowSetTests extends BaseTest { try { rsf = RowSetProvider.newFactory(); } catch (SQLException ex) { - Assert.fail(ex.getMessage()); + fail(ex.getMessage()); } } @@ -111,84 +117,76 @@ public abstract class CommonRowSetTests extends BaseTest { * DataProvider used to specify the value to set and check for the * methods for fetch direction */ - @DataProvider(name = "rowSetFetchDirection") - protected Object[][] rowSetFetchDirection() throws Exception { + protected Stream rowSetFetchDirection() throws Exception { RowSet rs = newInstance(); - return new Object[][]{ - {rs, ResultSet.FETCH_FORWARD}, - {rs, ResultSet.FETCH_REVERSE}, - {rs, ResultSet.FETCH_UNKNOWN} - }; + return Stream.of( + Arguments.of(rs, ResultSet.FETCH_FORWARD), + Arguments.of(rs, ResultSet.FETCH_REVERSE), + Arguments.of(rs, ResultSet.FETCH_UNKNOWN) + ); } /* * DataProvider used to specify the value to set and check for the * methods for Cursor Scroll Type */ - @DataProvider(name = "rowSetScrollTypes") - protected Object[][] rowSetScrollTypes() throws Exception { + protected Stream rowSetScrollTypes() throws Exception { RowSet rs = newInstance(); - return new Object[][]{ - {rs, ResultSet.TYPE_FORWARD_ONLY}, - {rs, ResultSet.TYPE_SCROLL_INSENSITIVE}, - {rs, ResultSet.TYPE_SCROLL_SENSITIVE} - }; + return Stream.of( + Arguments.of(rs, ResultSet.TYPE_FORWARD_ONLY), + Arguments.of(rs, ResultSet.TYPE_SCROLL_INSENSITIVE), + Arguments.of(rs, ResultSet.TYPE_SCROLL_SENSITIVE) + ); } /* * DataProvider used to specify the value to set and check for * methods using transaction isolation types */ - @DataProvider(name = "rowSetIsolationTypes") - protected Object[][] rowSetIsolationTypes() throws Exception { + protected Stream rowSetIsolationTypes() throws Exception { RowSet rs = newInstance(); - return new Object[][]{ - {rs, Connection.TRANSACTION_NONE}, - {rs, Connection.TRANSACTION_READ_COMMITTED}, - {rs, Connection.TRANSACTION_READ_UNCOMMITTED}, - {rs, Connection.TRANSACTION_REPEATABLE_READ}, - {rs, Connection.TRANSACTION_SERIALIZABLE} - }; + return Stream.of( + Arguments.of(rs, Connection.TRANSACTION_NONE), + Arguments.of(rs, Connection.TRANSACTION_READ_COMMITTED), + Arguments.of(rs, Connection.TRANSACTION_READ_UNCOMMITTED), + Arguments.of(rs, Connection.TRANSACTION_REPEATABLE_READ), + Arguments.of(rs, Connection.TRANSACTION_SERIALIZABLE) + ); } /* * DataProvider used to specify the value to set and check for the * methods for Concurrency */ - @DataProvider(name = "rowSetConcurrencyTypes") - protected Object[][] rowSetConcurrencyTypes() throws Exception { + protected Stream rowSetConcurrencyTypes() throws Exception { RowSet rs = newInstance(); - return new Object[][]{ - {rs, ResultSet.CONCUR_READ_ONLY}, - {rs, ResultSet.CONCUR_UPDATABLE} - }; + return Stream.of( + Arguments.of(rs, ResultSet.CONCUR_READ_ONLY), + Arguments.of(rs, ResultSet.CONCUR_UPDATABLE) + ); } /* * DataProvider used to specify the value to set and check for * methods using boolean values */ - @DataProvider(name = "rowSetTrueFalse") - protected Object[][] rowSetTrueFalse() throws Exception { + protected Stream rowSetTrueFalse() throws Exception { RowSet rs = newInstance(); - return new Object[][]{ - {rs, true}, - {rs, false} - }; + return Stream.of( + Arguments.of(rs, true), + Arguments.of(rs, false) + ); } /* * DataProvider used to specify the type of RowSet to use. We also must * initialize the RowSet */ - @DataProvider(name = "rowSetType") - protected Object[][] rowSetType() throws Exception { + protected Stream rowSetType() throws Exception { RowSet rs = newInstance(); - return new Object[][]{ - {rs} - }; + return Stream.of(rs); } /* @@ -503,7 +501,8 @@ public abstract class CommonRowSetTests extends BaseTest { /* * Validate that getCommand() returns null by default */ - @Test(dataProvider = "rowSetType") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0000(RowSet rs) { assertNull(rs.getCommand()); } @@ -511,7 +510,8 @@ public abstract class CommonRowSetTests extends BaseTest { /* * Validate that getCommand() returns command specified to setCommand */ - @Test(dataProvider = "rowSetType") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0001(RowSet rs) throws Exception { rs.setCommand(query); assertTrue(rs.getCommand().equals(query)); @@ -521,7 +521,8 @@ public abstract class CommonRowSetTests extends BaseTest { /* * Validate that getCurrency() returns the correct default value */ - @Test(dataProvider = "rowSetType") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0002(RowSet rs) throws Exception { assertTrue(rs.getConcurrency() == ResultSet.CONCUR_UPDATABLE); } @@ -530,7 +531,8 @@ public abstract class CommonRowSetTests extends BaseTest { * Validate that getCurrency() returns the correct value * after a call to setConcurrency()) */ - @Test(dataProvider = "rowSetConcurrencyTypes") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetConcurrencyTypes") public void commonRowSetTest0003(RowSet rs, int concurType) throws Exception { rs.setConcurrency(concurType); assertTrue(rs.getConcurrency() == concurType); @@ -539,15 +541,17 @@ public abstract class CommonRowSetTests extends BaseTest { /* * Validate that getCurrency() throws a SQLException for an invalid value */ - @Test(dataProvider = "rowSetType", expectedExceptions = SQLException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0004(RowSet rs) throws Exception { - rs.setConcurrency(ResultSet.CLOSE_CURSORS_AT_COMMIT); + assertThrows(SQLException.class, () -> rs.setConcurrency(ResultSet.CLOSE_CURSORS_AT_COMMIT)); } /* * Validate that getDataSourceName() returns null by default */ - @Test(dataProvider = "rowSetType") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0005(RowSet rs) throws Exception { assertTrue(rs.getDataSourceName() == null); } @@ -556,7 +560,8 @@ public abstract class CommonRowSetTests extends BaseTest { * Validate that getDataSourceName() returns the value specified * by setDataSourceName() and getUrl() returns null */ - @Test(dataProvider = "rowSetType") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0006(RowSet rs) throws Exception { rs.setUrl(url); rs.setDataSourceName(dsName); @@ -568,16 +573,20 @@ public abstract class CommonRowSetTests extends BaseTest { * Validate that setDataSourceName() throws a SQLException for an empty * String specified for the data source name */ - @Test(dataProvider = "rowSetType", expectedExceptions = SQLException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0007(RowSet rs) throws Exception { - String dsname = ""; - rs.setDataSourceName(dsname); + assertThrows(SQLException.class, () -> { + String dsname = ""; + rs.setDataSourceName(dsname); + }); } /* * Validate that getEscapeProcessing() returns false by default */ - @Test(dataProvider = "rowSetType") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0008(RowSet rs) throws Exception { assertTrue(rs.getEscapeProcessing()); } @@ -586,7 +595,8 @@ public abstract class CommonRowSetTests extends BaseTest { * Validate that getEscapeProcessing() returns value set by * setEscapeProcessing() */ - @Test(dataProvider = "rowSetTrueFalse") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetTrueFalse") public void commonRowSetTest0009(RowSet rs, boolean val) throws Exception { rs.setEscapeProcessing(val); assertTrue(rs.getEscapeProcessing() == val); @@ -595,7 +605,8 @@ public abstract class CommonRowSetTests extends BaseTest { /* * Validate that getFetchDirection() returns the correct default value */ - @Test(dataProvider = "rowSetType") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0010(RowSet rs) throws Exception { assertTrue(rs.getFetchDirection() == ResultSet.FETCH_FORWARD); } @@ -604,7 +615,8 @@ public abstract class CommonRowSetTests extends BaseTest { * Validate that getFetchDirection() returns the value set by * setFetchDirection() */ - @Test(dataProvider = "rowSetFetchDirection") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetFetchDirection") public void commonRowSetTest0011(RowSet rs, int direction) throws Exception { rs.setFetchDirection(direction); assertTrue(rs.getFetchDirection() == direction); @@ -613,26 +625,31 @@ public abstract class CommonRowSetTests extends BaseTest { /* * Validate that setFetchSize() throws a SQLException for an invalid value */ - @Test(dataProvider = "rowSetType", expectedExceptions = SQLException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0013(RowSet rs) throws Exception { - rs.setFetchSize(-1); + assertThrows(SQLException.class, () -> rs.setFetchSize(-1)); } /* * Validate that setFetchSize() throws a SQLException for a * value greater than getMaxRows() */ - @Test(dataProvider = "rowSetType", expectedExceptions = SQLException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0014(RowSet rs) throws Exception { - rs.setMaxRows(5); - rs.setFetchSize(rs.getMaxRows() + 1); + assertThrows(SQLException.class, () -> { + rs.setMaxRows(5); + rs.setFetchSize(rs.getMaxRows() + 1); + }); } /* * Validate that getFetchSize() returns the correct value after * setFetchSize() has been called */ - @Test(dataProvider = "rowSetType") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0015(RowSet rs) throws Exception { int maxRows = 150; rs.setFetchSize(0); @@ -647,16 +664,18 @@ public abstract class CommonRowSetTests extends BaseTest { /* * Validate that setMaxFieldSize() throws a SQLException for an invalid value */ - @Test(dataProvider = "rowSetType", expectedExceptions = SQLException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0016(RowSet rs) throws Exception { - rs.setMaxFieldSize(-1); + assertThrows(SQLException.class, () -> rs.setMaxFieldSize(-1)); } /* * Validate that getMaxFieldSize() returns the value set by * setMaxFieldSize() */ - @Test(dataProvider = "rowSetType") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0017(RowSet rs) throws Exception { rs.setMaxFieldSize(0); assertTrue(rs.getMaxFieldSize() == 0); @@ -670,7 +689,8 @@ public abstract class CommonRowSetTests extends BaseTest { * Validate that isReadOnly() returns value set by * setReadOnly() */ - @Test(dataProvider = "rowSetTrueFalse") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetTrueFalse") public void commonRowSetTest0018(RowSet rs, boolean val) throws Exception { rs.setReadOnly(val); assertTrue(rs.isReadOnly() == val); @@ -680,7 +700,8 @@ public abstract class CommonRowSetTests extends BaseTest { * Validate that getTransactionIsolation() returns value set by * setTransactionIsolation() */ - @Test(dataProvider = "rowSetIsolationTypes") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetIsolationTypes") public void commonRowSetTest0019(RowSet rs, int val) throws Exception { rs.setTransactionIsolation(val); assertTrue(rs.getTransactionIsolation() == val); @@ -689,7 +710,8 @@ public abstract class CommonRowSetTests extends BaseTest { /* * Validate that getType() returns value set by setType() */ - @Test(dataProvider = "rowSetScrollTypes") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetScrollTypes") public void commonRowSetTest0020(RowSet rs, int val) throws Exception { rs.setType(val); assertTrue(rs.getType() == val); @@ -699,7 +721,8 @@ public abstract class CommonRowSetTests extends BaseTest { * Validate that getEscapeProcessing() returns value set by * setEscapeProcessing() */ - @Test(dataProvider = "rowSetTrueFalse") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetTrueFalse") public void commonRowSetTest0021(BaseRowSet rs, boolean val) throws Exception { rs.setShowDeleted(val); assertTrue(rs.getShowDeleted() == val); @@ -709,7 +732,8 @@ public abstract class CommonRowSetTests extends BaseTest { * Validate that getTypeMap() returns same value set by * setTypeMap() */ - @Test(dataProvider = "rowSetType") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0022(RowSet rs) throws Exception { Map> map = new HashMap<>(); map.put("SUPERHERO", Class.forName("util.SuperHero")); @@ -721,7 +745,8 @@ public abstract class CommonRowSetTests extends BaseTest { * Validate that getUsername() returns same value set by * setUsername() */ - @Test(dataProvider = "rowSetType") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0023(RowSet rs) throws Exception { rs.setUsername(user); assertTrue(rs.getUsername().equals(user)); @@ -731,7 +756,8 @@ public abstract class CommonRowSetTests extends BaseTest { * Validate that getPassword() returns same password set by * setPassword() */ - @Test(dataProvider = "rowSetType") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0024(RowSet rs) throws Exception { rs.setPassword(password); assertTrue(rs.getPassword().equals(password)); @@ -741,7 +767,8 @@ public abstract class CommonRowSetTests extends BaseTest { * Validate that getQueryTimeout() returns same value set by * setQueryTimeout() and that 0 is a valid timeout value */ - @Test(dataProvider = "rowSetType") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0025(RowSet rs) throws Exception { int timeout = 0; rs.setQueryTimeout(timeout); @@ -752,7 +779,8 @@ public abstract class CommonRowSetTests extends BaseTest { * Validate that getQueryTimeout() returns same value set by * setQueryTimeout() and that 0 is a valid timeout value */ - @Test(dataProvider = "rowSetType") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0026(RowSet rs) throws Exception { int timeout = 10000; rs.setQueryTimeout(timeout); @@ -763,9 +791,10 @@ public abstract class CommonRowSetTests extends BaseTest { * Validate that setQueryTimeout() throws a SQLException for a timeout * value < 0 */ - @Test(dataProvider = "rowSetType", expectedExceptions = SQLException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0027(RowSet rs) throws Exception { - rs.setQueryTimeout(-1); + assertThrows(SQLException.class, () -> rs.setQueryTimeout(-1)); } @@ -773,7 +802,8 @@ public abstract class CommonRowSetTests extends BaseTest { * Validate addRowSetListener does not throw an Exception when null is * passed as the parameter */ - @Test(dataProvider = "rowSetType") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0028(RowSet rs) throws Exception { rs.addRowSetListener(null); } @@ -782,7 +812,8 @@ public abstract class CommonRowSetTests extends BaseTest { * Validate removeRowSetListener does not throw an Exception when null is * passed as the parameter */ - @Test(dataProvider = "rowSetType") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0029(RowSet rs) throws Exception { rs.removeRowSetListener(null); } @@ -790,7 +821,8 @@ public abstract class CommonRowSetTests extends BaseTest { /* * Set two parameters and then validate clearParameters() will clear them */ - @Test(dataProvider = "rowSetType") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0030(BaseRowSet rs) throws Exception { rs.setInt(1, 1); rs.setString(2, query); @@ -803,7 +835,8 @@ public abstract class CommonRowSetTests extends BaseTest { * Validate that getURL() returns same value set by * setURL() */ - @Test(dataProvider = "rowSetType") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0031(RowSet rs) throws Exception { rs.setUrl(url); assertTrue(rs.getUrl().equals(url)); @@ -813,560 +846,614 @@ public abstract class CommonRowSetTests extends BaseTest { * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0100(RowSet rs) throws Exception { - InputStream is = null; - rs.setAsciiStream(1, is); + assertThrows(SQLFeatureNotSupportedException.class, () -> { + InputStream is = null; + rs.setAsciiStream(1, is); + }); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0101(RowSet rs) throws Exception { - InputStream is = null; - rs.setAsciiStream("one", is); + assertThrows(SQLFeatureNotSupportedException.class, () -> { + InputStream is = null; + rs.setAsciiStream("one", is); + }); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0102(RowSet rs) throws Exception { - InputStream is = null; - rs.setAsciiStream("one", is, query.length()); + assertThrows(SQLFeatureNotSupportedException.class, () -> { + InputStream is = null; + rs.setAsciiStream("one", is, query.length()); + }); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0103(RowSet rs) throws Exception { - InputStream is = null; - rs.setBinaryStream(1, is); + assertThrows(SQLFeatureNotSupportedException.class, () -> { + InputStream is = null; + rs.setBinaryStream(1, is); + }); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0104(RowSet rs) throws Exception { - InputStream is = null; - rs.setBinaryStream("one", is); + assertThrows(SQLFeatureNotSupportedException.class, () -> { + InputStream is = null; + rs.setBinaryStream("one", is); + }); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0105(RowSet rs) throws Exception { - InputStream is = null; - rs.setBinaryStream("one", is, query.length()); + assertThrows(SQLFeatureNotSupportedException.class, () -> { + InputStream is = null; + rs.setBinaryStream("one", is, query.length()); + }); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0106(RowSet rs) throws Exception { - rs.setBigDecimal("one", BigDecimal.ONE); + assertThrows(SQLFeatureNotSupportedException.class, () -> rs.setBigDecimal("one", BigDecimal.ONE)); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0107(RowSet rs) throws Exception { - InputStream is = null; - rs.setBlob(1, is); + assertThrows(SQLFeatureNotSupportedException.class, () -> { + InputStream is = null; + rs.setBlob(1, is); + }); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0108(RowSet rs) throws Exception { - InputStream is = null; - rs.setBlob("one", is); + assertThrows(SQLFeatureNotSupportedException.class, () -> { + InputStream is = null; + rs.setBlob("one", is); + }); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0109(RowSet rs) throws Exception { - InputStream is = null; - rs.setBlob("one", is, query.length()); + assertThrows(SQLFeatureNotSupportedException.class, () -> { + InputStream is = null; + rs.setBlob("one", is, query.length()); + }); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0110(RowSet rs) throws Exception { - rs.setBlob("one", new StubBlob()); + assertThrows(SQLFeatureNotSupportedException.class, () -> rs.setBlob("one", new StubBlob())); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0111(RowSet rs) throws Exception { - rs.setBoolean("one", true); + assertThrows(SQLFeatureNotSupportedException.class, () -> rs.setBoolean("one", true)); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0112(RowSet rs) throws Exception { - byte b = 1; - rs.setByte("one", b); + assertThrows(SQLFeatureNotSupportedException.class, () -> { + byte b = 1; + rs.setByte("one", b); + }); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0113(RowSet rs) throws Exception { - byte b = 1; - rs.setBytes("one", new byte[10]); + assertThrows(SQLFeatureNotSupportedException.class, () -> { + byte b = 1; + rs.setBytes("one", new byte[10]); + }); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0114(RowSet rs) throws Exception { - Reader rdr = null; - rs.setCharacterStream("one", rdr, query.length()); + assertThrows(SQLFeatureNotSupportedException.class, () -> { + Reader rdr = null; + rs.setCharacterStream("one", rdr, query.length()); + }); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0115(RowSet rs) throws Exception { - Reader rdr = null; - rs.setCharacterStream("one", rdr); + assertThrows(SQLFeatureNotSupportedException.class, () -> { + Reader rdr = null; + rs.setCharacterStream("one", rdr); + }); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0116(RowSet rs) throws Exception { - Reader rdr = null; - rs.setCharacterStream(1, rdr); + assertThrows(SQLFeatureNotSupportedException.class, () -> { + Reader rdr = null; + rs.setCharacterStream(1, rdr); + }); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0117(RowSet rs) throws Exception { - Reader rdr = null; - rs.setClob(1, rdr); + assertThrows(SQLFeatureNotSupportedException.class, () -> { + Reader rdr = null; + rs.setClob(1, rdr); + }); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0118(RowSet rs) throws Exception { - Reader rdr = null; - rs.setClob("one", rdr); + assertThrows(SQLFeatureNotSupportedException.class, () -> { + Reader rdr = null; + rs.setClob("one", rdr); + }); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0119(RowSet rs) throws Exception { - Reader rdr = null; - rs.setClob("one", rdr, query.length()); + assertThrows(SQLFeatureNotSupportedException.class, () -> { + Reader rdr = null; + rs.setClob("one", rdr, query.length()); + }); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0120(RowSet rs) throws Exception { - rs.setClob("one", new StubClob()); + assertThrows(SQLFeatureNotSupportedException.class, () -> rs.setClob("one", new StubClob())); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0121(RowSet rs) throws Exception { - rs.setDate("one", Date.valueOf(LocalDate.now())); + assertThrows(SQLFeatureNotSupportedException.class, () -> rs.setDate("one", Date.valueOf(LocalDate.now()))); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0122(RowSet rs) throws Exception { - rs.setDate("one", Date.valueOf(LocalDate.now()), - Calendar.getInstance()); + assertThrows(SQLFeatureNotSupportedException.class, () -> rs.setDate("one", Date.valueOf(LocalDate.now()), + Calendar.getInstance())); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0123(RowSet rs) throws Exception { - rs.setTime("one", Time.valueOf(LocalTime.now())); + assertThrows(SQLFeatureNotSupportedException.class, () -> rs.setTime("one", Time.valueOf(LocalTime.now()))); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0124(RowSet rs) throws Exception { - rs.setTime("one", Time.valueOf(LocalTime.now()), - Calendar.getInstance()); + assertThrows(SQLFeatureNotSupportedException.class, () -> rs.setTime("one", Time.valueOf(LocalTime.now()), + Calendar.getInstance())); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0125(RowSet rs) throws Exception { - rs.setTimestamp("one", Timestamp.valueOf(LocalDateTime.now())); + assertThrows(SQLFeatureNotSupportedException.class, () -> rs.setTimestamp("one", Timestamp.valueOf(LocalDateTime.now()))); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0126(RowSet rs) throws Exception { - rs.setTimestamp("one", Timestamp.valueOf(LocalDateTime.now()), - Calendar.getInstance()); + assertThrows(SQLFeatureNotSupportedException.class, () -> rs.setTimestamp("one", Timestamp.valueOf(LocalDateTime.now()), + Calendar.getInstance())); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0127(RowSet rs) throws Exception { - rs.setDouble("one", 2.0d); + assertThrows(SQLFeatureNotSupportedException.class, () -> rs.setDouble("one", 2.0d)); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0128(RowSet rs) throws Exception { - rs.setFloat("one", 2.0f); + assertThrows(SQLFeatureNotSupportedException.class, () -> rs.setFloat("one", 2.0f)); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0129(RowSet rs) throws Exception { - rs.setInt("one", 21); + assertThrows(SQLFeatureNotSupportedException.class, () -> rs.setInt("one", 21)); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0130(RowSet rs) throws Exception { - rs.setLong("one", 21l); + assertThrows(SQLFeatureNotSupportedException.class, () -> rs.setLong("one", 21l)); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0131(RowSet rs) throws Exception { - Reader rdr = null; - rs.setNCharacterStream("one", rdr, query.length()); + assertThrows(SQLFeatureNotSupportedException.class, () -> { + Reader rdr = null; + rs.setNCharacterStream("one", rdr, query.length()); + }); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0132(RowSet rs) throws Exception { - Reader rdr = null; - rs.setNCharacterStream("one", rdr); + assertThrows(SQLFeatureNotSupportedException.class, () -> { + Reader rdr = null; + rs.setNCharacterStream("one", rdr); + }); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0133(RowSet rs) throws Exception { - Reader rdr = null; - rs.setNCharacterStream(1, rdr); + assertThrows(SQLFeatureNotSupportedException.class, () -> { + Reader rdr = null; + rs.setNCharacterStream(1, rdr); + }); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0134(RowSet rs) throws Exception { - Reader rdr = null; - rs.setNCharacterStream(1, rdr, query.length()); + assertThrows(SQLFeatureNotSupportedException.class, () -> { + Reader rdr = null; + rs.setNCharacterStream(1, rdr, query.length()); + }); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0135(RowSet rs) throws Exception { - Reader rdr = null; - rs.setClob("one", rdr); + assertThrows(SQLFeatureNotSupportedException.class, () -> { + Reader rdr = null; + rs.setClob("one", rdr); + }); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0136(RowSet rs) throws Exception { - Reader rdr = null; - rs.setClob("one", rdr, query.length()); + assertThrows(SQLFeatureNotSupportedException.class, () -> { + Reader rdr = null; + rs.setClob("one", rdr, query.length()); + }); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0137(RowSet rs) throws Exception { - rs.setNClob("one", new StubNClob()); + assertThrows(SQLFeatureNotSupportedException.class, () -> rs.setNClob("one", new StubNClob())); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0138(RowSet rs) throws Exception { - Reader rdr = null; - rs.setNClob(1, rdr); + assertThrows(SQLFeatureNotSupportedException.class, () -> { + Reader rdr = null; + rs.setNClob(1, rdr); + }); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0139(RowSet rs) throws Exception { - Reader rdr = null; - rs.setNClob(1, rdr, query.length()); + assertThrows(SQLFeatureNotSupportedException.class, () -> { + Reader rdr = null; + rs.setNClob(1, rdr, query.length()); + }); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0140(RowSet rs) throws Exception { - rs.setNClob(1, new StubNClob()); + assertThrows(SQLFeatureNotSupportedException.class, () -> rs.setNClob(1, new StubNClob())); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0141(RowSet rs) throws Exception { - rs.setNString(1, query); + assertThrows(SQLFeatureNotSupportedException.class, () -> rs.setNString(1, query)); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0142(RowSet rs) throws Exception { - rs.setNull("one", Types.INTEGER); + assertThrows(SQLFeatureNotSupportedException.class, () -> rs.setNull("one", Types.INTEGER)); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0143(RowSet rs) throws Exception { - rs.setNull("one", Types.INTEGER, "my.type"); + assertThrows(SQLFeatureNotSupportedException.class, () -> rs.setNull("one", Types.INTEGER, "my.type")); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0144(RowSet rs) throws Exception { - rs.setObject("one", query, Types.VARCHAR); + assertThrows(SQLFeatureNotSupportedException.class, () -> rs.setObject("one", query, Types.VARCHAR)); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0145(RowSet rs) throws Exception { - rs.setObject("one", query, Types.VARCHAR, 0); + assertThrows(SQLFeatureNotSupportedException.class, () -> rs.setObject("one", query, Types.VARCHAR, 0)); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0146(RowSet rs) throws Exception { - rs.setObject("one", query); + assertThrows(SQLFeatureNotSupportedException.class, () -> rs.setObject("one", query)); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0147(RowSet rs) throws Exception { - RowId aRowid = null; - rs.setRowId("one", aRowid); + assertThrows(SQLFeatureNotSupportedException.class, () -> { + RowId aRowid = null; + rs.setRowId("one", aRowid); + }); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0148(RowSet rs) throws Exception { - rs.setSQLXML("one", new StubSQLXML()); + assertThrows(SQLFeatureNotSupportedException.class, () -> rs.setSQLXML("one", new StubSQLXML())); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0149(RowSet rs) throws Exception { - rs.setSQLXML(1, new StubSQLXML()); + assertThrows(SQLFeatureNotSupportedException.class, () -> rs.setSQLXML(1, new StubSQLXML())); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0150(RowSet rs) throws Exception { - rs.setNString(1, query); + assertThrows(SQLFeatureNotSupportedException.class, () -> rs.setNString(1, query)); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0151(RowSet rs) throws Exception { - rs.setNString("one", query); + assertThrows(SQLFeatureNotSupportedException.class, () -> rs.setNString("one", query)); } /* * This method is currently not implemented in BaseRowSet and will * throw a SQLFeatureNotSupportedException */ - @Test(dataProvider = "rowSetType", - expectedExceptions = SQLFeatureNotSupportedException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonRowSetTest0152(RowSet rs) throws Exception { - short val = 21; - rs.setShort("one", val); + assertThrows(SQLFeatureNotSupportedException.class, () -> { + short val = 21; + rs.setShort("one", val); + }); } } diff --git a/test/jdk/javax/sql/testng/test/rowset/RowSetFactoryTests.java b/test/jdk/javax/sql/test/rowset/RowSetFactoryTests.java similarity index 80% rename from test/jdk/javax/sql/testng/test/rowset/RowSetFactoryTests.java rename to test/jdk/javax/sql/test/rowset/RowSetFactoryTests.java index 72a4341c7aa..480033afc2b 100644 --- a/test/jdk/javax/sql/testng/test/rowset/RowSetFactoryTests.java +++ b/test/jdk/javax/sql/test/rowset/RowSetFactoryTests.java @@ -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 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) + ); } } diff --git a/test/jdk/javax/sql/testng/test/rowset/RowSetMetaDataTests.java b/test/jdk/javax/sql/test/rowset/RowSetMetaDataTests.java similarity index 55% rename from test/jdk/javax/sql/testng/test/rowset/RowSetMetaDataTests.java rename to test/jdk/javax/sql/test/rowset/RowSetMetaDataTests.java index 8a944a8bbb1..59dc4f43033 100644 --- a/test/jdk/javax/sql/testng/test/rowset/RowSetMetaDataTests.java +++ b/test/jdk/javax/sql/test/rowset/RowSetMetaDataTests.java @@ -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 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 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 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 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") + ); } - } diff --git a/test/jdk/javax/sql/testng/test/rowset/RowSetProviderTests.java b/test/jdk/javax/sql/test/rowset/RowSetProviderTests.java similarity index 79% rename from test/jdk/javax/sql/testng/test/rowset/RowSetProviderTests.java rename to test/jdk/javax/sql/test/rowset/RowSetProviderTests.java index 47a5cdb1eb0..25422cf0950 100644 --- a/test/jdk/javax/sql/testng/test/rowset/RowSetProviderTests.java +++ b/test/jdk/javax/sql/test/rowset/RowSetProviderTests.java @@ -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 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) + ); } } diff --git a/test/jdk/javax/sql/testng/test/rowset/RowSetWarningTests.java b/test/jdk/javax/sql/test/rowset/RowSetWarningTests.java similarity index 97% rename from test/jdk/javax/sql/testng/test/rowset/RowSetWarningTests.java rename to test/jdk/javax/sql/test/rowset/RowSetWarningTests.java index 41b52c4ef57..81ae97af785 100644 --- a/test/jdk/javax/sql/testng/test/rowset/RowSetWarningTests.java +++ b/test/jdk/javax/sql/test/rowset/RowSetWarningTests.java @@ -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 { diff --git a/test/jdk/javax/sql/testng/test/rowset/cachedrowset/CachedRowSetTests.java b/test/jdk/javax/sql/test/rowset/cachedrowset/CachedRowSetTests.java similarity index 94% rename from test/jdk/javax/sql/testng/test/rowset/cachedrowset/CachedRowSetTests.java rename to test/jdk/javax/sql/test/rowset/cachedrowset/CachedRowSetTests.java index 1155a889187..5fd473924c3 100644 --- a/test/jdk/javax/sql/testng/test/rowset/cachedrowset/CachedRowSetTests.java +++ b/test/jdk/javax/sql/test/rowset/cachedrowset/CachedRowSetTests.java @@ -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 diff --git a/test/jdk/javax/sql/testng/test/rowset/cachedrowset/CommonCachedRowSetTests.java b/test/jdk/javax/sql/test/rowset/cachedrowset/CommonCachedRowSetTests.java similarity index 79% rename from test/jdk/javax/sql/testng/test/rowset/cachedrowset/CommonCachedRowSetTests.java rename to test/jdk/javax/sql/test/rowset/cachedrowset/CommonCachedRowSetTests.java index 642c03c9a45..bc63ce28497 100644 --- a/test/jdk/javax/sql/testng/test/rowset/cachedrowset/CommonCachedRowSetTests.java +++ b/test/jdk/javax/sql/test/rowset/cachedrowset/CommonCachedRowSetTests.java @@ -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 @@ -37,6 +37,7 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; import java.util.Collection; +import java.util.stream.Stream; import javax.sql.RowSet; import javax.sql.rowset.CachedRowSet; import javax.sql.rowset.RowSetMetaDataImpl; @@ -44,12 +45,18 @@ import javax.sql.rowset.serial.SerialRef; import javax.sql.rowset.spi.SyncFactory; import javax.sql.rowset.spi.SyncProvider; import javax.sql.rowset.spi.SyncProviderException; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; -import org.testng.annotations.DataProvider; -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.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +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.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + import test.rowset.CommonRowSetTests; import util.StubArray; import util.StubRef; @@ -83,52 +90,43 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests { /* * DataProvider that uses a RowSet with the COFFEE_HOUSES Table */ - @DataProvider(name = "rowsetUsingCoffeeHouses") - protected Object[][] rowsetUsingCoffeeHouses() throws Exception { - RowSet rs = createCoffeeHousesRowSet(); - return new Object[][]{ - {rs} - }; + protected Stream rowsetUsingCoffeeHouses() throws Exception { + return Stream.of(createCoffeeHousesRowSet()); } /* * DataProvider that uses a RowSet with the COFFEES Table */ - @DataProvider(name = "rowsetUsingCoffees") - protected Object[][] rowsetUsingCoffees() throws Exception { - RowSet rs = createCoffeesRowSet(); - return new Object[][]{ - {rs} - }; + protected Stream rowsetUsingCoffees() throws Exception { + return Stream.of(createCoffeesRowSet()); } /* * DataProvider that uses a RowSet with the DATAYPES Table and * used to validate the various supported data types */ - @DataProvider(name = "rowsetUsingDataTypes") - protected Object[][] rowsetUsingDataTypes() throws Exception { + protected Stream rowsetUsingDataTypes() throws Exception { CachedRowSet rs = createDataTypesRowSet(); - return new Object[][]{ - {rs, JDBCType.INTEGER}, - {rs, JDBCType.CHAR}, - {rs, JDBCType.VARCHAR}, - {rs, JDBCType.BIGINT}, - {rs, JDBCType.BOOLEAN}, - {rs, JDBCType.SMALLINT}, - {rs, JDBCType.DOUBLE}, - {rs, JDBCType.DECIMAL}, - {rs, JDBCType.REAL}, - {rs, JDBCType.TINYINT}, - {rs, JDBCType.DATE}, - {rs, JDBCType.TIME}, - {rs, JDBCType.TIMESTAMP}, - {rs, JDBCType.VARBINARY}, - {rs, JDBCType.ARRAY}, - {rs, JDBCType.REF}, - {rs, JDBCType.FLOAT} - }; + return Stream.of( + Arguments.of(rs, JDBCType.INTEGER), + Arguments.of(rs, JDBCType.CHAR), + Arguments.of(rs, JDBCType.VARCHAR), + Arguments.of(rs, JDBCType.BIGINT), + Arguments.of(rs, JDBCType.BOOLEAN), + Arguments.of(rs, JDBCType.SMALLINT), + Arguments.of(rs, JDBCType.DOUBLE), + Arguments.of(rs, JDBCType.DECIMAL), + Arguments.of(rs, JDBCType.REAL), + Arguments.of(rs, JDBCType.TINYINT), + Arguments.of(rs, JDBCType.DATE), + Arguments.of(rs, JDBCType.TIME), + Arguments.of(rs, JDBCType.TIMESTAMP), + Arguments.of(rs, JDBCType.VARBINARY), + Arguments.of(rs, JDBCType.ARRAY), + Arguments.of(rs, JDBCType.REF), + Arguments.of(rs, JDBCType.FLOAT) + ); } /* @@ -254,7 +252,7 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests { private void compareMetaData(ResultSetMetaData rsmd, ResultSetMetaData rsmd1) throws SQLException { - assertEquals(rsmd1.getColumnCount(), rsmd.getColumnCount()); + assertEquals(rsmd.getColumnCount(), rsmd1.getColumnCount()); int cols = rsmd.getColumnCount(); for (int i = 1; i <= cols; i++) { assertTrue(rsmd1.getCatalogName(i).equals(rsmd.getCatalogName(i))); @@ -356,26 +354,33 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests { * Validate SyncProviderException is thrown when acceptChanges is called * but there is not a way to make a connection to the datasource */ - @Test(dataProvider = "rowSetType", expectedExceptions = SyncProviderException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonCachedRowSetTest0000(CachedRowSet rs) throws Exception { - rs.acceptChanges(); - rs.close(); + assertThrows(SyncProviderException.class, () -> { + rs.acceptChanges(); + rs.close(); + }); } /* * Validate SyncProviderException is thrown when acceptChanges is called * when null is passed as the datasource */ - @Test(dataProvider = "rowSetType", expectedExceptions = SyncProviderException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonCachedRowSetTest0001(CachedRowSet rs) throws Exception { - rs.acceptChanges(null); - rs.close(); + assertThrows(SyncProviderException.class, () -> { + rs.acceptChanges(null); + rs.close(); + }); } /* * Validate that that RIOPtimsticProvider is the default SyncProvider */ - @Test(dataProvider = "rowSetType") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonCachedRowSetTest0002(CachedRowSet rs) throws SQLException { SyncProvider sp = rs.getSyncProvider(); assertTrue(sp instanceof com.sun.rowset.providers.RIOptimisticProvider); @@ -385,7 +390,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests { /* * Validate that you can specify a SyncProvider */ - @Test(dataProvider = "rowSetType") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonCachedRowSetTest0003(CachedRowSet rs) throws SQLException { // Register a provider and make sure it is avaiable @@ -400,7 +406,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests { /* * Create a RowSetListener and validate that notifyRowSetChanged is called */ - @Test(dataProvider = "rowSetType") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonCachedRowSetTest0004(CachedRowSet rs) throws Exception { TestRowSetListener rsl = new TestRowSetListener(); rs.addRowSetListener(rsl); @@ -412,7 +419,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests { /* * Create a RowSetListener and validate that notifyRowSetChanged is called */ - @Test(dataProvider = "rowSetType") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonCachedRowSetTest0005(CachedRowSet rs) throws Exception { TestRowSetListener rsl = new TestRowSetListener(); rs.addRowSetListener(rsl); @@ -424,7 +432,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests { /* * Create a RowSetListener and validate that notifyRowChanged is called */ - @Test(dataProvider = "rowsetUsingCoffeeHouses") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingCoffeeHouses") public void commonCachedRowSetTest0006(RowSet rs) throws Exception { TestRowSetListener rsl = new TestRowSetListener(); rs.addRowSetListener(rsl); @@ -443,7 +452,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests { * Create a multiple RowSetListeners and validate that notifyRowChanged, * notifiyMoved is called on all listners */ - @Test(dataProvider = "rowsetUsingCoffeeHouses") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingCoffeeHouses") public void commonCachedRowSetTest0007(RowSet rs) throws Exception { TestRowSetListener rsl = new TestRowSetListener(); TestRowSetListener rsl2 = new TestRowSetListener(); @@ -467,7 +477,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests { * Create a RowSetListener and validate that notifyRowChanged and * notifyCursorMoved are called */ - @Test(dataProvider = "rowsetUsingCoffeeHouses") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingCoffeeHouses") public void commonCachedRowSetTest0008(CachedRowSet rs) throws Exception { TestRowSetListener rsl = new TestRowSetListener(); rs.addRowSetListener(rsl); @@ -487,7 +498,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests { /* * Create a RowSetListener and validate that notifyCursorMoved is called */ - @Test(dataProvider = "rowSetType") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonCachedRowSetTest0009(RowSet rs) throws Exception { TestRowSetListener rsl = new TestRowSetListener(); rs.addRowSetListener(rsl); @@ -499,7 +511,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests { /* * Validate that getTableName() returns the proper values */ - @Test(dataProvider = "rowSetType") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonCachedRowSetTest0010(CachedRowSet rs) throws Exception { assertNull(rs.getTableName()); rs.setTableName(COFFEE_HOUSES_TABLE); @@ -510,12 +523,13 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests { /* * Validate that getKeyColumns() returns the proper values */ - @Test(dataProvider = "rowSetType") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonCachedRowSetTest0011(CachedRowSet rs) throws Exception { int[] pkeys = {1, 3}; assertNull(rs.getKeyColumns()); rs.setKeyColumns(pkeys); - assertEquals(rs.getKeyColumns(), pkeys); + assertArrayEquals(pkeys, rs.getKeyColumns()); rs.close(); } @@ -523,52 +537,62 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests { * Validate that setMatchColumn throws a SQLException if the column * index specified is out of range */ - @Test(dataProvider = "rowsetUsingCoffeeHouses", - expectedExceptions = SQLException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingCoffeeHouses") public void commonCachedRowSetTest0012(CachedRowSet rs) throws Exception { - rs.setMatchColumn(-1); - rs.close(); + assertThrows(SQLException.class, () -> { + rs.setMatchColumn(-1); + rs.close(); + }); } /* * Validate that setMatchColumn throws a SQLException if the column * index specified is out of range */ - @Test(dataProvider = "rowsetUsingCoffeeHouses", - expectedExceptions = SQLException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingCoffeeHouses") public void commonCachedRowSetTest0013(CachedRowSet rs) throws Exception { - int[] cols = {1, -1}; - rs.setMatchColumn(cols); - rs.close(); + assertThrows(SQLException.class, () -> { + int[] cols = {1, -1}; + rs.setMatchColumn(cols); + rs.close(); + }); } /* * Validate that setMatchColumn throws a SQLException if the column * index specified is out of range */ - @Test(dataProvider = "rowsetUsingCoffeeHouses", - expectedExceptions = SQLException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingCoffeeHouses") public void commonCachedRowSetTest0014(CachedRowSet rs) throws Exception { - rs.setMatchColumn((String) null); - rs.close(); + assertThrows(SQLException.class, () -> { + rs.setMatchColumn((String) null); + rs.close(); + }); } /* * Validate that setMatchColumn throws a SQLException if the column * index specified is out of range */ - @Test(dataProvider = "rowsetUsingCoffeeHouses", - expectedExceptions = SQLException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingCoffeeHouses") public void commonCachedRowSetTest0015(CachedRowSet rs) throws Exception { - String[] cols = {"ID", null}; - rs.setMatchColumn(cols); + assertThrows(SQLException.class, () -> { + String[] cols = {"ID", null}; + rs.setMatchColumn(cols); + }); } /* * Validate that getMatchColumn returns the same value specified by * setMatchColumn */ - @Test(dataProvider = "rowsetUsingCoffeeHouses", enabled = false) + @Disabled + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingCoffeeHouses") public void commonCachedRowSetTest0016(CachedRowSet rs) throws Exception { int[] expectedCols = {1}; String[] expectedColNames = {"ID"}; @@ -578,8 +602,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests { for (int i = 0; i < actualCols.length; i++) { System.out.println(actualCols[i]); } - assertEquals(actualCols, expectedCols); - assertEquals(actualColNames, expectedColNames); + assertArrayEquals(expectedCols, actualCols); + assertArrayEquals(expectedColNames, actualColNames); rs.close(); } @@ -587,15 +611,17 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests { * Validate that getMatchColumn returns the same value specified by * setMatchColumn */ - @Test(dataProvider = "rowsetUsingCoffeeHouses", enabled = false) + @Disabled + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingCoffeeHouses") public void commonCachedRowSetTest0017(CachedRowSet rs) throws Exception { int[] expectedCols = {1}; String[] expectedColNames = {"ID"}; rs.setMatchColumn(expectedColNames[0]); int[] actualCols = rs.getMatchColumnIndexes(); String[] actualColNames = rs.getMatchColumnNames(); - assertEquals(actualCols, expectedCols); - assertEquals(actualColNames, expectedColNames); + assertArrayEquals(expectedCols, actualCols); + assertArrayEquals(expectedColNames, actualColNames); rs.close(); } @@ -603,16 +629,18 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests { * Validate that getMatchColumn returns the same valid value specified by * setMatchColumn */ - @Test(dataProvider = "rowsetUsingCoffeeHouses", enabled = false) + @Disabled + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingCoffeeHouses") public void commonCachedRowSetTest0018(CachedRowSet rs) throws Exception { int[] expectedCols = {1, 3}; String[] expectedColNames = {"COF_ID", "SUP_ID"}; rs.setMatchColumn(expectedCols); int[] actualCols = rs.getMatchColumnIndexes(); String[] actualColNames = rs.getMatchColumnNames(); - assertEquals(actualCols, expectedCols); - assertEquals(actualColNames, expectedColNames); - assertEquals(actualCols, expectedCols); + assertArrayEquals(expectedCols, actualCols); + assertArrayEquals(expectedColNames, actualColNames); + assertArrayEquals(expectedCols, actualCols); rs.close(); } @@ -620,15 +648,17 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests { * Validate that getMatchColumn returns the same valid value specified by * setMatchColumn */ - @Test(dataProvider = "rowsetUsingCoffeeHouses", enabled = false) + @Disabled + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingCoffeeHouses") public void commonCachedRowSetTest0019(CachedRowSet rs) throws Exception { int[] expectedCols = {1, 3}; String[] expectedColNames = {"COF_ID", "SUP_ID"}; rs.setMatchColumn(expectedColNames); int[] actualCols = rs.getMatchColumnIndexes(); String[] actualColNames = rs.getMatchColumnNames(); - assertEquals(actualCols, expectedCols); - assertEquals(actualColNames, expectedColNames); + assertArrayEquals(expectedCols, actualCols); + assertArrayEquals(expectedColNames, actualColNames); rs.close(); } @@ -636,69 +666,78 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests { * Validate that getMatchColumnIndexes throws a SQLException if * unsetMatchColumn has been called */ - @Test(dataProvider = "rowsetUsingCoffeeHouses", - expectedExceptions = SQLException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingCoffeeHouses") public void commonCachedRowSetTest0020(CachedRowSet rs) throws Exception { - rs.setMatchColumn(1); - int[] actualCols = rs.getMatchColumnIndexes(); - assertTrue(actualCols != null); - rs.unsetMatchColumn(1); - actualCols = rs.getMatchColumnIndexes(); - rs.close(); + assertThrows(SQLException.class, () -> { + rs.setMatchColumn(1); + int[] actualCols = rs.getMatchColumnIndexes(); + assertTrue(actualCols != null); + rs.unsetMatchColumn(1); + actualCols = rs.getMatchColumnIndexes(); + rs.close(); + }); } /* * Validate that getMatchColumnNames throws a SQLException if * unsetMatchColumn has been called */ - @Test(dataProvider = "rowsetUsingCoffeeHouses", - expectedExceptions = SQLException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingCoffeeHouses") public void commonCachedRowSetTest0021(CachedRowSet rs) throws Exception { - String matchColumn = "ID"; - rs.setMatchColumn(matchColumn); - String[] actualColNames = rs.getMatchColumnNames(); - assertTrue(actualColNames != null); - rs.unsetMatchColumn(matchColumn); - actualColNames = rs.getMatchColumnNames(); - rs.close(); + assertThrows(SQLException.class, () -> { + String matchColumn = "ID"; + rs.setMatchColumn(matchColumn); + String[] actualColNames = rs.getMatchColumnNames(); + assertTrue(actualColNames != null); + rs.unsetMatchColumn(matchColumn); + actualColNames = rs.getMatchColumnNames(); + rs.close(); + }); } /* * Validate that getMatchColumnIndexes throws a SQLException if * unsetMatchColumn has been called */ - @Test(dataProvider = "rowsetUsingCoffeeHouses", - expectedExceptions = SQLException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingCoffeeHouses") public void commonCachedRowSetTest0022(CachedRowSet rs) throws Exception { - int[] expectedCols = {1, 3}; - rs.setMatchColumn(expectedCols); - int[] actualCols = rs.getMatchColumnIndexes(); - assertTrue(actualCols != null); - rs.unsetMatchColumn(expectedCols); - actualCols = rs.getMatchColumnIndexes(); - rs.close(); + assertThrows(SQLException.class, () -> { + int[] expectedCols = {1, 3}; + rs.setMatchColumn(expectedCols); + int[] actualCols = rs.getMatchColumnIndexes(); + assertTrue(actualCols != null); + rs.unsetMatchColumn(expectedCols); + actualCols = rs.getMatchColumnIndexes(); + rs.close(); + }); } /* * Validate that getMatchColumnNames throws a SQLException if * unsetMatchColumn has been called */ - @Test(dataProvider = "rowsetUsingCoffeeHouses", - expectedExceptions = SQLException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingCoffeeHouses") public void commonCachedRowSetTest0023(CachedRowSet rs) throws Exception { - String[] expectedColNames = {"COF_ID", "SUP_ID"}; - rs.setMatchColumn(expectedColNames); - String[] actualColNames = rs.getMatchColumnNames(); - assertTrue(actualColNames != null); - rs.unsetMatchColumn(expectedColNames); - actualColNames = rs.getMatchColumnNames(); - rs.close(); + assertThrows(SQLException.class, () -> { + String[] expectedColNames = {"COF_ID", "SUP_ID"}; + rs.setMatchColumn(expectedColNames); + String[] actualColNames = rs.getMatchColumnNames(); + assertTrue(actualColNames != null); + rs.unsetMatchColumn(expectedColNames); + actualColNames = rs.getMatchColumnNames(); + rs.close(); + }); } /* * Validate size() returns the correct number of rows */ - @Test(dataProvider = "rowsetUsingCoffeeHouses") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingCoffeeHouses") public void commonCachedRowSetTest0024(CachedRowSet rs) throws Exception { assertTrue(rs.size() == COFFEE_HOUSES_ROWS); rs.close(); @@ -708,9 +747,10 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests { * Validate that the correct rows are returned comparing the primary * keys */ - @Test(dataProvider = "rowsetUsingCoffeeHouses") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingCoffeeHouses") public void commonCachedRowSetTest0025(RowSet rs) throws SQLException { - assertEquals(getPrimaryKeys(rs), COFFEE_HOUSES_PRIMARY_KEYS); + assertArrayEquals(COFFEE_HOUSES_PRIMARY_KEYS, getPrimaryKeys(rs)); rs.close(); } @@ -719,7 +759,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests { * Validate the visibility of the row depending on the value of * setShowdelete */ - @Test(dataProvider = "rowsetUsingCoffeeHouses") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingCoffeeHouses") public void commonCachedRowSetTest0026(CachedRowSet rs) throws Exception { Object[] afterDelete = { 10023, 33002, 10040, 32001, 10042, 10024, 10039, 10041, @@ -727,13 +768,13 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests { }; int rowToDelete = 10035; // All rows should be found - assertEquals(getPrimaryKeys(rs), COFFEE_HOUSES_PRIMARY_KEYS); + assertArrayEquals(COFFEE_HOUSES_PRIMARY_KEYS, getPrimaryKeys(rs)); // Delete the row assertTrue(deleteRowByPrimaryKey(rs, rowToDelete, 1)); // With setShowDeleted(false) which is the default, // the deleted row should not be visible assertFalse(findRowByPrimaryKey(rs, rowToDelete, 1)); - assertEquals(getPrimaryKeys(rs), afterDelete); + assertArrayEquals(afterDelete, getPrimaryKeys(rs)); assertTrue(rs.size() == COFFEE_HOUSES_ROWS); // With setShowDeleted(true), the deleted row should be visible rs.setShowDeleted(true); @@ -744,7 +785,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests { /* * Validate that there is no page size by default */ - @Test(dataProvider = "rowSetType") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonCachedRowSetTest0027(CachedRowSet rs) throws Exception { assertTrue(rs.getPageSize() == 0); rs.close(); @@ -754,7 +796,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests { * Validate the value you set via setPageSize is returned by getPageSize * then reset to having no limit */ - @Test(dataProvider = "rowSetType") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonCachedRowSetTest0028(CachedRowSet rs) throws Exception { int rows = 100; rs.setPageSize(rows); @@ -768,30 +811,39 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests { * Validate SQLException is thrown when an invalid value is specified * for setPageSize */ - @Test(dataProvider = "rowSetType", expectedExceptions = SQLException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonCachedRowSetTest0029(CachedRowSet rs) throws Exception { - rs.setPageSize(-1); - rs.close(); + assertThrows(SQLException.class, () -> { + rs.setPageSize(-1); + rs.close(); + }); } /* * Validate SQLException is thrown when nextPage is called without a * call to populate or execute */ - @Test(dataProvider = "rowSetType", expectedExceptions = SQLException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonCachedRowSetTest0030(CachedRowSet rs) throws Exception { - rs.nextPage(); - rs.close(); + assertThrows(SQLException.class, () -> { + rs.nextPage(); + rs.close(); + }); } /* * Validate SQLException is thrown when previousPage is called without a * call to populate or execute */ - @Test(dataProvider = "rowSetType", expectedExceptions = SQLException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonCachedRowSetTest0031(CachedRowSet rs) throws Exception { - rs.previousPage(); - rs.close(); + assertThrows(SQLException.class, () -> { + rs.previousPage(); + rs.close(); + }); } @@ -799,40 +851,48 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests { * Validate SQLException is thrown when execute is called * but there is not a way to make a connection to the datasource */ - @Test(dataProvider = "rowSetType", expectedExceptions = SQLException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonCachedRowSetTest0032(CachedRowSet rs) throws Exception { - rs.execute(null); - rs.close(); + assertThrows(SQLException.class, () -> { + rs.execute(null); + rs.close(); + }); } /* * Validate SQLException is thrown when execute is called * but there is not a way to make a connection to the datasource */ - @Test(dataProvider = "rowSetType", expectedExceptions = SQLException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowSetType") public void commonCachedRowSetTest0033(CachedRowSet rs) throws Exception { - rs.execute(); - rs.close(); + assertThrows(SQLException.class, () -> { + rs.execute(); + rs.close(); + }); } /* * Validate that toCollection() returns the proper values */ - @Test(dataProvider = "rowsetUsingCoffeeHouses") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingCoffeeHouses") public void commonCachedRowSetTest0034(CachedRowSet rs) throws Exception { Object[] cities = {"Mendocino", "Seattle", "SF", "Portland", "SF", "Sacramento", "Carmel", "LA", "Olympia", "Seattle", "SF", "LA", "San Jose", "Eugene"}; rs.beforeFirst(); - assertEquals(rs.toCollection(2).toArray(), cities); - assertEquals(rs.toCollection("CITY").toArray(), cities); + assertArrayEquals(cities, rs.toCollection(2).toArray()); + assertArrayEquals(cities, rs.toCollection("CITY").toArray()); rs.close(); } /* * Validate that toCollection() returns the proper values */ - @Test(dataProvider = "rowsetUsingCoffeeHouses") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingCoffeeHouses") public void commonCachedRowSetTest0035(CachedRowSet rs) throws Exception { Collection col = rs.toCollection(); assertTrue(rs.size() == col.size()); @@ -850,7 +910,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests { /* * Validate that createCopy() returns the proper values */ - @Test(dataProvider = "rowsetUsingCoffeeHouses") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingCoffeeHouses") public void commonCachedRowSetTest0036(CachedRowSet rs) throws Exception { try (CachedRowSet crs1 = rs.createCopy()) { compareRowSets(rs, crs1); @@ -861,7 +922,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests { /* * Validate that createCopySchema() returns the proper values */ - @Test(dataProvider = "rowsetUsingCoffeeHouses") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingCoffeeHouses") public void commonCachedRowSetTest0037(CachedRowSet rs) throws Exception { try (CachedRowSet crs1 = rs.createCopySchema()) { assertTrue(crs1.size() == 0); @@ -875,7 +937,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests { * and getMatchColumnIndexes should throw a SQLException. This test * specifies setMatchColumn(int) */ - @Test(dataProvider = "rowsetUsingCoffeeHouses") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingCoffeeHouses") public void commonCachedRowSetTest0038(CachedRowSet rs) throws Exception { rs.setMatchColumn(1); try (CachedRowSet crs1 = rs.createCopyNoConstraints()) { @@ -904,7 +967,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests { * and getMatchColumnIndexes should throw a SQLException. This test * specifies setMatchColumn(String) */ - @Test(dataProvider = "rowsetUsingCoffeeHouses") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingCoffeeHouses") public void commonCachedRowSetTest0039(CachedRowSet rs) throws Exception { rs.setMatchColumn("ID"); try (CachedRowSet crs1 = rs.createCopyNoConstraints()) { @@ -932,7 +996,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests { * Validate that columnUpdated works with the various datatypes specifying * the column index */ - @Test(dataProvider = "rowsetUsingDataTypes") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingDataTypes") public void commonCachedRowSetTest0040(CachedRowSet rs, JDBCType type) throws Exception { rs.beforeFirst(); assertTrue(rs.next()); @@ -1029,7 +1094,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests { * Validate that columnUpdated works with the various datatypes specifying * the column name */ - @Test(dataProvider = "rowsetUsingDataTypes") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingDataTypes") public void commonCachedRowSetTest0041(CachedRowSet rs, JDBCType type) throws Exception { rs.beforeFirst(); assertTrue(rs.next()); @@ -1127,7 +1193,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests { * Validate isBeforeFirst(), isFirst() and first() return the correct * results */ - @Test(dataProvider = "rowsetUsingCoffeeHouses") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingCoffeeHouses") public void commonCachedRowSetTest0042(RowSet rs) throws Exception { assertFalse(rs.isBeforeFirst()); assertFalse(rs.isFirst()); @@ -1150,7 +1217,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests { * Validate isAfterLast(), isLast() and last() return the correct * results */ - @Test(dataProvider = "rowsetUsingCoffeeHouses") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingCoffeeHouses") public void commonCachedRowSetTest0043(RowSet rs) throws Exception { assertFalse(rs.isAfterLast()); assertFalse(rs.isLast()); @@ -1173,121 +1241,140 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests { * Validate a SQLException is thrown when undoDelete is called on the * insertRow */ - @Test(dataProvider = "rowsetUsingCoffeeHouses", - expectedExceptions = SQLException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingCoffeeHouses") public void commonCachedRowSetTest0044(CachedRowSet rs) throws Exception { - rs.insertRow(); - rs.undoDelete(); - rs.close(); + assertThrows(SQLException.class, () -> { + rs.insertRow(); + rs.undoDelete(); + rs.close(); + }); } /* * Validate a SQLException is thrown when undoDelete is called when * cursor is before the first row */ - @Test(dataProvider = "rowsetUsingCoffeeHouses", - expectedExceptions = SQLException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingCoffeeHouses") public void commonCachedRowSetTest0045(CachedRowSet rs) throws Exception { - rs.setShowDeleted(true); - rs.beforeFirst(); - rs.undoDelete(); - rs.close(); + assertThrows(SQLException.class, () -> { + rs.setShowDeleted(true); + rs.beforeFirst(); + rs.undoDelete(); + rs.close(); + }); } /* * Validate a SQLException is thrown when undoDelete is called when * cursor is after the last row */ - @Test(dataProvider = "rowsetUsingCoffeeHouses", - expectedExceptions = SQLException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingCoffeeHouses") public void commonCachedRowSetTest0046(CachedRowSet rs) throws Exception { - rs.setShowDeleted(true); - rs.afterLast(); - rs.undoDelete(); - rs.close(); + assertThrows(SQLException.class, () -> { + rs.setShowDeleted(true); + rs.afterLast(); + rs.undoDelete(); + rs.close(); + }); } /* * Validate a SQLException is thrown when undoUpdate is called on the * insertRow */ - @Test(dataProvider = "rowsetUsingCoffeeHouses", - expectedExceptions = SQLException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingCoffeeHouses") public void commonCachedRowSetTest0047(CachedRowSet rs) throws Exception { - rs.insertRow(); - rs.undoUpdate(); - rs.close(); + assertThrows(SQLException.class, () -> { + rs.insertRow(); + rs.undoUpdate(); + rs.close(); + }); } /* * Validate a SQLException is thrown when undoUpdate is called when * cursor is before the first row */ - @Test(dataProvider = "rowsetUsingCoffeeHouses", - expectedExceptions = SQLException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingCoffeeHouses") public void commonCachedRowSetTest0048(CachedRowSet rs) throws Exception { - rs.setShowDeleted(true); - rs.beforeFirst(); - rs.undoUpdate(); - rs.close(); + assertThrows(SQLException.class, () -> { + rs.setShowDeleted(true); + rs.beforeFirst(); + rs.undoUpdate(); + rs.close(); + }); } /* * Validate a SQLException is thrown when undoUpdate is called when * cursor is after the last row */ - @Test(dataProvider = "rowsetUsingCoffeeHouses", - expectedExceptions = SQLException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingCoffeeHouses") public void commonCachedRowSetTest0049(CachedRowSet rs) throws Exception { - rs.setShowDeleted(true); - rs.afterLast(); - rs.undoUpdate(); - rs.close(); + assertThrows(SQLException.class, () -> { + rs.setShowDeleted(true); + rs.afterLast(); + rs.undoUpdate(); + rs.close(); + }); } /* * Validate a SQLException is thrown when undoInsert is called on the * insertRow */ - @Test(dataProvider = "rowsetUsingCoffeeHouses", - expectedExceptions = SQLException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingCoffeeHouses") public void commonCachedRowSetTest0050(CachedRowSet rs) throws Exception { - rs.insertRow(); - rs.undoInsert(); - rs.close(); + assertThrows(SQLException.class, () -> { + rs.insertRow(); + rs.undoInsert(); + rs.close(); + }); } /* * Validate a SQLException is thrown when undoInsert is called when * cursor is before the first row */ - @Test(dataProvider = "rowsetUsingCoffeeHouses", - expectedExceptions = SQLException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingCoffeeHouses") public void commonCachedRowSetTest0051(CachedRowSet rs) throws Exception { - rs.setShowDeleted(true); - rs.beforeFirst(); - rs.undoInsert(); - rs.close(); + assertThrows(SQLException.class, () -> { + rs.setShowDeleted(true); + rs.beforeFirst(); + rs.undoInsert(); + rs.close(); + }); } /* * Validate a SQLException is thrown when undoInsert is called when * cursor is after the last row */ - @Test(dataProvider = "rowsetUsingCoffeeHouses", - expectedExceptions = SQLException.class) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingCoffeeHouses") public void commonCachedRowSetTest0052(CachedRowSet rs) throws Exception { - rs.setShowDeleted(true); - rs.afterLast(); - rs.undoInsert(); - rs.close(); + assertThrows(SQLException.class, () -> { + rs.setShowDeleted(true); + rs.afterLast(); + rs.undoInsert(); + rs.close(); + }); } /* * Insert a row, then call undoInsert to roll back the insert and validate * the row is not there */ - @Test(dataProvider = "rowsetUsingCoffeeHouses") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingCoffeeHouses") public void commonCachedRowSetTest0053(CachedRowSet rs) throws Exception { int rowToInsert = 1961; assertTrue(rs.size() == COFFEE_HOUSES_ROWS); @@ -1314,7 +1401,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests { * Insert a row, delete the row and then call undoDelete to make sure it * is comes back */ - @Test(dataProvider = "rowsetUsingCoffeeHouses") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingCoffeeHouses") public void commonCachedRowSetTest0054(CachedRowSet rs) throws Exception { int rowToDelete = 1961; assertTrue(rs.size() == COFFEE_HOUSES_ROWS); @@ -1348,7 +1436,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests { * Insert a row, modify a field and then call undoUpdate to revert the * insert */ - @Test(dataProvider = "rowsetUsingCoffeeHouses") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingCoffeeHouses") public void commonCachedRowSetTest0055(CachedRowSet rs) throws Exception { int rowToInsert = 1961; assertTrue(rs.size() == COFFEE_HOUSES_ROWS); @@ -1385,7 +1474,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests { * Validate getOriginal returns a ResultSet which is a copy of the original * RowSet */ - @Test(dataProvider = "rowsetUsingCoffees") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingCoffees") public void commonCachedRowSetTest0056(CachedRowSet rs) throws Exception { String coffee = "Hazelnut"; int sales = 100; @@ -1414,12 +1504,12 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests { assertTrue(rs1.getInt(1) == origId); assertTrue(rs1.getString(2).equals(origCoffee)); assertTrue(rs1.getInt(5) == origSales); - assertEquals(getPrimaryKeys(rs1), COFFEES_PRIMARY_KEYS); + assertArrayEquals(COFFEES_PRIMARY_KEYS, getPrimaryKeys(rs1)); // Check current rowset assertTrue(rs.getInt(1) == id); assertTrue(rs.getString(2).equals(coffee)); assertTrue(rs.getInt(5) == sales); - assertEquals(getPrimaryKeys(rs), updatedPkeys); + assertArrayEquals(updatedPkeys, getPrimaryKeys(rs)); } rs.close(); } @@ -1428,7 +1518,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests { * Validate getOriginalRow returns a ResultSet which is a copy of the * original row that was modified */ - @Test(dataProvider = "rowsetUsingCoffees") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingCoffees") public void commonCachedRowSetTest0057(CachedRowSet rs) throws Exception { String coffee = "Hazelnut"; int sales = 100; @@ -1463,7 +1554,7 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests { assertTrue(rs.getInt(1) == id); assertTrue(rs.getString(2).equals(coffee)); assertTrue(rs.getInt(5) == sales); - assertEquals(getPrimaryKeys(rs), updatedPkeys); + assertArrayEquals(updatedPkeys, getPrimaryKeys(rs)); } rs.close(); } @@ -1472,7 +1563,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests { * Validate that restoreOrginal will restore the RowSet to its * state prior to the insert of a row */ - @Test(dataProvider = "rowsetUsingCoffeeHouses") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingCoffeeHouses") public void commonCachedRowSetTest0058(CachedRowSet rs) throws Exception { int rowToInsert = 1961; assertTrue(rs.size() == COFFEE_HOUSES_ROWS); @@ -1509,7 +1601,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests { * Validate that restoreOrginal will restore the RowSet to its * state prior to deleting a row */ - @Test(dataProvider = "rowsetUsingCoffees", enabled = true) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingCoffees") public void commonCachedRowSetTest0059(CachedRowSet rs) throws Exception { int rowToDelete = 2; try (CachedRowSet crs1 = rsf.createCachedRowSet()) { @@ -1540,7 +1633,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests { * Validate that restoreOrginal will restore the RowSet to its * state prior to updating a row */ - @Test(dataProvider = "rowsetUsingCoffees", enabled = true) + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingCoffees") public void commonCachedRowSetTest0060(CachedRowSet rs) throws Exception { int rowToUpdate = 2; String coffee = "Hazelnut"; @@ -1578,7 +1672,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests { * Initialize a RowSet via the populate method. Validate it matches * the original ResultSet */ - @Test(dataProvider = "rowsetUsingCoffeeHouses") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingCoffeeHouses") public void commonCachedRowSetTest0061(CachedRowSet rs) throws Exception { try (CachedRowSet crs1 = rsf.createCachedRowSet()) { rs.beforeFirst(); @@ -1593,7 +1688,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests { * Validate it matches the original ResultSet starting for the specofied * offset */ - @Test(dataProvider = "rowsetUsingCoffeeHouses") + @ParameterizedTest(autoCloseArguments = false) + @MethodSource("rowsetUsingCoffeeHouses") public void commonCachedRowSetTest0062(CachedRowSet rs) throws Exception { Object[] expectedRows = { 32001, 10042, 10024, 10039, 10041, 33005, 33010, 10035, 10037, @@ -1603,8 +1699,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests { try (CachedRowSet crs1 = rsf.createCachedRowSet()) { rs.beforeFirst(); crs1.populate(rs, startingRow); - assertEquals(crs1.size(), COFFEE_HOUSES_ROWS - startingRow + 1); - assertEquals(getPrimaryKeys(crs1), expectedRows); + assertEquals(COFFEE_HOUSES_ROWS - startingRow + 1, crs1.size()); + assertArrayEquals(expectedRows, getPrimaryKeys(crs1)); } rs.close(); } diff --git a/test/jdk/javax/sql/testng/test/rowset/filteredrowset/CityFilter.java b/test/jdk/javax/sql/test/rowset/filteredrowset/CityFilter.java similarity index 97% rename from test/jdk/javax/sql/testng/test/rowset/filteredrowset/CityFilter.java rename to test/jdk/javax/sql/test/rowset/filteredrowset/CityFilter.java index 2188c4eed08..458088ccb45 100644 --- a/test/jdk/javax/sql/testng/test/rowset/filteredrowset/CityFilter.java +++ b/test/jdk/javax/sql/test/rowset/filteredrowset/CityFilter.java @@ -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 diff --git a/test/jdk/javax/sql/testng/test/rowset/filteredrowset/FilteredRowSetTests.java b/test/jdk/javax/sql/test/rowset/filteredrowset/FilteredRowSetTests.java similarity index 81% rename from test/jdk/javax/sql/testng/test/rowset/filteredrowset/FilteredRowSetTests.java rename to test/jdk/javax/sql/test/rowset/filteredrowset/FilteredRowSetTests.java index 263a79a68b6..55d9323f373 100644 --- a/test/jdk/javax/sql/testng/test/rowset/filteredrowset/FilteredRowSetTests.java +++ b/test/jdk/javax/sql/test/rowset/filteredrowset/FilteredRowSetTests.java @@ -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 } diff --git a/test/jdk/javax/sql/testng/test/rowset/filteredrowset/PrimaryKeyFilter.java b/test/jdk/javax/sql/test/rowset/filteredrowset/PrimaryKeyFilter.java similarity index 97% rename from test/jdk/javax/sql/testng/test/rowset/filteredrowset/PrimaryKeyFilter.java rename to test/jdk/javax/sql/test/rowset/filteredrowset/PrimaryKeyFilter.java index 2a748314006..0353312419c 100644 --- a/test/jdk/javax/sql/testng/test/rowset/filteredrowset/PrimaryKeyFilter.java +++ b/test/jdk/javax/sql/test/rowset/filteredrowset/PrimaryKeyFilter.java @@ -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 diff --git a/test/jdk/javax/sql/testng/test/rowset/jdbcrowset/JdbcRowSetDriverManagerTest.java b/test/jdk/javax/sql/test/rowset/jdbcrowset/JdbcRowSetDriverManagerTest.java similarity index 95% rename from test/jdk/javax/sql/testng/test/rowset/jdbcrowset/JdbcRowSetDriverManagerTest.java rename to test/jdk/javax/sql/test/rowset/jdbcrowset/JdbcRowSetDriverManagerTest.java index be86798177a..5b135e16b5c 100644 --- a/test/jdk/javax/sql/testng/test/rowset/jdbcrowset/JdbcRowSetDriverManagerTest.java +++ b/test/jdk/javax/sql/test/rowset/jdbcrowset/JdbcRowSetDriverManagerTest.java @@ -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()); diff --git a/test/jdk/javax/sql/testng/test/rowset/joinrowset/JoinRowSetTests.java b/test/jdk/javax/sql/test/rowset/joinrowset/JoinRowSetTests.java similarity index 83% rename from test/jdk/javax/sql/testng/test/rowset/joinrowset/JoinRowSetTests.java rename to test/jdk/javax/sql/test/rowset/joinrowset/JoinRowSetTests.java index b84453e9a3b..92ce09bcf85 100644 --- a/test/jdk/javax/sql/testng/test/rowset/joinrowset/JoinRowSetTests.java +++ b/test/jdk/javax/sql/test/rowset/joinrowset/JoinRowSetTests.java @@ -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 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 { } } diff --git a/test/jdk/javax/sql/test/rowset/resourcebundle/TEST.properties b/test/jdk/javax/sql/test/rowset/resourcebundle/TEST.properties new file mode 100644 index 00000000000..045227a0c2b --- /dev/null +++ b/test/jdk/javax/sql/test/rowset/resourcebundle/TEST.properties @@ -0,0 +1,2 @@ +# Enabled for ValidateGetBundle.java +modules = java.sql.rowset/com.sun.rowset:+open diff --git a/test/jdk/javax/sql/resourceBundleTests/ValidateGetBundle.java b/test/jdk/javax/sql/test/rowset/resourcebundle/ValidateGetBundle.java similarity index 94% rename from test/jdk/javax/sql/resourceBundleTests/ValidateGetBundle.java rename to test/jdk/javax/sql/test/rowset/resourcebundle/ValidateGetBundle.java index be17caed5c8..63f12740c09 100644 --- a/test/jdk/javax/sql/resourceBundleTests/ValidateGetBundle.java +++ b/test/jdk/javax/sql/test/rowset/resourcebundle/ValidateGetBundle.java @@ -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{ diff --git a/test/jdk/javax/sql/testng/test/rowset/ValidateResourceBundleAccess.java b/test/jdk/javax/sql/test/rowset/resourcebundle/ValidateResourceBundleAccess.java similarity index 89% rename from test/jdk/javax/sql/testng/test/rowset/ValidateResourceBundleAccess.java rename to test/jdk/javax/sql/test/rowset/resourcebundle/ValidateResourceBundleAccess.java index 7591891c42b..5deca26cb25 100644 --- a/test/jdk/javax/sql/testng/test/rowset/ValidateResourceBundleAccess.java +++ b/test/jdk/javax/sql/test/rowset/resourcebundle/ValidateResourceBundleAccess.java @@ -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); } diff --git a/test/jdk/javax/sql/testng/test/rowset/serial/SQLInputImplTests.java b/test/jdk/javax/sql/test/rowset/serial/SQLInputImplTests.java similarity index 92% rename from test/jdk/javax/sql/testng/test/rowset/serial/SQLInputImplTests.java rename to test/jdk/javax/sql/test/rowset/serial/SQLInputImplTests.java index 5bd10ed8848..33efda61c4e 100644 --- a/test/jdk/javax/sql/testng/test/rowset/serial/SQLInputImplTests.java +++ b/test/jdk/javax/sql/test/rowset/serial/SQLInputImplTests.java @@ -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}; diff --git a/test/jdk/javax/sql/testng/test/rowset/serial/SQLOutputImplTests.java b/test/jdk/javax/sql/test/rowset/serial/SQLOutputImplTests.java similarity index 91% rename from test/jdk/javax/sql/testng/test/rowset/serial/SQLOutputImplTests.java rename to test/jdk/javax/sql/test/rowset/serial/SQLOutputImplTests.java index 1f90c9981a7..83712e81396 100644 --- a/test/jdk/javax/sql/testng/test/rowset/serial/SQLOutputImplTests.java +++ b/test/jdk/javax/sql/test/rowset/serial/SQLOutputImplTests.java @@ -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"}; diff --git a/test/jdk/javax/sql/testng/test/rowset/serial/SerialArrayTests.java b/test/jdk/javax/sql/test/rowset/serial/SerialArrayTests.java similarity index 72% rename from test/jdk/javax/sql/testng/test/rowset/serial/SerialArrayTests.java rename to test/jdk/javax/sql/test/rowset/serial/SerialArrayTests.java index 345315b7f05..892de9416a1 100644 --- a/test/jdk/javax/sql/testng/test/rowset/serial/SerialArrayTests.java +++ b/test/jdk/javax/sql/test/rowset/serial/SerialArrayTests.java @@ -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> 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(); + }); } /* diff --git a/test/jdk/javax/sql/testng/test/rowset/serial/SerialBlobTests.java b/test/jdk/javax/sql/test/rowset/serial/SerialBlobTests.java similarity index 69% rename from test/jdk/javax/sql/testng/test/rowset/serial/SerialBlobTests.java rename to test/jdk/javax/sql/test/rowset/serial/SerialBlobTests.java index f3f6c327683..f4a32bc19d7 100644 --- a/test/jdk/javax/sql/testng/test/rowset/serial/SerialBlobTests.java +++ b/test/jdk/javax/sql/test/rowset/serial/SerialBlobTests.java @@ -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); + }); } } diff --git a/test/jdk/javax/sql/testng/test/rowset/serial/SerialClobTests.java b/test/jdk/javax/sql/test/rowset/serial/SerialClobTests.java similarity index 72% rename from test/jdk/javax/sql/testng/test/rowset/serial/SerialClobTests.java rename to test/jdk/javax/sql/test/rowset/serial/SerialClobTests.java index 95c5f6f64a7..2636c3b6a84 100644 --- a/test/jdk/javax/sql/testng/test/rowset/serial/SerialClobTests.java +++ b/test/jdk/javax/sql/test/rowset/serial/SerialClobTests.java @@ -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); + }); } } diff --git a/test/jdk/javax/sql/testng/test/rowset/serial/SerialDataLinkTests.java b/test/jdk/javax/sql/test/rowset/serial/SerialDataLinkTests.java similarity index 90% rename from test/jdk/javax/sql/testng/test/rowset/serial/SerialDataLinkTests.java rename to test/jdk/javax/sql/test/rowset/serial/SerialDataLinkTests.java index 0c7f19e85b1..12c1341161d 100644 --- a/test/jdk/javax/sql/testng/test/rowset/serial/SerialDataLinkTests.java +++ b/test/jdk/javax/sql/test/rowset/serial/SerialDataLinkTests.java @@ -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); + }); } /* diff --git a/test/jdk/javax/sql/testng/test/rowset/serial/SerialExceptionTests.java b/test/jdk/javax/sql/test/rowset/serial/SerialExceptionTests.java similarity index 95% rename from test/jdk/javax/sql/testng/test/rowset/serial/SerialExceptionTests.java rename to test/jdk/javax/sql/test/rowset/serial/SerialExceptionTests.java index 8ef215584a9..51c733b995a 100644 --- a/test/jdk/javax/sql/testng/test/rowset/serial/SerialExceptionTests.java +++ b/test/jdk/javax/sql/test/rowset/serial/SerialExceptionTests.java @@ -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 { diff --git a/test/jdk/javax/sql/testng/test/rowset/serial/SerialJavaObjectTests.java b/test/jdk/javax/sql/test/rowset/serial/SerialJavaObjectTests.java similarity index 86% rename from test/jdk/javax/sql/testng/test/rowset/serial/SerialJavaObjectTests.java rename to test/jdk/javax/sql/test/rowset/serial/SerialJavaObjectTests.java index c2fcf2fa48f..e521125df97 100644 --- a/test/jdk/javax/sql/testng/test/rowset/serial/SerialJavaObjectTests.java +++ b/test/jdk/javax/sql/test/rowset/serial/SerialJavaObjectTests.java @@ -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()); + }); } /* diff --git a/test/jdk/javax/sql/testng/test/rowset/serial/SerialRefTests.java b/test/jdk/javax/sql/test/rowset/serial/SerialRefTests.java similarity index 86% rename from test/jdk/javax/sql/testng/test/rowset/serial/SerialRefTests.java rename to test/jdk/javax/sql/test/rowset/serial/SerialRefTests.java index 8f23de70aa6..1b4e72593b0 100644 --- a/test/jdk/javax/sql/testng/test/rowset/serial/SerialRefTests.java +++ b/test/jdk/javax/sql/test/rowset/serial/SerialRefTests.java @@ -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))); diff --git a/test/jdk/javax/sql/testng/test/rowset/serial/SerialStructTests.java b/test/jdk/javax/sql/test/rowset/serial/SerialStructTests.java similarity index 92% rename from test/jdk/javax/sql/testng/test/rowset/serial/SerialStructTests.java rename to test/jdk/javax/sql/test/rowset/serial/SerialStructTests.java index 79ac2421c9a..dfc34b60e2b 100644 --- a/test/jdk/javax/sql/testng/test/rowset/serial/SerialStructTests.java +++ b/test/jdk/javax/sql/test/rowset/serial/SerialStructTests.java @@ -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()); } /* diff --git a/test/jdk/javax/sql/testng/test/rowset/spi/SyncFactoryExceptionTests.java b/test/jdk/javax/sql/test/rowset/spi/SyncFactoryExceptionTests.java similarity index 95% rename from test/jdk/javax/sql/testng/test/rowset/spi/SyncFactoryExceptionTests.java rename to test/jdk/javax/sql/test/rowset/spi/SyncFactoryExceptionTests.java index e93a6109ec7..b747c48989d 100644 --- a/test/jdk/javax/sql/testng/test/rowset/spi/SyncFactoryExceptionTests.java +++ b/test/jdk/javax/sql/test/rowset/spi/SyncFactoryExceptionTests.java @@ -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 { diff --git a/test/jdk/javax/sql/testng/test/rowset/spi/SyncFactoryTests.java b/test/jdk/javax/sql/test/rowset/spi/SyncFactoryTests.java similarity index 92% rename from test/jdk/javax/sql/testng/test/rowset/spi/SyncFactoryTests.java rename to test/jdk/javax/sql/test/rowset/spi/SyncFactoryTests.java index 415488abb9f..260cf150f59 100644 --- a/test/jdk/javax/sql/testng/test/rowset/spi/SyncFactoryTests.java +++ b/test/jdk/javax/sql/test/rowset/spi/SyncFactoryTests.java @@ -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); } diff --git a/test/jdk/javax/sql/testng/test/rowset/spi/SyncProviderExceptionTests.java b/test/jdk/javax/sql/test/rowset/spi/SyncProviderExceptionTests.java similarity index 96% rename from test/jdk/javax/sql/testng/test/rowset/spi/SyncProviderExceptionTests.java rename to test/jdk/javax/sql/test/rowset/spi/SyncProviderExceptionTests.java index 22863b0f6bb..f8786f1b429 100644 --- a/test/jdk/javax/sql/testng/test/rowset/spi/SyncProviderExceptionTests.java +++ b/test/jdk/javax/sql/test/rowset/spi/SyncProviderExceptionTests.java @@ -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(); } diff --git a/test/jdk/javax/sql/testng/test/rowset/webrowset/CommonWebRowSetTests.java b/test/jdk/javax/sql/test/rowset/webrowset/CommonWebRowSetTests.java similarity index 81% rename from test/jdk/javax/sql/testng/test/rowset/webrowset/CommonWebRowSetTests.java rename to test/jdk/javax/sql/test/rowset/webrowset/CommonWebRowSetTests.java index ce0801e0fe4..023adc8254b 100644 --- a/test/jdk/javax/sql/testng/test/rowset/webrowset/CommonWebRowSetTests.java +++ b/test/jdk/javax/sql/test/rowset/webrowset/CommonWebRowSetTests.java @@ -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) { diff --git a/test/jdk/javax/sql/testng/test/rowset/webrowset/WebRowSetTests.java b/test/jdk/javax/sql/test/rowset/webrowset/WebRowSetTests.java similarity index 94% rename from test/jdk/javax/sql/testng/test/rowset/webrowset/WebRowSetTests.java rename to test/jdk/javax/sql/test/rowset/webrowset/WebRowSetTests.java index 5f2890e0b5b..4692c0cee84 100644 --- a/test/jdk/javax/sql/testng/test/rowset/webrowset/WebRowSetTests.java +++ b/test/jdk/javax/sql/test/rowset/webrowset/WebRowSetTests.java @@ -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 diff --git a/test/jdk/javax/sql/testng/util/PropertyStubProvider.java b/test/jdk/javax/sql/util/PropertyStubProvider.java similarity index 92% rename from test/jdk/javax/sql/testng/util/PropertyStubProvider.java rename to test/jdk/javax/sql/util/PropertyStubProvider.java index d397cc1c7d4..1cadcef26bb 100644 --- a/test/jdk/javax/sql/testng/util/PropertyStubProvider.java +++ b/test/jdk/javax/sql/util/PropertyStubProvider.java @@ -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 diff --git a/test/jdk/javax/sql/testng/util/StubArray.java b/test/jdk/javax/sql/util/StubArray.java similarity index 97% rename from test/jdk/javax/sql/testng/util/StubArray.java rename to test/jdk/javax/sql/util/StubArray.java index 1d2ef0e5b6f..b57760679a0 100644 --- a/test/jdk/javax/sql/testng/util/StubArray.java +++ b/test/jdk/javax/sql/util/StubArray.java @@ -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 diff --git a/test/jdk/javax/sql/testng/util/StubBaseRowSet.java b/test/jdk/javax/sql/util/StubBaseRowSet.java similarity index 99% rename from test/jdk/javax/sql/testng/util/StubBaseRowSet.java rename to test/jdk/javax/sql/util/StubBaseRowSet.java index e003b522ed9..94be7f8e348 100644 --- a/test/jdk/javax/sql/testng/util/StubBaseRowSet.java +++ b/test/jdk/javax/sql/util/StubBaseRowSet.java @@ -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 diff --git a/test/jdk/javax/sql/testng/util/StubBlob.java b/test/jdk/javax/sql/util/StubBlob.java similarity index 97% rename from test/jdk/javax/sql/testng/util/StubBlob.java rename to test/jdk/javax/sql/util/StubBlob.java index 727e8a926d5..f86fd540841 100644 --- a/test/jdk/javax/sql/testng/util/StubBlob.java +++ b/test/jdk/javax/sql/util/StubBlob.java @@ -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 diff --git a/test/jdk/javax/sql/testng/util/StubCachedRowSetImpl.java b/test/jdk/javax/sql/util/StubCachedRowSetImpl.java similarity index 99% rename from test/jdk/javax/sql/testng/util/StubCachedRowSetImpl.java rename to test/jdk/javax/sql/util/StubCachedRowSetImpl.java index 9000deb1b65..65e8169dbb6 100644 --- a/test/jdk/javax/sql/testng/util/StubCachedRowSetImpl.java +++ b/test/jdk/javax/sql/util/StubCachedRowSetImpl.java @@ -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 diff --git a/test/jdk/javax/sql/testng/util/StubClob.java b/test/jdk/javax/sql/util/StubClob.java similarity index 97% rename from test/jdk/javax/sql/testng/util/StubClob.java rename to test/jdk/javax/sql/util/StubClob.java index cb1e0c0a62a..b0db14b3526 100644 --- a/test/jdk/javax/sql/testng/util/StubClob.java +++ b/test/jdk/javax/sql/util/StubClob.java @@ -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 diff --git a/test/jdk/javax/sql/testng/util/StubContext.java b/test/jdk/javax/sql/util/StubContext.java similarity index 98% rename from test/jdk/javax/sql/testng/util/StubContext.java rename to test/jdk/javax/sql/util/StubContext.java index af03534d991..6f03a1abd48 100644 --- a/test/jdk/javax/sql/testng/util/StubContext.java +++ b/test/jdk/javax/sql/util/StubContext.java @@ -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 diff --git a/test/jdk/javax/sql/testng/util/StubFilteredRowSetImpl.java b/test/jdk/javax/sql/util/StubFilteredRowSetImpl.java similarity index 99% rename from test/jdk/javax/sql/testng/util/StubFilteredRowSetImpl.java rename to test/jdk/javax/sql/util/StubFilteredRowSetImpl.java index 8fcbfa4c085..0b73abc6c01 100644 --- a/test/jdk/javax/sql/testng/util/StubFilteredRowSetImpl.java +++ b/test/jdk/javax/sql/util/StubFilteredRowSetImpl.java @@ -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 diff --git a/test/jdk/javax/sql/testng/util/StubJdbcRowSetImpl.java b/test/jdk/javax/sql/util/StubJdbcRowSetImpl.java similarity index 99% rename from test/jdk/javax/sql/testng/util/StubJdbcRowSetImpl.java rename to test/jdk/javax/sql/util/StubJdbcRowSetImpl.java index ec59eb6c556..441b662ddc6 100644 --- a/test/jdk/javax/sql/testng/util/StubJdbcRowSetImpl.java +++ b/test/jdk/javax/sql/util/StubJdbcRowSetImpl.java @@ -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 diff --git a/test/jdk/javax/sql/testng/util/StubJoinRowSetImpl.java b/test/jdk/javax/sql/util/StubJoinRowSetImpl.java similarity index 99% rename from test/jdk/javax/sql/testng/util/StubJoinRowSetImpl.java rename to test/jdk/javax/sql/util/StubJoinRowSetImpl.java index c7ece7cd523..1f506f830ef 100644 --- a/test/jdk/javax/sql/testng/util/StubJoinRowSetImpl.java +++ b/test/jdk/javax/sql/util/StubJoinRowSetImpl.java @@ -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 diff --git a/test/jdk/javax/sql/testng/util/StubNClob.java b/test/jdk/javax/sql/util/StubNClob.java similarity index 93% rename from test/jdk/javax/sql/testng/util/StubNClob.java rename to test/jdk/javax/sql/util/StubNClob.java index 10682578b9a..0664aa42795 100644 --- a/test/jdk/javax/sql/testng/util/StubNClob.java +++ b/test/jdk/javax/sql/util/StubNClob.java @@ -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 diff --git a/test/jdk/javax/sql/testng/util/StubRef.java b/test/jdk/javax/sql/util/StubRef.java similarity index 95% rename from test/jdk/javax/sql/testng/util/StubRef.java rename to test/jdk/javax/sql/util/StubRef.java index 052bd92c740..54a42df1e1c 100644 --- a/test/jdk/javax/sql/testng/util/StubRef.java +++ b/test/jdk/javax/sql/util/StubRef.java @@ -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 diff --git a/test/jdk/javax/sql/testng/util/StubRowId.java b/test/jdk/javax/sql/util/StubRowId.java similarity index 93% rename from test/jdk/javax/sql/testng/util/StubRowId.java rename to test/jdk/javax/sql/util/StubRowId.java index f8e90d49867..d3bc51b9320 100644 --- a/test/jdk/javax/sql/testng/util/StubRowId.java +++ b/test/jdk/javax/sql/util/StubRowId.java @@ -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 diff --git a/test/jdk/javax/sql/testng/util/StubRowSetFactory.java b/test/jdk/javax/sql/util/StubRowSetFactory.java similarity index 96% rename from test/jdk/javax/sql/testng/util/StubRowSetFactory.java rename to test/jdk/javax/sql/util/StubRowSetFactory.java index 624c53af1e7..abc34894a18 100644 --- a/test/jdk/javax/sql/testng/util/StubRowSetFactory.java +++ b/test/jdk/javax/sql/util/StubRowSetFactory.java @@ -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 diff --git a/test/jdk/javax/sql/testng/util/StubSQLXML.java b/test/jdk/javax/sql/util/StubSQLXML.java similarity index 97% rename from test/jdk/javax/sql/testng/util/StubSQLXML.java rename to test/jdk/javax/sql/util/StubSQLXML.java index 44d1351b357..5e4d1647853 100644 --- a/test/jdk/javax/sql/testng/util/StubSQLXML.java +++ b/test/jdk/javax/sql/util/StubSQLXML.java @@ -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 diff --git a/test/jdk/javax/sql/testng/util/StubStruct.java b/test/jdk/javax/sql/util/StubStruct.java similarity index 95% rename from test/jdk/javax/sql/testng/util/StubStruct.java rename to test/jdk/javax/sql/util/StubStruct.java index 1dee8028a2c..a5a2004a09d 100644 --- a/test/jdk/javax/sql/testng/util/StubStruct.java +++ b/test/jdk/javax/sql/util/StubStruct.java @@ -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 diff --git a/test/jdk/javax/sql/testng/util/StubSyncProvider.java b/test/jdk/javax/sql/util/StubSyncProvider.java similarity index 97% rename from test/jdk/javax/sql/testng/util/StubSyncProvider.java rename to test/jdk/javax/sql/util/StubSyncProvider.java index 8947455c701..a6a44e0f509 100644 --- a/test/jdk/javax/sql/testng/util/StubSyncProvider.java +++ b/test/jdk/javax/sql/util/StubSyncProvider.java @@ -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 diff --git a/test/jdk/javax/sql/testng/util/StubSyncResolver.java b/test/jdk/javax/sql/util/StubSyncResolver.java similarity index 99% rename from test/jdk/javax/sql/testng/util/StubSyncResolver.java rename to test/jdk/javax/sql/util/StubSyncResolver.java index 02477c7f9be..f24c3ec4b13 100644 --- a/test/jdk/javax/sql/testng/util/StubSyncResolver.java +++ b/test/jdk/javax/sql/util/StubSyncResolver.java @@ -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 diff --git a/test/jdk/javax/sql/testng/util/StubWebRowSetImpl.java b/test/jdk/javax/sql/util/StubWebRowSetImpl.java similarity index 99% rename from test/jdk/javax/sql/testng/util/StubWebRowSetImpl.java rename to test/jdk/javax/sql/util/StubWebRowSetImpl.java index 918d5bd0482..48c237e73ae 100644 --- a/test/jdk/javax/sql/testng/util/StubWebRowSetImpl.java +++ b/test/jdk/javax/sql/util/StubWebRowSetImpl.java @@ -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 diff --git a/test/jdk/javax/sql/testng/util/SuperHero.java b/test/jdk/javax/sql/util/SuperHero.java similarity index 97% rename from test/jdk/javax/sql/testng/util/SuperHero.java rename to test/jdk/javax/sql/util/SuperHero.java index c8afb3831de..2d6e68a7c9e 100644 --- a/test/jdk/javax/sql/testng/util/SuperHero.java +++ b/test/jdk/javax/sql/util/SuperHero.java @@ -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 diff --git a/test/jdk/javax/sql/testng/util/TestRowSetListener.java b/test/jdk/javax/sql/util/TestRowSetListener.java similarity index 96% rename from test/jdk/javax/sql/testng/util/TestRowSetListener.java rename to test/jdk/javax/sql/util/TestRowSetListener.java index 069ade29ca2..4f71f12da2e 100644 --- a/test/jdk/javax/sql/testng/util/TestRowSetListener.java +++ b/test/jdk/javax/sql/util/TestRowSetListener.java @@ -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 diff --git a/test/jdk/javax/sql/testng/util/TestSQLDataImpl.java b/test/jdk/javax/sql/util/TestSQLDataImpl.java similarity index 98% rename from test/jdk/javax/sql/testng/util/TestSQLDataImpl.java rename to test/jdk/javax/sql/util/TestSQLDataImpl.java index 0694add3ef9..f02eeb6fece 100644 --- a/test/jdk/javax/sql/testng/util/TestSQLDataImpl.java +++ b/test/jdk/javax/sql/util/TestSQLDataImpl.java @@ -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 diff --git a/test/jdk/javax/sql/testng/xml/COFFEE_ROWS.xml b/test/jdk/javax/sql/xml/COFFEE_ROWS.xml similarity index 100% rename from test/jdk/javax/sql/testng/xml/COFFEE_ROWS.xml rename to test/jdk/javax/sql/xml/COFFEE_ROWS.xml diff --git a/test/jdk/javax/sql/testng/xml/DELETED_COFFEE_ROWS.xml b/test/jdk/javax/sql/xml/DELETED_COFFEE_ROWS.xml similarity index 100% rename from test/jdk/javax/sql/testng/xml/DELETED_COFFEE_ROWS.xml rename to test/jdk/javax/sql/xml/DELETED_COFFEE_ROWS.xml diff --git a/test/jdk/javax/sql/testng/xml/INSERTED_COFFEE_ROWS.xml b/test/jdk/javax/sql/xml/INSERTED_COFFEE_ROWS.xml similarity index 100% rename from test/jdk/javax/sql/testng/xml/INSERTED_COFFEE_ROWS.xml rename to test/jdk/javax/sql/xml/INSERTED_COFFEE_ROWS.xml diff --git a/test/jdk/javax/sql/testng/xml/MODFIED_DELETED_COFFEE_ROWS.xml b/test/jdk/javax/sql/xml/MODFIED_DELETED_COFFEE_ROWS.xml similarity index 100% rename from test/jdk/javax/sql/testng/xml/MODFIED_DELETED_COFFEE_ROWS.xml rename to test/jdk/javax/sql/xml/MODFIED_DELETED_COFFEE_ROWS.xml diff --git a/test/jdk/javax/sql/testng/xml/UPDATED_COFFEE_ROWS.xml b/test/jdk/javax/sql/xml/UPDATED_COFFEE_ROWS.xml similarity index 100% rename from test/jdk/javax/sql/testng/xml/UPDATED_COFFEE_ROWS.xml rename to test/jdk/javax/sql/xml/UPDATED_COFFEE_ROWS.xml diff --git a/test/jdk/javax/sql/testng/xml/UPDATED_INSERTED_COFFEE_ROWS.xml b/test/jdk/javax/sql/xml/UPDATED_INSERTED_COFFEE_ROWS.xml similarity index 100% rename from test/jdk/javax/sql/testng/xml/UPDATED_INSERTED_COFFEE_ROWS.xml rename to test/jdk/javax/sql/xml/UPDATED_INSERTED_COFFEE_ROWS.xml