public class Neo4jRule extends Object implements org.junit.rules.TestRule, TestServerBuilder
TestServerBuilder, exposing it as a JUnit
rule.
Note that it will try to start the web server on the standard 7474 port, but if that is not available
(typically because you already have an instance of Neo4j running) it will try other ports. Therefore it is necessary
for the test code to use httpURI() and then URI.resolve(String) to create the URIs to be invoked.| Constructor and Description |
|---|
Neo4jRule() |
Neo4jRule(File workingDirectory) |
| Modifier and Type | Method and Description |
|---|---|
org.junit.runners.model.Statement |
apply(org.junit.runners.model.Statement base,
org.junit.runner.Description description) |
URI |
boltURI() |
Neo4jRule |
copyFrom(File sourceDirectory)
Pre-populate the server with a database copied from the specified directory
|
org.neo4j.graphdb.config.Configuration |
getConfig() |
org.neo4j.graphdb.GraphDatabaseService |
getGraphDatabaseService() |
URI |
httpsURI() |
URI |
httpURI() |
ServerControls |
newServer()
Start a new server.
|
Neo4jRule |
withConfig(org.neo4j.graphdb.config.Setting<?> key,
String value)
Configure the Neo4j instance.
|
Neo4jRule |
withConfig(String key,
String value) |
Neo4jRule |
withExtension(String mountPath,
Class<?> extension)
Shortcut for configuring the server to use an unmanaged extension.
|
Neo4jRule |
withExtension(String mountPath,
String packageName)
Shortcut for configuring the server to find and mount all unmanaged extensions in the given package.
|
Neo4jRule |
withFixture(File cypherFileOrDirectory)
Data fixtures to inject upon server start.
|
Neo4jRule |
withFixture(Function<org.neo4j.graphdb.GraphDatabaseService,Void> fixtureFunction)
Data fixture to inject upon server start.
|
Neo4jRule |
withFixture(String fixtureStatement)
Data fixture to inject upon server start.
|
Neo4jRule |
withFunction(Class<?> functionClass)
Configure the server to load the specified function definition class.
|
Neo4jRule |
withProcedure(Class<?> procedureClass)
Configure the server to load the specified procedure definition class.
|
public Neo4jRule()
public Neo4jRule(File workingDirectory)
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base,
org.junit.runner.Description description)
apply in interface org.junit.rules.TestRulepublic ServerControls newServer()
TestServerBuilderServerControls.httpURI() method. You could also specify explicit ports using the
TestServerBuilder.withConfig(org.neo4j.graphdb.config.Setting, String) method. Please refer to the Neo4j Manual for
details on available configuration options.
When the returned controls are closed, the temporary directory the server used
will be removed as well.newServer in interface TestServerBuilderpublic Neo4jRule withConfig(org.neo4j.graphdb.config.Setting<?> key, String value)
TestServerBuilderwithConfig in interface TestServerBuilderkey - the config keyvalue - the config valuepublic Neo4jRule withConfig(String key, String value)
withConfig in interface TestServerBuilderTestServerBuilder.withConfig(org.neo4j.graphdb.config.Setting, String)public Neo4jRule withExtension(String mountPath, Class<?> extension)
TestServerBuilderwithExtension in interface TestServerBuildermountPath - the http path, relative to the server base URI, that this extension should be mounted at.extension - the extension class.public Neo4jRule withExtension(String mountPath, String packageName)
TestServerBuilderwithExtension in interface TestServerBuildermountPath - the http path, relative to the server base URI, that this extension should be mounted at.packageName - a java package with extension classes.TestServerBuilder.withExtension(String, Class)public Neo4jRule withFixture(File cypherFileOrDirectory)
TestServerBuilderwithFixture in interface TestServerBuildercypherFileOrDirectory - file with cypher statement, or directory containing ".cyp"-suffixed files.public Neo4jRule withFixture(String fixtureStatement)
TestServerBuilderwithFixture in interface TestServerBuilderfixtureStatement - a cypher statementpublic Neo4jRule withFixture(Function<org.neo4j.graphdb.GraphDatabaseService,Void> fixtureFunction)
TestServerBuilderGraphDatabaseService instancewithFixture in interface TestServerBuilderfixtureFunction - a fixture functionpublic Neo4jRule copyFrom(File sourceDirectory)
TestServerBuildercopyFrom in interface TestServerBuildersourceDirectory - the directory to copy frompublic Neo4jRule withProcedure(Class<?> procedureClass)
TestServerBuilderProcedure, these will become available to call through
cypher.withProcedure in interface TestServerBuilderprocedureClass - a class containing one or more procedure definitionspublic Neo4jRule withFunction(Class<?> functionClass)
TestServerBuilderUserFunction, these will become available to call through
cypher.withFunction in interface TestServerBuilderfunctionClass - a class containing one or more function definitionspublic URI boltURI()
public URI httpURI()
public URI httpsURI()
public org.neo4j.graphdb.GraphDatabaseService getGraphDatabaseService()
public org.neo4j.graphdb.config.Configuration getConfig()
Copyright © 2002–2017 The Neo4j Graph Database Project. All rights reserved.