Search in sources :

Example 11 with CollectingOutput

use of org.neo4j.shell.impl.CollectingOutput in project neo4j by neo4j.

the class TransactionGuardIntegrationTest method terminateLongRunningShellQuery.

@Test
public void terminateLongRunningShellQuery() throws Exception {
    GraphDatabaseAPI database = startDatabaseWithTimeout();
    GraphDatabaseShellServer shellServer = getGraphDatabaseShellServer(database);
    try {
        SameJvmClient client = getShellClient(shellServer);
        CollectingOutput commandOutput = new CollectingOutput();
        execute(shellServer, commandOutput, client.getId(), "begin Transaction");
        fakeClock.forward(3, TimeUnit.SECONDS);
        execute(shellServer, commandOutput, client.getId(), "create (n);");
        execute(shellServer, commandOutput, client.getId(), "commit");
        fail("Transaction should be already terminated.");
    } catch (ShellException e) {
        assertThat(e.getMessage(), containsString("Transaction timeout."));
    }
    assertDatabaseDoesNotHaveNodes(database);
}
Also used : SameJvmClient(org.neo4j.shell.impl.SameJvmClient) GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) GraphDatabaseShellServer(org.neo4j.shell.kernel.GraphDatabaseShellServer) CollectingOutput(org.neo4j.shell.impl.CollectingOutput) ShellException(org.neo4j.shell.ShellException) Test(org.junit.Test)

Example 12 with CollectingOutput

use of org.neo4j.shell.impl.CollectingOutput in project neo4j by neo4j.

the class TransactionGuardIntegrationTest method getShellClient.

private SameJvmClient getShellClient(GraphDatabaseShellServer shellServer) throws ShellException, RemoteException {
    SameJvmClient client = new SameJvmClient(new HashMap<>(), shellServer, new CollectingOutput(), InterruptSignalHandler.getHandler());
    cleanupRule.add(client);
    return client;
}
Also used : SameJvmClient(org.neo4j.shell.impl.SameJvmClient) CollectingOutput(org.neo4j.shell.impl.CollectingOutput)

Aggregations

CollectingOutput (org.neo4j.shell.impl.CollectingOutput)12 Test (org.junit.Test)6 SameJvmClient (org.neo4j.shell.impl.SameJvmClient)6 Serializable (java.io.Serializable)3 Pattern (java.util.regex.Pattern)2 StringContains.containsString (org.hamcrest.core.StringContains.containsString)2 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)2 ShellException (org.neo4j.shell.ShellException)2 GraphDatabaseShellServer (org.neo4j.shell.kernel.GraphDatabaseShellServer)2 URL (java.net.URL)1 RemoteException (java.rmi.RemoteException)1 HashMap (java.util.HashMap)1 Before (org.junit.Before)1 AbstractClient (org.neo4j.shell.impl.AbstractClient)1 TestGraphDatabaseFactory (org.neo4j.test.TestGraphDatabaseFactory)1