Skip to content

Commit 12f6d46

Browse files
authored
migrate all tests to junit jupiter (#402)
1 parent b8941e3 commit 12f6d46

File tree

8 files changed

+112
-106
lines changed

8 files changed

+112
-106
lines changed

pom.xml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<plugin>
3838
<groupId>org.apache.maven.plugins</groupId>
3939
<artifactId>maven-compiler-plugin</artifactId>
40-
<version>3.11.0</version>
40+
<version>3.13.0</version>
4141
<configuration>
4242
<source>${neo4j.java.version}</source>
4343
<target>${neo4j.java.version}</target>
@@ -304,12 +304,6 @@
304304
</dependency>
305305

306306
<!-- The JUnit-Hamcrest-Mockito combo -->
307-
<dependency>
308-
<groupId>org.junit.vintage</groupId>
309-
<artifactId>junit-vintage-engine</artifactId>
310-
<version>${junit.version}</version>
311-
<scope>test</scope>
312-
</dependency>
313307
<dependency>
314308
<groupId>org.junit.jupiter</groupId>
315309
<artifactId>junit-jupiter-engine</artifactId>

src/test/java/org/neo4j/gis/spatial/LayersTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121

2222
import static org.hamcrest.MatcherAssert.assertThat;
2323
import static org.junit.jupiter.api.Assertions.assertEquals;
24+
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
2425
import static org.junit.jupiter.api.Assertions.assertNotNull;
2526
import static org.junit.jupiter.api.Assertions.assertNull;
26-
import static org.junit.jupiter.api.Assertions.assertTrue;
2727
import static org.neo4j.configuration.GraphDatabaseSettings.DEFAULT_DATABASE_NAME;
2828

2929
import java.io.File;
@@ -274,12 +274,12 @@ private String testSpecificEditableLayer(String layerName, Class<? extends Geome
274274
inTx(tx -> {
275275
Layer layer = spatial.createLayer(tx, layerName, geometryEncoderClass, layerClass);
276276
assertNotNull(layer);
277-
assertTrue(layer instanceof EditableLayer, "Should be an editable layer");
277+
assertInstanceOf(EditableLayer.class, layer, "Should be an editable layer");
278278
});
279279
inTx(tx -> {
280280
Layer layer = spatial.getLayer(tx, layerName);
281281
assertNotNull(layer);
282-
assertTrue(layer instanceof EditableLayer, "Should be an editable layer");
282+
assertInstanceOf(EditableLayer.class, layer, "Should be an editable layer");
283283
EditableLayer editableLayer = (EditableLayer) layer;
284284

285285
CoordinateList coordinates = new CoordinateList();
@@ -388,7 +388,7 @@ public void testIndexAccessAfterBulkInsertion() {
388388
Result result = tx.execute(cypher);
389389
// System.out.println(result.columns().toString());
390390
Object obj = result.columnAs("count(p)").next();
391-
assertTrue(obj instanceof Long);
391+
assertInstanceOf(Long.class, obj);
392392
assertEquals(1000L, (long) ((Long) obj));
393393
tx.commit();
394394
}

src/test/java/org/neo4j/gis/spatial/Neo4jTestUtils.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
*/
2020
package org.neo4j.gis.spatial;
2121

22-
import static org.junit.Assert.assertEquals;
23-
import static org.junit.Assert.assertTrue;
22+
import static org.junit.jupiter.api.Assertions.assertEquals;
23+
import static org.junit.jupiter.api.Assertions.assertTrue;
2424

2525
import java.io.File;
2626
import java.util.ArrayList;
@@ -117,7 +117,7 @@ public static void printTree(Node root, int depth) {
117117

118118
public static <T> void assertCollection(Collection<T> collection, T... expectedItems) {
119119
String collectionString = join(", ", collection.toArray());
120-
assertEquals(collectionString, expectedItems.length, collection.size());
120+
assertEquals(expectedItems.length, collection.size(), collectionString);
121121
for (T item : expectedItems) {
122122
assertTrue(collection.contains(item));
123123
}

src/test/java/org/neo4j/gis/spatial/RTreeBulkInsertTest.java

Lines changed: 48 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@
2323
import static org.hamcrest.MatcherAssert.assertThat;
2424
import static org.hamcrest.Matchers.lessThan;
2525
import static org.hamcrest.Matchers.lessThanOrEqualTo;
26-
import static org.junit.Assert.assertEquals;
27-
import static org.junit.Assert.assertNotNull;
28-
import static org.junit.Assert.assertTrue;
26+
import static org.junit.jupiter.api.Assertions.assertEquals;
27+
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
28+
import static org.junit.jupiter.api.Assertions.assertNotNull;
29+
import static org.junit.jupiter.api.Assertions.assertTrue;
2930
import static org.neo4j.configuration.GraphDatabaseSettings.DEFAULT_DATABASE_NAME;
3031
import static org.neo4j.gis.spatial.rtree.RTreeIndex.DEFAULT_MAX_NODE_REFERENCES;
3132
import static org.neo4j.internal.helpers.collection.MapUtil.map;
@@ -49,11 +50,11 @@
4950
import org.geotools.api.referencing.crs.CoordinateReferenceSystem;
5051
import org.geotools.data.neo4j.Neo4jFeatureBuilder;
5152
import org.geotools.referencing.crs.DefaultEngineeringCRS;
52-
import org.junit.After;
53-
import org.junit.AfterClass;
54-
import org.junit.Before;
55-
import org.junit.Ignore;
56-
import org.junit.Test;
53+
import org.junit.jupiter.api.AfterAll;
54+
import org.junit.jupiter.api.AfterEach;
55+
import org.junit.jupiter.api.BeforeEach;
56+
import org.junit.jupiter.api.Disabled;
57+
import org.junit.jupiter.api.Test;
5758
import org.locationtech.jts.geom.Coordinate;
5859
import org.locationtech.jts.geom.Geometry;
5960
import org.neo4j.dbms.api.DatabaseManagementService;
@@ -94,17 +95,17 @@ public class RTreeBulkInsertTest {
9495
// While the current lucene index implmentation is so slow (16n/s) we disable all benchmarks for lucene backed indexes
9596
private static final boolean enableLucene = false;
9697

97-
@Before
98+
@BeforeEach
9899
public void before() throws IOException {
99100
restart();
100101
}
101102

102-
@After
103+
@AfterEach
103104
public void after() throws IOException {
104105
doCleanShutdown();
105106
}
106107

107-
@Ignore
108+
@Disabled
108109
public void shouldDeleteRecursiveTree() {
109110
int depth = 5;
110111
int width = 2;
@@ -185,7 +186,7 @@ private EditableLayer getOrCreateSimplePointLayer(String name, String index, Str
185186
}
186187
}
187188

188-
@Ignore
189+
@Disabled
189190
public void shouldInsertSimpleRTree() {
190191
int width = 20;
191192
int blockSize = 10000;
@@ -603,12 +604,12 @@ public void shouldInsertManyNodesInBulkWithHilbert_small() throws FactoryExcepti
603604
insertManyNodesInBulk(new HilbertIndexMaker("Coordinates", "Bulk", testConfigs.get("small")), 5000);
604605
}
605606

606-
@Ignore // takes too long, change to @Test when benchmarking
607+
@Disabled // takes too long, change to @Test when benchmarking
607608
public void shouldInsertManyNodesIndividuallyWithQuadraticSplit_small_10() throws FactoryException, IOException {
608609
insertManyNodesIndividually(RTreeIndex.QUADRATIC_SPLIT, 5000, 10, testConfigs.get("small"));
609610
}
610611

611-
@Ignore // takes too long, change to @Test when benchmarking
612+
@Disabled // takes too long, change to @Test when benchmarking
612613
public void shouldInsertManyNodesIndividuallyGreenesSplit_small_10() throws FactoryException, IOException {
613614
insertManyNodesIndividually(RTreeIndex.GREENES_SPLIT, 5000, 10, testConfigs.get("small"));
614615
}
@@ -627,12 +628,12 @@ public void shouldInsertManyNodesInBulkWithGreenesSplit_small_10() throws Factor
627628
* Small model 250*250 nodes (shallow tree)
628629
*/
629630

630-
@Ignore // takes too long, change to @Test when benchmarking
631+
@Disabled // takes too long, change to @Test when benchmarking
631632
public void shouldInsertManyNodesIndividuallyWithQuadraticSplit_small_100() throws FactoryException, IOException {
632633
insertManyNodesIndividually(RTreeIndex.QUADRATIC_SPLIT, 5000, 100, testConfigs.get("small"));
633634
}
634635

635-
@Ignore // takes too long, change to @Test when benchmarking
636+
@Disabled // takes too long, change to @Test when benchmarking
636637
public void shouldInsertManyNodesIndividuallyGreenesSplit_small_100() throws FactoryException, IOException {
637638
insertManyNodesIndividually(RTreeIndex.GREENES_SPLIT, 5000, 100, testConfigs.get("small"));
638639
}
@@ -681,12 +682,12 @@ public void shouldInsertManyNodesInBulkWithHilbert_medium() throws FactoryExcept
681682
insertManyNodesInBulk(new HilbertIndexMaker("Coordinates", "Bulk", testConfigs.get("medium")), 5000);
682683
}
683684

684-
@Ignore
685+
@Disabled
685686
public void shouldInsertManyNodesIndividuallyWithQuadraticSplit_medium_10() throws FactoryException, IOException {
686687
insertManyNodesIndividually(RTreeIndex.QUADRATIC_SPLIT, 5000, 10, testConfigs.get("medium"));
687688
}
688689

689-
@Ignore
690+
@Disabled
690691
public void shouldInsertManyNodesIndividuallyGreenesSplit_medium_10() throws FactoryException, IOException {
691692
insertManyNodesIndividually(RTreeIndex.GREENES_SPLIT, 5000, 10, testConfigs.get("medium"));
692693
}
@@ -701,12 +702,12 @@ public void shouldInsertManyNodesInBulkWithGreenesSplit_medium_10() throws Facto
701702
insertManyNodesInBulk(RTreeIndex.GREENES_SPLIT, 5000, 10, testConfigs.get("medium"));
702703
}
703704

704-
@Ignore
705+
@Disabled
705706
public void shouldInsertManyNodesInBulkWithQuadraticSplit_medium_10_merge() throws FactoryException, IOException {
706707
insertManyNodesInBulk(RTreeIndex.QUADRATIC_SPLIT, 5000, 10, testConfigs.get("medium"), true);
707708
}
708709

709-
@Ignore
710+
@Disabled
710711
public void shouldInsertManyNodesInBulkWithGreenesSplit_medium_10_merge() throws FactoryException, IOException {
711712
insertManyNodesInBulk(RTreeIndex.GREENES_SPLIT, 5000, 10, testConfigs.get("medium"), true);
712713
}
@@ -715,17 +716,17 @@ public void shouldInsertManyNodesInBulkWithGreenesSplit_medium_10_merge() throws
715716
* Medium model 500*500 nodes (shallow tree - factor 100)
716717
*/
717718

718-
@Ignore
719+
@Disabled
719720
public void shouldInsertManyNodesIndividuallyWithQuadraticSplit_medium_100() throws FactoryException, IOException {
720721
insertManyNodesIndividually(RTreeIndex.QUADRATIC_SPLIT, 5000, 100, testConfigs.get("medium"));
721722
}
722723

723-
@Ignore
724+
@Disabled
724725
public void shouldInsertManyNodesIndividuallyGreenesSplit_medium_100() throws FactoryException, IOException {
725726
insertManyNodesIndividually(RTreeIndex.GREENES_SPLIT, 5000, 100, testConfigs.get("medium"));
726727
}
727728

728-
@Ignore // takes too long, change to @Test when benchmarking
729+
@Disabled // takes too long, change to @Test when benchmarking
729730
public void shouldInsertManyNodesInBulkWithQuadraticSplit_medium_100() throws FactoryException, IOException {
730731
insertManyNodesInBulk(RTreeIndex.QUADRATIC_SPLIT, 5000, 100, testConfigs.get("medium"));
731732
}
@@ -735,12 +736,12 @@ public void shouldInsertManyNodesInBulkWithGreenesSplit_medium_100() throws Fact
735736
insertManyNodesInBulk(RTreeIndex.GREENES_SPLIT, 5000, 100, testConfigs.get("medium"));
736737
}
737738

738-
@Ignore
739+
@Disabled
739740
public void shouldInsertManyNodesInBulkWithQuadraticSplit_medium_100_merge() throws FactoryException, IOException {
740741
insertManyNodesInBulk(RTreeIndex.QUADRATIC_SPLIT, 5000, 100, testConfigs.get("medium"), true);
741742
}
742743

743-
@Ignore
744+
@Disabled
744745
public void shouldInsertManyNodesInBulkWithGreenesSplit_medium_100_merge() throws FactoryException, IOException {
745746
insertManyNodesInBulk(RTreeIndex.GREENES_SPLIT, 5000, 100, testConfigs.get("medium"), true);
746747
}
@@ -779,22 +780,22 @@ public void shouldInsertManyNodesInBulkWithHilbert_large() throws FactoryExcepti
779780
insertManyNodesInBulk(new HilbertIndexMaker("Coordinates", "Bulk", testConfigs.get("large")), 5000);
780781
}
781782

782-
@Ignore // takes too long, change to @Test when benchmarking
783+
@Disabled // takes too long, change to @Test when benchmarking
783784
public void shouldInsertManyNodesInBulkWithQuadraticSplit_large_10() throws FactoryException, IOException {
784785
insertManyNodesInBulk(RTreeIndex.QUADRATIC_SPLIT, 5000, 10, testConfigs.get("large"));
785786
}
786787

787-
@Ignore // takes too long, change to @Test when benchmarking
788+
@Disabled // takes too long, change to @Test when benchmarking
788789
public void shouldInsertManyNodesInBulkWithGreenesSplit_large_10() throws FactoryException, IOException {
789790
insertManyNodesInBulk(RTreeIndex.GREENES_SPLIT, 5000, 10, testConfigs.get("large"));
790791
}
791792

792-
@Ignore // takes too long, change to @Test when benchmarking
793+
@Disabled // takes too long, change to @Test when benchmarking
793794
public void shouldInsertManyNodesInBulkWithQuadraticSplit_large_100() throws FactoryException, IOException {
794795
insertManyNodesInBulk(RTreeIndex.QUADRATIC_SPLIT, 5000, 100, testConfigs.get("large"));
795796
}
796797

797-
@Ignore // takes too long, change to @Test when benchmarking
798+
@Disabled // takes too long, change to @Test when benchmarking
798799
public void shouldInsertManyNodesInBulkWithGreenesSplit_large_100() throws FactoryException, IOException {
799800
insertManyNodesInBulk(RTreeIndex.GREENES_SPLIT, 5000, 100, testConfigs.get("large"));
800801
}
@@ -916,7 +917,7 @@ private void insertManyNodesIndividually(IndexMaker indexMaker, int blockSize) {
916917
* Run this manually to generate images of RTree that can be used for animation.
917918
* ffmpeg -f image2 -r 12 -i rtree-single/rtree-%d.png -r 12 -s 1280x960 rtree-single2_12fps.mp4
918919
*/
919-
@Ignore
920+
@Disabled
920921
public void shouldInsertManyNodesIndividuallyAndGenerateImagesForAnimation() throws FactoryException, IOException {
921922
IndexTestConfig config = testConfigs.get("medium");
922923
int blockSize = 5;
@@ -1029,7 +1030,7 @@ private void insertManyNodesInBulk(IndexMaker indexMaker, int blockSize) {
10291030
* Run this manually to generate images of RTree that can be used for animation.
10301031
* ffmpeg -f image2 -r 12 -i rtree-single/rtree-%d.png -r 12 -s 1280x960 rtree-single2_12fps.mp4
10311032
*/
1032-
@Ignore
1033+
@Disabled
10331034
public void shouldInsertManyNodesInBulkAndGenerateImagesForAnimation() throws FactoryException, IOException {
10341035
IndexTestConfig config = testConfigs.get("medium");
10351036
int blockSize = 1000;
@@ -1085,7 +1086,7 @@ public void shouldInsertManyNodesInBulkAndGenerateImagesForAnimation() throws Fa
10851086
// debugIndexTree((RTreeIndex) layer.getIndex());
10861087
}
10871088

1088-
@Ignore
1089+
@Disabled
10891090
public void shouldAccessIndexAfterBulkInsertion() throws Exception {
10901091
// Use these two lines if you want to examine the output.
10911092
// File dbPath = new File("target/var/BulkTest");
@@ -1137,7 +1138,7 @@ public void shouldAccessIndexAfterBulkInsertion() throws Exception {
11371138
Result result = tx.execute(cypher);
11381139
// System.out.println(result.columns().toString());
11391140
Object obj = result.columnAs("count").next();
1140-
assertTrue(obj instanceof Long);
1141+
assertInstanceOf(Long.class, obj);
11411142
assertEquals((long) ((Long) obj), numNodes);
11421143
tx.commit();
11431144
}
@@ -1152,14 +1153,14 @@ public void shouldAccessIndexAfterBulkInsertion() throws Exception {
11521153
Result result = tx.execute(cypher);
11531154
// System.out.println(result.columns().toString());
11541155
Object obj = result.columnAs("count").next();
1155-
assertTrue(obj instanceof Long);
1156+
assertInstanceOf(Long.class, obj);
11561157
assertEquals((long) ((Long) obj), numNodes);
11571158
tx.commit();
11581159
}
11591160
System.out.println("\t" + (System.currentTimeMillis() - start) + "ms");
11601161
}
11611162

1162-
@Ignore
1163+
@Disabled
11631164
public void shouldBuildTreeFromScratch() throws Exception {
11641165
//GraphDatabaseService db = this.databases.database("BultTest2");
11651166
GraphDatabaseService db = this.db;
@@ -1215,7 +1216,7 @@ public void shouldBuildTreeFromScratch() throws Exception {
12151216
}
12161217
}
12171218

1218-
@Ignore
1219+
@Disabled
12191220
public void shouldPerformRTreeBulkInsertion() throws Exception {
12201221
// Use this line if you want to examine the output.
12211222
//GraphDatabaseService db = databases.database("BulkTest");
@@ -1492,8 +1493,8 @@ private List<Node> queryIndex(Layer layer, TestStats stats) {
14921493
stats.put("Indexed", geometrySize);
14931494
System.out.println("Index contains " + geometrySize + " geometries");
14941495
}
1495-
assertEquals("Expected " + config.expectedGeometries + " nodes to be returned", config.expectedGeometries,
1496-
countGeometries);
1496+
assertEquals(config.expectedGeometries, countGeometries,
1497+
"Expected " + config.expectedGeometries + " nodes to be returned");
14971498
return nodes;
14981499
}
14991500

@@ -1529,7 +1530,8 @@ private void getRTreeIndexStats(RTreeIndex index, TreeMonitor monitor, TestStats
15291530
// unless the polygon is a rectangle, in which case they are not contained, leading to
15301531
// different numbers for expectedGeometries and expectedCount.
15311532
// See https://github.com/locationtech/jts/blob/master/modules/core/src/main/java/org/locationtech/jts/operation/predicate/RectangleContains.java#L70
1532-
assertEquals("Expected " + config.expectedCount + " nodes to be matched", config.expectedCount, matched);
1533+
assertEquals(config.expectedCount, matched,
1534+
"Expected " + config.expectedCount + " nodes to be matched");
15331535
int maxNodeReferences = stats.maxNodeReferences;
15341536
int maxExpectedGeometriesTouched = matched * maxNodeReferences;
15351537
if (countGeometries > 1 && assertTouches) {
@@ -1555,7 +1557,8 @@ private void getExplicitIndexBackedIndexStats(ExplicitIndexBackedPointIndex inde
15551557
// unless the polygon is a rectangle, in which case they are not contained, leading to
15561558
// different numbers for expectedGeometries and expectedCount.
15571559
// See https://github.com/locationtech/jts/blob/master/modules/core/src/main/java/org/locationtech/jts/operation/predicate/RectangleContains.java#L70
1558-
assertEquals("Expected " + config.expectedCount + " nodes to be matched", config.expectedCount, matched);
1560+
assertEquals(config.expectedCount, matched,
1561+
"Expected " + config.expectedCount + " nodes to be matched");
15591562
}
15601563

15611564
private class TimedLogger {
@@ -1599,17 +1602,17 @@ private void log(String line, long number) {
15991602

16001603
private void verifyGeohashIndex(Layer layer) {
16011604
LayerIndexReader index = layer.getIndex();
1602-
assertTrue("Index should be a geohash index", index instanceof LayerGeohashPointIndex);
1605+
assertInstanceOf(LayerGeohashPointIndex.class, index, "Index should be a geohash index");
16031606
}
16041607

16051608
private void verifyHilbertIndex(Layer layer) {
16061609
LayerIndexReader index = layer.getIndex();
1607-
assertTrue("Index should be a hilbert index", index instanceof LayerHilbertPointIndex);
1610+
assertInstanceOf(LayerHilbertPointIndex.class, index, "Index should be a hilbert index");
16081611
}
16091612

16101613
private void verifyZOrderIndex(Layer layer) {
16111614
LayerIndexReader index = layer.getIndex();
1612-
assertTrue("Index should be a Z-Order index", index instanceof LayerZOrderPointIndex);
1615+
assertInstanceOf(LayerZOrderPointIndex.class, index, "Index should be a Z-Order index");
16131616
}
16141617

16151618
private void verifyTreeStructure(Layer layer, String splitMode, TestStats stats) {
@@ -1650,7 +1653,7 @@ private void verifyTreeStructure(Layer layer, String splitMode, TestStats stats)
16501653
System.out.println("Tree depth to all geometries: " + depthMap);
16511654
}
16521655
}
1653-
assertEquals("All geometries should be at the same depth", 1, balanced);
1656+
assertEquals(1, balanced, "All geometries should be at the same depth");
16541657
Map<String, Object> leafMap;
16551658
try (Transaction tx = db.beginTx()) {
16561659
Result resultNumChildren = tx.execute(queryNumChildren, params);
@@ -1803,7 +1806,7 @@ public String toString() {
18031806

18041807
private static final LinkedHashSet<TestStats> allStats = new LinkedHashSet<>();
18051808

1806-
@AfterClass
1809+
@AfterAll
18071810
public static void afterClass() {
18081811
System.out.println("\n\nComposite stats for " + allStats.size() + " tests run");
18091812
System.out.println(TestStats.headerString());

0 commit comments

Comments
 (0)