Skip to content

Commit 05d3fc0

Browse files
Upgrade jupyter-jvm-basekernel tests to JUnit 5
1 parent 4b69272 commit 05d3fc0

File tree

10 files changed

+1048
-706
lines changed

10 files changed

+1048
-706
lines changed

jupyter-jvm-basekernel/pom.xml

+7-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,13 @@
2222
</dependency>
2323

2424
<dependency>
25-
<groupId>junit</groupId>
26-
<artifactId>junit</artifactId>
25+
<groupId>org.junit.jupiter</groupId>
26+
<artifactId>junit-jupiter-api</artifactId>
27+
<scope>test</scope>
28+
</dependency>
29+
<dependency>
30+
<groupId>org.junit.jupiter</groupId>
31+
<artifactId>junit-jupiter-params</artifactId>
2732
<scope>test</scope>
2833
</dependency>
2934
<dependency>
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,21 @@
11
package org.dflib.jjava.jupyter.kernel.display;
22

33
import org.dflib.jjava.jupyter.kernel.display.mime.MIMEType;
4-
import org.junit.Test;
5-
import org.junit.runner.RunWith;
6-
import org.junit.runners.Parameterized;
4+
import org.junit.jupiter.api.Assertions;
5+
import org.junit.jupiter.params.ParameterizedTest;
6+
import org.junit.jupiter.params.provider.Arguments;
7+
import org.junit.jupiter.params.provider.MethodSource;
78

8-
import java.util.Arrays;
9-
import java.util.Collection;
10-
import java.util.Collections;
119
import java.util.List;
10+
import java.util.stream.Stream;
1211

13-
import static org.junit.Assert.assertEquals;
14-
15-
@RunWith(Parameterized.class)
1612
public class RenderRequestTypesResolutionTest {
17-
@Parameterized.Parameters
18-
public static Collection<Object[]> data() {
19-
return Arrays.asList(new Object[][]{
20-
{ "image/svg+xml", "image/svg+xml", Collections.singletonList("image/svg+xml") },
21-
{ "image/svg+xml", "image/svg", Collections.singletonList("image/svg") },
22-
{ "image/svg+xml", "image/svg+xml", Collections.singletonList("image/*") },
23-
{ "image/svg+xml", "image/svg+xml", Collections.singletonList("image") },
24-
{ "image/svg+xml", "application/xml", Collections.singletonList("application/xml") },
25-
{ "image/svg+xml", "application/xml", Collections.singletonList("application/*") },
26-
{ "image/svg+xml", "application/xml", Collections.singletonList("application") },
27-
{ "image/svg+xml", "image/svg+xml", Collections.singletonList("*") },
28-
29-
{ "image/svg", "image/svg", Collections.singletonList("image/svg") },
30-
31-
{ "image/svg", null, Collections.singletonList("application/xml") },
32-
{ "image/svg+xml", null, Collections.singletonList("application/json") },
33-
});
34-
}
35-
36-
private final MIMEType supported;
37-
private final MIMEType expected;
38-
private final RenderRequestTypes requestTypes;
39-
40-
public RenderRequestTypesResolutionTest(String supported, String expected, List<String> requestTypes) {
41-
this.supported = supported == null ? null : MIMEType.parse(supported);
42-
this.expected = expected == null ? null : MIMEType.parse(expected);
4313

14+
@ParameterizedTest
15+
@MethodSource("data")
16+
public void test(String supported, String expected, List<String> requestTypes) {
17+
MIMEType supportedMime = MIMEType.parse(supported);
18+
MIMEType expectedMime = expected == null ? null : MIMEType.parse(expected);
4419
RenderRequestTypes.Builder builder = new RenderRequestTypes.Builder(group -> {
4520
switch (group) {
4621
case "xml":
@@ -54,13 +29,26 @@ public RenderRequestTypesResolutionTest(String supported, String expected, List<
5429
requestTypes.stream()
5530
.map(MIMEType::parse)
5631
.forEach(builder::withType);
57-
this.requestTypes = builder.build();
58-
}
32+
RenderRequestTypes renderRequestTypes = builder.build();
5933

60-
@Test
61-
public void test() {
62-
MIMEType actual = this.requestTypes.resolveSupportedType(this.supported);
34+
MIMEType actualMime = renderRequestTypes.resolveSupportedType(supportedMime);
35+
36+
Assertions.assertEquals(expectedMime, actualMime);
37+
}
6338

64-
assertEquals(expected, actual);
39+
public static Stream<Arguments> data() {
40+
return Stream.of(
41+
Arguments.of("image/svg+xml", "image/svg+xml", List.of("image/svg+xml")),
42+
Arguments.of("image/svg+xml", "image/svg", List.of("image/svg")),
43+
Arguments.of("image/svg+xml", "image/svg+xml", List.of("image/*")),
44+
Arguments.of("image/svg+xml", "image/svg+xml", List.of("image")),
45+
Arguments.of("image/svg+xml", "application/xml", List.of("application/xml")),
46+
Arguments.of("image/svg+xml", "application/xml", List.of("application/*")),
47+
Arguments.of("image/svg+xml", "application/xml", List.of("application")),
48+
Arguments.of("image/svg+xml", "image/svg+xml", List.of("*")),
49+
Arguments.of("image/svg", "image/svg", List.of("image/svg")),
50+
Arguments.of("image/svg", null, List.of("application/xml")),
51+
Arguments.of("image/svg+xml", null, List.of("application/json"))
52+
);
6553
}
66-
}
54+
}

0 commit comments

Comments
 (0)