Skip to content

Commit fa2ffef

Browse files
authored
Merge pull request #52 from scijava/scijava/incubator/junit5
Update all incubator projects to JUnit 5
2 parents 4e7ddf3 + f7bb0a6 commit fa2ffef

87 files changed

Lines changed: 880 additions & 864 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

scijava/scijava-discovery-plugin/pom.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,13 @@
104104
</dependency>
105105
<!-- Test scope dependencies -->
106106
<dependency>
107-
<groupId>junit</groupId>
108-
<artifactId>junit</artifactId>
107+
<groupId>org.junit.jupiter</groupId>
108+
<artifactId>junit-jupiter-api</artifactId>
109+
<scope>test</scope>
110+
</dependency>
111+
<dependency>
112+
<groupId>org.junit.jupiter</groupId>
113+
<artifactId>junit-jupiter-engine</artifactId>
109114
<scope>test</scope>
110115
</dependency>
111116
</dependencies>

scijava/scijava-discovery-plugin/src/test/java/org/scijava/discovery/plugin/PluginDiscovererTest.java

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,17 @@
33

44
import java.util.List;
55

6-
import org.junit.AfterClass;
7-
import org.junit.Assert;
8-
import org.junit.BeforeClass;
9-
import org.junit.Test;
10-
import org.scijava.Context;
6+
import org.junit.jupiter.api.Assertions;
7+
import org.junit.jupiter.api.Test;
118
import org.scijava.discovery.Discoverer;
12-
import org.scijava.plugin.PluginService;
139

1410
public class PluginDiscovererTest {
1511

16-
private static Context ctx;
17-
private static PluginService plugins;
18-
19-
@BeforeClass
20-
public static void setUp() {
21-
ctx = new Context(PluginService.class);
22-
plugins = ctx.getService(PluginService.class);
23-
}
24-
25-
@AfterClass
26-
public static void tearDown() throws Exception {
27-
ctx.close();
28-
plugins = null;
29-
}
30-
3112
@Test
3213
public void testPluginDiscovery() {
3314
Discoverer d = new PluginBasedDiscoverer();
3415
List<TestPlugin> discoveries = d.discover(TestPlugin.class);
35-
Assert.assertTrue(discoveries.stream().anyMatch(o -> o.getClass() == TestPluginImpl.class));
16+
Assertions.assertTrue(discoveries.stream().anyMatch(o -> o.getClass() == TestPluginImpl.class));
3617
}
3718

3819
}

scijava/scijava-discovery-test/pom.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,13 @@
119119
</dependency>
120120
<!-- Test Scope Dependencies -->
121121
<dependency>
122-
<groupId>junit</groupId>
123-
<artifactId>junit</artifactId>
122+
<groupId>org.junit.jupiter</groupId>
123+
<artifactId>junit-jupiter-api</artifactId>
124+
<scope>test</scope>
125+
</dependency>
126+
<dependency>
127+
<groupId>org.junit.jupiter</groupId>
128+
<artifactId>junit-jupiter-engine</artifactId>
124129
<scope>test</scope>
125130
</dependency>
126131
</dependencies>

scijava/scijava-discovery-test/src/test/java/org/scijava/discovery/test/ServiceLoaderDiscovererTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import java.util.ServiceLoader;
66
import java.util.stream.Collectors;
77

8-
import org.junit.Assert;
9-
import org.junit.Test;
8+
import org.junit.jupiter.api.Assertions;
9+
import org.junit.jupiter.api.Test;
1010
import org.scijava.discovery.Discoverer;
1111
import org.scijava.ops.spi.Op;
1212
import org.scijava.ops.spi.OpCollection;
@@ -25,8 +25,8 @@ private static <T> void assertDiscoveryRequirements(Discoverer d, Class<T> disco
2525
List<Class<T>> implementingClasses = d.discover(discovery).stream().map(o -> (Class<T>) o.getClass()).collect(
2626
Collectors.toList());
2727
for(Class<? extends T> cls : impls)
28-
Assert.assertTrue(implementingClasses.contains(cls));
28+
Assertions.assertTrue(implementingClasses.contains(cls));
2929

30-
Assert.assertEquals(impls.length, implementingClasses.size());
30+
Assertions.assertEquals(impls.length, implementingClasses.size());
3131
}
3232
}

scijava/scijava-discovery-therapi/pom.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,13 @@
114114
</dependency>
115115
<!-- Test scope dependencies -->
116116
<dependency>
117-
<groupId>junit</groupId>
118-
<artifactId>junit</artifactId>
117+
<groupId>org.junit.jupiter</groupId>
118+
<artifactId>junit-jupiter-api</artifactId>
119+
<scope>test</scope>
120+
</dependency>
121+
<dependency>
122+
<groupId>org.junit.jupiter</groupId>
123+
<artifactId>junit-jupiter-engine</artifactId>
119124
<scope>test</scope>
120125
</dependency>
121126
</dependencies>
Lines changed: 35 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,33 @@
11

22
package org.scijava.discovery.therapi;
33

4+
import org.junit.jupiter.api.Test;
5+
46
import java.util.List;
57

