'How do I use apoc with the neo4j test container?

I believe I have enabled the apoc for the neo4j test container.

   @Container
    private static Neo4jContainer<?> neo4j = new Neo4jContainer<>(DockerImageName.parse("neo4j:4.2.14-enterprise"))
            .withAdminPassword(password)
            .withNeo4jConfig("dbms.security.procedures.unrestricted", "apoc.*")
            .withEnv("NEO4JLABS_PLUGINS", "[\\\"apoc\\\"]")
            .withEnv("NEO4J_ACCEPT_LICENSE_AGREEMENT", "yes")
            .withReuse(true);

Here is the pom.xml

        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>testcontainers</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>junit-jupiter</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>neo4j</artifactId>
            <scope>test</scope>
        </dependency>

However, when I try to run my unit tests I get the follow error:

org.neo4j.driver.exceptions.ClientException: There is no procedure with the name apoc.periodic.iterate registered for this database instance. Please ensure you've spelled the procedure name correctly and that the procedure is properly deployed.



Solution 1:[1]

According to the Testcontainers Neo4j module documentation you can use a special method withLabsPlugins() instead of your NEO4JLABS_PLUGINS environment variable. Like:

...
.withLabsPlugins(Neo4jLabsPlugin.APOC)
...

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 yuppie-flu