1

我将嵌入式 Neo4j 用于具有以下规则配置的 JUnit 测试:

@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 进行连接,以便在某个时候查看测试数据库中的实际内容。不幸的是,既没有cypher-shell -a localhost:4711也没有neo4j-shell -port 5555得到连接。第一个不返回(仍然挂起),第二个返回Connection refused。我错过了什么?关于如何建立连接的任何想法?

4

1 回答 1

1

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

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

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

上面的代码会暂停100s,你可以点击控制台中的链接打开Neo4j浏览器查询数据库。

于 2020-03-16T23:37:26.547 回答