6-
import org.junit.Assert;
7-
import org.junit.Test;
8+
import static org.junit.jupiter.api.Assertions.assertEquals;
9+
import static org.junit.jupiter.api.Assertions.assertThrows;
810

911
public class TagOptionsTest {
1012

11-
private List<TaggedElement> getTaggedDiscoveries(
12-
String tagType)
13-
{
13+
private List<TaggedElement> getTaggedDiscoveries(String tagType) {
1414
return new TaggedElementDiscoverer(tagType).discover(TaggedElement.class);
1515
}
1616

1717
@Test
1818
public void optionsTest() {
19-
List<TaggedElement> elements = getTaggedDiscoveries(
20-
"optionsTest");
19+
List<TaggedElement> elements = getTaggedDiscoveries("optionsTest");
2120
TaggedElement annotatedElement = elements.get(0);
22-
Assert.assertEquals("e", annotatedElement.option("singleKey"));
23-
Assert.assertEquals("[e1, e2]", annotatedElement.option("listKey"));
21+
assertEquals("e", annotatedElement.option("singleKey"));
22+
assertEquals("[e1, e2]", annotatedElement.option("listKey"));
2423
}
2524

2625
@Test
2726
public void optionsPerLineTest() {
28-
List<TaggedElement> elements = getTaggedDiscoveries(
29-
"optionsPerLineTest");
27+
List<TaggedElement> elements = getTaggedDiscoveries("optionsPerLineTest");
3028
TaggedElement annotatedElement = elements.get(0);
31-
Assert.assertEquals("e", annotatedElement.option("singleKey"));
32-
Assert.assertEquals("[e1, e2]", annotatedElement.option("listKey"));
29+
assertEquals("e", annotatedElement.option("singleKey"));
30+
assertEquals("[e1, e2]", annotatedElement.option("listKey"));
3331
}
3432

3533
/**
@@ -38,90 +36,90 @@ public void optionsPerLineTest() {
3836
*/
3937
@Test
4038
public void forgottenCommaTest() {
41-
List<TaggedElement> elements = getTaggedDiscoveries(
42-
"forgottenComma");
39+
List<TaggedElement> elements = getTaggedDiscoveries("forgottenComma");
4340
TaggedElement annotatedElement = elements.get(0);
44-
Assert.assertThrows(IllegalArgumentException.class, //
45-
() -> annotatedElement.option("singleKey"));
41+
assertThrows(IllegalArgumentException.class, //
42+
() -> annotatedElement.option("singleKey"));
4643
}
4744

4845
/**
4946
* Tests ability to parse options without quotes.
5047
*/
5148
@Test
5249
public void forgottenQuoteTest() {
53-
List<TaggedElement> elements = getTaggedDiscoveries(
54-
"forgottenQuote");
50+
List<TaggedElement> elements = getTaggedDiscoveries("forgottenQuote");
5551
TaggedElement annotatedElement = elements.get(0);
56-
Assert.assertEquals("e", annotatedElement.option("singleKey"));
52+
assertEquals("e", annotatedElement.option("singleKey"));
5753
}
5854

5955
/**
60-
* Tests duplicate definition behaviors. When a tag tries to define a tag
61-
* twice, we expect that the second definition overwrites the first.
56+
* Tests duplicate definition behaviors. When a tag tries to define a tag twice,
57+
* we expect that the second definition overwrites the first.
6258
*/
6359
@Test
6460
public void duplicateOptionTest() {
65-
List<TaggedElement> elements = getTaggedDiscoveries(
66-
"duplicateOption");
61+
List<TaggedElement> elements = getTaggedDiscoveries("duplicateOption");
6762
TaggedElement annotatedElement = elements.get(0);
68-
Assert.assertEquals("[e1, e2]", annotatedElement.option("singleKey"));
63+
assertEquals("[e1, e2]", annotatedElement.option("singleKey"));
6964
}
7065

7166
/**
7267
* Tests behavior for options not present on a tagged element.
7368
*/
7469
@Test
7570
public void absentOptionTest() {
76-
List<TaggedElement> elements = getTaggedDiscoveries(
77-
"absentOption");
71+
List<TaggedElement> elements = getTaggedDiscoveries("absentOption");
7872
TaggedElement annotatedElement = elements.get(0);
79-
Assert.assertEquals("", annotatedElement.option("singleKey"));
73+
assertEquals("", annotatedElement.option("singleKey"));
8074
}
8175

8276
/**
8377
* @implNote optionsTest singleKey='e', listKey={'e1', 'e2'}
8478
*/
8579
@SuppressWarnings("unused")
86-
public void foo() {}
80+
public void foo() {
81+
}
8782

8883
/**
89-
* @implNote optionsPerLineTest
90-
* singleKey='e',
91-
* listKey={'e1', 'e2'}
84+
* @implNote optionsPerLineTest singleKey='e', listKey={'e1', 'e2'}
9285
*/
9386
@SuppressWarnings("unused")
94-
public void boo() {}
87+
public void boo() {
88+
}
9589

9690
/**
9791
* A tagged element whose tag doesn't have a comma between options
9892
*
9993
* @implNote forgottenComma singleKey='e' listKey={'e1', 'e2'}
10094
*/
10195
@SuppressWarnings("unused")
102-
public void too() {}
96+
public void too() {
97+
}
10398

10499
/**
105100
* A tagged element whose tag doesn't have a quotes surrounding the value
106101
*
107102
* @implNote forgottenQuote singleKey=e, listKey={'e1', 'e2'}
108103
*/
109104
@SuppressWarnings("unused")
110-
public void moo() {}
105+
public void moo() {
106+
}
111107

112108
/**
113109
* A tagged element whose tag tries to define a key twice
114110
*
115111
* @implNote duplicateOption singleKey='e', singleKey={'e1', 'e2'}
116112
*/
117113
@SuppressWarnings("unused")
118-
public void coo() {}
114+
public void coo() {
115+
}
119116

120117
/**
121118
* A tagged element who has no options
122119
*
123120
* @implNote absentOption
124121
*/
125122
@SuppressWarnings("unused")
126-
public void woo() {}
123+
public void woo() {
124+
}
127125
}

scijava/scijava-discovery-therapi/src/test/java/org/scijava/discovery/therapi/TherapiDiscovererTest.java

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,32 @@
44
import java.util.List;
55
import java.util.function.Function;
66

7-
import org.junit.Assert;
8-
import org.junit.Test;
7+
import org.junit.jupiter.api.Test;
98
import org.scijava.discovery.Discoverer;
109

10+
import static org.junit.jupiter.api.Assertions.assertTrue;
11+
1112
public class TherapiDiscovererTest {
1213

13-
private Discoverer discoverer()
14-
{
14+
private Discoverer discoverer() {
1515
return new TaggedElementDiscoverer("test");
1616
}
1717

1818
@Test
1919
public void discoverClass() {
2020
List<TaggedElement> elements = discoverer().discover(TaggedElement.class);
21-
Assert.assertTrue(elements.stream().anyMatch(e -> e.discovery() == ClassTest.class));
21+
assertTrue(elements.stream().anyMatch(e -> e.discovery() == ClassTest.class));
2222
}
2323

2424
@Test
2525
public void discoverField() throws SecurityException {
2626
List<TaggedElement> elements = discoverer().discover(TaggedElement.class);
27-
Assert.assertTrue(elements.stream().anyMatch(d -> {
27+
assertTrue(elements.stream().anyMatch(d -> {
2828
try {
2929
AnnotatedElement actual = d.discovery();
3030
AnnotatedElement expected = this.getClass().getDeclaredField("fieldTest");
3131
return expected.equals(actual);
32-
}
33-
catch (NoSuchFieldException ex) {
32+
} catch (NoSuchFieldException ex) {
3433
return false;
3534
}
3635
}));
@@ -39,13 +38,12 @@ public void discoverField() throws SecurityException {
3938
@Test
4039
public void discoverMethod() throws SecurityException {
4140
List<TaggedElement> elements = discoverer().discover(TaggedElement.class);
42-
Assert.assertTrue(elements.stream().anyMatch(d -> {
41+
assertTrue(elements.stream().anyMatch(d -> {
4342
try {
4443
AnnotatedElement actual = d.discovery();
4544
AnnotatedElement expected = this.getClass().getDeclaredMethod("methodTest");
4645
return expected.equals(actual);
47-
}
48-
catch (NoSuchMethodException ex) {
46+
} catch (NoSuchMethodException ex) {
4947
return false;
5048
}
5149
}));
@@ -55,13 +53,13 @@ public void discoverMethod() throws SecurityException {
5553
* @implNote test
5654
*/
5755
public void methodTest() {
58-
56+
5957
}
6058

6159
/**
6260
* @implNote test
6361
*/
64-
public final Function<Integer, Integer> fieldTest = (in) -> in+ 1;
62+
public final Function<Integer, Integer> fieldTest = (in) -> in + 1;
6563
}
6664

6765
/**
@@ -70,5 +68,5 @@ public void methodTest() {
7068
*
7169
*/
7270
class ClassTest {
73-
71+
7472
}

scijava/scijava-log2/pom.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,13 @@
9494
<dependencies>
9595
<!-- Test scope dependencies -->
9696
<dependency>
97-
<groupId>junit</groupId>
98-
<artifactId>junit</artifactId>
97+
<groupId>org.junit.jupiter</groupId>
98+
<artifactId>junit-jupiter-api</artifactId>
99+
<scope>test</scope>
100+
</dependency>
101+
<dependency>
102+
<groupId>org.junit.jupiter</groupId>
103+
<artifactId>junit-jupiter-engine</artifactId>
99104
<scope>test</scope>
100105
</dependency>
101106
</dependencies>

scijava/scijava-log2/src/test/java/org/scijava/log2/CallingClassUtilsTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929

3030
package org.scijava.log2;
3131

32-
import static org.junit.Assert.assertEquals;
32+
import org.junit.jupiter.api.Test;
3333

34-
import org.junit.Test;
34+
import static org.junit.jupiter.api.Assertions.assertEquals;
3535

3636
/**
3737
* Tests {@link CallingClassUtils}.

0 commit comments

Comments
 (0)