Last active
May 4, 2018 20:23
-
-
Save michaelahlers/461c95981a0a2ae346567e5a1ae7a5e7 to your computer and use it in GitHub Desktop.
Neo4j Impermanent Database with Bolt Connector
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
libraryDependencies ++= | |
"org.neo4j" % "neo4j-bolt" % "3.3.5" :: | |
//("org.neo4j" % "neo4j-bolt" % "3.3.5" % classifier "tests"):: | |
//"org.neo4j" % "neo4j-cypher" % "3.3.5" % :: | |
//("org.neo4j" % "neo4j-cypher" % "3.3.5" % classifier "tests") :: | |
//"org.neo4j" % "neo4j-io" % "3.3.5" % :: | |
("org.neo4j" % "neo4j-io" % "3.3.5" % classifier "tests") :: | |
("org.neo4j" % "neo4j-kernel" % "3.3.5") :: | |
("org.neo4j" % "neo4j-kernel" % "3.3.5" % classifier "tests") :: | |
Nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.neo4j.driver.v1._ | |
import org.neo4j.graphdb.factory.GraphDatabaseSettings | |
import org.neo4j.helpers.ListenSocketAddress._ | |
import org.neo4j.kernel.configuration.BoltConnector.EncryptionLevel._ | |
import org.neo4j.kernel.configuration.Connector.ConnectorType._ | |
import org.neo4j.kernel.configuration.Settings.{ FALSE, TRUE } | |
import org.neo4j.kernel.configuration._ | |
import org.neo4j.test._ | |
import org.scalatest._ | |
val host = "localhost" | |
val port = new ServerSocket(0).getLocalPort | |
val connector = new BoltConnector("(bolt-connector-integration-tests)") | |
val database = | |
new TestGraphDatabaseFactory().newImpermanentDatabaseBuilder() | |
.setConfig(connector.`type`, BOLT.name()) | |
.setConfig(connector.enabled, TRUE) | |
.setConfig(GraphDatabaseSettings.auth_enabled, FALSE) | |
.setConfig(connector.encryption_level, DISABLED.name()) | |
.setConfig(connector.listen_address, listenAddress(host, port)) | |
.newGraphDatabase() | |
val driver = GraphDatabase.driver(s"bolt://$host:$port") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A snippet illustrating how to create an impermanent, embedded Neo4j database with the Bolt connector enabled and listening on a random port. Won't work with Scala 2.12 possibly due to neo4j/neo4j#8832.