在测试调试期间连接到嵌入式Neo4j

时间:2018-06-07 10:13:47

标签: unit-testing neo4j neo4j-shell

我使用嵌入式Neo4j进行JUnit测试,并使用以下规则配置:

;

现在我想在调试(断点集)期间通过cypher-shell连接,以便在某个时候查看测试数据库中的实际内容。不幸的是,@Rule public Neo4jRule neo4jRule = new Neo4jRule() .withConfig("dbms.connector.1.enabled", "true") .withConfig("dbms.connector.1.listen_address", "localhost:4710") .withConfig("dbms.connector.1.type", "HTTP") .withConfig("dbms.connector.bolt.enabled", "true") .withConfig("dbms.connector.bolt.listen_address", ":4711") .withConfig("apoc.autoIndex.enabled", "true") .withConfig("ShellSettings.remote_shell_enabled", "true") .withConfig("ShellSettings.remote_shell_port", "5555") .withProcedure(apoc.index.FulltextIndex.class) .withProcedure(apoc.index.FreeTextSearch.class) .withProcedure(apoc.cypher.Cypher.class); cypher-shell -a localhost:4711都没有获得连接。第一个不返回(保持挂起),第二个返回neo4j-shell -port 5555。我错过了什么?关于如何建立联系的任何想法?

1 个答案:

答案 0 :(得分:1)

在调试过程中遇到断点时,嵌入式服务器也会停止响应。

如果要在单元测试期间查看数据库的状态,则需要在没有断点的情况下暂停执行。我的解决方案不是您想要的,但是您可以尝试一下

@Test
public void yourTest() throws IOException {
    try {
       System.out.pritnln(neo4j.httpURI());
       Thread.sleep(100000L);
    } catch (Exception e) {
       e.printStackTrace();
    }
}

以上代码将暂停100秒钟,您可以单击控制台中的链接以打开Neo4j浏览器并查询数据库。

相关问题