Skip to content

Commit

Permalink
Ported to Neo4j 4.4, which involved upgrading several dependencies
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
craigtaverner committed Feb 6, 2022
1 parent 8d34003 commit a727340
Show file tree
Hide file tree
Showing 32 changed files with 671 additions and 593 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ The Neo4j Spatial Plugin is available for inclusion in the server version of Neo
* [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)
* [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)
* [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)
* [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)

For versions up to 0.15-neo4j-2.3.4:

Expand Down Expand Up @@ -475,7 +476,7 @@ Add the following repositories and dependency to your project's pom.xml:
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-spatial</artifactId>
<version>0.28.1-neo4j-4.3.10</version>
<version>0.28.1-neo4j-4.4.3</version>
</dependency>
~~~

Expand Down
59 changes: 43 additions & 16 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<properties>
<neo4j.version>4.3.10</neo4j.version>
<lucene.version>8.2.0</lucene.version>
<neo4j.version>4.4.3</neo4j.version>
<lucene.version>8.4.1</lucene.version> <!-- Neo4j 4.4 uses 8.9.0, but lucene-spatial only existed up to 8.4.1 -->
<!-- make sure lucene version is the same as the one the current neo4j depends on -->
<neo4j.java.version>11</neo4j.java.version>
<maven-compiler-plugin.version>3.1</maven-compiler-plugin.version>
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
<maven-gpg-plugin.version>1.4</maven-gpg-plugin.version>
<maven-resources-plugin.version>2.6</maven-resources-plugin.version>
<maven-assembly-plugin.version>2.5.4</maven-assembly-plugin.version>
<maven-resources-plugin.version>3.1.0</maven-resources-plugin.version>
<maven-assembly-plugin.version>3.3.0</maven-assembly-plugin.version>
<skinGroupId>org.neo4j.maven.skins</skinGroupId>
<skinArtifactId>default-skin</skinArtifactId>
<skinVersion>2</skinVersion>
<geotools.version>24.2</geotools.version>
<geotools.version>26.2</geotools.version>
<spatial.test.osm.version>20100819</spatial.test.osm.version>
<spatial.test.shp.version>20100819</spatial.test.shp.version>
<bundle.namespace>org.neo4j.gis</bundle.namespace>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<bundle.namespace>org.neo4j.gis</bundle.namespace>
<github.global.server>github</github.global.server>
<junit.version>5.7.2</junit.version>
<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 -->
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<asciidoctor.maven.plugin.version>2.2.1</asciidoctor.maven.plugin.version>
</properties>

