Apply automated conversion to javax/sql and update testng to junit naming for folder & properties

This commit is contained in:
Justin Lu 2026-01-23 14:33:23 -08:00
parent 1b273a5a0f
commit 436ab27d7e
60 changed files with 1637 additions and 1037 deletions

View File

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

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -45,9 +45,13 @@ 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.api.TestInstance;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import util.StubArray;
import util.StubBaseRowSet;
import util.StubBlob;
@ -55,6 +59,7 @@ import util.StubClob;
import util.StubRef;
import util.TestRowSetListener;
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class BaseRowSetTests extends CommonRowSetTests {
private StubBaseRowSet brs;
@ -67,7 +72,8 @@ public class BaseRowSetTests extends CommonRowSetTests {
/*
* Create a RowSetListener and validate that notifyCursorMoved is called
*/
@Test(dataProvider = "rowSetType")
@ParameterizedTest
@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
@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
@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
@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
@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
@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
@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
@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
@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
@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
@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
@MethodSource("TODO: cannot automatically find data provider named 'jdbcTypes', please resolve manually.")
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
@MethodSource("TODO: cannot automatically find data provider named 'jdbcTypes', please resolve manually.")
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
@MethodSource("rowSetType")
public void baseRowSetTest0016(StubBaseRowSet rs) throws Exception {
rs.setInt(1, 1);
rs.initParams();
@ -285,7 +304,6 @@ public class BaseRowSetTests extends CommonRowSetTests {
/*
* DataProvider used to set parameters for basic types that are supported
*/
@DataProvider(name = "testBaseParameters")
private Object[][] testBaseParameters() throws SQLException {
Integer aInt = 1;
Long aLong = Long.MAX_VALUE;
@ -346,7 +364,6 @@ public class BaseRowSetTests extends CommonRowSetTests {
/*
* DataProvider used to set advanced parameters for types that are supported
*/
@DataProvider(name = "testAdvancedParameters")
private Object[][] testAdvancedParameters() throws SQLException {
byte[] bytes = new byte[10];

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -25,11 +25,15 @@ package test.rowset;
import java.sql.SQLException;
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.api.TestInstance;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import util.BaseTest;
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class RowSetFactoryTests extends BaseTest {
// RowSet implementations that we are testing for
@ -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
@MethodSource("RowSetValues")
public void test(RowSetFactory rsf, String impl) throws SQLException {
validateRowSetImpl(rsf, impl);
}
@ -98,7 +103,6 @@ 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 {
RowSetFactory rsf = RowSetProvider.newFactory();
RowSetFactory rsf1 = RowSetProvider.newFactory(STUB_FACTORY_CLASSNAME, null);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -27,12 +27,18 @@ import java.sql.SQLException;
import java.sql.Types;
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 org.junit.jupiter.api.Assertions;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import util.BaseTest;
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class RowSetMetaDataTests extends BaseTest {
// Max columns used in the tests
@ -40,7 +46,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 +55,397 @@ public class RowSetMetaDataTests extends BaseTest {
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest
@MethodSource("invalidColumnRanges")
public void test(Integer col) throws Exception {
rsmd.getCatalogName(col);
Assertions.assertThrows(SQLException.class, () -> {
rsmd.getCatalogName(col);
});
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest
@MethodSource("invalidColumnRanges")
public void test01(Integer col) throws Exception {
rsmd.getColumnClassName(col);
Assertions.assertThrows(SQLException.class, () -> {
rsmd.getColumnClassName(col);
});
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest
@MethodSource("invalidColumnRanges")
public void test02(Integer col) throws Exception {
rsmd.getColumnDisplaySize(col);
Assertions.assertThrows(SQLException.class, () -> {
rsmd.getColumnDisplaySize(col);
});
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest
@MethodSource("invalidColumnRanges")
public void test03(Integer col) throws Exception {
rsmd.getColumnLabel(col);
Assertions.assertThrows(SQLException.class, () -> {
rsmd.getColumnLabel(col);
});
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest
@MethodSource("invalidColumnRanges")
public void test04(Integer col) throws Exception {
rsmd.getColumnName(col);
Assertions.assertThrows(SQLException.class, () -> {
rsmd.getColumnName(col);
});
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest
@MethodSource("invalidColumnRanges")
public void test05(Integer col) throws Exception {
rsmd.getColumnType(col);
Assertions.assertThrows(SQLException.class, () -> {
rsmd.getColumnType(col);
});
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest
@MethodSource("invalidColumnRanges")
public void test06(Integer col) throws Exception {
rsmd.getColumnTypeName(col);
Assertions.assertThrows(SQLException.class, () -> {
rsmd.getColumnTypeName(col);
});
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest
@MethodSource("invalidColumnRanges")
public void test07(Integer col) throws Exception {
rsmd.getPrecision(col);
Assertions.assertThrows(SQLException.class, () -> {
rsmd.getPrecision(col);
});
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest
@MethodSource("invalidColumnRanges")
public void test08(Integer col) throws Exception {
rsmd.getScale(col);
Assertions.assertThrows(SQLException.class, () -> {
rsmd.getScale(col);
});
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest
@MethodSource("invalidColumnRanges")
public void test09(Integer col) throws Exception {
rsmd.getSchemaName(col);
Assertions.assertThrows(SQLException.class, () -> {
rsmd.getSchemaName(col);
});
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest
@MethodSource("invalidColumnRanges")
public void test10(Integer col) throws Exception {
rsmd.getTableName(col);
Assertions.assertThrows(SQLException.class, () -> {
rsmd.getTableName(col);
});
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest
@MethodSource("invalidColumnRanges")
public void test11(Integer col) throws Exception {
rsmd.isAutoIncrement(col);
Assertions.assertThrows(SQLException.class, () -> {
rsmd.isAutoIncrement(col);
});
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest
@MethodSource("invalidColumnRanges")
public void test12(Integer col) throws Exception {
rsmd.isCaseSensitive(col);
Assertions.assertThrows(SQLException.class, () -> {
rsmd.isCaseSensitive(col);
});
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest
@MethodSource("invalidColumnRanges")
public void test13(Integer col) throws Exception {
rsmd.isCurrency(col);
Assertions.assertThrows(SQLException.class, () -> {
rsmd.isCurrency(col);
});
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest
@MethodSource("invalidColumnRanges")
public void test14(Integer col) throws Exception {
rsmd.isDefinitelyWritable(col);
Assertions.assertThrows(SQLException.class, () -> {
rsmd.isDefinitelyWritable(col);
});
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest
@MethodSource("invalidColumnRanges")
public void test15(Integer col) throws Exception {
rsmd.isNullable(col);
Assertions.assertThrows(SQLException.class, () -> {
rsmd.isNullable(col);
});
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest
@MethodSource("invalidColumnRanges")
public void test16(Integer col) throws Exception {
rsmd.isReadOnly(col);
Assertions.assertThrows(SQLException.class, () -> {
rsmd.isReadOnly(col);
});
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest
@MethodSource("invalidColumnRanges")
public void test17(Integer col) throws Exception {
rsmd.isSearchable(col);
Assertions.assertThrows(SQLException.class, () -> {
rsmd.isSearchable(col);
});
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest
@MethodSource("invalidColumnRanges")
public void test18(Integer col) throws Exception {
rsmd.isSigned(col);
Assertions.assertThrows(SQLException.class, () -> {
rsmd.isSigned(col);
});
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest
@MethodSource("invalidColumnRanges")
public void test19(Integer col) throws Exception {
rsmd.isWritable(col);
Assertions.assertThrows(SQLException.class, () -> {
rsmd.isWritable(col);
});
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest
@MethodSource("invalidColumnRanges")
public void test20(Integer col) throws Exception {
rsmd.setAutoIncrement(col, true);
Assertions.assertThrows(SQLException.class, () -> {
rsmd.setAutoIncrement(col, true);
});
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest
@MethodSource("invalidColumnRanges")
public void test21(Integer col) throws Exception {
rsmd.setCaseSensitive(col, true);
Assertions.assertThrows(SQLException.class, () -> {
rsmd.setCaseSensitive(col, true);
});
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest
@MethodSource("invalidColumnRanges")
public void test22(Integer col) throws Exception {
rsmd.setCatalogName(col, null);
Assertions.assertThrows(SQLException.class, () -> {
rsmd.setCatalogName(col, null);
});
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest
@MethodSource("invalidColumnRanges")
public void test23(Integer col) throws Exception {
rsmd.setColumnDisplaySize(col, 5);
Assertions.assertThrows(SQLException.class, () -> {
rsmd.setColumnDisplaySize(col, 5);
});
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest
@MethodSource("invalidColumnRanges")
public void test24(Integer col) throws Exception {
rsmd.setColumnLabel(col, "label");
Assertions.assertThrows(SQLException.class, () -> {
rsmd.setColumnLabel(col, "label");
});
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest
@MethodSource("invalidColumnRanges")
public void test25(Integer col) throws Exception {
rsmd.setColumnName(col, "F1");
Assertions.assertThrows(SQLException.class, () -> {
rsmd.setColumnName(col, "F1");
});
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest
@MethodSource("invalidColumnRanges")
public void test26(Integer col) throws Exception {
rsmd.setColumnType(col, Types.CHAR);
Assertions.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
@MethodSource("invalidColumnRanges")
public void test27(Integer col) throws Exception {
rsmd.setColumnTypeName(col, "F1");
Assertions.assertThrows(SQLException.class, () -> {
rsmd.setColumnTypeName(col, "F1");
});
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest
@MethodSource("invalidColumnRanges")
public void test28(Integer col) throws Exception {
rsmd.setCurrency(col, true);
Assertions.assertThrows(SQLException.class, () -> {
rsmd.setCurrency(col, true);
});
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest
@MethodSource("invalidColumnRanges")
public void test29(Integer col) throws Exception {
rsmd.setNullable(col, ResultSetMetaData.columnNoNulls);
Assertions.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
@MethodSource("invalidColumnRanges")
public void test30(Integer col) throws Exception {
rsmd.setPrecision(col, 2);
Assertions.assertThrows(SQLException.class, () -> {
rsmd.setPrecision(col, 2);
});
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest
@MethodSource("invalidColumnRanges")
public void test31(Integer col) throws Exception {
rsmd.setScale(col, 2);
Assertions.assertThrows(SQLException.class, () -> {
rsmd.setScale(col, 2);
});
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest
@MethodSource("invalidColumnRanges")
public void test32(Integer col) throws Exception {
rsmd.setSchemaName(col, "Gotham");
Assertions.assertThrows(SQLException.class, () -> {
rsmd.setSchemaName(col, "Gotham");
});
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest
@MethodSource("invalidColumnRanges")
public void test33(Integer col) throws Exception {
rsmd.setSearchable(col, false);
Assertions.assertThrows(SQLException.class, () -> {
rsmd.setSearchable(col, false);
});
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest
@MethodSource("invalidColumnRanges")
public void test34(Integer col) throws Exception {
rsmd.setSigned(col, false);
Assertions.assertThrows(SQLException.class, () -> {
rsmd.setSigned(col, false);
});
}
/*
* Validate a SQLException is thrown for an invalid column index
*/
@Test(dataProvider = "invalidColumnRanges",
expectedExceptions = SQLException.class)
@ParameterizedTest
@MethodSource("invalidColumnRanges")
public void test35(Integer col) throws Exception {
rsmd.setTableName(col, "SUPERHEROS");
Assertions.assertThrows(SQLException.class, () -> {
rsmd.setTableName(col, "SUPERHEROS");
});
}
/*
@ -375,7 +453,8 @@ public class RowSetMetaDataTests extends BaseTest {
* Note: Once setColumnClassName is added to RowSetMetaData, this
* method will need to change.
*/
@Test(dataProvider = "columnClassNames")
@ParameterizedTest
@MethodSource("columnClassNames")
public void test36(Integer type, String name) throws Exception {
rsmd.setColumnType(1, type);
assertTrue(rsmd.getColumnClassName(1).equals(name));
@ -385,7 +464,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
@MethodSource("columnRanges")
public void test37(Integer col) throws Exception {
rsmd.setAutoIncrement(col, true);
assertTrue(rsmd.isAutoIncrement(col));
@ -429,7 +509,8 @@ public class RowSetMetaDataTests extends BaseTest {
/*
* Validate that the proper values are accepted by setNullable
*/
@Test(dataProvider = "validSetNullableValues")
@ParameterizedTest
@MethodSource("validSetNullableValues")
public void test38(Integer val) throws Exception {
rsmd.setNullable(1, val);
}
@ -437,7 +518,8 @@ public class RowSetMetaDataTests extends BaseTest {
/*
* Validate that the correct type is returned for the column
*/
@Test(dataProvider = "jdbcTypes")
@ParameterizedTest
@MethodSource("TODO: cannot automatically find data provider named 'jdbcTypes', please resolve manually.")
public void test39(Integer type) throws Exception {
rsmd.setColumnType(1, type);
assertTrue(type == rsmd.getColumnType(1));
@ -446,7 +528,8 @@ public class RowSetMetaDataTests extends BaseTest {
/*
* Validate that the correct value is returned from the isXXX methods
*/
@Test(dataProvider = "trueFalse")
@ParameterizedTest
@MethodSource("TODO: cannot automatically find data provider named 'trueFalse', please resolve manually.")
public void test40(Boolean b) throws Exception {
rsmd.setAutoIncrement(1, b);
rsmd.setCaseSensitive(1, b);
@ -483,7 +566,6 @@ 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},
@ -496,7 +578,6 @@ public class RowSetMetaDataTests extends BaseTest {
* 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},
@ -509,7 +590,6 @@ public class RowSetMetaDataTests extends BaseTest {
* 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++) {
@ -522,7 +602,6 @@ public class RowSetMetaDataTests extends BaseTest {
* 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"},

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -29,15 +29,21 @@ import java.net.URLClassLoader;
import java.sql.SQLException;
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 org.junit.jupiter.api.Assertions;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import util.BaseTest;
import util.StubRowSetFactory;
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class RowSetProviderTests extends BaseTest {
// Default RowSetFactory Implementation
@ -57,7 +63,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 +74,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 +86,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 +95,8 @@ public class RowSetProviderTests extends BaseTest {
/*
* Validate that the correct RowSetFactory is returned by newFactory().
*/
@Test(dataProvider = "RowSetFactoryValues")
@ParameterizedTest
@MethodSource("RowSetFactoryValues")
public void test(RowSetFactory rsf, String impl) throws SQLException {
validateProvider(rsf, impl);
}
@ -109,7 +116,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 +127,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();
Assertions.assertThrows(SQLException.class, () -> {
System.setProperty("javax.sql.rowset.RowSetFactory",
"invalid.RowSetFactoryImpl");
RowSetFactory rsf = RowSetProvider.newFactory();
});
}
/*
@ -144,13 +153,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();
Assertions.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,7 +185,6 @@ 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 {
RowSetFactory rsf = RowSetProvider.newFactory();
RowSetFactory rsf1 = RowSetProvider.newFactory(STUB_FACTORY_CLASSNAME, null);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -24,8 +24,10 @@ package test.rowset;
import java.sql.SQLException;
import javax.sql.rowset.RowSetWarning;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import util.BaseTest;
public class RowSetWarningTests extends BaseTest {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 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
@ -25,17 +25,20 @@ package test.rowset;
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;
import org.junit.jupiter.api.TestInstance;
/**
* @test
* @bug 8294989
* @summary Check that the resource bundle can be accessed
* @throws SQLException if an unexpected error occurs
* @run testng/othervm
* @run junit/othervm
*/
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class ValidateResourceBundleAccess{
// Expected JDBCResourceBundle message, jdbcrowsetimpl.invalstate
private static final String INVALIDSTATE = "Invalid state";
@ -43,7 +46,7 @@ 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
@BeforeAll
public void setEnglishEnvironment() {
Locale.setDefault(Locale.US);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -25,6 +25,9 @@ package test.rowset.cachedrowset;
import java.sql.SQLException;
import javax.sql.rowset.CachedRowSet;
import org.junit.jupiter.api.TestInstance;
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class CachedRowSetTests extends CommonCachedRowSetTests {
@Override

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -44,18 +44,24 @@ 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 org.junit.jupiter.api.Assertions;
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.assertTrue;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import test.rowset.CommonRowSetTests;
import util.StubArray;
import util.StubRef;
import util.StubSyncProvider;
import util.TestRowSetListener;
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public abstract class CommonCachedRowSetTests extends CommonRowSetTests {
/*
@ -83,7 +89,6 @@ 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[][]{
@ -94,7 +99,6 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests {
/*
* DataProvider that uses a RowSet with the COFFEES Table
*/
@DataProvider(name = "rowsetUsingCoffees")
protected Object[][] rowsetUsingCoffees() throws Exception {
RowSet rs = createCoffeesRowSet();
return new Object[][]{
@ -106,7 +110,6 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests {
* 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 {
CachedRowSet rs = createDataTypesRowSet();
@ -254,7 +257,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 +359,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
@MethodSource("rowSetType")
public void commonCachedRowSetTest0000(CachedRowSet rs) throws Exception {
rs.acceptChanges();
rs.close();
Assertions.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
@MethodSource("rowSetType")
public void commonCachedRowSetTest0001(CachedRowSet rs) throws Exception {
rs.acceptChanges(null);
rs.close();
Assertions.assertThrows(SyncProviderException.class, () -> {
rs.acceptChanges(null);
rs.close();
});
}
/*
* Validate that that RIOPtimsticProvider is the default SyncProvider
*/
@Test(dataProvider = "rowSetType")
@ParameterizedTest
@MethodSource("rowSetType")
public void commonCachedRowSetTest0002(CachedRowSet rs) throws SQLException {
SyncProvider sp = rs.getSyncProvider();
assertTrue(sp instanceof com.sun.rowset.providers.RIOptimisticProvider);
@ -385,7 +395,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests {
/*
* Validate that you can specify a SyncProvider
*/
@Test(dataProvider = "rowSetType")
@ParameterizedTest
@MethodSource("rowSetType")
public void commonCachedRowSetTest0003(CachedRowSet rs) throws SQLException {
// Register a provider and make sure it is avaiable
@ -400,7 +411,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests {
/*
* Create a RowSetListener and validate that notifyRowSetChanged is called
*/
@Test(dataProvider = "rowSetType")
@ParameterizedTest
@MethodSource("rowSetType")
public void commonCachedRowSetTest0004(CachedRowSet rs) throws Exception {
TestRowSetListener rsl = new TestRowSetListener();
rs.addRowSetListener(rsl);
@ -412,7 +424,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests {
/*
* Create a RowSetListener and validate that notifyRowSetChanged is called
*/
@Test(dataProvider = "rowSetType")
@ParameterizedTest
@MethodSource("rowSetType")
public void commonCachedRowSetTest0005(CachedRowSet rs) throws Exception {
TestRowSetListener rsl = new TestRowSetListener();
rs.addRowSetListener(rsl);
@ -424,7 +437,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests {
/*
* Create a RowSetListener and validate that notifyRowChanged is called
*/
@Test(dataProvider = "rowsetUsingCoffeeHouses")
@ParameterizedTest
@MethodSource("rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0006(RowSet rs) throws Exception {
TestRowSetListener rsl = new TestRowSetListener();
rs.addRowSetListener(rsl);
@ -443,7 +457,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
@MethodSource("rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0007(RowSet rs) throws Exception {
TestRowSetListener rsl = new TestRowSetListener();
TestRowSetListener rsl2 = new TestRowSetListener();
@ -467,7 +482,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests {
* Create a RowSetListener and validate that notifyRowChanged and
* notifyCursorMoved are called
*/
@Test(dataProvider = "rowsetUsingCoffeeHouses")
@ParameterizedTest
@MethodSource("rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0008(CachedRowSet rs) throws Exception {
TestRowSetListener rsl = new TestRowSetListener();
rs.addRowSetListener(rsl);
@ -487,7 +503,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests {
/*
* Create a RowSetListener and validate that notifyCursorMoved is called
*/
@Test(dataProvider = "rowSetType")
@ParameterizedTest
@MethodSource("rowSetType")
public void commonCachedRowSetTest0009(RowSet rs) throws Exception {
TestRowSetListener rsl = new TestRowSetListener();
rs.addRowSetListener(rsl);
@ -499,7 +516,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests {
/*
* Validate that getTableName() returns the proper values
*/
@Test(dataProvider = "rowSetType")
@ParameterizedTest
@MethodSource("rowSetType")
public void commonCachedRowSetTest0010(CachedRowSet rs) throws Exception {
assertNull(rs.getTableName());
rs.setTableName(COFFEE_HOUSES_TABLE);
@ -510,12 +528,13 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests {
/*
* Validate that getKeyColumns() returns the proper values
*/
@Test(dataProvider = "rowSetType")
@ParameterizedTest
@MethodSource("rowSetType")
public void commonCachedRowSetTest0011(CachedRowSet rs) throws Exception {
int[] pkeys = {1, 3};
assertNull(rs.getKeyColumns());
rs.setKeyColumns(pkeys);
assertEquals(rs.getKeyColumns(), pkeys);
Assertions.assertArrayEquals(pkeys, rs.getKeyColumns());
rs.close();
}
@ -523,52 +542,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
@MethodSource("rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0012(CachedRowSet rs) throws Exception {
rs.setMatchColumn(-1);
rs.close();
Assertions.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
@MethodSource("rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0013(CachedRowSet rs) throws Exception {
int[] cols = {1, -1};
rs.setMatchColumn(cols);
rs.close();
Assertions.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
@MethodSource("rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0014(CachedRowSet rs) throws Exception {
rs.setMatchColumn((String) null);
rs.close();
Assertions.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
@MethodSource("rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0015(CachedRowSet rs) throws Exception {
String[] cols = {"ID", null};
rs.setMatchColumn(cols);
Assertions.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
@MethodSource("rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0016(CachedRowSet rs) throws Exception {
int[] expectedCols = {1};
String[] expectedColNames = {"ID"};
@ -578,8 +607,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);
Assertions.assertArrayEquals(expectedCols, actualCols);
Assertions.assertArrayEquals(expectedColNames, actualColNames);
rs.close();
}
@ -587,15 +616,17 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests {
* Validate that getMatchColumn returns the same value specified by
* setMatchColumn
*/
@Test(dataProvider = "rowsetUsingCoffeeHouses", enabled = false)
@Disabled
@ParameterizedTest
@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);
Assertions.assertArrayEquals(expectedCols, actualCols);
Assertions.assertArrayEquals(expectedColNames, actualColNames);
rs.close();
}
@ -603,16 +634,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
@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);
Assertions.assertArrayEquals(expectedCols, actualCols);
Assertions.assertArrayEquals(expectedColNames, actualColNames);
Assertions.assertArrayEquals(expectedCols, actualCols);
rs.close();
}
@ -620,15 +653,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
@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);
Assertions.assertArrayEquals(expectedCols, actualCols);
Assertions.assertArrayEquals(expectedColNames, actualColNames);
rs.close();
}
@ -636,69 +671,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
@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();
Assertions.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
@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();
Assertions.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
@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();
Assertions.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
@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();
Assertions.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
@MethodSource("rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0024(CachedRowSet rs) throws Exception {
assertTrue(rs.size() == COFFEE_HOUSES_ROWS);
rs.close();
@ -708,9 +752,10 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests {
* Validate that the correct rows are returned comparing the primary
* keys
*/
@Test(dataProvider = "rowsetUsingCoffeeHouses")
@ParameterizedTest
@MethodSource("rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0025(RowSet rs) throws SQLException {
assertEquals(getPrimaryKeys(rs), COFFEE_HOUSES_PRIMARY_KEYS);
Assertions.assertArrayEquals(COFFEE_HOUSES_PRIMARY_KEYS, getPrimaryKeys(rs));
rs.close();
}
@ -719,7 +764,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests {
* Validate the visibility of the row depending on the value of
* setShowdelete
*/
@Test(dataProvider = "rowsetUsingCoffeeHouses")
@ParameterizedTest
@MethodSource("rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0026(CachedRowSet rs) throws Exception {
Object[] afterDelete = {
10023, 33002, 10040, 32001, 10042, 10024, 10039, 10041,
@ -727,13 +773,13 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests {
};
int rowToDelete = 10035;
// All rows should be found
assertEquals(getPrimaryKeys(rs), COFFEE_HOUSES_PRIMARY_KEYS);
Assertions.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);
Assertions.assertArrayEquals(afterDelete, getPrimaryKeys(rs));
assertTrue(rs.size() == COFFEE_HOUSES_ROWS);
// With setShowDeleted(true), the deleted row should be visible
rs.setShowDeleted(true);
@ -744,7 +790,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests {
/*
* Validate that there is no page size by default
*/
@Test(dataProvider = "rowSetType")
@ParameterizedTest
@MethodSource("rowSetType")
public void commonCachedRowSetTest0027(CachedRowSet rs) throws Exception {
assertTrue(rs.getPageSize() == 0);
rs.close();
@ -754,7 +801,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
@MethodSource("rowSetType")
public void commonCachedRowSetTest0028(CachedRowSet rs) throws Exception {
int rows = 100;
rs.setPageSize(rows);
@ -768,30 +816,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
@MethodSource("rowSetType")
public void commonCachedRowSetTest0029(CachedRowSet rs) throws Exception {
rs.setPageSize(-1);
rs.close();
Assertions.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
@MethodSource("rowSetType")
public void commonCachedRowSetTest0030(CachedRowSet rs) throws Exception {
rs.nextPage();
rs.close();
Assertions.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
@MethodSource("rowSetType")
public void commonCachedRowSetTest0031(CachedRowSet rs) throws Exception {
rs.previousPage();
rs.close();
Assertions.assertThrows(SQLException.class, () -> {
rs.previousPage();
rs.close();
});
}
@ -799,40 +856,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
@MethodSource("rowSetType")
public void commonCachedRowSetTest0032(CachedRowSet rs) throws Exception {
rs.execute(null);
rs.close();
Assertions.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
@MethodSource("rowSetType")
public void commonCachedRowSetTest0033(CachedRowSet rs) throws Exception {
rs.execute();
rs.close();
Assertions.assertThrows(SQLException.class, () -> {
rs.execute();
rs.close();
});
}
/*
* Validate that toCollection(<column>) returns the proper values
*/
@Test(dataProvider = "rowsetUsingCoffeeHouses")
@ParameterizedTest
@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);
Assertions.assertArrayEquals(cities, rs.toCollection(2).toArray());
Assertions.assertArrayEquals(cities, rs.toCollection("CITY").toArray());
rs.close();
}
/*
* Validate that toCollection() returns the proper values
*/
@Test(dataProvider = "rowsetUsingCoffeeHouses")
@ParameterizedTest
@MethodSource("rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0035(CachedRowSet rs) throws Exception {
Collection<?> col = rs.toCollection();
assertTrue(rs.size() == col.size());
@ -850,7 +915,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests {
/*
* Validate that createCopy() returns the proper values
*/
@Test(dataProvider = "rowsetUsingCoffeeHouses")
@ParameterizedTest
@MethodSource("rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0036(CachedRowSet rs) throws Exception {
try (CachedRowSet crs1 = rs.createCopy()) {
compareRowSets(rs, crs1);
@ -861,7 +927,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests {
/*
* Validate that createCopySchema() returns the proper values
*/
@Test(dataProvider = "rowsetUsingCoffeeHouses")
@ParameterizedTest
@MethodSource("rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0037(CachedRowSet rs) throws Exception {
try (CachedRowSet crs1 = rs.createCopySchema()) {
assertTrue(crs1.size() == 0);
@ -875,7 +942,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests {
* and getMatchColumnIndexes should throw a SQLException. This test
* specifies setMatchColumn(int)
*/
@Test(dataProvider = "rowsetUsingCoffeeHouses")
@ParameterizedTest
@MethodSource("rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0038(CachedRowSet rs) throws Exception {
rs.setMatchColumn(1);
try (CachedRowSet crs1 = rs.createCopyNoConstraints()) {
@ -904,7 +972,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests {
* and getMatchColumnIndexes should throw a SQLException. This test
* specifies setMatchColumn(String)
*/
@Test(dataProvider = "rowsetUsingCoffeeHouses")
@ParameterizedTest
@MethodSource("rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0039(CachedRowSet rs) throws Exception {
rs.setMatchColumn("ID");
try (CachedRowSet crs1 = rs.createCopyNoConstraints()) {
@ -932,7 +1001,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests {
* Validate that columnUpdated works with the various datatypes specifying
* the column index
*/
@Test(dataProvider = "rowsetUsingDataTypes")
@ParameterizedTest
@MethodSource("rowsetUsingDataTypes")
public void commonCachedRowSetTest0040(CachedRowSet rs, JDBCType type) throws Exception {
rs.beforeFirst();
assertTrue(rs.next());
@ -1029,7 +1099,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests {
* Validate that columnUpdated works with the various datatypes specifying
* the column name
*/
@Test(dataProvider = "rowsetUsingDataTypes")
@ParameterizedTest
@MethodSource("rowsetUsingDataTypes")
public void commonCachedRowSetTest0041(CachedRowSet rs, JDBCType type) throws Exception {
rs.beforeFirst();
assertTrue(rs.next());
@ -1127,7 +1198,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests {
* Validate isBeforeFirst(), isFirst() and first() return the correct
* results
*/
@Test(dataProvider = "rowsetUsingCoffeeHouses")
@ParameterizedTest
@MethodSource("rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0042(RowSet rs) throws Exception {
assertFalse(rs.isBeforeFirst());
assertFalse(rs.isFirst());
@ -1150,7 +1222,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests {
* Validate isAfterLast(), isLast() and last() return the correct
* results
*/
@Test(dataProvider = "rowsetUsingCoffeeHouses")
@ParameterizedTest
@MethodSource("rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0043(RowSet rs) throws Exception {
assertFalse(rs.isAfterLast());
assertFalse(rs.isLast());
@ -1173,121 +1246,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
@MethodSource("rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0044(CachedRowSet rs) throws Exception {
rs.insertRow();
rs.undoDelete();
rs.close();
Assertions.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
@MethodSource("rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0045(CachedRowSet rs) throws Exception {
rs.setShowDeleted(true);
rs.beforeFirst();
rs.undoDelete();
rs.close();
Assertions.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
@MethodSource("rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0046(CachedRowSet rs) throws Exception {
rs.setShowDeleted(true);
rs.afterLast();
rs.undoDelete();
rs.close();
Assertions.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
@MethodSource("rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0047(CachedRowSet rs) throws Exception {
rs.insertRow();
rs.undoUpdate();
rs.close();
Assertions.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
@MethodSource("rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0048(CachedRowSet rs) throws Exception {
rs.setShowDeleted(true);
rs.beforeFirst();
rs.undoUpdate();
rs.close();
Assertions.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
@MethodSource("rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0049(CachedRowSet rs) throws Exception {
rs.setShowDeleted(true);
rs.afterLast();
rs.undoUpdate();
rs.close();
Assertions.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
@MethodSource("rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0050(CachedRowSet rs) throws Exception {
rs.insertRow();
rs.undoInsert();
rs.close();
Assertions.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
@MethodSource("rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0051(CachedRowSet rs) throws Exception {
rs.setShowDeleted(true);
rs.beforeFirst();
rs.undoInsert();
rs.close();
Assertions.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
@MethodSource("rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0052(CachedRowSet rs) throws Exception {
rs.setShowDeleted(true);
rs.afterLast();
rs.undoInsert();
rs.close();
Assertions.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
@MethodSource("rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0053(CachedRowSet rs) throws Exception {
int rowToInsert = 1961;
assertTrue(rs.size() == COFFEE_HOUSES_ROWS);
@ -1314,7 +1406,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
@MethodSource("rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0054(CachedRowSet rs) throws Exception {
int rowToDelete = 1961;
assertTrue(rs.size() == COFFEE_HOUSES_ROWS);
@ -1348,7 +1441,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
@MethodSource("rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0055(CachedRowSet rs) throws Exception {
int rowToInsert = 1961;
assertTrue(rs.size() == COFFEE_HOUSES_ROWS);
@ -1385,7 +1479,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests {
* Validate getOriginal returns a ResultSet which is a copy of the original
* RowSet
*/
@Test(dataProvider = "rowsetUsingCoffees")
@ParameterizedTest
@MethodSource("rowsetUsingCoffees")
public void commonCachedRowSetTest0056(CachedRowSet rs) throws Exception {
String coffee = "Hazelnut";
int sales = 100;
@ -1414,12 +1509,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);
Assertions.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);
Assertions.assertArrayEquals(updatedPkeys, getPrimaryKeys(rs));
}
rs.close();
}
@ -1428,7 +1523,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
@MethodSource("rowsetUsingCoffees")
public void commonCachedRowSetTest0057(CachedRowSet rs) throws Exception {
String coffee = "Hazelnut";
int sales = 100;
@ -1463,7 +1559,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);
Assertions.assertArrayEquals(updatedPkeys, getPrimaryKeys(rs));
}
rs.close();
}
@ -1472,7 +1568,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
@MethodSource("rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0058(CachedRowSet rs) throws Exception {
int rowToInsert = 1961;
assertTrue(rs.size() == COFFEE_HOUSES_ROWS);
@ -1509,7 +1606,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
@MethodSource("rowsetUsingCoffees")
public void commonCachedRowSetTest0059(CachedRowSet rs) throws Exception {
int rowToDelete = 2;
try (CachedRowSet crs1 = rsf.createCachedRowSet()) {
@ -1540,7 +1638,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
@MethodSource("rowsetUsingCoffees")
public void commonCachedRowSetTest0060(CachedRowSet rs) throws Exception {
int rowToUpdate = 2;
String coffee = "Hazelnut";
@ -1578,7 +1677,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests {
* Initialize a RowSet via the populate method. Validate it matches
* the original ResultSet
*/
@Test(dataProvider = "rowsetUsingCoffeeHouses")
@ParameterizedTest
@MethodSource("rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0061(CachedRowSet rs) throws Exception {
try (CachedRowSet crs1 = rsf.createCachedRowSet()) {
rs.beforeFirst();
@ -1593,7 +1693,8 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests {
* Validate it matches the original ResultSet starting for the specofied
* offset
*/
@Test(dataProvider = "rowsetUsingCoffeeHouses")
@ParameterizedTest
@MethodSource("rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0062(CachedRowSet rs) throws Exception {
Object[] expectedRows = {
32001, 10042, 10024, 10039, 10041, 33005, 33010, 10035, 10037,
@ -1603,8 +1704,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());
Assertions.assertArrayEquals(expectedRows, getPrimaryKeys(crs1));
}
rs.close();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -26,24 +26,32 @@ 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 org.junit.jupiter.api.Assertions;
import static org.junit.jupiter.api.Assertions.assertEquals;
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.api.TestInstance;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import test.rowset.webrowset.CommonWebRowSetTests;
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
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 +91,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);
Assertions.assertArrayEquals(expectedKeys, getPrimaryKeys(frs));
}
/*
@ -96,7 +104,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);
Assertions.assertArrayEquals(expectedKeys, getPrimaryKeys(frs));
}
@ -111,7 +119,7 @@ public class FilteredRowSetTests extends CommonWebRowSetTests {
};
String[] cityArray = {"SF", "LA"};
frs.setFilter(new CityFilter(cityArray, 2));
assertEquals(getPrimaryKeys(frs), expectedKeys);
Assertions.assertArrayEquals(expectedKeys, getPrimaryKeys(frs));
}
/*
@ -125,14 +133,16 @@ public class FilteredRowSetTests extends CommonWebRowSetTests {
};
String[] cityArray = {"SF", "LA"};
frs.setFilter(new CityFilter(cityArray, "CITY"));
assertEquals(getPrimaryKeys(frs), expectedKeys);
Assertions.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
@MethodSource("rowSetType")
public void commonCachedRowSetTest0043(RowSet rs) throws Exception {
// Need to fix bug in FilteredRowSets
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -28,7 +28,9 @@ import java.sql.SQLException;
import javax.sql.rowset.JdbcRowSet;
import javax.sql.rowset.RowSetFactory;
import javax.sql.rowset.RowSetProvider;
import org.testng.annotations.Test;
import org.junit.jupiter.api.Test;
import util.BaseTest;
import util.StubDriver;
@ -41,7 +43,7 @@ public class JdbcRowSetDriverManagerTest extends BaseTest {
* Validate that JDBCRowSetImpl can connect to a JDBC driver that is
* register by DriverManager.
*/
@Test(enabled = true)
@Test
public void test0000() throws SQLException {
DriverManager.registerDriver(new StubDriver());

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -31,11 +31,17 @@ 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.Assertions;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import test.rowset.webrowset.CommonWebRowSetTests;
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class JoinRowSetTests extends CommonWebRowSetTests {
private final String SUPPLIERS_TABLE = "SUPPLIERS";
@ -150,7 +156,6 @@ public class JoinRowSetTests extends CommonWebRowSetTests {
/*
* DataProvider used to set parameters for basic types that are supported
*/
@DataProvider(name = "createCachedRowSetsToUse")
private Object[][] createCachedRowSetsToUse() throws SQLException {
CachedRowSet crs = rsf.createCachedRowSet();
initCoffeesMetaData(crs);
@ -178,13 +183,14 @@ public class JoinRowSetTests extends CommonWebRowSetTests {
results.add(jrs.getInt("COF_ID"));
}
}
assertEquals(results.toArray(), EXPECTED);
Assertions.assertArrayEquals(EXPECTED, results.toArray());
}
/*
* Join two CachedRowSets specifying a column name to join against
*/
@Test(dataProvider = "createCachedRowSetsToUse")
@ParameterizedTest
@MethodSource("createCachedRowSetsToUse")
public void joinRowSetTests0000(CachedRowSet crs, CachedRowSet crs1)
throws Exception {
@ -200,7 +206,8 @@ public class JoinRowSetTests extends CommonWebRowSetTests {
/*
* Join two CachedRowSets specifying a column index to join against
*/
@Test(dataProvider = "createCachedRowSetsToUse")
@ParameterizedTest
@MethodSource("createCachedRowSetsToUse")
public void joinRowSetTests0001(CachedRowSet crs, CachedRowSet crs1)
throws Exception {
@ -216,7 +223,8 @@ public class JoinRowSetTests extends CommonWebRowSetTests {
/*
* Join two CachedRowSets specifying a column name to join against
*/
@Test(dataProvider = "createCachedRowSetsToUse")
@ParameterizedTest
@MethodSource("createCachedRowSetsToUse")
public void joinRowSetTests0002(CachedRowSet crs, CachedRowSet crs1)
throws Exception {
@ -233,7 +241,8 @@ public class JoinRowSetTests extends CommonWebRowSetTests {
/*
* Join two CachedRowSets specifying a column index to join against
*/
@Test(dataProvider = "createCachedRowSetsToUse")
@ParameterizedTest
@MethodSource("createCachedRowSetsToUse")
public void joinRowSetTests0003(CachedRowSet crs, CachedRowSet crs1)
throws Exception {
@ -251,7 +260,8 @@ public class JoinRowSetTests extends CommonWebRowSetTests {
/*
* Join two CachedRowSets specifying a column name to join against
*/
@Test(dataProvider = "createCachedRowSetsToUse")
@ParameterizedTest
@MethodSource("createCachedRowSetsToUse")
public void joinRowSetTests0005(CachedRowSet crs, CachedRowSet crs1)
throws Exception {
@ -269,7 +279,8 @@ public class JoinRowSetTests extends CommonWebRowSetTests {
/*
* Join two CachedRowSets specifying a column index to join against
*/
@Test(dataProvider = "createCachedRowSetsToUse")
@ParameterizedTest
@MethodSource("createCachedRowSetsToUse")
public void joinRowSetTests0006(CachedRowSet crs, CachedRowSet crs1)
throws Exception {
@ -286,39 +297,56 @@ public class JoinRowSetTests extends CommonWebRowSetTests {
}
// Disabled tests due to bugs in JoinRowSet
@Test(dataProvider = "rowSetType", enabled = false)
@Disabled
@ParameterizedTest
@MethodSource("rowSetType")
public void commonCachedRowSetTest0004(CachedRowSet rs) throws Exception {
}
@Test(dataProvider = "rowSetType", enabled = false)
@Disabled
@ParameterizedTest
@MethodSource("rowSetType")
public void commonCachedRowSetTest0005(CachedRowSet rs) throws Exception {
}
@Test(dataProvider = "rowSetType", enabled = false)
@Disabled
@ParameterizedTest
@MethodSource("rowSetType")
public void commonCachedRowSetTest0008(CachedRowSet rs) throws Exception {
}
@Test(dataProvider = "rowSetType", enabled = false)
@Disabled
@ParameterizedTest
@MethodSource("rowSetType")
public void commonCachedRowSetTest0026(CachedRowSet rs) throws Exception {
}
@Test(dataProvider = "rowSetType", enabled = false)
@Disabled
@ParameterizedTest
@MethodSource("rowSetType")
public void commonCachedRowSetTest0027(CachedRowSet rs) throws Exception {
}
@Test(dataProvider = "rowSetType", enabled = false)
@Disabled
@ParameterizedTest
@MethodSource("rowSetType")
public void commonCachedRowSetTest0053(CachedRowSet rs) throws Exception {
}
@Test(dataProvider = "rowSetType", enabled = false)
@Disabled
@ParameterizedTest
@MethodSource("rowSetType")
public void commonCachedRowSetTest0054(CachedRowSet rs) throws Exception {
}
@Test(dataProvider = "rowSetType", enabled = false)
@Disabled
@ParameterizedTest
@MethodSource("rowSetType")
public void commonCachedRowSetTest0055(CachedRowSet rs) throws Exception {
}
@Test(dataProvider = "rowSetType")
@ParameterizedTest
@MethodSource("rowSetType")
public void WebRowSetTest0009(WebRowSet wrs1) throws Exception {
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -33,9 +33,12 @@ 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 org.junit.jupiter.api.Assertions;
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 +57,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 +71,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);
Assertions.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);
Assertions.assertThrows(SQLException.class, () -> {
SQLInputImpl x = new SQLInputImpl(typeValues, null);
});
}
/*
@ -124,7 +131,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 +146,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 +160,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 +173,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 +186,7 @@ public class SQLInputImplTests extends BaseTest {
/*
* Validate a URL can be read
*/
@Test(enabled = true)
@Test
public void test10() throws Exception {
URL u = new URL("http://www.oracle.com/");
Object[] values = {u};

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -41,9 +41,12 @@ 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 org.junit.jupiter.api.Assertions;
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 +67,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 +81,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);
Assertions.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);
Assertions.assertThrows(SQLException.class, () -> {
SQLOutputImpl x = new SQLOutputImpl(results, null);
});
}
/*
@ -109,7 +116,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 +130,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 +143,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 +155,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 +166,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 +180,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 +193,7 @@ public class SQLOutputImplTests extends BaseTest {
/*
* Validate an Object implementing SQLData can be written and returned
*/
@Test(enabled = true)
@Test
public void test10() throws Exception {
Object[] attributes = new Object[]{"Bruce", "Wayne", 1939,
"Batman"};

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -29,9 +29,12 @@ 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 org.junit.jupiter.api.Assertions;
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 +45,7 @@ public class SerialArrayTests extends BaseTest {
private Array a;
private Map<String, Class<?>> map;
@BeforeMethod
@BeforeEach
public void setUpMethod() throws Exception {
coffees = new Object[]{"Espresso", "Colombian", "French Roast",
"Cappuccino"};
@ -61,111 +64,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);
Assertions.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();
Assertions.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);
Assertions.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);
Assertions.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);
Assertions.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();
Assertions.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);
Assertions.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);
Assertions.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);
Assertions.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();
Assertions.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();
Assertions.assertThrows(SerialException.class, () -> {
SerialArray sa = new SerialArray(a);
sa.free();
sa.getBaseTypeName();
});
}
/*

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -27,8 +27,11 @@ import java.io.OutputStream;
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 org.junit.jupiter.api.Assertions;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import util.BaseTest;
import util.StubBlob;
@ -50,110 +53,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();
Assertions.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);
Assertions.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);
Assertions.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();
Assertions.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);
Assertions.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);
Assertions.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);
Assertions.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]);
Assertions.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);
Assertions.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);
Assertions.assertThrows(SerialException.class, () -> {
SerialBlob sb = new SerialBlob(new StubBlob());
sb.free();
sb.truncate(1);
});
}
/*
@ -173,56 +196,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);
Assertions.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);
Assertions.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);
Assertions.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);
Assertions.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);
Assertions.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);
Assertions.assertThrows(SerialException.class, () -> {
SerialBlob sb = new SerialBlob(bytes);
InputStream is = sb.getBinaryStream(bytes.length + 2, 6);
});
}
/*
@ -241,12 +276,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);
Assertions.assertThrows(SerialException.class, () -> {
SerialBlob sb = new SerialBlob(bytes);
sb.free();
SerialBlob sb2 = (SerialBlob) sb.clone();
InputStream is = sb2.getBinaryStream(1, 3);
});
}
/*
@ -264,10 +301,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);
Assertions.assertThrows(SerialException.class, () -> {
SerialBlob sb = new SerialBlob(bytes);
sb.setBinaryStream(3);
});
}
/*
@ -281,7 +320,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 +339,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 +394,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 +407,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 +420,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 +433,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 +450,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 +467,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 +484,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);
Assertions.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);
Assertions.assertThrows(SerialException.class, () -> {
int offset = 1;
int length = Integer.MAX_VALUE;
SerialBlob sb = new SerialBlob(bytes);
int written = sb.setBytes(1, new byte[]{1, 2, 3}, offset, length);
});
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -28,8 +28,12 @@ import java.io.Reader;
import java.io.Writer;
import javax.sql.rowset.serial.SerialClob;
import javax.sql.rowset.serial.SerialException;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
import org.junit.jupiter.api.Assertions;
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;
@ -56,192 +60,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();
Assertions.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();
Assertions.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);
Assertions.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);
Assertions.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);
Assertions.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();
Assertions.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();
Assertions.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);
Assertions.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);
Assertions.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);
Assertions.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);
Assertions.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");
Assertions.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);
Assertions.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);
Assertions.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);
Assertions.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);
Assertions.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);
Assertions.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);
Assertions.assertThrows(SerialException.class, () -> {
SerialClob sc = new SerialClob(chars);
sc.getCharacterStream(100, 5);
});
}
/*
@ -401,7 +441,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 +460,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 +518,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 +545,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);
Assertions.assertThrows(SerialException.class, () -> {
String val1 = "hello";
int offset = val1.length() + 1;
SerialClob sc = new SerialClob(chars);
sc.setString(1, val1, offset, 0);
});
}
/*
@ -526,8 +569,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 +587,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);
Assertions.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);
Assertions.assertThrows(SerialException.class, () -> {
int offset = 1;
int length = Integer.MAX_VALUE;
SerialClob sc = new SerialClob(chars);
int written = sc.setString(1, "hello", offset, length);
});
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -25,9 +25,12 @@ 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 org.junit.jupiter.api.Assertions;
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 +39,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 +49,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);
Assertions.assertThrows(SerialException.class, () -> {
SerialDatalink dl1 = new SerialDatalink(null);
});
}
/*

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -24,8 +24,10 @@ package test.rowset.serial;
import java.sql.SQLException;
import javax.sql.rowset.serial.SerialException;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import util.BaseTest;
public class SerialExceptionTests extends BaseTest {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -27,8 +27,12 @@ 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 org.junit.jupiter.api.Assertions;
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 +41,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);
Assertions.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());
Assertions.assertThrows(SerialException.class, () -> {
SerialJavaObject sjo = new SerialJavaObject(new RowSetMetaDataImpl());
});
}
/*

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -27,9 +27,13 @@ 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 org.junit.jupiter.api.Assertions;
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 +45,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 +55,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);
Assertions.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));
Assertions.assertThrows(SQLException.class, () -> {
SerialRef sr = new SerialRef(new StubRef(null, hero));
});
}
/*
@ -72,7 +80,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 +95,8 @@ public class SerialRefTests extends BaseTest {
/*
* Validate that getObject() returns the same object used to create the Ref
*/
@Test(enabled = false)
@Test
@Disabled
public void test05() throws Exception {
SerialRef sr = new SerialRef(ref);
assertTrue(hero.equals(sr.getObject(map)));

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -27,9 +27,11 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import javax.sql.rowset.serial.SerialStruct;
import static org.testng.Assert.*;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import util.BaseTest;
import util.StubStruct;
import util.SuperHero;
@ -42,7 +44,7 @@ public class SerialStructTests extends BaseTest {
private final String sqlType = "SUPERHERO";
private SuperHero hero;
@BeforeMethod
@BeforeEach
public void setUpMethod() throws Exception {
attributes = new Object[]{"Bruce", "Wayne", 1939,
"Batman"};
@ -58,7 +60,7 @@ public class SerialStructTests extends BaseTest {
@Test
public void test01() throws Exception {
SerialStruct ss = new SerialStruct(struct, map);
assertEquals(ss.getSQLTypeName(), sqlType);
assertEquals(sqlType, ss.getSQLTypeName());
}
/*
@ -68,7 +70,7 @@ public class SerialStructTests extends BaseTest {
@Test
public void test02() throws Exception {
SerialStruct ss = new SerialStruct(hero, map);
assertEquals(ss.getSQLTypeName(), sqlType);
assertEquals(sqlType, ss.getSQLTypeName());
}
/*

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -24,8 +24,10 @@ package test.rowset.spi;
import java.sql.SQLException;
import javax.sql.rowset.spi.SyncFactoryException;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import util.BaseTest;
public class SyncFactoryExceptionTests extends BaseTest {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -33,9 +33,12 @@ 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 org.junit.jupiter.api.Assertions;
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 +70,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 +123,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);
Assertions.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();
Assertions.assertThrows(SyncFactoryException.class, () -> {
Logger l = SyncFactory.getLogger();
});
}
/*
@ -179,15 +186,17 @@ 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);
Assertions.assertThrows(SyncFactoryException.class, () -> {
SyncFactory.setJNDIContext(null);
});
}
/*
* Validate that setJNDIContext succeeds
*/
@Test(enabled=true)
@Test
public void test09() throws Exception {
SyncFactory.setJNDIContext(ctx);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -27,29 +27,32 @@ 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 org.junit.jupiter.api.TestInstance;
import util.BaseTest;
import util.StubSyncResolver;
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class SyncProviderExceptionTests extends BaseTest {
// Used by SyncProviderException::getSyncResolver tests
private SyncResolver resolver;
@BeforeClass
@BeforeAll
public static void setUpClass() throws Exception {
System.out.println(System.getProperty("java.naming.factory.initial"));
}
@AfterClass
@AfterAll
public static void tearDownClass() throws Exception {
}
@BeforeMethod
@BeforeEach
public void setupTest() {
resolver = new SyncProviderException().getSyncResolver();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -35,13 +35,20 @@ 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 org.junit.jupiter.api.Assertions;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEqualsNoOrder;
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.api.TestInstance;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import test.rowset.cachedrowset.CommonCachedRowSetTests;
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public abstract class CommonWebRowSetTests extends CommonCachedRowSetTests {
protected final String XMLFILEPATH = System.getProperty("test.src", ".")
@ -131,10 +138,11 @@ public abstract class CommonWebRowSetTests extends CommonCachedRowSetTests {
/*
* Validate the expected Rows are contained within the RowSet
*/
@Test(dataProvider = "rowsetUsingCoffees")
@ParameterizedTest
@MethodSource("rowsetUsingCoffees")
public void WebRowSetTest0000(WebRowSet wrs) throws Exception {
assertEquals(getPrimaryKeys(wrs), COFFEES_PRIMARY_KEYS);
assertEquals(wrs.size(), COFFEES_ROWS);
Assertions.assertArrayEquals(COFFEES_PRIMARY_KEYS, getPrimaryKeys(wrs));
assertEquals(COFFEES_ROWS, wrs.size());
wrs.close();
}
@ -142,14 +150,15 @@ public abstract class CommonWebRowSetTests extends CommonCachedRowSetTests {
* Validate the expected Rows are contained within the RowSet
* populated by readXML(Reader)
*/
@Test(dataProvider = "rowSetType")
@ParameterizedTest
@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);
Assertions.assertArrayEquals(COFFEES_PRIMARY_KEYS, getPrimaryKeys(wrs1));
assertEquals(COFFEES_ROWS, wrs1.size());
wrs1.close();
}
@ -158,13 +167,14 @@ public abstract class CommonWebRowSetTests extends CommonCachedRowSetTests {
* Validate the expected Rows are contained within the RowSet
* populated by readXML(InputStream)
*/
@Test(dataProvider = "rowSetType")
@ParameterizedTest
@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);
Assertions.assertArrayEquals(COFFEES_PRIMARY_KEYS, getPrimaryKeys(wrs1));
assertEquals(COFFEES_ROWS, wrs1.size());
wrs1.close();
}
@ -173,12 +183,13 @@ public abstract class CommonWebRowSetTests extends CommonCachedRowSetTests {
* back via readXML(InputStream) and validate the primary keys
* are the same
*/
@Test(dataProvider = "rowsetUsingCoffees")
@ParameterizedTest
@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);
Assertions.assertArrayEquals(COFFEES_PRIMARY_KEYS, getPrimaryKeys(wrs1));
assertEquals(COFFEES_ROWS, wrs1.size());
}
}
@ -187,14 +198,15 @@ public abstract class CommonWebRowSetTests extends CommonCachedRowSetTests {
* back via readXML(InputStream) and validate the primary keys
* are the same
*/
@Test(dataProvider = "rowsetUsingCoffees")
@ParameterizedTest
@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);
Assertions.assertArrayEquals(COFFEES_PRIMARY_KEYS, getPrimaryKeys(wrs1));
assertEquals(COFFEES_ROWS, wrs1.size());
}
}
@ -203,12 +215,13 @@ public abstract class CommonWebRowSetTests extends CommonCachedRowSetTests {
* back via readXML(Reader) and validate the primary keys
* are the same
*/
@Test(dataProvider = "rowsetUsingCoffees")
@ParameterizedTest
@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);
Assertions.assertArrayEquals(COFFEES_PRIMARY_KEYS, getPrimaryKeys(wrs1));
assertEquals(COFFEES_ROWS, wrs1.size());
}
}
@ -217,14 +230,15 @@ public abstract class CommonWebRowSetTests extends CommonCachedRowSetTests {
* back via readXML(Reader) and validate the primary keys
* are the same
*/
@Test(dataProvider = "rowsetUsingCoffees")
@ParameterizedTest
@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);
Assertions.assertArrayEquals(COFFEES_PRIMARY_KEYS, getPrimaryKeys(wrs1));
assertEquals(COFFEES_ROWS, wrs1.size());
}
}
@ -232,11 +246,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
@MethodSource("rowsetUsingCoffees")
public void WebRowSetTest0007(WebRowSet wrs) throws Exception {
assertEquals(getPrimaryKeys(wrs), COFFEES_PRIMARY_KEYS);
Assertions.assertArrayEquals(COFFEES_PRIMARY_KEYS, getPrimaryKeys(wrs));
int[] rowsToDelete = {2, 4};
assertEquals(getPrimaryKeys(wrs), COFFEES_PRIMARY_KEYS);
Assertions.assertArrayEquals(COFFEES_PRIMARY_KEYS, getPrimaryKeys(wrs));
for (int row : rowsToDelete) {
assertTrue(deleteRowByPrimaryKey(wrs, row, 1));
}
@ -262,12 +278,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
@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);
Assertions.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 +301,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
@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);
Assertions.assertArrayEquals(expectedRows, getPrimaryKeys(wrs1));
// With setShowDeleted(false) which is the default,
// the deleted row should not be visible
for (int row : rowsToDelete) {
@ -302,7 +320,7 @@ public abstract class CommonWebRowSetTests extends CommonCachedRowSetTests {
for (int row : rowsToDelete) {
assertTrue(findRowByPrimaryKey(wrs1, row, 1));
}
assertEquals(getPrimaryKeys(wrs1), COFFEES_PRIMARY_KEYS);
Assertions.assertArrayEquals(COFFEES_PRIMARY_KEYS, getPrimaryKeys(wrs1));
wrs1.close();
}
@ -311,12 +329,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
@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);
Assertions.assertArrayEquals(COFFEES_PRIMARY_KEYS, getPrimaryKeys(wrs1));
wrs1.beforeFirst();
while (wrs1.next()) {
if (wrs1.getInt(1) == 3) {
@ -337,7 +356,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
@MethodSource("rowSetType")
public void WebRowSetTest0011(WebRowSet wrs1) throws Exception {
int expectedSize = COFFEES_ROWS + 2;
int addedRowPK = 15;
@ -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
@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);
Assertions.assertArrayEquals(expected, getPrimaryKeys(wrs1));
wrs1.beforeFirst();
while (wrs1.next()) {
if (wrs1.getInt(1) == addedRowPK) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -25,6 +25,9 @@ package test.rowset.webrowset;
import java.sql.SQLException;
import javax.sql.rowset.WebRowSet;
import org.junit.jupiter.api.TestInstance;
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class WebRowSetTests extends CommonWebRowSetTests {
@Override

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it