Skip to content

Commit a727340

Browse files
committed
Ported to Neo4j 4.4, which involved upgrading several dependencies
Neo4j from 4.3.10 to 4.4.3 Lucene from 8.2 to 8.4.1 Maven plugins * compiler from 3.1 to 3.8.1 * resources from 2.6 to 3.1.8 * assembly from 2.5.4 to 3.3.0 * surefire from 2.18.1 to 2.22.2 ascidoctor from 1.5.3 to 2.2.1 geotools from 24.2 to 26.2 junit from 4.12 to 5.7.2 * junit platform to 1.6.2 The move from junit4 to junit5 in particular required a major update to every test class.
1 parent 8d34003 commit a727340

32 files changed

+671
-593
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ The Neo4j Spatial Plugin is available for inclusion in the server version of Neo
359359
* [v0.27.2 for Neo4j 4.2.3](https://github.com/neo4j-contrib/m2/blob/master/releases/org/neo4j/neo4j-spatial/0.27.2-neo4j-4.2.3/neo4j-spatial-0.27.2-neo4j-4.2.3-server-plugin.jar?raw=true)
360360
* [v0.28.0 for Neo4j 4.2.3](https://github.com/neo4j-contrib/m2/blob/master/releases/org/neo4j/neo4j-spatial/0.28.0-neo4j-4.2.3/neo4j-spatial-0.28.0-neo4j-4.2.3-server-plugin.jar?raw=true)
361361
* [v0.28.1 for Neo4j 4.3.10](https://github.com/neo4j-contrib/m2/blob/master/releases/org/neo4j/neo4j-spatial/0.28.1-neo4j-4.3.10/neo4j-spatial-0.28.1-neo4j-4.3.10-server-plugin.jar?raw=true)
362+
* [v0.28.1 for Neo4j 4.4.3](https://github.com/neo4j-contrib/m2/blob/master/releases/org/neo4j/neo4j-spatial/0.28.1-neo4j-4.4.3/neo4j-spatial-0.28.1-neo4j-4.4.3-server-plugin.jar?raw=true)
362363

363364
For versions up to 0.15-neo4j-2.3.4:
364365

@@ -475,7 +476,7 @@ Add the following repositories and dependency to your project's pom.xml:
475476
<dependency>
476477
<groupId>org.neo4j</groupId>
477478
<artifactId>neo4j-spatial</artifactId>
478-
<version>0.28.1-neo4j-4.3.10</version>
479+
<version>0.28.1-neo4j-4.4.3</version>
479480
</dependency>
480481
~~~
481482

pom.xml

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,33 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
33
<properties>
4-
<neo4j.version>4.3.10</neo4j.version>
5-
<lucene.version>8.2.0</lucene.version>
4+
<neo4j.version>4.4.3</neo4j.version>
5+
<lucene.version>8.4.1</lucene.version> <!-- Neo4j 4.4 uses 8.9.0, but lucene-spatial only existed up to 8.4.1 -->
66
<!-- make sure lucene version is the same as the one the current neo4j depends on -->
77
<neo4j.java.version>11</neo4j.java.version>
8-
<maven-compiler-plugin.version>3.1</maven-compiler-plugin.version>
8+
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
99
<maven-gpg-plugin.version>1.4</maven-gpg-plugin.version>
10-
<maven-resources-plugin.version>2.6</maven-resources-plugin.version>
11-
<maven-assembly-plugin.version>2.5.4</maven-assembly-plugin.version>
10+
<maven-resources-plugin.version>3.1.0</maven-resources-plugin.version>
11+
<maven-assembly-plugin.version>3.3.0</maven-assembly-plugin.version>
1212
<skinGroupId>org.neo4j.maven.skins</skinGroupId>
1313
<skinArtifactId>default-skin</skinArtifactId>
1414
<skinVersion>2</skinVersion>
15-
<geotools.version>24.2</geotools.version>
15+
<geotools.version>26.2</geotools.version>
1616
<spatial.test.osm.version>20100819</spatial.test.osm.version>
1717
<spatial.test.shp.version>20100819</spatial.test.shp.version>
18-
<bundle.namespace>org.neo4j.gis</bundle.namespace>
1918
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
19+
<bundle.namespace>org.neo4j.gis</bundle.namespace>
2020
<github.global.server>github</github.global.server>
21+
<junit.version>5.7.2</junit.version>
22+
<junit.platform.version>1.6.2</junit.platform.version> <!-- Surefire only supports 1.3.1, but 1.6.2 works by luck since the signatures are the same -->
23+
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
24+
<asciidoctor.maven.plugin.version>2.2.1</asciidoctor.maven.plugin.version>
2125
</properties>
2226

2327
<modelVersion>4.0.0</modelVersion>
2428
<artifactId>neo4j-spatial</artifactId>
2529
<groupId>org.neo4j</groupId>
26-
<version>0.28.1-neo4j-4.3.10</version>
30+
<version>0.28.1-neo4j-4.4.3</version>
2731
<name>Neo4j - Spatial Components</name>
2832
<description>Spatial utilities and components for Neo4j</description>
2933
<url>http://components.neo4j.org/${project.artifactId}/${project.version}</url>
@@ -151,7 +155,7 @@
151155
</plugin>
152156
<plugin>
153157
<artifactId>maven-surefire-plugin</artifactId>
154-
<version>2.18.1</version>
158+
<version>${maven-surefire-plugin.version}</version>
155159
<configuration>
156160
<threadCount>1</threadCount>
157161
<forkCount>1</forkCount>
@@ -162,7 +166,7 @@
162166
<plugin>
163167
<groupId>org.asciidoctor</groupId>
164168
<artifactId>asciidoctor-maven-plugin</artifactId>
165-
<version>1.5.3</version>
169+
<version>${asciidoctor.maven.plugin.version}</version>
166170
<executions>
167171
<execution>
168172
<id>generate-docs</id>
@@ -217,7 +221,7 @@
217221
<dependency>
218222
<groupId>org.asciidoctor</groupId>
219223
<artifactId>asciidoctorj-diagram</artifactId>
220-
<version>1.3.1</version>
224+
<version>2.2.1</version>
221225
</dependency>
222226
</dependencies>
223227
</plugin>
@@ -317,6 +321,12 @@
317321
<version>${neo4j.version}</version>
318322
<scope>provided</scope>
319323
</dependency>
324+
<dependency>
325+
<groupId>org.neo4j</groupId>
326+
<artifactId>neo4j-data-collector</artifactId>
327+
<version>${neo4j.version}</version>
328+
<scope>provided</scope>
329+
</dependency>
320330
<dependency>
321331
<groupId>org.neo4j.app</groupId>
322332
<artifactId>neo4j-server</artifactId>
@@ -357,12 +367,29 @@
357367

358368
<!-- The JUnit-Hamcrest-Mockito combo -->
359369
<dependency>
360-
<groupId>junit</groupId>
361-
<artifactId>junit</artifactId>
362-
<version>4.12</version>
370+
<groupId>org.junit.vintage</groupId>
371+
<artifactId>junit-vintage-engine</artifactId>
372+
<version>${junit.version}</version>
363373
<scope>test</scope>
364374
</dependency>
365375
<dependency>
376+
<groupId>org.junit.platform</groupId>
377+
<artifactId>junit-platform-launcher</artifactId>
378+
<version>${junit.platform.version}</version>
379+
<scope>test</scope>
380+
</dependency>
381+
<dependency>
382+
<groupId>org.junit.jupiter</groupId>
383+
<artifactId>junit-jupiter-engine</artifactId>
384+
<version>${junit.version}</version>
385+
<scope>test</scope>
386+
</dependency>
387+
<dependency>
388+
<groupId>org.junit.jupiter</groupId>
389+
<artifactId>junit-jupiter-params</artifactId>
390+
<version>${junit.version}</version>
391+
<scope>test</scope>
392+
</dependency> <dependency>
366393
<groupId>org.hamcrest</groupId>
367394
<artifactId>hamcrest-core</artifactId>
368395
<version>1.3</version>
@@ -496,7 +523,7 @@
496523
<dependency>
497524
<groupId>org.neo4j.build.plugins</groupId>
498525
<artifactId>neo4j-doctools</artifactId>
499-
<version>14</version>
526+
<version>33</version>
500527
<scope>provided</scope>
501528
</dependency>
502529
</dependencies>
@@ -693,7 +720,7 @@
693720
<plugin>
694721
<groupId>org.apache.maven.plugins</groupId>
695722
<artifactId>maven-surefire-plugin</artifactId>
696-
<version>2.18.1</version>
723+
<version>${maven-surefire-plugin.version}</version>
697724
<configuration>
698725
<argLine>-server -Xms512m -Xmx2G -XX:+UseConcMarkSweepGC -Djava.awt.headless=true</argLine>
699726
</configuration>

src/main/java/org/geotools/data/neo4j/Neo4jSpatialDataStoreFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public boolean canProcess(Map params) {
6363
}
6464

6565
@Override
66-
public DataStore createDataStore(Map<String, java.io.Serializable> params) throws IOException {
66+
public DataStore createDataStore(Map<String, ?> params) throws IOException {
6767

6868
if (!canProcess(params)) {
6969
throw new IOException("The parameters map isn't correct!!");

src/main/java/org/neo4j/gis/spatial/index/IndexManager.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import org.neo4j.graphdb.Label;
44
import org.neo4j.graphdb.Transaction;
55
import org.neo4j.graphdb.schema.IndexDefinition;
6+
import org.neo4j.internal.kernel.api.security.PermissionState;
67
import org.neo4j.internal.kernel.api.security.PrivilegeAction;
78
import org.neo4j.internal.kernel.api.security.SecurityContext;
89
import org.neo4j.kernel.api.KernelTransaction;
@@ -27,8 +28,8 @@ private IndexAccessMode(SecurityContext securityContext) {
2728
}
2829

2930
@Override
30-
public boolean allowsTokenCreates(PrivilegeAction action) {
31-
return true;
31+
public PermissionState allowsTokenCreates(PrivilegeAction action) {
32+
return PermissionState.EXPLICIT_GRANT;
3233
}
3334

3435
@Override
@@ -37,8 +38,8 @@ public boolean allowsSchemaWrites() {
3738
}
3839

3940
@Override
40-
public boolean allowsSchemaWrites(PrivilegeAction action) {
41-
return true;
41+
public PermissionState allowsSchemaWrites(PrivilegeAction action) {
42+
return PermissionState.EXPLICIT_GRANT;
4243
}
4344
}
4445

src/main/java/org/neo4j/gis/spatial/index/LayerSpaceFillingCurvePointIndex.java

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
import org.neo4j.internal.kernel.api.*;
3535
import org.neo4j.internal.schema.IndexDescriptor;
3636
import org.neo4j.internal.schema.IndexType;
37-
import org.neo4j.internal.schema.SchemaDescriptor;
37+
import org.neo4j.internal.schema.SchemaDescriptors;
3838
import org.neo4j.io.pagecache.context.CursorContext;
3939
import org.neo4j.kernel.api.KernelTransaction;
4040
import org.neo4j.kernel.impl.core.NodeEntity;
@@ -127,34 +127,28 @@ public Iterator<Node> search(KernelTransaction ktx, Label label, String property
127127
return Iterators.concat(results.iterator());
128128
}
129129

130-
private ResourceIterator<Node> nodesByLabelAndProperty(KernelTransaction transaction, int labelId, PropertyIndexQuery query )
131-
{
130+
private ResourceIterator<Node> nodesByLabelAndProperty(KernelTransaction transaction, int labelId, PropertyIndexQuery query) {
132131
Read read = transaction.dataRead();
133132

134-
if ( query.propertyKeyId() == TokenRead.NO_TOKEN || labelId == TokenRead.NO_TOKEN )
135-
{
133+
if (query.propertyKeyId() == TokenRead.NO_TOKEN || labelId == TokenRead.NO_TOKEN) {
136134
return emptyResourceIterator();
137135
}
138-
Iterator<IndexDescriptor> iterator = transaction.schemaRead().index( SchemaDescriptor.forLabel( labelId, query.propertyKeyId() ) );
139-
while ( iterator.hasNext() )
140-
{
136+
Iterator<IndexDescriptor> iterator = transaction.schemaRead().index(SchemaDescriptors.forLabel(labelId, query.propertyKeyId()));
137+
while (iterator.hasNext()) {
141138
IndexDescriptor index = iterator.next();
142-
if ( index.getIndexType() != IndexType.BTREE )
143-
{
139+
// TODO: Do we need to support the new IndexType.RANGE index in Neo4j 4.4?
140+
if (index.getIndexType() != IndexType.BTREE) {
144141
// Skip special indexes, such as the full-text indexes, because they can't handle all the queries we might throw at them.
145142
continue;
146143
}
147144
// Ha! We found an index - let's use it to find matching nodes
148-
try
149-
{
145+
try {
150146
NodeValueIndexCursor cursor = transaction.cursors().allocateNodeValueIndexCursor(CursorContext.NULL, EmptyMemoryTracker.INSTANCE);
151-
IndexReadSession indexSession = read.indexReadSession( index );
152-
read.nodeIndexSeek( indexSession, cursor, IndexQueryConstraints.unordered(false), query );
147+
IndexReadSession indexSession = read.indexReadSession(index);
148+
read.nodeIndexSeek(transaction.queryContext(), indexSession, cursor, IndexQueryConstraints.unordered(false), query);
153149

154150
return new CursorIterator<>(cursor, NodeIndexCursor::nodeReference, (c) -> new NodeEntity(transaction.internalTransaction(), c.nodeReference()), EMPTY_RESOURCE_TRACKER);
155-
}
156-
catch ( KernelException e )
157-
{
151+
} catch (KernelException e) {
158152
// weird at this point but ignore and fallback to a label scan
159153
}
160154
}

src/main/resources/META-INF/services/org.neo4j.server.plugins.ServerPlugin

Lines changed: 0 additions & 1 deletion
This file was deleted.

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

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

22-
import org.junit.After;
23-
import org.junit.AfterClass;
24-
import org.junit.Before;
25-
import org.junit.Rule;
22+
import org.junit.jupiter.api.AfterAll;
23+
import org.junit.jupiter.api.AfterEach;
24+
import org.junit.jupiter.api.BeforeEach;
25+
import org.junit.jupiter.api.extension.RegisterExtension;
2626
import org.neo4j.dbms.api.DatabaseManagementService;
2727
import org.neo4j.doc.tools.JavaTestDocsGenerator;
2828
import org.neo4j.graphdb.GraphDatabaseService;
@@ -38,19 +38,14 @@
3838
* This class was copied from the class of the same name in neo4j-examples, in order to reduce the dependency chain
3939
*/
4040
public abstract class AbstractJavaDocTestBase implements GraphHolder {
41-
@Rule
42-
public TestData<JavaTestDocsGenerator> gen;
43-
@Rule
44-
public TestData<Map<String, Node>> data;
41+
@RegisterExtension
42+
public TestData<Map<String, Node>> data = TestData.producedThrough(GraphDescription.createGraphFor(this));
43+
@RegisterExtension
44+
public TestData<JavaTestDocsGenerator> gen = TestData.producedThrough(JavaTestDocsGenerator.PRODUCER);
4545
protected static DatabaseManagementService databases;
4646
protected static GraphDatabaseService db;
4747

48-
public AbstractJavaDocTestBase() {
49-
this.gen = TestData.producedThrough(JavaTestDocsGenerator.PRODUCER);
50-
this.data = TestData.producedThrough(GraphDescription.createGraphFor(this));
51-
}
52-
53-
@AfterClass
48+
@AfterAll
5449
public static void shutdownDb() {
5550
try {
5651
if (databases != null) {
@@ -67,14 +62,14 @@ public GraphDatabaseService graphdb() {
6762
return db;
6863
}
6964

70-
@Before
65+
@BeforeEach
7166
public void setUp() {
7267
GraphDatabaseService graphdb = this.graphdb();
7368
GraphDatabaseServiceCleaner.cleanDatabaseContent(graphdb);
7469
this.gen.get().setGraph(graphdb);
7570
}
7671

77-
@After
72+
@AfterEach
7873
public void doc() {
7974
this.gen.get().document("target/docs/dev", "examples");
8075
}

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

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

22-
import org.junit.Before;
23-
import org.junit.Test;
22+
import org.junit.jupiter.api.BeforeEach;
23+
import org.junit.jupiter.api.Test;
2424
import org.neo4j.gis.spatial.index.IndexManager;
2525
import org.neo4j.graphdb.Transaction;
2626
import org.neo4j.internal.kernel.api.security.SecurityContext;
@@ -29,12 +29,12 @@
2929
import java.util.function.Consumer;
3030
import java.util.function.Function;
3131

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

3434
public class LayerSignatureTest extends Neo4jTestCase implements Constants {
3535
private SpatialDatabaseService spatial;
3636

37-
@Before
37+
@BeforeEach
3838
public void setup() throws Exception {
3939
super.setUp();
4040
spatial = new SpatialDatabaseService(new IndexManager((GraphDatabaseAPI) graphDb(), SecurityContext.AUTH_DISABLED));

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

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

22+
import org.junit.jupiter.api.AfterEach;
23+
import org.junit.jupiter.api.BeforeEach;
24+
import org.junit.jupiter.api.Test;
2225
import org.locationtech.jts.geom.Coordinate;
2326
import org.locationtech.jts.geom.CoordinateList;
2427
import org.locationtech.jts.geom.Envelope;
2528
import org.locationtech.jts.geom.LineString;
26-
import org.junit.After;
27-
import org.junit.Before;
28-
import org.junit.Test;
2929
import org.neo4j.dbms.api.DatabaseManagementService;
3030
import org.neo4j.exceptions.KernelException;
3131
import org.neo4j.gis.spatial.encoders.NativePointEncoder;
@@ -54,21 +54,21 @@
5454
import java.util.function.Consumer;
5555

5656
import static org.hamcrest.MatcherAssert.assertThat;
57-
import static org.junit.Assert.*;
57+
import static org.junit.jupiter.api.Assertions.*;
5858
import static org.neo4j.configuration.GraphDatabaseSettings.DEFAULT_DATABASE_NAME;
5959

6060
public class LayersTest {
6161
private DatabaseManagementService databases;
6262
private GraphDatabaseService graphDb;
6363

64-
@Before
64+
@BeforeEach
6565
public void setup() throws KernelException {
6666
databases = new TestDatabaseManagementServiceBuilder(new File("target/layers").toPath()).impermanent().build();
6767
graphDb = databases.database(DEFAULT_DATABASE_NAME);
6868
((GraphDatabaseAPI) graphDb).getDependencyResolver().resolveDependency(GlobalProcedures.class).registerProcedure(SpatialProcedures.class);
6969
}
7070

71-
@After
71+
@AfterEach
7272
public void teardown() {
7373
databases.shutdown();
7474
}
@@ -239,12 +239,12 @@ private String testSpecificEditableLayer(String layerName, Class<? extends Geome
239239
inTx(tx -> {
240240
Layer layer = spatial.createLayer(tx, layerName, geometryEncoderClass, layerClass);
241241
assertNotNull(layer);
242-
assertTrue("Should be an editable layer", layer instanceof EditableLayer);
242+
assertTrue(layer instanceof EditableLayer, "Should be an editable layer");
243243
});
244244
inTx(tx -> {
245245
Layer layer = spatial.getLayer(tx, layerName);
246246
assertNotNull(layer);
247-
assertTrue("Should be an editable layer", layer instanceof EditableLayer);
247+
assertTrue(layer instanceof EditableLayer, "Should be an editable layer");
248248
EditableLayer editableLayer = (EditableLayer) layer;
249249

250250
CoordinateList coordinates = new CoordinateList();

0 commit comments

Comments
 (0)