use of org.neo4j.shell.ShellServer in project neo4j by neo4j.
the class BashVariableInterpreterTest method customInterpreter.
@Test
public void customInterpreter() throws Exception {
// GIVEN
interpreter.addReplacer("test", new Replacer() {
@Override
public String getReplacement(ShellServer server, Session session) throws ShellException {
return "Hello";
}
});
// WHEN
String interpreted = interpreter.interpret("\\test world", server, session);
// THEN
assertEquals("Hello world", interpreted);
}
use of org.neo4j.shell.ShellServer in project neo4j by neo4j.
the class RemoteClient method findRemoteServer.
private ShellServer findRemoteServer() throws ShellException {
try {
ShellServer result = (ShellServer) this.serverLocation.getBoundObject();
sayHi(result);
updateTimeForMostRecentConnection();
return result;
} catch (RemoteException e) {
throw ShellException.wrapCause(e);
}
}
use of org.neo4j.shell.ShellServer in project neo4j by neo4j.
the class ClientIT method shouldExitMultilineModeAfterGettingWarningOrError.
@Test
public void shouldExitMultilineModeAfterGettingWarningOrError() throws ShellException, RemoteException {
final CollectingOutput output = new CollectingOutput();
final String message = "Test method called";
final String prompt = "our test prompt";
AbstractClient client = new AbstractClient(null, null) {
@Override
public ShellServer getServer() {
ShellServer server = null;
try {
server = new GraphDatabaseShellServer(null) {
@Override
public Response interpretLine(Serializable clientId, String line, Output out) throws ShellException {
try {
out.println(message);
} catch (RemoteException ignored) {
}
return new Response(prompt, line.endsWith(";") ? Continuation.EXCEPTION_CAUGHT : Continuation.INPUT_INCOMPLETE);
}
};
} catch (RemoteException ignored) {
}
return server;
}
@Override
public Output getOutput() {
return output;
}
};
client.evaluate("RETURN ");
assertThat(client.getPrompt(), equalTo("> "));
client.evaluate("i;");
Set<String> messages = new HashSet<>();
for (String s : output) {
messages.add(s);
}
assertThat(messages, contains(message));
assertThat(client.getPrompt(), equalTo(prompt));
}
use of org.neo4j.shell.ShellServer in project neo4j by neo4j.
the class ClientIT method shouldHandleNormalInput.
@Test
public void shouldHandleNormalInput() throws ShellException, RemoteException {
final CollectingOutput output = new CollectingOutput();
final String message = "Test method called";
AbstractClient client = new AbstractClient(null, null) {
@Override
public ShellServer getServer() {
ShellServer server = null;
try {
server = new GraphDatabaseShellServer(null) {
@Override
public Response interpretLine(Serializable clientId, String line, Output out) throws ShellException {
try {
out.println(message);
} catch (RemoteException ignored) {
}
return new Response("", Continuation.INPUT_COMPLETE);
}
};
} catch (RemoteException ignored) {
}
return server;
}
@Override
public Output getOutput() {
return output;
}
};
client.evaluate("RETURN 1;");
Set<String> messages = new HashSet<>();
for (String s : output) {
messages.add(s);
}
assertThat(messages, contains(message));
}
use of org.neo4j.shell.ShellServer in project neo4j-documentation by neo4j.
the class Neo4jShell method startLocalShell.
private static void startLocalShell() throws Exception {
graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(databaseDirectory);
createExampleGraph();
ShellServer shellServer = new GraphDatabaseShellServer((GraphDatabaseAPI) graphDb);
ShellLobby.newClient(shellServer).grabPrompt();
shellServer.shutdown();
}
Aggregations