我在http://neo4j.com/developer/java/之后将 Neo4j Bolt 驱动程序添加到我的应用程序中:
import org.neo4j.driver.v1.*;
Driver driver = GraphDatabase.driver( "bolt://localhost", AuthTokens.basic( "neo4j", "neo4j" ) );
Session session = driver.session();
session.run( "CREATE (a:Person {name:'Arthur', title:'King'})" );
StatementResult result = session.run( "MATCH (a:Person) WHERE a.name = 'Arthur' RETURN a.name AS name, a.title AS title" );
while ( result.hasNext() )
{
Record record = result.next();
System.out.println( record.get( "title" ).asString() + " " + record.get("name").asString() );
}
session.close();
driver.close();
但是,总是使用官方文档进行单元测试:
GraphDatabaseService db = new TestGraphDatabaseFactory()
.newImpermanentDatabaseBuilder()
所以如果我想以某种方式测试上面的代码,我必须GraphDatabase.driver( "bolt://localhost",...)
用GraphDatabaseService
来自测试的替换。我怎样才能做到这一点?in-memory driver
据我所知,我无法从那里提取任何类型的东西。