mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 12:09:14 +00:00
Convert testNG Object[][] style data providers to Stream
This commit is contained in:
parent
447aabe47d
commit
7a29264da5
@ -24,11 +24,13 @@ package test.sql;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.time.LocalDate;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
import util.BaseTest;
|
||||
@ -331,31 +333,31 @@ public class DateTests extends BaseTest {
|
||||
* to validate that an IllegalArgumentException will be thrown from the
|
||||
* valueOf method
|
||||
*/
|
||||
private Object[][] invalidDateValues() {
|
||||
return new Object[][]{
|
||||
{"20009-11-01"},
|
||||
{"09-11-01"},
|
||||
{"-11-01"},
|
||||
{"2009-111-01"},
|
||||
{"2009--01"},
|
||||
{"2009-13-01"},
|
||||
{"2009-11-011"},
|
||||
{"2009-11-"},
|
||||
{"2009-11-00"},
|
||||
{"2009-11-33"},
|
||||
{"--"},
|
||||
{""},
|
||||
{null},
|
||||
{"-"},
|
||||
{"2009"},
|
||||
{"2009-01"},
|
||||
{"---"},
|
||||
{"2009-13--1"},
|
||||
{"1900-1-0"},
|
||||
{"2009-01-01 10:50:01"},
|
||||
{"1996-12-10 12:26:19.1"},
|
||||
{"10:50:01"}
|
||||
};
|
||||
private Stream<String> invalidDateValues() {
|
||||
return Stream.of(
|
||||
"20009-11-01",
|
||||
"09-11-01",
|
||||
"-11-01",
|
||||
"2009-111-01",
|
||||
"2009--01",
|
||||
"2009-13-01",
|
||||
"2009-11-011",
|
||||
"2009-11-",
|
||||
"2009-11-00",
|
||||
"2009-11-33",
|
||||
"--",
|
||||
"",
|
||||
null,
|
||||
"-",
|
||||
"2009",
|
||||
"2009-01",
|
||||
"---",
|
||||
"2009-13--1",
|
||||
"1900-1-0",
|
||||
"2009-01-01 10:50:01",
|
||||
"1996-12-10 12:26:19.1",
|
||||
"10:50:01"
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -363,13 +365,12 @@ public class DateTests extends BaseTest {
|
||||
* to validate that an IllegalArgumentException will not be thrown from the
|
||||
* valueOf method and the corect value from toString() is returned
|
||||
*/
|
||||
private Object[][] validDateValues() {
|
||||
return new Object[][]{
|
||||
{"2009-08-30", "2009-08-30"},
|
||||
{"2009-01-8", "2009-01-08"},
|
||||
{"2009-1-01", "2009-01-01"},
|
||||
{"2009-1-1", "2009-01-01"}
|
||||
|
||||
};
|
||||
private Stream<Arguments> validDateValues() {
|
||||
return Stream.of(
|
||||
Arguments.of("2009-08-30", "2009-08-30"),
|
||||
Arguments.of("2009-01-8", "2009-01-08"),
|
||||
Arguments.of("2009-1-01", "2009-01-01"),
|
||||
Arguments.of("2009-1-1", "2009-01-01")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,11 +24,13 @@ package test.sql;
|
||||
|
||||
import java.sql.Time;
|
||||
import java.time.LocalTime;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
import util.BaseTest;
|
||||
@ -304,28 +306,28 @@ public class TimeTests extends BaseTest {
|
||||
* to validate that an IllegalArgumentException will be thrown from the
|
||||
* valueOf method
|
||||
*/
|
||||
private Object[][] invalidTimeValues() {
|
||||
return new Object[][]{
|
||||
{"2009-11-01 10:50:01"},
|
||||
{"1961-08-30 10:50:01.1"},
|
||||
{"1961-08-30"},
|
||||
{"00:00:00."},
|
||||
{"10:50:0.1"},
|
||||
{":00:00"},
|
||||
{"00::00"},
|
||||
{"00:00:"},
|
||||
{"::"},
|
||||
{" : : "},
|
||||
{"0a:00:00"},
|
||||
{"00:bb:00"},
|
||||
{"00:01:cc"},
|
||||
{"08:10:Batman"},
|
||||
{"08:10:10:10"},
|
||||
{"08:10"},
|
||||
{"a:b:c"},
|
||||
{null},
|
||||
{"8:"}
|
||||
};
|
||||
private Stream<String> invalidTimeValues() {
|
||||
return Stream.of(
|
||||
"2009-11-01 10:50:01",
|
||||
"1961-08-30 10:50:01.1",
|
||||
"1961-08-30",
|
||||
"00:00:00.",
|
||||
"10:50:0.1",
|
||||
":00:00",
|
||||
"00::00",
|
||||
"00:00:",
|
||||
"::",
|
||||
" : : ",
|
||||
"0a:00:00",
|
||||
"00:bb:00",
|
||||
"00:01:cc",
|
||||
"08:10:Batman",
|
||||
"08:10:10:10",
|
||||
"08:10",
|
||||
"a:b:c",
|
||||
null,
|
||||
"8:"
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -334,18 +336,18 @@ public class TimeTests extends BaseTest {
|
||||
* valueOf method. It also contains the expected return value from
|
||||
* toString()
|
||||
*/
|
||||
private Object[][] validTimeValues() {
|
||||
return new Object[][]{
|
||||
{"10:50:01", "10:50:01"},
|
||||
{"01:1:1", "01:01:01"},
|
||||
{"01:01:1", "01:01:01"},
|
||||
{"1:01:1", "01:01:01"},
|
||||
{"2:02:02", "02:02:02"},
|
||||
{"2:02:2", "02:02:02"},
|
||||
{"10:50:1", "10:50:01"},
|
||||
{"00:00:00", "00:00:00"},
|
||||
{"08:30:59", "08:30:59"},
|
||||
{"9:0:1", "09:00:01"}
|
||||
};
|
||||
private Stream<Arguments> validTimeValues() {
|
||||
return Stream.of(
|
||||
Arguments.of("10:50:01", "10:50:01"),
|
||||
Arguments.of("01:1:1", "01:01:01"),
|
||||
Arguments.of("01:01:1", "01:01:01"),
|
||||
Arguments.of("1:01:1", "01:01:01"),
|
||||
Arguments.of("2:02:02", "02:02:02"),
|
||||
Arguments.of("2:02:2", "02:02:02"),
|
||||
Arguments.of("10:50:1", "10:50:01"),
|
||||
Arguments.of("00:00:00", "00:00:00"),
|
||||
Arguments.of("08:30:59", "08:30:59"),
|
||||
Arguments.of("9:0:1", "09:00:01")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,6 +30,7 @@ import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.Calendar;
|
||||
import java.util.TimeZone;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
@ -37,6 +38,7 @@ import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
import util.BaseTest;
|
||||
@ -717,32 +719,32 @@ public class TimestampTests extends BaseTest {
|
||||
* to validate that an IllegalArgumentException will be thrown from the
|
||||
* valueOf method
|
||||
*/
|
||||
private Object[][] invalidTimestampValues() {
|
||||
return new Object[][]{
|
||||
{"2009-11-01-01 10:50:01"},
|
||||
{"aaaa-11-01-01 10:50"},
|
||||
{"aaaa-11-01 10:50"},
|
||||
{"1961--30 00:00:00"},
|
||||
{"--30 00:00:00"},
|
||||
{"-- 00:00:00"},
|
||||
{"1961-1- 00:00:00"},
|
||||
{"2009-11-01"},
|
||||
{"10:50:01"},
|
||||
{"1961-a-30 00:00:00"},
|
||||
{"1961-01-bb 00:00:00"},
|
||||
{"1961-08-30 00:00:00."},
|
||||
{"1961-08-30 :00:00"},
|
||||
{"1961-08-30 00::00"},
|
||||
{"1961-08-30 00:00:"},
|
||||
{"1961-08-30 ::"},
|
||||
{"1961-08-30 0a:00:00"},
|
||||
{"1961-08-30 00:bb:00"},
|
||||
{"1961-08-30 00:01:cc"},
|
||||
{"1961-08-30 00:00:00.01a"},
|
||||
{"1961-08-30 00:00:00.a"},
|
||||
{"1996-12-10 12:26:19.1234567890"},
|
||||
{null}
|
||||
};
|
||||
private Stream<String> invalidTimestampValues() {
|
||||
return Stream.of(
|
||||
"2009-11-01-01 10:50:01",
|
||||
"aaaa-11-01-01 10:50",
|
||||
"aaaa-11-01 10:50",
|
||||
"1961--30 00:00:00",
|
||||
"--30 00:00:00",
|
||||
"-- 00:00:00",
|
||||
"1961-1- 00:00:00",
|
||||
"2009-11-01",
|
||||
"10:50:01",
|
||||
"1961-a-30 00:00:00",
|
||||
"1961-01-bb 00:00:00",
|
||||
"1961-08-30 00:00:00.",
|
||||
"1961-08-30 :00:00",
|
||||
"1961-08-30 00::00",
|
||||
"1961-08-30 00:00:",
|
||||
"1961-08-30 ::",
|
||||
"1961-08-30 0a:00:00",
|
||||
"1961-08-30 00:bb:00",
|
||||
"1961-08-30 00:01:cc",
|
||||
"1961-08-30 00:00:00.01a",
|
||||
"1961-08-30 00:00:00.a",
|
||||
"1996-12-10 12:26:19.1234567890",
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -750,65 +752,65 @@ public class TimestampTests extends BaseTest {
|
||||
* to validate that an IllegalArgumentException will not be thrown from the
|
||||
* valueOf method and the corect value from toString() is returned
|
||||
*/
|
||||
private Object[][] validTimestampValues() {
|
||||
return new Object[][]{
|
||||
{"1961-08-30 00:00:00", "1961-08-30 00:00:00.0"},
|
||||
{"1961-08-30 11:22:33", "1961-08-30 11:22:33.0"},
|
||||
{"1961-8-30 00:00:00", "1961-08-30 00:00:00.0"},
|
||||
{"1966-08-1 00:00:00", "1966-08-01 00:00:00.0"},
|
||||
{"1996-12-10 12:26:19.1", "1996-12-10 12:26:19.1"},
|
||||
{"1996-12-10 12:26:19.12", "1996-12-10 12:26:19.12"},
|
||||
{"1996-12-10 12:26:19.123", "1996-12-10 12:26:19.123"},
|
||||
{"1996-12-10 12:26:19.1234", "1996-12-10 12:26:19.1234"},
|
||||
{"1996-12-10 12:26:19.12345", "1996-12-10 12:26:19.12345"},
|
||||
{"1996-12-10 12:26:19.123456", "1996-12-10 12:26:19.123456"},
|
||||
{"1996-12-10 12:26:19.1234567", "1996-12-10 12:26:19.1234567"},
|
||||
{"1996-12-10 12:26:19.12345678", "1996-12-10 12:26:19.12345678"},
|
||||
{"1996-12-10 12:26:19.123456789", "1996-12-10 12:26:19.123456789"},
|
||||
{"1996-12-10 12:26:19.000000001", "1996-12-10 12:26:19.000000001"},
|
||||
{"1996-12-10 12:26:19.000000012", "1996-12-10 12:26:19.000000012"},
|
||||
{"1996-12-10 12:26:19.000000123", "1996-12-10 12:26:19.000000123"},
|
||||
{"1996-12-10 12:26:19.000001234", "1996-12-10 12:26:19.000001234"},
|
||||
{"1996-12-10 12:26:19.000012345", "1996-12-10 12:26:19.000012345"},
|
||||
{"1996-12-10 12:26:19.000123456", "1996-12-10 12:26:19.000123456"},
|
||||
{"1996-12-10 12:26:19.001234567", "1996-12-10 12:26:19.001234567"},
|
||||
{"1996-12-10 12:26:19.12345678", "1996-12-10 12:26:19.12345678"},
|
||||
{"1996-12-10 12:26:19.0", "1996-12-10 12:26:19.0"},
|
||||
{"1996-12-10 12:26:19.01230", "1996-12-10 12:26:19.0123"}
|
||||
};
|
||||
private Stream<Arguments> validTimestampValues() {
|
||||
return Stream.of(
|
||||
Arguments.of("1961-08-30 00:00:00", "1961-08-30 00:00:00.0"),
|
||||
Arguments.of("1961-08-30 11:22:33", "1961-08-30 11:22:33.0"),
|
||||
Arguments.of("1961-8-30 00:00:00", "1961-08-30 00:00:00.0"),
|
||||
Arguments.of("1966-08-1 00:00:00", "1966-08-01 00:00:00.0"),
|
||||
Arguments.of("1996-12-10 12:26:19.1", "1996-12-10 12:26:19.1"),
|
||||
Arguments.of("1996-12-10 12:26:19.12", "1996-12-10 12:26:19.12"),
|
||||
Arguments.of("1996-12-10 12:26:19.123", "1996-12-10 12:26:19.123"),
|
||||
Arguments.of("1996-12-10 12:26:19.1234", "1996-12-10 12:26:19.1234"),
|
||||
Arguments.of("1996-12-10 12:26:19.12345", "1996-12-10 12:26:19.12345"),
|
||||
Arguments.of("1996-12-10 12:26:19.123456", "1996-12-10 12:26:19.123456"),
|
||||
Arguments.of("1996-12-10 12:26:19.1234567", "1996-12-10 12:26:19.1234567"),
|
||||
Arguments.of("1996-12-10 12:26:19.12345678", "1996-12-10 12:26:19.12345678"),
|
||||
Arguments.of("1996-12-10 12:26:19.123456789", "1996-12-10 12:26:19.123456789"),
|
||||
Arguments.of("1996-12-10 12:26:19.000000001", "1996-12-10 12:26:19.000000001"),
|
||||
Arguments.of("1996-12-10 12:26:19.000000012", "1996-12-10 12:26:19.000000012"),
|
||||
Arguments.of("1996-12-10 12:26:19.000000123", "1996-12-10 12:26:19.000000123"),
|
||||
Arguments.of("1996-12-10 12:26:19.000001234", "1996-12-10 12:26:19.000001234"),
|
||||
Arguments.of("1996-12-10 12:26:19.000012345", "1996-12-10 12:26:19.000012345"),
|
||||
Arguments.of("1996-12-10 12:26:19.000123456", "1996-12-10 12:26:19.000123456"),
|
||||
Arguments.of("1996-12-10 12:26:19.001234567", "1996-12-10 12:26:19.001234567"),
|
||||
Arguments.of("1996-12-10 12:26:19.12345678", "1996-12-10 12:26:19.12345678"),
|
||||
Arguments.of("1996-12-10 12:26:19.0", "1996-12-10 12:26:19.0"),
|
||||
Arguments.of("1996-12-10 12:26:19.01230", "1996-12-10 12:26:19.0123")
|
||||
);
|
||||
}
|
||||
|
||||
private Object[][] validTimestampLongValues() {
|
||||
return new Object[][]{
|
||||
{1L, "1970-01-01 01:00:00.001"},
|
||||
{-3600*1000L - 1, "1969-12-31 23:59:59.999"},
|
||||
{-(20000L*365*24*60*60*1000), "18018-08-28 01:00:00.0"},
|
||||
{Timestamp.valueOf("1961-08-30 11:22:33").getTime(), "1961-08-30 11:22:33.0"},
|
||||
{Timestamp.valueOf("1961-08-30 11:22:33.54321000").getTime(), "1961-08-30 11:22:33.543"}, // nanoprecision lost
|
||||
{new Timestamp(114, 10, 10, 10, 10, 10, 100000000).getTime(), "2014-11-10 10:10:10.1"},
|
||||
{new Timestamp(0, 10, 10, 10, 10, 10, 100000).getTime(), "1900-11-10 10:10:10.0"}, // nanoprecision lost
|
||||
{new Date(114, 10, 10).getTime(), "2014-11-10 00:00:00.0"},
|
||||
{new Date(0, 10, 10).getTime(), "1900-11-10 00:00:00.0"},
|
||||
{LocalDateTime.of(1960, 10, 10, 10, 10, 10, 50000).atZone(ZoneId.of("America/Los_Angeles"))
|
||||
.toInstant().toEpochMilli(), "1960-10-10 19:10:10.0"},
|
||||
private Stream<Arguments> validTimestampLongValues() {
|
||||
return Stream.of(
|
||||
Arguments.of(1L, "1970-01-01 01:00:00.001"),
|
||||
Arguments.of(-3600*1000L - 1, "1969-12-31 23:59:59.999"),
|
||||
Arguments.of(-(20000L*365*24*60*60*1000), "18018-08-28 01:00:00.0"),
|
||||
Arguments.of(Timestamp.valueOf("1961-08-30 11:22:33").getTime(), "1961-08-30 11:22:33.0"),
|
||||
Arguments.of(Timestamp.valueOf("1961-08-30 11:22:33.54321000").getTime(), "1961-08-30 11:22:33.543"), // nanoprecision lost
|
||||
Arguments.of(new Timestamp(114, 10, 10, 10, 10, 10, 100000000).getTime(), "2014-11-10 10:10:10.1"),
|
||||
Arguments.of(new Timestamp(0, 10, 10, 10, 10, 10, 100000).getTime(), "1900-11-10 10:10:10.0"), // nanoprecision lost
|
||||
Arguments.of(new Date(114, 10, 10).getTime(), "2014-11-10 00:00:00.0"),
|
||||
Arguments.of(new Date(0, 10, 10).getTime(), "1900-11-10 00:00:00.0"),
|
||||
Arguments.of(LocalDateTime.of(1960, 10, 10, 10, 10, 10, 50000).atZone(ZoneId.of("America/Los_Angeles"))
|
||||
.toInstant().toEpochMilli(), "1960-10-10 19:10:10.0"),
|
||||
|
||||
// millisecond timestamps wraps around at year 1, so Long.MIN_VALUE looks similar
|
||||
// Long.MAX_VALUE, while actually representing 292278994 BCE
|
||||
{Long.MIN_VALUE, "292278994-08-17 08:12:55.192"},
|
||||
{Long.MAX_VALUE + 1, "292278994-08-17 08:12:55.192"},
|
||||
{Long.MAX_VALUE, "292278994-08-17 08:12:55.807"},
|
||||
{Long.MIN_VALUE - 1, "292278994-08-17 08:12:55.807"},
|
||||
Arguments.of(Long.MIN_VALUE, "292278994-08-17 08:12:55.192"),
|
||||
Arguments.of(Long.MAX_VALUE + 1, "292278994-08-17 08:12:55.192"),
|
||||
Arguments.of(Long.MAX_VALUE, "292278994-08-17 08:12:55.807"),
|
||||
Arguments.of(Long.MIN_VALUE - 1, "292278994-08-17 08:12:55.807"),
|
||||
|
||||
// wrap around point near 0001-01-01, test that we never get a negative year:
|
||||
{-(1970L*365*24*60*60*1000), "0001-04-25 01:00:00.0"},
|
||||
{-(1970L*365*24*60*60*1000 + 115*24*60*60*1000L), "0001-12-31 01:00:00.0"},
|
||||
{-(1970L*365*24*60*60*1000 + 115*24*60*60*1000L - 23*60*60*1000L), "0001-01-01 00:00:00.0"},
|
||||
Arguments.of(-(1970L*365*24*60*60*1000), "0001-04-25 01:00:00.0"),
|
||||
Arguments.of(-(1970L*365*24*60*60*1000 + 115*24*60*60*1000L), "0001-12-31 01:00:00.0"),
|
||||
Arguments.of(-(1970L*365*24*60*60*1000 + 115*24*60*60*1000L - 23*60*60*1000L), "0001-01-01 00:00:00.0"),
|
||||
|
||||
{LocalDateTime.of(0, 1, 1, 10, 10, 10, 50000).atZone(ZoneId.of("America/Los_Angeles"))
|
||||
.toInstant().toEpochMilli() - 2*24*60*60*1000L, "0001-01-01 19:03:08.0"}, // 1 BCE
|
||||
{LocalDateTime.of(0, 1, 1, 10, 10, 10, 50000).atZone(ZoneId.of("America/Los_Angeles"))
|
||||
.toInstant().toEpochMilli() - 3*24*60*60*1000L, "0002-12-31 19:03:08.0"} // 2 BCE
|
||||
};
|
||||
Arguments.of(LocalDateTime.of(0, 1, 1, 10, 10, 10, 50000).atZone(ZoneId.of("America/Los_Angeles"))
|
||||
.toInstant().toEpochMilli() - 2*24*60*60*1000L, "0001-01-01 19:03:08.0"), // 1 BCE
|
||||
Arguments.of(LocalDateTime.of(0, 1, 1, 10, 10, 10, 50000).atZone(ZoneId.of("America/Los_Angeles"))
|
||||
.toInstant().toEpochMilli() - 3*24*60*60*1000L, "0002-12-31 19:03:08.0") // 2 BCE
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -816,28 +818,28 @@ public class TimestampTests extends BaseTest {
|
||||
* validate that the correct Nanos value is generated from the specified
|
||||
* Timestamp
|
||||
*/
|
||||
private Object[][] validateNanos() {
|
||||
return new Object[][]{
|
||||
{"1961-08-30 00:00:00", 0},
|
||||
{"1996-12-10 12:26:19.1", 100000000},
|
||||
{"1996-12-10 12:26:19.12", 120000000},
|
||||
{"1996-12-10 12:26:19.123", 123000000},
|
||||
{"1996-12-10 12:26:19.1234", 123400000},
|
||||
{"1996-12-10 12:26:19.12345", 123450000},
|
||||
{"1996-12-10 12:26:19.123456", 123456000},
|
||||
{"1996-12-10 12:26:19.1234567", 123456700},
|
||||
{"1996-12-10 12:26:19.12345678", 123456780},
|
||||
{"1996-12-10 12:26:19.123456789", 123456789},
|
||||
{"1996-12-10 12:26:19.000000001", 1},
|
||||
{"1996-12-10 12:26:19.000000012", 12},
|
||||
{"1996-12-10 12:26:19.000000123", 123},
|
||||
{"1996-12-10 12:26:19.000001234", 1234},
|
||||
{"1996-12-10 12:26:19.000012345", 12345},
|
||||
{"1996-12-10 12:26:19.000123456", 123456},
|
||||
{"1996-12-10 12:26:19.001234567", 1234567},
|
||||
{"1996-12-10 12:26:19.012345678", 12345678},
|
||||
{"1996-12-10 12:26:19.0", 0},
|
||||
{"1996-12-10 12:26:19.01230", 12300000}
|
||||
};
|
||||
private Stream<Arguments> validateNanos() {
|
||||
return Stream.of(
|
||||
Arguments.of("1961-08-30 00:00:00", 0),
|
||||
Arguments.of("1996-12-10 12:26:19.1", 100000000),
|
||||
Arguments.of("1996-12-10 12:26:19.12", 120000000),
|
||||
Arguments.of("1996-12-10 12:26:19.123", 123000000),
|
||||
Arguments.of("1996-12-10 12:26:19.1234", 123400000),
|
||||
Arguments.of("1996-12-10 12:26:19.12345", 123450000),
|
||||
Arguments.of("1996-12-10 12:26:19.123456", 123456000),
|
||||
Arguments.of("1996-12-10 12:26:19.1234567", 123456700),
|
||||
Arguments.of("1996-12-10 12:26:19.12345678", 123456780),
|
||||
Arguments.of("1996-12-10 12:26:19.123456789", 123456789),
|
||||
Arguments.of("1996-12-10 12:26:19.000000001", 1),
|
||||
Arguments.of("1996-12-10 12:26:19.000000012", 12),
|
||||
Arguments.of("1996-12-10 12:26:19.000000123", 123),
|
||||
Arguments.of("1996-12-10 12:26:19.000001234", 1234),
|
||||
Arguments.of("1996-12-10 12:26:19.000012345", 12345),
|
||||
Arguments.of("1996-12-10 12:26:19.000123456", 123456),
|
||||
Arguments.of("1996-12-10 12:26:19.001234567", 1234567),
|
||||
Arguments.of("1996-12-10 12:26:19.012345678", 12345678),
|
||||
Arguments.of("1996-12-10 12:26:19.0", 0),
|
||||
Arguments.of("1996-12-10 12:26:19.01230", 12300000)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,8 +29,10 @@ import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.sql.JDBCType;
|
||||
import java.sql.SQLException;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
public class BaseTest {
|
||||
@ -77,13 +79,8 @@ public class BaseTest {
|
||||
/*
|
||||
* DataProvider used to specify the standard JDBC Types
|
||||
*/
|
||||
protected Object[][] jdbcTypes() {
|
||||
Object[][] o = new Object[JDBCType.values().length][1];
|
||||
int pos = 0;
|
||||
for (JDBCType c : JDBCType.values()) {
|
||||
o[pos++][0] = c.getVendorTypeNumber();
|
||||
}
|
||||
return o;
|
||||
protected Stream<Integer> jdbcTypes() {
|
||||
return Stream.of(JDBCType.values()).map(JDBCType::getVendorTypeNumber);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -91,14 +88,14 @@ public class BaseTest {
|
||||
* that enquoteLiteral converts a string to a literal and every instance of
|
||||
* a single quote will be converted into two single quotes in the literal.
|
||||
*/
|
||||
protected Object[][] validEnquotedLiteralValues() {
|
||||
return new Object[][]{
|
||||
{"Hello", "'Hello'"},
|
||||
{"G'Day", "'G''Day'"},
|
||||
{"'G''Day'", "'''G''''Day'''"},
|
||||
{"I'''M", "'I''''''M'"},
|
||||
{"The Dark Knight", "'The Dark Knight'"},
|
||||
};
|
||||
protected Stream<Arguments> validEnquotedLiteralValues() {
|
||||
return Stream.of(
|
||||
Arguments.of("Hello", "'Hello'"),
|
||||
Arguments.of("G'Day", "'G''Day'"),
|
||||
Arguments.of("'G''Day'", "'''G''''Day'''"),
|
||||
Arguments.of("I'''M", "'I''''''M'"),
|
||||
Arguments.of("The Dark Knight", "'The Dark Knight'")
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -106,35 +103,37 @@ public class BaseTest {
|
||||
* that enqouteIdentifier returns a simple SQL Identifier or a
|
||||
* quoted identifier
|
||||
*/
|
||||
protected Object[][] validEnquotedIdentifierValues() {
|
||||
return new Object[][]{
|
||||
{"b", false, "b"},
|
||||
{"b", true, "\"b\""},
|
||||
{MAX_LENGTH_IDENTIFIER, false, MAX_LENGTH_IDENTIFIER},
|
||||
{MAX_LENGTH_IDENTIFIER, true, "\"" + MAX_LENGTH_IDENTIFIER + "\""},
|
||||
{"Hello", false, "Hello"},
|
||||
{"Hello", true, "\"Hello\""},
|
||||
{"G'Day", false, "\"G'Day\""},
|
||||
{"G'Day", true, "\"G'Day\""},
|
||||
{"Bruce Wayne", false, "\"Bruce Wayne\""},
|
||||
{"Bruce Wayne", true, "\"Bruce Wayne\""},
|
||||
{"select", false, "\"select\""},
|
||||
{"table", true, "\"table\""},
|
||||
{"GoodDay$", false, "\"GoodDay$\""},
|
||||
{"GoodDay$", true, "\"GoodDay$\""},};
|
||||
protected Stream<Arguments> validEnquotedIdentifierValues() {
|
||||
return Stream.of(
|
||||
Arguments.of("b", false, "b"),
|
||||
Arguments.of("b", true, "\"b\""),
|
||||
Arguments.of(MAX_LENGTH_IDENTIFIER, false, MAX_LENGTH_IDENTIFIER),
|
||||
Arguments.of(MAX_LENGTH_IDENTIFIER, true, "\"" + MAX_LENGTH_IDENTIFIER + "\""),
|
||||
Arguments.of("Hello", false, "Hello"),
|
||||
Arguments.of("Hello", true, "\"Hello\""),
|
||||
Arguments.of("G'Day", false, "\"G'Day\""),
|
||||
Arguments.of("G'Day", true, "\"G'Day\""),
|
||||
Arguments.of("Bruce Wayne", false, "\"Bruce Wayne\""),
|
||||
Arguments.of("Bruce Wayne", true, "\"Bruce Wayne\""),
|
||||
Arguments.of("select", false, "\"select\""),
|
||||
Arguments.of("table", true, "\"table\""),
|
||||
Arguments.of("GoodDay$", false, "\"GoodDay$\""),
|
||||
Arguments.of("GoodDay$", true, "\"GoodDay$\"")
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* DataProvider used to provide strings are invalid for enquoteIdentifier
|
||||
* resulting in a SQLException being thrown
|
||||
*/
|
||||
protected Object[][] invalidEnquotedIdentifierValues() {
|
||||
return new Object[][]{
|
||||
{"Hel\"lo", false},
|
||||
{"\"Hel\"lo\"", true},
|
||||
{"Hello" + '\0', false},
|
||||
{"", false},
|
||||
{MAX_LENGTH_IDENTIFIER + 'a', false},};
|
||||
protected Stream<Arguments> invalidEnquotedIdentifierValues() {
|
||||
return Stream.of(
|
||||
Arguments.of("Hel\"lo", false),
|
||||
Arguments.of("\"Hel\"lo\"", true),
|
||||
Arguments.of("Hello" + '\0', false),
|
||||
Arguments.of("", false),
|
||||
Arguments.of(MAX_LENGTH_IDENTIFIER + 'a', false)
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -142,21 +141,21 @@ public class BaseTest {
|
||||
* that isSimpleIdentifier returns the correct value based on the
|
||||
* identifier specified.
|
||||
*/
|
||||
protected Object[][] simpleIdentifierValues() {
|
||||
return new Object[][]{
|
||||
{"b", true},
|
||||
{"Hello", true},
|
||||
{"\"Gotham\"", false},
|
||||
{"G'Day", false},
|
||||
{"Bruce Wayne", false},
|
||||
{"GoodDay$", false},
|
||||
{"Dick_Grayson", true},
|
||||
{"Batmobile1966", true},
|
||||
{MAX_LENGTH_IDENTIFIER, true},
|
||||
{MAX_LENGTH_IDENTIFIER + 'a', false},
|
||||
{"", false},
|
||||
{"select", false}
|
||||
};
|
||||
protected Stream<Arguments> simpleIdentifierValues() {
|
||||
return Stream.of(
|
||||
Arguments.of("b", true),
|
||||
Arguments.of("Hello", true),
|
||||
Arguments.of("\"Gotham\"", false),
|
||||
Arguments.of("G'Day", false),
|
||||
Arguments.of("Bruce Wayne", false),
|
||||
Arguments.of("GoodDay$", false),
|
||||
Arguments.of("Dick_Grayson", true),
|
||||
Arguments.of("Batmobile1966", true),
|
||||
Arguments.of(MAX_LENGTH_IDENTIFIER, true),
|
||||
Arguments.of(MAX_LENGTH_IDENTIFIER + 'a', false),
|
||||
Arguments.of("", false),
|
||||
Arguments.of("select", false)
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -165,14 +164,14 @@ public class BaseTest {
|
||||
* literal and every instance of
|
||||
* a single quote will be converted into two single quotes in the literal.
|
||||
*/
|
||||
protected Object[][] validEnquotedNCharLiteralValues() {
|
||||
return new Object[][]{
|
||||
{"Hello", "N'Hello'"},
|
||||
{"G'Day", "N'G''Day'"},
|
||||
{"'G''Day'", "N'''G''''Day'''"},
|
||||
{"I'''M", "N'I''''''M'"},
|
||||
{"N'Hello'", "N'N''Hello'''"},
|
||||
{"The Dark Knight", "N'The Dark Knight'"}
|
||||
};
|
||||
protected Stream<Arguments> validEnquotedNCharLiteralValues() {
|
||||
return Stream.of(
|
||||
Arguments.of("Hello", "N'Hello'"),
|
||||
Arguments.of("G'Day", "N'G''Day'"),
|
||||
Arguments.of("'G''Day'", "N'''G''''Day'''"),
|
||||
Arguments.of("I'''M", "N'I''''''M'"),
|
||||
Arguments.of("N'Hello'", "N'N''Hello'''"),
|
||||
Arguments.of("The Dark Knight", "N'The Dark Knight'")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,6 +40,7 @@ import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.Calendar;
|
||||
import java.util.stream.Stream;
|
||||
import javax.sql.RowSet;
|
||||
import javax.sql.rowset.serial.SerialArray;
|
||||
import javax.sql.rowset.serial.SerialBlob;
|
||||
@ -50,6 +51,7 @@ 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.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
import util.StubArray;
|
||||
@ -304,7 +306,7 @@ public class BaseRowSetTests extends CommonRowSetTests {
|
||||
/*
|
||||
* DataProvider used to set parameters for basic types that are supported
|
||||
*/
|
||||
private Object[][] testBaseParameters() throws SQLException {
|
||||
private Stream<Arguments> testBaseParameters() throws SQLException {
|
||||
Integer aInt = 1;
|
||||
Long aLong = Long.MAX_VALUE;
|
||||
Short aShort = Short.MIN_VALUE;
|
||||
@ -338,33 +340,32 @@ public class BaseRowSetTests extends CommonRowSetTests {
|
||||
brs.setObject(17, query, Types.CHAR);
|
||||
brs.setObject(18, query, Types.CHAR, 0);
|
||||
|
||||
return new Object[][]{
|
||||
{1, aInt},
|
||||
{2, query},
|
||||
{3, aLong},
|
||||
{4, aBoolean},
|
||||
{5, aShort},
|
||||
{6, aDouble},
|
||||
{7, bd},
|
||||
{8, aFloat},
|
||||
{9, aByte},
|
||||
{10, aDate},
|
||||
{11, aTime},
|
||||
{12, aTimeStamp},
|
||||
{13, aDate},
|
||||
{14, aTime},
|
||||
{15, aTimeStamp},
|
||||
{16, query},
|
||||
{17, query},
|
||||
{18, query}
|
||||
|
||||
};
|
||||
return Stream.of(
|
||||
Arguments.of(1, aInt),
|
||||
Arguments.of(2, query),
|
||||
Arguments.of(3, aLong),
|
||||
Arguments.of(4, aBoolean),
|
||||
Arguments.of(5, aShort),
|
||||
Arguments.of(6, aDouble),
|
||||
Arguments.of(7, bd),
|
||||
Arguments.of(8, aFloat),
|
||||
Arguments.of(9, aByte),
|
||||
Arguments.of(10, aDate),
|
||||
Arguments.of(11, aTime),
|
||||
Arguments.of(12, aTimeStamp),
|
||||
Arguments.of(13, aDate),
|
||||
Arguments.of(14, aTime),
|
||||
Arguments.of(15, aTimeStamp),
|
||||
Arguments.of(16, query),
|
||||
Arguments.of(17, query),
|
||||
Arguments.of(18, query)
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* DataProvider used to set advanced parameters for types that are supported
|
||||
*/
|
||||
private Object[][] testAdvancedParameters() throws SQLException {
|
||||
private Stream<Arguments> testAdvancedParameters() throws SQLException {
|
||||
|
||||
byte[] bytes = new byte[10];
|
||||
Ref aRef = new SerialRef(new StubRef("INTEGER", query));
|
||||
@ -384,17 +385,17 @@ public class BaseRowSetTests extends CommonRowSetTests {
|
||||
brs.setUnicodeStream(8, is, query.length());
|
||||
brs.setCharacterStream(9, rdr, query.length());
|
||||
|
||||
return new Object[][]{
|
||||
{1, bytes},
|
||||
{2, is},
|
||||
{3, aRef},
|
||||
{4, aArray},
|
||||
{5, aBlob},
|
||||
{6, aClob},
|
||||
{7, is},
|
||||
{8, is},
|
||||
{9, rdr}
|
||||
};
|
||||
return Stream.of(
|
||||
Arguments.of(1, bytes),
|
||||
Arguments.of(2, is),
|
||||
Arguments.of(3, aRef),
|
||||
Arguments.of(4, aArray),
|
||||
Arguments.of(5, aBlob),
|
||||
Arguments.of(6, aClob),
|
||||
Arguments.of(7, is),
|
||||
Arguments.of(8, is),
|
||||
Arguments.of(9, rdr)
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@ -43,6 +43,7 @@ import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Stream;
|
||||
import javax.sql.RowSet;
|
||||
import javax.sql.rowset.BaseRowSet;
|
||||
import javax.sql.rowset.CachedRowSet;
|
||||
@ -55,6 +56,7 @@ import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
import util.BaseTest;
|
||||
@ -115,78 +117,76 @@ public abstract class CommonRowSetTests extends BaseTest {
|
||||
* DataProvider used to specify the value to set and check for the
|
||||
* methods for fetch direction
|
||||
*/
|
||||
protected Object[][] rowSetFetchDirection() throws Exception {
|
||||
protected Stream<Arguments> rowSetFetchDirection() throws Exception {
|
||||
RowSet rs = newInstance();
|
||||
return new Object[][]{
|
||||
{rs, ResultSet.FETCH_FORWARD},
|
||||
{rs, ResultSet.FETCH_REVERSE},
|
||||
{rs, ResultSet.FETCH_UNKNOWN}
|
||||
};
|
||||
return Stream.of(
|
||||
Arguments.of(rs, ResultSet.FETCH_FORWARD),
|
||||
Arguments.of(rs, ResultSet.FETCH_REVERSE),
|
||||
Arguments.of(rs, ResultSet.FETCH_UNKNOWN)
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* DataProvider used to specify the value to set and check for the
|
||||
* methods for Cursor Scroll Type
|
||||
*/
|
||||
protected Object[][] rowSetScrollTypes() throws Exception {
|
||||
protected Stream<Arguments> rowSetScrollTypes() throws Exception {
|
||||
RowSet rs = newInstance();
|
||||
|
||||
return new Object[][]{
|
||||
{rs, ResultSet.TYPE_FORWARD_ONLY},
|
||||
{rs, ResultSet.TYPE_SCROLL_INSENSITIVE},
|
||||
{rs, ResultSet.TYPE_SCROLL_SENSITIVE}
|
||||
};
|
||||
return Stream.of(
|
||||
Arguments.of(rs, ResultSet.TYPE_FORWARD_ONLY),
|
||||
Arguments.of(rs, ResultSet.TYPE_SCROLL_INSENSITIVE),
|
||||
Arguments.of(rs, ResultSet.TYPE_SCROLL_SENSITIVE)
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* DataProvider used to specify the value to set and check for
|
||||
* methods using transaction isolation types
|
||||
*/
|
||||
protected Object[][] rowSetIsolationTypes() throws Exception {
|
||||
protected Stream<Arguments> rowSetIsolationTypes() throws Exception {
|
||||
RowSet rs = newInstance();
|
||||
|
||||
return new Object[][]{
|
||||
{rs, Connection.TRANSACTION_NONE},
|
||||
{rs, Connection.TRANSACTION_READ_COMMITTED},
|
||||
{rs, Connection.TRANSACTION_READ_UNCOMMITTED},
|
||||
{rs, Connection.TRANSACTION_REPEATABLE_READ},
|
||||
{rs, Connection.TRANSACTION_SERIALIZABLE}
|
||||
};
|
||||
return Stream.of(
|
||||
Arguments.of(rs, Connection.TRANSACTION_NONE),
|
||||
Arguments.of(rs, Connection.TRANSACTION_READ_COMMITTED),
|
||||
Arguments.of(rs, Connection.TRANSACTION_READ_UNCOMMITTED),
|
||||
Arguments.of(rs, Connection.TRANSACTION_REPEATABLE_READ),
|
||||
Arguments.of(rs, Connection.TRANSACTION_SERIALIZABLE)
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* DataProvider used to specify the value to set and check for the
|
||||
* methods for Concurrency
|
||||
*/
|
||||
protected Object[][] rowSetConcurrencyTypes() throws Exception {
|
||||
protected Stream<Arguments> rowSetConcurrencyTypes() throws Exception {
|
||||
RowSet rs = newInstance();
|
||||
return new Object[][]{
|
||||
{rs, ResultSet.CONCUR_READ_ONLY},
|
||||
{rs, ResultSet.CONCUR_UPDATABLE}
|
||||
};
|
||||
return Stream.of(
|
||||
Arguments.of(rs, ResultSet.CONCUR_READ_ONLY),
|
||||
Arguments.of(rs, ResultSet.CONCUR_UPDATABLE)
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* DataProvider used to specify the value to set and check for
|
||||
* methods using boolean values
|
||||
*/
|
||||
protected Object[][] rowSetTrueFalse() throws Exception {
|
||||
protected Stream<Arguments> rowSetTrueFalse() throws Exception {
|
||||
RowSet rs = newInstance();
|
||||
return new Object[][]{
|
||||
{rs, true},
|
||||
{rs, false}
|
||||
};
|
||||
return Stream.of(
|
||||
Arguments.of(rs, true),
|
||||
Arguments.of(rs, false)
|
||||
);
|
||||
}
|
||||
/*
|
||||
* DataProvider used to specify the type of RowSet to use. We also must
|
||||
* initialize the RowSet
|
||||
*/
|
||||
protected Object[][] rowSetType() throws Exception {
|
||||
protected Stream<RowSet> rowSetType() throws Exception {
|
||||
|
||||
RowSet rs = newInstance();
|
||||
return new Object[][]{
|
||||
{rs}
|
||||
};
|
||||
return Stream.of(rs);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@ -23,12 +23,14 @@
|
||||
package test.rowset;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.stream.Stream;
|
||||
import javax.sql.rowset.RowSetFactory;
|
||||
import javax.sql.rowset.RowSetProvider;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
import util.BaseTest;
|
||||
@ -103,21 +105,20 @@ public class RowSetFactoryTests extends BaseTest {
|
||||
* DataProvider used to provide the RowSetFactory and the RowSet
|
||||
* implementation that should be returned
|
||||
*/
|
||||
private Object[][] RowSetValues() throws SQLException {
|
||||
private Stream<Arguments> RowSetValues() throws SQLException {
|
||||
RowSetFactory rsf = RowSetProvider.newFactory();
|
||||
RowSetFactory rsf1 = RowSetProvider.newFactory(STUB_FACTORY_CLASSNAME, null);
|
||||
return new Object[][]{
|
||||
{rsf, DEFAULT_CACHEDROWSET_CLASSNAME},
|
||||
{rsf, DEFAULT_FILTEREDROWSET_CLASSNAME},
|
||||
{rsf, DEFAULT_JDBCROWSET_CLASSNAME},
|
||||
{rsf, DEFAULT_JOINROWSET_CLASSNAME},
|
||||
{rsf, DEFAULT_WEBROWSET_CLASSNAME},
|
||||
{rsf1, STUB_CACHEDROWSET_CLASSNAME},
|
||||
{rsf1, STUB_FILTEREDROWSET_CLASSNAME},
|
||||
{rsf1, STUB_JDBCROWSET_CLASSNAME},
|
||||
{rsf1, STUB_JOINROWSET_CLASSNAME},
|
||||
{rsf1, STUB_WEBROWSET_CLASSNAME}
|
||||
|
||||
};
|
||||
return Stream.of(
|
||||
Arguments.of(rsf, DEFAULT_CACHEDROWSET_CLASSNAME),
|
||||
Arguments.of(rsf, DEFAULT_FILTEREDROWSET_CLASSNAME),
|
||||
Arguments.of(rsf, DEFAULT_JDBCROWSET_CLASSNAME),
|
||||
Arguments.of(rsf, DEFAULT_JOINROWSET_CLASSNAME),
|
||||
Arguments.of(rsf, DEFAULT_WEBROWSET_CLASSNAME),
|
||||
Arguments.of(rsf1, STUB_CACHEDROWSET_CLASSNAME),
|
||||
Arguments.of(rsf1, STUB_FILTEREDROWSET_CLASSNAME),
|
||||
Arguments.of(rsf1, STUB_JDBCROWSET_CLASSNAME),
|
||||
Arguments.of(rsf1, STUB_JOINROWSET_CLASSNAME),
|
||||
Arguments.of(rsf1, STUB_WEBROWSET_CLASSNAME)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,6 +25,8 @@ package test.rowset;
|
||||
import java.sql.ResultSetMetaData;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
import java.util.stream.IntStream;
|
||||
import java.util.stream.Stream;
|
||||
import javax.sql.RowSetMetaData;
|
||||
import javax.sql.rowset.RowSetMetaDataImpl;
|
||||
|
||||
@ -34,6 +36,7 @@ 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.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
@ -567,69 +570,62 @@ public class RowSetMetaDataTests extends BaseTest {
|
||||
* to validate that an IllegalArgumentException will be thrown from the
|
||||
* valueOf method
|
||||
*/
|
||||
private Object[][] validSetNullableValues() {
|
||||
return new Object[][]{
|
||||
{ResultSetMetaData.columnNoNulls},
|
||||
{ResultSetMetaData.columnNullable},
|
||||
{ResultSetMetaData.columnNullableUnknown}
|
||||
};
|
||||
private Stream<Integer> validSetNullableValues() {
|
||||
return Stream.of(
|
||||
ResultSetMetaData.columnNoNulls,
|
||||
ResultSetMetaData.columnNullable,
|
||||
ResultSetMetaData.columnNullableUnknown
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* DataProvider used to provide column indexes that are out of range so that
|
||||
* SQLException is thrown
|
||||
*/
|
||||
private Object[][] invalidColumnRanges() {
|
||||
return new Object[][]{
|
||||
{-1},
|
||||
{0},
|
||||
{MAX_COLUMNS + 1}
|
||||
};
|
||||
private Stream<Integer> invalidColumnRanges() {
|
||||
return Stream.of(
|
||||
-1,
|
||||
0,
|
||||
MAX_COLUMNS + 1
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* DataProvider used to provide the valid column ranges for the
|
||||
* RowSetMetaDataImpl object
|
||||
*/
|
||||
private Object[][] columnRanges() {
|
||||
Object[][] o = new Object[MAX_COLUMNS][1];
|
||||
for (int i = 1; i <= MAX_COLUMNS; i++) {
|
||||
o[i - 1][0] = i;
|
||||
}
|
||||
return o;
|
||||
private Stream<Integer> columnRanges() {
|
||||
return IntStream.rangeClosed(1, MAX_COLUMNS).boxed();
|
||||
}
|
||||
|
||||
/*
|
||||
* DataProvider used to specify the value to set via setColumnType and
|
||||
* the expected value to be returned from getColumnClassName
|
||||
*/
|
||||
private Object[][] columnClassNames() {
|
||||
return new Object[][]{
|
||||
{Types.CHAR, "java.lang.String"},
|
||||
{Types.NCHAR, "java.lang.String"},
|
||||
{Types.VARCHAR, "java.lang.String"},
|
||||
{Types.NVARCHAR, "java.lang.String"},
|
||||
{Types.LONGVARCHAR, "java.lang.String"},
|
||||
{Types.LONGNVARCHAR, "java.lang.String"},
|
||||
{Types.NUMERIC, "java.math.BigDecimal"},
|
||||
{Types.DECIMAL, "java.math.BigDecimal"},
|
||||
{Types.BIT, "java.lang.Boolean"},
|
||||
{Types.TINYINT, "java.lang.Byte"},
|
||||
{Types.SMALLINT, "java.lang.Short"},
|
||||
{Types.INTEGER, "java.lang.Integer"},
|
||||
{Types.FLOAT, "java.lang.Double"},
|
||||
{Types.DOUBLE, "java.lang.Double"},
|
||||
{Types.BINARY, "byte[]"},
|
||||
{Types.VARBINARY, "byte[]"},
|
||||
{Types.LONGVARBINARY, "byte[]"},
|
||||
{Types.DATE, "java.sql.Date"},
|
||||
{Types.TIME, "java.sql.Time"},
|
||||
{Types.TIMESTAMP, "java.sql.Timestamp"},
|
||||
{Types.CLOB, "java.sql.Clob"},
|
||||
{Types.BLOB, "java.sql.Blob"}
|
||||
|
||||
};
|
||||
|
||||
private Stream<Arguments> columnClassNames() {
|
||||
return Stream.of(
|
||||
Arguments.of(Types.CHAR, "java.lang.String"),
|
||||
Arguments.of(Types.NCHAR, "java.lang.String"),
|
||||
Arguments.of(Types.VARCHAR, "java.lang.String"),
|
||||
Arguments.of(Types.NVARCHAR, "java.lang.String"),
|
||||
Arguments.of(Types.LONGVARCHAR, "java.lang.String"),
|
||||
Arguments.of(Types.LONGNVARCHAR, "java.lang.String"),
|
||||
Arguments.of(Types.NUMERIC, "java.math.BigDecimal"),
|
||||
Arguments.of(Types.DECIMAL, "java.math.BigDecimal"),
|
||||
Arguments.of(Types.BIT, "java.lang.Boolean"),
|
||||
Arguments.of(Types.TINYINT, "java.lang.Byte"),
|
||||
Arguments.of(Types.SMALLINT, "java.lang.Short"),
|
||||
Arguments.of(Types.INTEGER, "java.lang.Integer"),
|
||||
Arguments.of(Types.FLOAT, "java.lang.Double"),
|
||||
Arguments.of(Types.DOUBLE, "java.lang.Double"),
|
||||
Arguments.of(Types.BINARY, "byte[]"),
|
||||
Arguments.of(Types.VARBINARY, "byte[]"),
|
||||
Arguments.of(Types.LONGVARBINARY, "byte[]"),
|
||||
Arguments.of(Types.DATE, "java.sql.Date"),
|
||||
Arguments.of(Types.TIME, "java.sql.Time"),
|
||||
Arguments.of(Types.TIMESTAMP, "java.sql.Timestamp"),
|
||||
Arguments.of(Types.CLOB, "java.sql.Clob"),
|
||||
Arguments.of(Types.BLOB, "java.sql.Blob")
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -27,6 +27,7 @@ import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.sql.SQLException;
|
||||
import java.util.stream.Stream;
|
||||
import javax.sql.rowset.RowSetFactory;
|
||||
import javax.sql.rowset.RowSetProvider;
|
||||
|
||||
@ -38,6 +39,7 @@ 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.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
import util.BaseTest;
|
||||
@ -185,15 +187,15 @@ public class RowSetProviderTests extends BaseTest {
|
||||
* DataProvider used to provide a RowSetFactory and the expected
|
||||
* RowSetFactory implementation that should be returned
|
||||
*/
|
||||
private Object[][] RowSetFactoryValues() throws SQLException {
|
||||
private Stream<Arguments> RowSetFactoryValues() throws SQLException {
|
||||
RowSetFactory rsf = RowSetProvider.newFactory();
|
||||
RowSetFactory rsf1 = RowSetProvider.newFactory(STUB_FACTORY_CLASSNAME, null);
|
||||
RowSetFactory rsf2 = RowSetProvider.newFactory(DEFFAULT_FACTORY_CLASSNAME, null);
|
||||
return new Object[][]{
|
||||
{rsf, NO_VALADATE_IMPL},
|
||||
{rsf, DEFFAULT_FACTORY_CLASSNAME},
|
||||
{rsf1, STUB_FACTORY_CLASSNAME},
|
||||
{rsf2, DEFFAULT_FACTORY_CLASSNAME}
|
||||
};
|
||||
return Stream.of(
|
||||
Arguments.of(rsf, NO_VALADATE_IMPL),
|
||||
Arguments.of(rsf, DEFFAULT_FACTORY_CLASSNAME),
|
||||
Arguments.of(rsf1, STUB_FACTORY_CLASSNAME),
|
||||
Arguments.of(rsf2, DEFFAULT_FACTORY_CLASSNAME)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,6 +37,7 @@ import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.Collection;
|
||||
import java.util.stream.Stream;
|
||||
import javax.sql.RowSet;
|
||||
import javax.sql.rowset.CachedRowSet;
|
||||
import javax.sql.rowset.RowSetMetaDataImpl;
|
||||
@ -53,6 +54,7 @@ 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.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
import test.rowset.CommonRowSetTests;
|
||||
@ -89,49 +91,43 @@ public abstract class CommonCachedRowSetTests extends CommonRowSetTests {
|
||||
/*
|
||||
* DataProvider that uses a RowSet with the COFFEE_HOUSES Table
|
||||
*/
|
||||
protected Object[][] rowsetUsingCoffeeHouses() throws Exception {
|
||||
RowSet rs = createCoffeeHousesRowSet();
|
||||
return new Object[][]{
|
||||
{rs}
|
||||
};
|
||||
protected Stream<RowSet> rowsetUsingCoffeeHouses() throws Exception {
|
||||
return Stream.of(createCoffeeHousesRowSet());
|
||||
}
|
||||
|
||||
/*
|
||||
* DataProvider that uses a RowSet with the COFFEES Table
|
||||
*/
|
||||
protected Object[][] rowsetUsingCoffees() throws Exception {
|
||||
RowSet rs = createCoffeesRowSet();
|
||||
return new Object[][]{
|
||||
{rs}
|
||||
};
|
||||
protected Stream<RowSet> rowsetUsingCoffees() throws Exception {
|
||||
return Stream.of(createCoffeesRowSet());
|
||||
}
|
||||
|
||||
/*
|
||||
* DataProvider that uses a RowSet with the DATAYPES Table and
|
||||
* used to validate the various supported data types
|
||||
*/
|
||||
protected Object[][] rowsetUsingDataTypes() throws Exception {
|
||||
protected Stream<Arguments> rowsetUsingDataTypes() throws Exception {
|
||||
|
||||
CachedRowSet rs = createDataTypesRowSet();
|
||||
return new Object[][]{
|
||||
{rs, JDBCType.INTEGER},
|
||||
{rs, JDBCType.CHAR},
|
||||
{rs, JDBCType.VARCHAR},
|
||||
{rs, JDBCType.BIGINT},
|
||||
{rs, JDBCType.BOOLEAN},
|
||||
{rs, JDBCType.SMALLINT},
|
||||
{rs, JDBCType.DOUBLE},
|
||||
{rs, JDBCType.DECIMAL},
|
||||
{rs, JDBCType.REAL},
|
||||
{rs, JDBCType.TINYINT},
|
||||
{rs, JDBCType.DATE},
|
||||
{rs, JDBCType.TIME},
|
||||
{rs, JDBCType.TIMESTAMP},
|
||||
{rs, JDBCType.VARBINARY},
|
||||
{rs, JDBCType.ARRAY},
|
||||
{rs, JDBCType.REF},
|
||||
{rs, JDBCType.FLOAT}
|
||||
};
|
||||
return Stream.of(
|
||||
Arguments.of(rs, JDBCType.INTEGER),
|
||||
Arguments.of(rs, JDBCType.CHAR),
|
||||
Arguments.of(rs, JDBCType.VARCHAR),
|
||||
Arguments.of(rs, JDBCType.BIGINT),
|
||||
Arguments.of(rs, JDBCType.BOOLEAN),
|
||||
Arguments.of(rs, JDBCType.SMALLINT),
|
||||
Arguments.of(rs, JDBCType.DOUBLE),
|
||||
Arguments.of(rs, JDBCType.DECIMAL),
|
||||
Arguments.of(rs, JDBCType.REAL),
|
||||
Arguments.of(rs, JDBCType.TINYINT),
|
||||
Arguments.of(rs, JDBCType.DATE),
|
||||
Arguments.of(rs, JDBCType.TIME),
|
||||
Arguments.of(rs, JDBCType.TIMESTAMP),
|
||||
Arguments.of(rs, JDBCType.VARBINARY),
|
||||
Arguments.of(rs, JDBCType.ARRAY),
|
||||
Arguments.of(rs, JDBCType.REF),
|
||||
Arguments.of(rs, JDBCType.FLOAT)
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@ -26,6 +26,7 @@ import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
import javax.sql.RowSet;
|
||||
import javax.sql.rowset.CachedRowSet;
|
||||
import javax.sql.rowset.JoinRowSet;
|
||||
@ -37,6 +38,7 @@ 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.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
import test.rowset.webrowset.CommonWebRowSetTests;
|
||||
@ -156,7 +158,7 @@ public class JoinRowSetTests extends CommonWebRowSetTests {
|
||||
/*
|
||||
* DataProvider used to set parameters for basic types that are supported
|
||||
*/
|
||||
private Object[][] createCachedRowSetsToUse() throws SQLException {
|
||||
private Stream<Arguments> createCachedRowSetsToUse() throws SQLException {
|
||||
CachedRowSet crs = rsf.createCachedRowSet();
|
||||
initCoffeesMetaData(crs);
|
||||
createCoffeesRows(crs);
|
||||
@ -167,9 +169,7 @@ public class JoinRowSetTests extends CommonWebRowSetTests {
|
||||
createSuppiersRows(crs1);
|
||||
// Make sure you are not on the insertRow
|
||||
crs1.moveToCurrentRow();
|
||||
return new Object[][]{
|
||||
{crs, crs1}
|
||||
};
|
||||
return Stream.of(Arguments.of(crs, crs1));
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user