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 |
withAggregationFunction(Class<?> functionClass)
Configure the server to load the specified aggregation function definition class.
|
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.TestRule
public ServerControls newServer()
TestServerBuilder
ServerControls.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 TestServerBuilder
public Neo4jRule withConfig(org.neo4j.graphdb.config.Setting<?> key, String value)
TestServerBuilder
withConfig
in interface TestServerBuilder
key
- the config keyvalue
- the config valuepublic Neo4jRule withConfig(String key, String value)
withConfig
in interface TestServerBuilder
TestServerBuilder.withConfig(org.neo4j.graphdb.config.Setting, String)
public Neo4jRule withExtension(String mountPath, Class<?> extension)
TestServerBuilder
withExtension
in interface TestServerBuilder
mountPath
- 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)
TestServerBuilder
withExtension
in interface TestServerBuilder
mountPath
- 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)
TestServerBuilder
withFixture
in interface TestServerBuilder
cypherFileOrDirectory
- file with cypher statement, or directory containing ".cyp"-suffixed files.public Neo4jRule withFixture(String fixtureStatement)
TestServerBuilder
withFixture
in interface TestServerBuilder
fixtureStatement
- a cypher statementpublic Neo4jRule withFixture(Function<org.neo4j.graphdb.GraphDatabaseService,Void> fixtureFunction)
TestServerBuilder
GraphDatabaseService
instancewithFixture
in interface TestServerBuilder
fixtureFunction
- a fixture functionpublic Neo4jRule copyFrom(File sourceDirectory)
TestServerBuilder
copyFrom
in interface TestServerBuilder
sourceDirectory
- the directory to copy frompublic Neo4jRule withProcedure(Class<?> procedureClass)
TestServerBuilder
Procedure
, these will become available to call through
cypher.withProcedure
in interface TestServerBuilder
procedureClass
- a class containing one or more procedure definitionspublic Neo4jRule withFunction(Class<?> functionClass)
TestServerBuilder
UserFunction
, these will become available to call through
cypher.withFunction
in interface TestServerBuilder
functionClass
- a class containing one or more function definitionspublic Neo4jRule withAggregationFunction(Class<?> functionClass)
TestServerBuilder
UserAggregationFunction
, these will become available to call through
cypher.withAggregationFunction
in interface TestServerBuilder
functionClass
- 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.