Search in sources :

Example 1 with CollectingOutput

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

the class AppsIT method canDisableWelcomeMessage.

@Test
public void canDisableWelcomeMessage() throws Exception {
    Map<String, Serializable> values = genericMap("quiet", "true");
    final CollectingOutput out = new CollectingOutput();
    ShellClient client = new SameJvmClient(values, shellServer, out);
    client.shutdown();
    final String outString = out.asString();
    assertEquals("Shows welcome message: " + outString, false, outString.contains("Welcome to the Neo4j Shell! Enter 'help' for a list of commands"));
}
Also used : SameJvmClient(org.neo4j.shell.impl.SameJvmClient) Serializable(java.io.Serializable) CollectingOutput(org.neo4j.shell.impl.CollectingOutput) StringContains.containsString(org.hamcrest.core.StringContains.containsString) Test(org.junit.Test)

Example 2 with CollectingOutput

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

the class AppsIT method doesShowWelcomeMessage.

@Test
public void doesShowWelcomeMessage() throws Exception {
    Map<String, Serializable> values = genericMap();
    final CollectingOutput out = new CollectingOutput();
    ShellClient client = new SameJvmClient(values, shellServer, out);
    client.shutdown();
    final String outString = out.asString();
    assertEquals("Shows welcome message: " + outString, true, outString.contains("Welcome to the Neo4j Shell! Enter 'help' for a list of commands"));
}
Also used : SameJvmClient(org.neo4j.shell.impl.SameJvmClient) Serializable(java.io.Serializable) CollectingOutput(org.neo4j.shell.impl.CollectingOutput) StringContains.containsString(org.hamcrest.core.StringContains.containsString) Test(org.junit.Test)

Example 3 with CollectingOutput

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

the class AbstractShellIT method executeCommand.

public void executeCommand(ShellClient client, String command, String... theseLinesMustExistRegEx) throws Exception {
    CollectingOutput output = new CollectingOutput();
    client.evaluate(command, output);
    for (String lineThatMustExist : theseLinesMustExistRegEx) {
        boolean negative = lineThatMustExist.startsWith("!");
        lineThatMustExist = negative ? lineThatMustExist.substring(1) : lineThatMustExist;
        Pattern pattern = compile(lineThatMustExist);
        boolean found = false;
        for (String line : output) {
            if (pattern.matcher(line).find()) {
                found = true;
                break;
            }
        }
        assertTrue("Was expecting a line matching '" + lineThatMustExist + "', but didn't find any from out of " + Iterables.asCollection(output), found != negative);
    }
}
Also used : Pattern(java.util.regex.Pattern) CollectingOutput(org.neo4j.shell.impl.CollectingOutput)

Example 4 with CollectingOutput

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

the class AbstractShellIT method executeCommandExpectingException.

public void executeCommandExpectingException(String command, String errorMessageShouldContain) throws Exception {
    CollectingOutput output = new CollectingOutput();
    try {
        shellClient.evaluate(command, output);
        fail("Was expecting an exception");
    } catch (ShellException e) {
        String errorMessage = e.getMessage();
        if (!errorMessage.toLowerCase().contains(errorMessageShouldContain.toLowerCase())) {
            fail("Error message '" + errorMessage + "' should have contained '" + errorMessageShouldContain + "'");
        }
    }
}
Also used : CollectingOutput(org.neo4j.shell.impl.CollectingOutput)

Example 5 with CollectingOutput

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

the class TransactionGuardIntegrationTest method terminateLongRunningShellPeriodicCommitQuery.

@Test
public void terminateLongRunningShellPeriodicCommitQuery() throws Exception {
    GraphDatabaseAPI database = startDatabaseWithTimeoutCustomGuard();
    GraphDatabaseShellServer shellServer = getGraphDatabaseShellServer(database);
    try {
        SameJvmClient client = getShellClient(shellServer);
        CollectingOutput commandOutput = new CollectingOutput();
        URL url = prepareTestImportFile(8);
        execute(shellServer, commandOutput, client.getId(), "USING PERIODIC COMMIT 5 LOAD CSV FROM '" + url + "' AS line CREATE ();");
        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) URL(java.net.URL) Test(org.junit.Test)

Aggregations

CollectingOutput (org.neo4j.shell.impl.CollectingOutput)14 Test (org.junit.Test)8 SameJvmClient (org.neo4j.shell.impl.SameJvmClient)6 Serializable (java.io.Serializable)3 TestGraphDatabaseFactory (org.neo4j.test.TestGraphDatabaseFactory)3 Pattern (java.util.regex.Pattern)2 StringContains.containsString (org.hamcrest.core.StringContains.containsString)2 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)2 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)2 ShellException (org.neo4j.shell.ShellException)2 RemoteClient (org.neo4j.shell.impl.RemoteClient)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