Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
07-09-2021 05:05 AM
07-09-2021 05:28 AM
You can add APOC (with Maven) as follows:
<dependency>
<groupId>org.neo4j.procedure</groupId>
<artifactId>apoc</artifactId>
<version>${apoc.version}</version>
<classifier>all</classifier>
<scope>provided</scope>
</dependency>
If you plan to only use APOC via its defined Cypher procedures/functions, provided scope is fine.
If you plan to use APOC Java methods directly (which I would not necessarily recommend), then you need to remove the scope setting.
For testing (assuming you only need APOC Cypher API, not the Java API), you can do something like this with TestContainers:
@Container
private static final Neo4jContainer<?> neo4jContainer = new Neo4jContainer<>("neo4j:4.3")
.withAdminPassword("s3cr3t")
.withPlugins(MountableFile.forClasspathResource(String.format("/apoc-%s-all.jar", apocVersion())));
07-09-2021 06:07 AM
Hi Florent,
it's primarly for testing using the APOC Cypher API. I've got the following class describing my test.
package SDM.BOM;
import org.junit.*;
import org.neo4j.driver.v1.*;
import org.neo4j.harness.junit.Neo4jRule;
import java.util.HashMap;
import java.util.Map;
public class ProceduresTest {
@Rule
public Neo4jRule neo4j = new Neo4jRule().withFunction(Procedures.class);
@Test
public void testRelevantComponent() {
try (Driver driver = GraphDatabase.driver(
neo4j.boltURI(), Config.build().withoutEncryption().toConfig()))
{
String query = "return SDM.BOM.doSomething() as result // run some nested cyphers from the plugin ";
Map<String, Object> params = new HashMap<>();
Session session = driver.session();
StatementResult result = session.run(query);
...
}
}
}
Where do I setup the Neo4jContainer as the environment does all neo4j stuff itself?
07-12-2021 01:47 AM
You are using Neo4j Test Harness, not TestContainers, which is fine 🙂
This issue captures what you are trying to do.
All the sessions of the conference are now available online