Skip to content

Commit 581f1a6

Browse files
committed
Upgrade to JUnit 6
1 parent 53425d3 commit 581f1a6

6 files changed

Lines changed: 21 additions & 50 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.1-SNAPSHOT, 6.0.0, 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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +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.
14+
JUnit Converters is based on the JUnit Framework 6 and requires Java 17 or higher.
1515

1616
## Getting Started
1717

pom.xml

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,20 @@
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.0</junit-framework.version>
39+
<junit-framework.version>6.0.0</junit-framework.version>
4040
</properties>
4141

4242
<dependencyManagement>
4343
<dependencies>
44+
<dependency>
45+
<groupId>org.assertj</groupId>
46+
<artifactId>assertj-core</artifactId>
47+
<version>4.0.0-M1</version>
48+
</dependency>
4449
<dependency>
4550
<groupId>org.junit</groupId>
4651
<artifactId>junit-bom</artifactId>
@@ -67,7 +72,6 @@
6772
<dependency>
6873
<groupId>org.assertj</groupId>
6974
<artifactId>assertj-core</artifactId>
70-
<version>4.0.0-M1</version>
7175
<scope>test</scope>
7276
</dependency>
7377
<dependency>
@@ -138,7 +142,6 @@
138142
<link>https://docs.junit.org/${junit-framework.version}/api/</link>
139143
<link>https://jspecify.dev/docs/api/</link>
140144
</links>
141-
<release>9</release>
142145
</configuration>
143146
</plugin>
144147
<plugin>
@@ -203,30 +206,6 @@
203206
</execution>
204207
</executions>
205208
</plugin>
206-
<plugin>
207-
<groupId>org.apache.maven.plugins</groupId>
208-
<artifactId>maven-compiler-plugin</artifactId>
209-
<executions>
210-
<execution>
211-
<id>default-compile</id>
212-
<configuration>
213-
<release>9</release>
214-
</configuration>
215-
</execution>
216-
<execution>
217-
<id>java-8</id>
218-
<goals>
219-
<goal>compile</goal>
220-
</goals>
221-
<configuration>
222-
<excludes>
223-
<exclude>module-info.java</exclude>
224-
</excludes>
225-
<failOnWarning>false</failOnWarning> <!-- https://github.com/jspecify/jspecify/issues/302 -->
226-
</configuration>
227-
</execution>
228-
</executions>
229-
</plugin>
230209
<plugin>
231210
<groupId>org.codehaus.mojo</groupId>
232211
<artifactId>flatten-maven-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();

src/test/java/io/github/scordio/tests/junit/converters/HexIntegrationTests.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,7 @@ void should_fail_with_unsupported_values() {
8989
cause(instanceOf(NullPointerException.class), message("'null' is not supported"))))
9090
.haveExactly(1, finishedWithFailure( // https://github.com/junit-team/junit-framework/issues/4801
9191
instanceOf(ParameterResolutionException.class),
92-
// https://github.com/junit-team/junit-framework/issues/4806
93-
message(message -> message.startsWith(
94-
"Error converting parameter at index 0: HexArgumentConverter cannot convert objects of type")
95-
&& message.endsWith("Only source objects of type [java.lang.String] are supported."))))
92+
message("Error converting parameter at index 0: HexArgumentConverter cannot convert objects of type [byte[]]. Only source objects of type [java.lang.String] are supported.")))
9693
.haveExactly(3, finishedWithFailure( //
9794
instanceOf(ParameterResolutionException.class),
9895
cause(instanceOf(ArgumentConversionException.class), message("Hex string must have even length"))))

0 commit comments

Comments
 (0)