Skip to content

Commit 661fae9

Browse files
committed
Update ArgumentsProvider for JUnit Jupiter
Updated 'ArgumentsProvider' method signature to include 'ParameterDeclarations' to resolve deprecation warnings with JUnit Jupiter 5.8 and newer.
1 parent 8811517 commit 661fae9

7 files changed

Lines changed: 17 additions & 10 deletions

File tree

src/test/java/io/github/spannm/jackcess/impl/expr/DefaultFunctionsTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.junit.jupiter.params.ParameterizedTest;
1212
import org.junit.jupiter.params.converter.ConvertWith;
1313
import org.junit.jupiter.params.provider.*;
14+
import org.junit.jupiter.params.support.ParameterDeclarations;
1415
import org.junit.platform.commons.support.AnnotationSupport;
1516

1617
import java.lang.annotation.*;
@@ -908,8 +909,8 @@ static Object eval(String _expr) {
908909

909910
class CustomFormatArgumentsProvider implements ArgumentsProvider {
910911
@Override
911-
public Stream<Arguments> provideArguments(ExtensionContext context) {
912-
return context.getElement().map(elem -> AnnotationSupport.findRepeatableAnnotations(elem, CustomFormatSource.class)).orElse(List.of()).stream()
912+
public Stream<Arguments> provideArguments(ParameterDeclarations _parameters, ExtensionContext _context) {
913+
return _context.getElement().map(elem -> AnnotationSupport.findRepeatableAnnotations(elem, CustomFormatSource.class)).orElse(List.of()).stream()
913914
.flatMap(src -> IntStream.range(0, src.testValues().length).filter(i -> i % 2 == 0).mapToObj(i -> {
914915
String expected = src.testValues()[i];
915916
String val = src.testValues()[i + 1];

src/test/java/io/github/spannm/jackcess/test/source/DbsInPathSource.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import org.junit.jupiter.params.provider.Arguments;
66
import org.junit.jupiter.params.provider.ArgumentsProvider;
77
import org.junit.jupiter.params.provider.ArgumentsSource;
8+
import org.junit.jupiter.params.support.ParameterDeclarations;
89
import org.junit.platform.commons.support.AnnotationSupport;
910

1011
import java.io.IOException;
@@ -36,7 +37,7 @@
3637
class DbsInPathSourceArgumentsProvider implements ArgumentsProvider {
3738

3839
@Override
39-
public Stream<Arguments> provideArguments(ExtensionContext _context) throws IOException {
40+
public Stream<Arguments> provideArguments(ParameterDeclarations _parameters, ExtensionContext _context) throws IOException {
4041
DbsInPathSource src = _context.getElement().map(elem -> AnnotationSupport.findAnnotation(elem, DbsInPathSource.class).get()).orElse(null);
4142
Path path = Paths.get(src.value());
4243
try (Stream<Path> walk = Files.walk(path)) {

src/test/java/io/github/spannm/jackcess/test/source/FileFormatSource.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import org.junit.jupiter.params.provider.Arguments;
88
import org.junit.jupiter.params.provider.ArgumentsProvider;
99
import org.junit.jupiter.params.provider.ArgumentsSource;
10+
import org.junit.jupiter.params.support.ParameterDeclarations;
1011
import org.junit.platform.commons.support.AnnotationSupport;
1112

1213
import java.lang.annotation.ElementType;
@@ -49,7 +50,7 @@ class FileFormatArgumentsProvider implements ArgumentsProvider {
4950
.collect(Collectors.toList());
5051

5152
@Override
52-
public Stream<Arguments> provideArguments(ExtensionContext _context) {
53+
public Stream<Arguments> provideArguments(ParameterDeclarations _parameters, ExtensionContext _context) {
5354
FileFormatSource src = _context.getElement().map(elem -> AnnotationSupport.findAnnotation(elem, FileFormatSource.class).get()).orElse(null);
5455
List<FileFormat> include = Arrays.stream(src.include()).map(FileFormat::valueOf).collect(Collectors.toList());
5556
if (include.isEmpty()) {

src/test/java/io/github/spannm/jackcess/test/source/IntMatrixSource.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import org.junit.jupiter.params.provider.Arguments;
66
import org.junit.jupiter.params.provider.ArgumentsProvider;
77
import org.junit.jupiter.params.provider.ArgumentsSource;
8+
import org.junit.jupiter.params.support.ParameterDeclarations;
89
import org.junit.platform.commons.support.AnnotationSupport;
910

1011
import java.lang.annotation.ElementType;
@@ -45,8 +46,8 @@
4546
class IntMatrixArgumentsProvider implements ArgumentsProvider {
4647

4748
@Override
48-
public Stream<Arguments> provideArguments(ExtensionContext context) {
49-
Optional<IntMatrixSource> optSrc = context.getElement().map(elem -> AnnotationSupport.findAnnotation(elem, IntMatrixSource.class).get());
49+
public Stream<Arguments> provideArguments(ParameterDeclarations _parameters, ExtensionContext _context) {
50+
Optional<IntMatrixSource> optSrc = _context.getElement().map(elem -> AnnotationSupport.findAnnotation(elem, IntMatrixSource.class).get());
5051
return optSrc.map(cfg -> {
5152
int end = cfg.end() + (cfg.endInclusive() ? 1 : 0);
5253
return IntStream.range(cfg.start(), end).boxed()

src/test/java/io/github/spannm/jackcess/test/source/IntRangeSource.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import org.junit.jupiter.params.provider.Arguments;
66
import org.junit.jupiter.params.provider.ArgumentsProvider;
77
import org.junit.jupiter.params.provider.ArgumentsSource;
8+
import org.junit.jupiter.params.support.ParameterDeclarations;
89
import org.junit.platform.commons.support.AnnotationSupport;
910

1011
import java.lang.annotation.ElementType;
@@ -44,8 +45,8 @@
4445
class IntRangeArgumentsProvider implements ArgumentsProvider {
4546

4647
@Override
47-
public Stream<Arguments> provideArguments(ExtensionContext context) {
48-
Optional<IntRangeSource> optSrc = context.getElement().map(elem -> AnnotationSupport.findAnnotation(elem, IntRangeSource.class).get());
48+
public Stream<Arguments> provideArguments(ParameterDeclarations _parameters, ExtensionContext _context) {
49+
Optional<IntRangeSource> optSrc = _context.getElement().map(elem -> AnnotationSupport.findAnnotation(elem, IntRangeSource.class).get());
4950
return optSrc.map(cfg -> IntStream.range(cfg.start(), cfg.endInclusive() ? cfg.end() + 1 : cfg.end()).boxed().map(Arguments::of)).orElse(Stream.empty());
5051
}
5152

src/test/java/io/github/spannm/jackcess/test/source/TestDbReadOnlySource.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import org.junit.jupiter.params.provider.Arguments;
99
import org.junit.jupiter.params.provider.ArgumentsProvider;
1010
import org.junit.jupiter.params.provider.ArgumentsSource;
11+
import org.junit.jupiter.params.support.ParameterDeclarations;
1112
import org.junit.platform.commons.support.AnnotationSupport;
1213

1314
import java.lang.annotation.ElementType;
@@ -32,7 +33,7 @@
3233

3334
class TestDbReadOnlyArgumentsProvider implements ArgumentsProvider {
3435
@Override
35-
public Stream<Arguments> provideArguments(ExtensionContext _context) {
36+
public Stream<Arguments> provideArguments(ParameterDeclarations _parameters, ExtensionContext _context) {
3637
TestDbReadOnlySource src = _context.getElement().map(elem -> AnnotationSupport.findAnnotation(elem, TestDbReadOnlySource.class).get()).orElse(null);
3738
return src == null ? Stream.empty() : TestDbArgumentsProvider.getDbs(src.value(), FileFormat.values()).stream().map(Arguments::of);
3839
}

src/test/java/io/github/spannm/jackcess/test/source/TestDbSource.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.junit.jupiter.params.provider.Arguments;
1414
import org.junit.jupiter.params.provider.ArgumentsProvider;
1515
import org.junit.jupiter.params.provider.ArgumentsSource;
16+
import org.junit.jupiter.params.support.ParameterDeclarations;
1617
import org.junit.platform.commons.support.AnnotationSupport;
1718

1819
import java.io.File;
@@ -94,7 +95,7 @@ static List<TestDb> getDbs(Basename[] _basenames, FileFormat[] _fileFormats) {
9495
}
9596

9697
@Override
97-
public Stream<Arguments> provideArguments(ExtensionContext _context) {
98+
public Stream<Arguments> provideArguments(ParameterDeclarations _parameters, ExtensionContext _context) {
9899
TestDbSource src = _context.getElement().map(elem -> AnnotationSupport.findAnnotation(elem, TestDbSource.class).get()).orElse(null);
99100
return src == null ? Stream.empty() : getDbs(src.value(), FILE_FORMATS_WRITE).stream().map(Arguments::of);
100101
}

0 commit comments

Comments
 (0)