Use apoc functions inside Java plugin

Hi community,

I'm running some cypher statements with apoc functions inside my Java plugin. Problem is, that the tests fail saying apoc functions are unknown. How can I include apoc to my project? Is there public lib I can import from?

Kind regards,

You can add APOC (with Maven) as follows:


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:

    private static final Neo4jContainer<?> neo4jContainer = new Neo4jContainer<>("neo4j:4.3")
            .withPlugins(MountableFile.forClasspathResource(String.format("/apoc-%s-all.jar", apocVersion())));

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 {
    public Neo4jRule neo4j = new Neo4jRule().withFunction(Procedures.class);

    public void testRelevantComponent() {
        try (Driver driver = GraphDatabase.driver(
          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 =;

Where do I setup the Neo4jContainer as the environment does all neo4j stuff itself?

You are using Neo4j Test Harness, not TestContainers, which is fine :)
This issue captures what you are trying to do.