use of org.neo4j.shell.impl.CollectingOutput in project neo4j by neo4j.
the class FakeShellServer 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);
}
}
use of org.neo4j.shell.impl.CollectingOutput in project neo4j by neo4j.
the class FakeShellServer 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 + "'");
}
}
}
use of org.neo4j.shell.impl.CollectingOutput in project neo4j by neo4j.
the class FakeShellServer method doBefore.
@Before
public void doBefore() throws Exception {
db = (GraphDatabaseAPI) new TestGraphDatabaseFactory().newImpermanentDatabase();
shellServer = new FakeShellServer(db);
shellClient = new SameJvmClient(new HashMap<String, Serializable>(), shellServer, new CollectingOutput());
}
use of org.neo4j.shell.impl.CollectingOutput in project neo4j by neo4j.
the class ConfigurationIT method deprecatedConfigName.
@Test
public void deprecatedConfigName() throws Exception {
CollectingOutput output = new CollectingOutput();
client.evaluate("pwd", output);
assertTrue(output.asString().contains("(?)"));
}
use of org.neo4j.shell.impl.CollectingOutput in project neo4j by neo4j.
the class CtrlCTest method shouldInstallProvidedHandlerAfterReadingUserInput.
@Test
public void shouldInstallProvidedHandlerAfterReadingUserInput() throws Exception {
final StubCtrlCHandler handler = new StubCtrlCHandler();
AbstractClient client = new AbstractClient(new HashMap<String, Serializable>(), handler) {
@Override
public ShellServer getServer() {
try {
return new FakeShellServer(null);
} catch (RemoteException e) {
throw new RuntimeException(e);
}
}
@Override
public Output getOutput() {
try {
return new CollectingOutput();
} catch (RemoteException e) {
throw new RuntimeException(e);
}
}
@Override
public String readLine(String ignored) {
assertFalse("handler installed, expected it to not be there", handler.installed);
return "CYPHER 2.1 RETURN 42;";
}
@Override
public void evaluate(String output) {
assertTrue("handler not installed, but expected to be there", handler.installed);
end();
}
};
client.grabPrompt();
assertFalse("handler installed, expected it to not be there", handler.installed);
}
Aggregations