Skip to content

Commit 02be4d9

Browse files
committed
Upgrade to JUnit 6
1 parent 92c5e9c commit 02be4d9

5 files changed

Lines changed: 15 additions & 47 deletions

File tree

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
strategy:
5656
fail-fast: false
5757
matrix:
58-
junit-framework: [5.14.3-SNAPSHOT, 6.0.2, 6.1.0-SNAPSHOT]
58+
junit-framework: [6.1.0-SNAPSHOT]
5959
runs-on: ubuntu-latest
6060

6161
steps:

docs/index.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ clear test cases without clutter.
1111

1212
## Compatibility
1313

14-
JUnit Converters is based on the JUnit Framework 5 and requires Java 8 or higher.
15-
16-
Compatibility is also guaranteed with the JUnit Framework 6.
14+
JUnit Converters is based on the JUnit Framework 6 and requires Java 17 or higher.
1715

1816
## Getting Started
1917

pom.xml

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@
3232
</scm>
3333

3434
<properties>
35-
<maven.compiler.release>8</maven.compiler.release>
35+
<maven.compiler.release>17</maven.compiler.release>
3636
<maven.compiler.testRelease>25</maven.compiler.testRelease>
3737
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3838
<!-- Dependency versions -->
39-
<junit-framework.version>5.14.3</junit-framework.version>
39+
<junit-framework.version>6.0.3</junit-framework.version>
4040
<spring-framework.version>7.0.6</spring-framework.version>
4141
</properties>
4242

@@ -151,7 +151,6 @@
151151
<link>https://docs.spring.io/spring-framework/docs/${spring-framework.version}/javadoc-api/</link>
152152
<link>https://jspecify.dev/docs/api/</link>
153153
</links>
154-
<release>9</release>
155154
</configuration>
156155
</plugin>
157156
<plugin>
@@ -216,30 +215,6 @@
216215
</execution>
217216
</executions>
218217
</plugin>
219-
<plugin>
220-
<groupId>org.apache.maven.plugins</groupId>
221-
<artifactId>maven-compiler-plugin</artifactId>
222-
<executions>
223-
<execution>
224-
<id>default-compile</id>
225-
<configuration>
226-
<release>9</release>
227-
</configuration>
228-
</execution>
229-
<execution>
230-
<id>java-8</id>
231-
<goals>
232-
<goal>compile</goal>
233-
</goals>
234-
<configuration>
235-
<excludes>
236-
<exclude>module-info.java</exclude>
237-
</excludes>
238-
<failOnWarning>false</failOnWarning> <!-- https://github.com/jspecify/jspecify/issues/302 -->
239-
</configuration>
240-
</execution>
241-
</executions>
242-
</plugin>
243218
<plugin>
244219
<groupId>org.apache.maven.plugins</groupId>
245220
<artifactId>maven-enforcer-plugin</artifactId>

src/main/java/io/github/scordio/junit/converters/Base64ArgumentConverter.java

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,28 +36,23 @@ protected Object convert(@Nullable Object source, Class<?> targetType, Base64 an
3636

3737
Decoder decoder = getDecoder(annotation.encoding());
3838

39-
if (source instanceof byte[]) {
40-
return decoder.decode((byte[]) source);
39+
if (source instanceof byte[] bytes) {
40+
return decoder.decode(bytes);
4141
}
42-
if (source instanceof String) {
43-
return decoder.decode((String) source);
42+
if (source instanceof String string) {
43+
return decoder.decode(string);
4444
}
4545

4646
throw new ArgumentConversionException(
4747
String.format("Source type %s is not supported", source.getClass().getTypeName()));
4848
}
4949

5050
private static Decoder getDecoder(Encoding encoding) {
51-
switch (encoding) {
52-
case BASIC:
53-
return java.util.Base64.getDecoder();
54-
case URL:
55-
return java.util.Base64.getUrlDecoder();
56-
case MIME:
57-
return java.util.Base64.getMimeDecoder();
58-
default:
59-
throw new IllegalArgumentException("Unsupported encoding " + encoding);
60-
}
51+
return switch (encoding) {
52+
case BASIC -> java.util.Base64.getDecoder();
53+
case URL -> java.util.Base64.getUrlDecoder();
54+
case MIME -> java.util.Base64.getMimeDecoder();
55+
};
6156
}
6257

6358
}

src/main/java/io/github/scordio/junit/converters/BytesArgumentConverter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ protected Object convert(@Nullable Object source, Class<?> targetType, Bytes ann
3535
String.format("Target type %s is not supported", targetType.getTypeName()));
3636
}
3737

38-
if (source instanceof String) {
39-
return ((String) source).getBytes(forName(annotation.charset()));
38+
if (source instanceof String string) {
39+
return string.getBytes(forName(annotation.charset()));
4040
}
4141
if (source instanceof Byte) {
4242
return ByteBuffer.allocate(Byte.BYTES).order(getOrder(annotation)).put((byte) source).array();

0 commit comments

Comments
 (0)