Search in sources :

Example 6 with SameJvmClient

use of org.neo4j.shell.impl.SameJvmClient 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 7 with SameJvmClient

use of org.neo4j.shell.impl.SameJvmClient 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

SameJvmClient (org.neo4j.shell.impl.SameJvmClient)7 CollectingOutput (org.neo4j.shell.impl.CollectingOutput)6 Test (org.junit.Test)4 GraphDatabaseShellServer (org.neo4j.shell.kernel.GraphDatabaseShellServer)3 Serializable (java.io.Serializable)2 StringContains.containsString (org.hamcrest.core.StringContains.containsString)2 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)2 ShellException (org.neo4j.shell.ShellException)2 File (java.io.File)1 URL (java.net.URL)1 HashMap (java.util.HashMap)1 Before (org.junit.Before)1 RmiPublicationIT.createDefaultConfigFile (org.neo4j.shell.RmiPublicationIT.createDefaultConfigFile)1 SystemOutput (org.neo4j.shell.impl.SystemOutput)1 TestGraphDatabaseFactory (org.neo4j.test.TestGraphDatabaseFactory)1