<modelVersion>4.0.0</modelVersion>
<artifactId>neo4j-spatial</artifactId>
<groupId>org.neo4j</groupId>
<version>0.28.1-neo4j-4.3.10</version>
<version>0.28.1-neo4j-4.4.3</version>
<name>Neo4j - Spatial Components</name>
<description>Spatial utilities and components for Neo4j</description>
<url>http://components.neo4j.org/${project.artifactId}/${project.version}</url>
Expand Down Expand Up @@ -151,7 +155,7 @@
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<threadCount>1</threadCount>
<forkCount>1</forkCount>
Expand All @@ -162,7 +166,7 @@
<plugin>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctor-maven-plugin</artifactId>
<version>1.5.3</version>
<version>${asciidoctor.maven.plugin.version}</version>
<executions>
<execution>
<id>generate-docs</id>
Expand Down Expand Up @@ -217,7 +221,7 @@
<dependency>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctorj-diagram</artifactId>
<version>1.3.1</version>
<version>2.2.1</version>
</dependency>
</dependencies>
</plugin>
Expand Down Expand Up @@ -317,6 +321,12 @@
<version>${neo4j.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-data-collector</artifactId>
<version>${neo4j.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.neo4j.app</groupId>
<artifactId>neo4j-server</artifactId>
Expand Down Expand Up @@ -357,12 +367,29 @@

<!-- The JUnit-Hamcrest-Mockito combo -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>${junit.platform.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency> <dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.3</version>
Expand Down Expand Up @@ -496,7 +523,7 @@
<dependency>
<groupId>org.neo4j.build.plugins</groupId>
<artifactId>neo4j-doctools</artifactId>
<version>14</version>
<version>33</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down Expand Up @@ -693,7 +720,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<argLine>-server -Xms512m -Xmx2G -XX:+UseConcMarkSweepGC -Djava.awt.headless=true</argLine>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public boolean canProcess(Map params) {
}

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

if (!canProcess(params)) {
throw new IOException("The parameters map isn't correct!!");
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/org/neo4j/gis/spatial/index/IndexManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.neo4j.graphdb.Label;
import org.neo4j.graphdb.Transaction;
import org.neo4j.graphdb.schema.IndexDefinition;
import org.neo4j.internal.kernel.api.security.PermissionState;
import org.neo4j.internal.kernel.api.security.PrivilegeAction;
import org.neo4j.internal.kernel.api.security.SecurityContext;
import org.neo4j.kernel.api.KernelTransaction;
Expand All @@ -27,8 +28,8 @@ private IndexAccessMode(SecurityContext securityContext) {
}

@Override
public boolean allowsTokenCreates(PrivilegeAction action) {
return true;
public PermissionState allowsTokenCreates(PrivilegeAction action) {
return PermissionState.EXPLICIT_GRANT;
}

@Override
Expand All @@ -37,8 +38,8 @@ public boolean allowsSchemaWrites() {
}

@Override
public boolean allowsSchemaWrites(PrivilegeAction action) {
return true;
public PermissionState allowsSchemaWrites(PrivilegeAction action) {
return PermissionState.EXPLICIT_GRANT;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import org.neo4j.internal.kernel.api.*;
import org.neo4j.internal.schema.IndexDescriptor;
import org.neo4j.internal.schema.IndexType;
import org.neo4j.internal.schema.SchemaDescriptor;
import org.neo4j.internal.schema.SchemaDescriptors;
import org.neo4j.io.pagecache.context.CursorContext;
import org.neo4j.kernel.api.KernelTransaction;
import org.neo4j.kernel.impl.core.NodeEntity;
Expand Down Expand Up @@ -127,34 +127,28 @@ public Iterator<Node> search(KernelTransaction ktx, Label label, String property
return Iterators.concat(results.iterator());
}

private ResourceIterator<Node> nodesByLabelAndProperty(KernelTransaction transaction, int labelId, PropertyIndexQuery query )
{
private ResourceIterator<Node> nodesByLabelAndProperty(KernelTransaction transaction, int labelId, PropertyIndexQuery query) {
Read read = transaction.dataRead();

if ( query.propertyKeyId() == TokenRead.NO_TOKEN || labelId == TokenRead.NO_TOKEN )
{
if (query.propertyKeyId() == TokenRead.NO_TOKEN || labelId == TokenRead.NO_TOKEN) {
return emptyResourceIterator();
}
Iterator<IndexDescriptor> iterator = transaction.schemaRead().index( SchemaDescriptor.forLabel( labelId, query.propertyKeyId() ) );
while ( iterator.hasNext() )
{
Iterator<IndexDescriptor> iterator = transaction.schemaRead().index(SchemaDescriptors.forLabel(labelId, query.propertyKeyId()));
while (iterator.hasNext()) {
IndexDescriptor index = iterator.next();
if ( index.getIndexType() != IndexType.BTREE )
{
// TODO: Do we need to support the new IndexType.RANGE index in Neo4j 4.4?
if (index.getIndexType() != IndexType.BTREE) {
// Skip special indexes, such as the full-text indexes, because they can't handle all the queries we might throw at them.
continue;
}
// Ha! We found an index - let's use it to find matching nodes
try
{
try {
NodeValueIndexCursor cursor = transaction.cursors().allocateNodeValueIndexCursor(CursorContext.NULL, EmptyMemoryTracker.INSTANCE);
IndexReadSession indexSession = read.indexReadSession( index );
read.nodeIndexSeek( indexSession, cursor, IndexQueryConstraints.unordered(false), query );
IndexReadSession indexSession = read.indexReadSession(index);
read.nodeIndexSeek(transaction.queryContext(), indexSession, cursor, IndexQueryConstraints.unordered(false), query);

return new CursorIterator<>(cursor, NodeIndexCursor::nodeReference, (c) -> new NodeEntity(transaction.internalTransaction(), c.nodeReference()), EMPTY_RESOURCE_TRACKER);
}
catch ( KernelException e )
{
} catch (KernelException e) {
// weird at this point but ignore and fallback to a label scan
}
}
Expand Down

This file was deleted.

27 changes: 11 additions & 16 deletions src/test/java/org/neo4j/gis/spatial/AbstractJavaDocTestBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
*/
package org.neo4j.gis.spatial;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Rule;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.neo4j.dbms.api.DatabaseManagementService;
import org.neo4j.doc.tools.JavaTestDocsGenerator;
import org.neo4j.graphdb.GraphDatabaseService;
Expand All @@ -38,19 +38,14 @@
* This class was copied from the class of the same name in neo4j-examples, in order to reduce the dependency chain
*/
public abstract class AbstractJavaDocTestBase implements GraphHolder {
@Rule
public TestData<JavaTestDocsGenerator> gen;
@Rule
public TestData<Map<String, Node>> data;
@RegisterExtension
public TestData<Map<String, Node>> data = TestData.producedThrough(GraphDescription.createGraphFor(this));
@RegisterExtension
public TestData<JavaTestDocsGenerator> gen = TestData.producedThrough(JavaTestDocsGenerator.PRODUCER);
protected static DatabaseManagementService databases;
protected static GraphDatabaseService db;

public AbstractJavaDocTestBase() {
this.gen = TestData.producedThrough(JavaTestDocsGenerator.PRODUCER);
this.data = TestData.producedThrough(GraphDescription.createGraphFor(this));
}

@AfterClass
@AfterAll
public static void shutdownDb() {
try {
if (databases != null) {
Expand All @@ -67,14 +62,14 @@ public GraphDatabaseService graphdb() {
return db;
}

@Before
@BeforeEach
public void setUp() {
GraphDatabaseService graphdb = this.graphdb();
GraphDatabaseServiceCleaner.cleanDatabaseContent(graphdb);
this.gen.get().setGraph(graphdb);
}

@After
@AfterEach
public void doc() {
this.gen.get().document("target/docs/dev", "examples");
}
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/org/neo4j/gis/spatial/LayerSignatureTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
*/
package org.neo4j.gis.spatial;

import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.neo4j.gis.spatial.index.IndexManager;
import org.neo4j.graphdb.Transaction;
import org.neo4j.internal.kernel.api.security.SecurityContext;
Expand All @@ -29,12 +29,12 @@
import java.util.function.Consumer;
import java.util.function.Function;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

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

@Before
@BeforeEach
public void setup() throws Exception {
super.setUp();
spatial = new SpatialDatabaseService(new IndexManager((GraphDatabaseAPI) graphDb(), SecurityContext.AUTH_DISABLED));
Expand Down
16 changes: 8 additions & 8 deletions src/test/java/org/neo4j/gis/spatial/LayersTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
*/
package org.neo4j.gis.spatial;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.CoordinateList;
import org.locationtech.jts.geom.Envelope;
import org.locationtech.jts.geom.LineString;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.neo4j.dbms.api.DatabaseManagementService;
import org.neo4j.exceptions.KernelException;
import org.neo4j.gis.spatial.encoders.NativePointEncoder;
Expand Down Expand Up @@ -54,21 +54,21 @@
import java.util.function.Consumer;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;
import static org.neo4j.configuration.GraphDatabaseSettings.DEFAULT_DATABASE_NAME;

public class LayersTest {
private DatabaseManagementService databases;
private GraphDatabaseService graphDb;

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

@After
@AfterEach
public void teardown() {
databases.shutdown();
}
Expand Down Expand Up @@ -239,12 +239,12 @@ private String testSpecificEditableLayer(String layerName, Class<? extends Geome
inTx(tx -> {
Layer layer = spatial.createLayer(tx, layerName, geometryEncoderClass, layerClass);
assertNotNull(layer);
assertTrue("Should be an editable layer", layer instanceof EditableLayer);
assertTrue(layer instanceof EditableLayer, "Should be an editable layer");
});
inTx(tx -> {
Layer layer = spatial.getLayer(tx, layerName);
assertNotNull(layer);
assertTrue("Should be an editable layer", layer instanceof EditableLayer);
assertTrue(layer instanceof EditableLayer, "Should be an editable layer");
EditableLayer editableLayer = (EditableLayer) layer;

CoordinateList coordinates = new CoordinateList();
Expand Down
Loading

0 comments on commit a727340

Please sign in to comment.