diff --git a/java/pom.xml b/java/pom.xml
--- a/java/pom.xml
+++ b/java/pom.xml
@@ -23,11 +23,17 @@
1.2.3
- junit
- junit
- 4.11
+ org.junit.jupiter
+ junit-jupiter-api
+ 5.7.0
test
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ 5.7.0
+ test
+
org.hamcrest
hamcrest
@@ -130,7 +136,11 @@
maven-surefire-plugin
- 2.22.1
+ 2.22.2
+
+
+ maven-failsafe-plugin
+ 2.22.2
maven-jar-plugin
diff --git a/java/src/test/java/org/softwareheritage/graph/AllowedEdgesTest.java b/java/src/test/java/org/softwareheritage/graph/AllowedEdgesTest.java
--- a/java/src/test/java/org/softwareheritage/graph/AllowedEdgesTest.java
+++ b/java/src/test/java/org/softwareheritage/graph/AllowedEdgesTest.java
@@ -1,9 +1,9 @@
package org.softwareheritage.graph;
-import java.util.ArrayList;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
-import org.junit.Test;
-import org.junit.Assert;
+import java.util.ArrayList;
public class AllowedEdgesTest extends GraphTest {
@@ -40,7 +40,7 @@
}
}
- Assert.assertEquals("Edge type: " + src + " -> " + dst, isAllowed, isExpected);
+ Assertions.assertEquals(isAllowed, isExpected, "Edge type: " + src + " -> " + dst);
}
}
}
@@ -98,7 +98,7 @@
// Special null value used to quickly bypass edge check when no restriction
AllowedEdges edges2 = new AllowedEdges("*");
- Assert.assertNull(edges2.restrictedTo);
+ Assertions.assertNull(edges2.restrictedTo);
}
@Test
diff --git a/java/src/test/java/org/softwareheritage/graph/GraphTest.java b/java/src/test/java/org/softwareheritage/graph/GraphTest.java
--- a/java/src/test/java/org/softwareheritage/graph/GraphTest.java
+++ b/java/src/test/java/org/softwareheritage/graph/GraphTest.java
@@ -3,22 +3,36 @@
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.Iterator;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder;
+import it.unimi.dsi.big.webgraph.LazyLongIterator;
+import it.unimi.dsi.big.webgraph.LazyLongIterators;
+import org.hamcrest.MatcherAssert;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
-import org.softwareheritage.graph.Graph;
+import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder;
public class GraphTest {
static Graph graph;
public static void assertEqualsAnyOrder(Collection expecteds, Collection actuals) {
- Assert.assertThat(expecteds, containsInAnyOrder(actuals.toArray()));
+ MatcherAssert.assertThat(expecteds, containsInAnyOrder(actuals.toArray()));
+ }
+
+ public static void assertLazyLongIteratorsEqual(LazyLongIterator expected, LazyLongIterator actual) {
+ ArrayList expectedList = new ArrayList<>();
+ ArrayList actualList = new ArrayList<>();
+ Iterator expectedIt = LazyLongIterators.eager(expected);
+ Iterator actualIt = LazyLongIterators.eager(actual);
+ expectedIt.forEachRemaining(expectedList::add);
+ actualIt.forEachRemaining(actualList::add);
+ Assertions.assertArrayEquals(expectedList.toArray(), actualList.toArray());
}
- @BeforeClass
+ @BeforeAll
public static void setUp() throws IOException {
Path graphPath = Paths.get("..", "swh", "graph", "tests", "dataset", "output", "example");
graph = new Graph(graphPath.toString());
diff --git a/java/src/test/java/org/softwareheritage/graph/LeavesTest.java b/java/src/test/java/org/softwareheritage/graph/LeavesTest.java
--- a/java/src/test/java/org/softwareheritage/graph/LeavesTest.java
+++ b/java/src/test/java/org/softwareheritage/graph/LeavesTest.java
@@ -2,8 +2,7 @@
import java.util.ArrayList;
-import org.junit.Test;
-
+import org.junit.jupiter.api.Test;
import org.softwareheritage.graph.server.Endpoint;
// Avoid warnings concerning Endpoint.Output.result manual cast
diff --git a/java/src/test/java/org/softwareheritage/graph/NeighborsTest.java b/java/src/test/java/org/softwareheritage/graph/NeighborsTest.java
--- a/java/src/test/java/org/softwareheritage/graph/NeighborsTest.java
+++ b/java/src/test/java/org/softwareheritage/graph/NeighborsTest.java
@@ -2,8 +2,7 @@
import java.util.ArrayList;
-import org.junit.Test;
-
+import org.junit.jupiter.api.Test;
import org.softwareheritage.graph.server.Endpoint;
// Avoid warnings concerning Endpoint.Output.result manual cast
diff --git a/java/src/test/java/org/softwareheritage/graph/VisitTest.java b/java/src/test/java/org/softwareheritage/graph/VisitTest.java
--- a/java/src/test/java/org/softwareheritage/graph/VisitTest.java
+++ b/java/src/test/java/org/softwareheritage/graph/VisitTest.java
@@ -4,8 +4,7 @@
import java.util.Set;
import java.util.HashSet;
-import org.junit.Test;
-
+import org.junit.jupiter.api.Test;
import org.softwareheritage.graph.server.Endpoint;
// Avoid warnings concerning Endpoint.Output.result manual cast
@@ -14,9 +13,7 @@
private void assertSameNodesFromPaths(ArrayList paths, ArrayList nodes) {
Set expectedNodes = new HashSet();
for (SwhPath path : paths) {
- for (SWHID node : path.getPath()) {
- expectedNodes.add(node);
- }
+ expectedNodes.addAll(path.getPath());
}
GraphTest.assertEqualsAnyOrder(expectedNodes, nodes);
}
diff --git a/java/src/test/java/org/softwareheritage/graph/WalkTest.java b/java/src/test/java/org/softwareheritage/graph/WalkTest.java
--- a/java/src/test/java/org/softwareheritage/graph/WalkTest.java
+++ b/java/src/test/java/org/softwareheritage/graph/WalkTest.java
@@ -3,9 +3,8 @@
import java.util.Arrays;
import java.util.List;
-import org.junit.Assert;
-import org.junit.Test;
-
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import org.softwareheritage.graph.server.Endpoint;
public class WalkTest extends GraphTest {
@@ -39,8 +38,8 @@
SwhPath bfsPath = (SwhPath) endpoint2.walk(new Endpoint.Input(src, dstFmt, "bfs")).result;
List possibleSolutions = Arrays.asList(solution1, solution2);
- Assert.assertTrue(possibleSolutions.contains(dfsPath));
- Assert.assertTrue(possibleSolutions.contains(bfsPath));
+ Assertions.assertTrue(possibleSolutions.contains(dfsPath));
+ Assertions.assertTrue(possibleSolutions.contains(bfsPath));
}
@Test
@@ -59,8 +58,8 @@
Endpoint endpoint2 = new Endpoint(graph, "forward", "*");
SwhPath bfsPath = (SwhPath) endpoint2.walk(new Endpoint.Input(src, dstFmt, "bfs")).result;
- Assert.assertEquals(dfsPath, expectedPath);
- Assert.assertEquals(bfsPath, expectedPath);
+ Assertions.assertEquals(dfsPath, expectedPath);
+ Assertions.assertEquals(bfsPath, expectedPath);
}
@Test
@@ -82,8 +81,8 @@
Endpoint endpoint2 = new Endpoint(graph, "forward", "rev:rev");
SwhPath bfsPath = (SwhPath) endpoint2.walk(new Endpoint.Input(src, dstFmt, "bfs")).result;
- Assert.assertEquals(dfsPath, expectedPath);
- Assert.assertEquals(bfsPath, expectedPath);
+ Assertions.assertEquals(dfsPath, expectedPath);
+ Assertions.assertEquals(bfsPath, expectedPath);
}
@Test
@@ -105,8 +104,8 @@
Endpoint endpoint2 = new Endpoint(graph, "backward", "rev:rev");
SwhPath bfsPath = (SwhPath) endpoint2.walk(new Endpoint.Input(src, dstFmt, "bfs")).result;
- Assert.assertEquals(dfsPath, expectedPath);
- Assert.assertEquals(bfsPath, expectedPath);
+ Assertions.assertEquals(dfsPath, expectedPath);
+ Assertions.assertEquals(bfsPath, expectedPath);
}
@Test
@@ -154,8 +153,8 @@
SwhPath bfsPath = (SwhPath) endpoint2.walk(new Endpoint.Input(src, dstFmt, "bfs")).result;
List possibleSolutions = Arrays.asList(solution1, solution2, solution3, solution4);
- Assert.assertTrue(possibleSolutions.contains(dfsPath));
- Assert.assertTrue(possibleSolutions.contains(bfsPath));
+ Assertions.assertTrue(possibleSolutions.contains(dfsPath));
+ Assertions.assertTrue(possibleSolutions.contains(bfsPath));
}
@Test
@@ -205,8 +204,8 @@
List possibleSolutions =
Arrays.asList(solution1, solution2, solution3, solution4, solution5);
- Assert.assertTrue(possibleSolutions.contains(dfsPath));
- Assert.assertTrue(possibleSolutions.contains(bfsPath));
+ Assertions.assertTrue(possibleSolutions.contains(dfsPath));
+ Assertions.assertTrue(possibleSolutions.contains(bfsPath));
}
@Test
@@ -228,7 +227,7 @@
Endpoint endpoint2 = new Endpoint(graph, "backward", "dir:dir,dir:rev,rev:*");
SwhPath bfsPath = (SwhPath) endpoint2.walk(new Endpoint.Input(src, dstFmt, "bfs")).result;
- Assert.assertEquals(dfsPath, expectedPath);
- Assert.assertEquals(bfsPath, expectedPath);
+ Assertions.assertEquals(dfsPath, expectedPath);
+ Assertions.assertEquals(bfsPath, expectedPath);
}
}