Package org.testcontainers.neo4j
Class Neo4jContainer
java.lang.Object
org.testcontainers.containers.GenericContainer<Neo4jContainer>
org.testcontainers.neo4j.Neo4jContainer
- All Implemented Interfaces:
AutoCloseable,org.testcontainers.containers.Container<Neo4jContainer>,org.testcontainers.containers.ContainerState,org.testcontainers.containers.traits.LinkableContainer,org.testcontainers.containers.wait.strategy.WaitStrategyTarget,org.testcontainers.lifecycle.Startable
Testcontainers implementation for Neo4j.
Supported image: neo4j
Exposed ports:
- Bolt: 7687
- HTTP: 7474
- HTTPS: 7473
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.testcontainers.containers.Container
org.testcontainers.containers.Container.ExecResult -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final org.testcontainers.containers.wait.strategy.WaitStrategyDefault wait strategiesFields inherited from class org.testcontainers.containers.GenericContainer
CONTAINER_RUNNING_TIMEOUT_SEC, dependencies, dockerClient, INTERNAL_HOST_HOSTNAME, waitStrategyFields inherited from interface org.testcontainers.containers.ContainerState
STATE_HEALTHY -
Constructor Summary
ConstructorsConstructorDescriptionNeo4jContainer(String dockerImageName) Creates a Neo4jContainer using a specific docker image.Neo4jContainer(org.testcontainers.utility.DockerImageName dockerImageName) Creates a Neo4jContainer using a specific docker image. -
Method Summary
Modifier and TypeMethodDescriptionAccepts the license agreement of the container.protected voidwithAdminPassword(String adminPassword) Sets the admin password for the default account (which iswithDatabase(org.testcontainers.utility.MountableFile graphDb) Copies an existinggraph.dbfolder into the container.withNeo4jConfig(String key, String value) Adds Neo4j configuration properties to the container.Disables authentication.withPlugins(String... plugins) Registers one or more Neo4j plugins for server startup.withPlugins(org.testcontainers.utility.MountableFile plugins) Adds plugins to the given directory to the container.Methods inherited from class org.testcontainers.containers.GenericContainer
addEnv, addExposedPort, addExposedPorts, addFileSystemBind, addFixedExposedPort, addFixedExposedPort, addLink, canBeReused, containerIsCreated, containerIsStarted, containerIsStarted, containerIsStarting, containerIsStarting, containerIsStopped, containerIsStopping, copyFileFromContainer, createVolumeDirectory, dependsOn, dependsOn, dependsOn, doStart, equals, getBinds, getCommandParts, getContainerId, getContainerInfo, getContainerName, getCopyToFileContainerPathMap, getCreateContainerCmdModifiers, getDependencies, getDockerClient, getDockerImageName, getEnv, getEnvMap, getExposedPorts, getExtraHosts, getImage, getIpAddress, getLabels, getLinkedContainers, getLivenessCheckPort, getLivenessCheckPorts, getLogConsumers, getNetwork, getNetworkAliases, getNetworkMode, getPortBindings, getShmSize, getStartupAttempts, getStartupCheckStrategy, getTestHostIpAddress, getTmpFsMapping, getVolumesFroms, getWaitStrategy, getWorkingDirectory, hashCode, isHostAccessible, isPrivilegedMode, isShouldBeReused, logger, setBinds, setCommand, setCommand, setCommandParts, setContainerDef, setCopyToFileContainerPathMap, setDockerImageName, setEnv, setExposedPorts, setExtraHosts, setHostAccessible, setImage, setLabels, setLinkedContainers, setLogConsumers, setNetwork, setNetworkAliases, setNetworkMode, setPortBindings, setPrivilegedMode, setShmSize, setStartupAttempts, setStartupCheckStrategy, setTmpFsMapping, setVolumesFroms, setWaitStrategy, setWorkingDirectory, start, stop, toString, waitingFor, waitUntilContainerStarted, withAccessToHost, withClasspathResourceMapping, withClasspathResourceMapping, withCommand, withCommand, withCopyFileToContainer, withCopyToContainer, withCreateContainerCmdModifier, withEnv, withEnv, withExposedPorts, withExtraHost, withFileSystemBind, withImagePullPolicy, withLabel, withLabels, withLogConsumer, withMinimumRunningDuration, withNetwork, withNetworkAliases, withNetworkMode, withPrivilegedMode, withReuse, withSharedMemorySize, withStartupAttempts, withStartupCheckStrategy, withStartupTimeout, withTmpFs, withVolumesFrom, withWorkingDirectoryMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.testcontainers.containers.Container
addFileSystemBind, followOutput, followOutput, self, withEnv, withFileSystemBindMethods inherited from interface org.testcontainers.containers.ContainerState
copyFileFromContainer, copyFileToContainer, copyFileToContainer, execInContainer, execInContainer, execInContainer, execInContainer, execInContainerWithUser, execInContainerWithUser, getBoundPortNumbers, getContainerIpAddress, getCurrentContainerInfo, getFirstMappedPort, getHost, getLogs, getLogs, getMappedPort, isCreated, isHealthy, isRunningMethods inherited from interface org.testcontainers.lifecycle.Startable
close
-
Field Details
-
WAIT_FOR_BOLT
public static final org.testcontainers.containers.wait.strategy.WaitStrategy WAIT_FOR_BOLTDefault wait strategies
-
-
Constructor Details
-
Neo4jContainer
Creates a Neo4jContainer using a specific docker image.- Parameters:
dockerImageName- The docker image to use.
-
Neo4jContainer
public Neo4jContainer(org.testcontainers.utility.DockerImageName dockerImageName) Creates a Neo4jContainer using a specific docker image.- Parameters:
dockerImageName- The docker image to use.
-
-
Method Details
-
getLivenessCheckPortNumbers
- Specified by:
getLivenessCheckPortNumbersin interfaceorg.testcontainers.containers.wait.strategy.WaitStrategyTarget- Overrides:
getLivenessCheckPortNumbersin classorg.testcontainers.containers.GenericContainer<Neo4jContainer>
-
configure
protected void configure()- Overrides:
configurein classorg.testcontainers.containers.GenericContainer<Neo4jContainer>
-
getBoltUrl
- Returns:
- Bolt URL for use with Neo4j's Java-Driver.
-
getHttpUrl
- Returns:
- URL of the transactional HTTP endpoint.
-
getHttpsUrl
- Returns:
- URL of the transactional HTTPS endpoint.
-
acceptLicense
Accepts the license agreement of the container.- Returns:
- this
-
withAdminPassword
Sets the admin password for the default account (which isneo4j
). A null value or an empty string disables authentication.- Parameters:
adminPassword- The admin password for the default database account.- Returns:
- This container.
-
withoutAuthentication
Disables authentication.- Returns:
- This container.
-
withDatabase
Copies an existinggraph.dbfolder into the container. This can either be a classpath resource or a host resource. Please have a look at the factory methods inMountableFile.
If you want to map your database into the container instead of copying them, please use#withClasspathResourceMapping, but this will only work when your test does not run in a container itself.
Note: This method only works with Neo4j 3.5.
Mapping would work like this:@Container private static final Neo4jContainer databaseServer = new Neo4jContainer<>() .withClasspathResourceMapping("/test-graph.db", "/data/databases/graph.db", BindMode.READ_WRITE);- Parameters:
graphDb- The graph.db folder to copy into the container- Returns:
- This container.
- Throws:
IllegalArgumentException- If the database version is not 3.5.
-
withPlugins
Adds plugins to the given directory to the container. Ifpluginsdenotes a directory, than all of that directory is mapped to Neo4j's plugins. Otherwise, single resources are copied over.
If you want to map your plugins into the container instead of copying them, please use#withClasspathResourceMapping, but this will only work when your test does not run in a container itself.- Parameters:
plugins-- Returns:
- This container.
-
withNeo4jConfig
Adds Neo4j configuration properties to the container. The properties can be added as in the official Neo4j configuration, the method automatically translate them into the format required by the Neo4j container.- Parameters:
key- The key to configure, i.e.dbms.security.procedures.unrestrictedvalue- The value to set- Returns:
- This container.
-
getAdminPassword
- Returns:
- The admin password for the
neo4jaccount or literalnullif auth is disabled.
-
withPlugins
Registers one or more Neo4j plugins for server startup. The plugins are listed here- Parameters:
plugins- The Neo4j plugins that should get started with the server.- Returns:
- This container.
-
withRandomPassword
-