use of org.neo4j.shell.kernel.GraphDatabaseShellServer in project neo4j by neo4j.
the class ConfigurationIT method before.
@Before
public void before() throws Exception {
db = (GraphDatabaseAPI) new TestGraphDatabaseFactory().newImpermanentDatabaseBuilder().newGraphDatabase();
server = new GraphDatabaseShellServer(db);
client = ShellLobby.newClient(server, InterruptSignalHandler.getHandler());
}
use of org.neo4j.shell.kernel.GraphDatabaseShellServer in project neo4j by neo4j.
the class AppsIT method startEvenIfReferenceNodeHasBeenDeleted.
@Test
public void startEvenIfReferenceNodeHasBeenDeleted() throws Exception {
Node node;
try (Transaction tx = db.beginTx()) {
node = db.createNode();
String name = "Test";
node.setProperty("name", name);
tx.success();
}
GraphDatabaseShellServer server = new GraphDatabaseShellServer(db);
ShellClient client = newShellClient(server);
executeCommand(client, "pwd", Pattern.quote("(?)"));
executeCommand(client, "ls " + node.getId(), "Test");
executeCommand(client, "cd -a " + node.getId());
executeCommand(client, "ls", "Test");
}
use of org.neo4j.shell.kernel.GraphDatabaseShellServer in project neo4j by neo4j.
the class StartClient method tryStartLocalServerAndClient.
private void tryStartLocalServerAndClient(File path, boolean readOnly, Args args, CtrlCHandler signalHandler) throws Exception {
String configFile = args.get(ARG_CONFIG, null);
final GraphDatabaseShellServer server = getGraphDatabaseShellServer(path, readOnly, configFile);
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
shutdownIfNecessary(server);
}
});
if (!isCommandLine(args)) {
out.println("NOTE: Local Neo4j graph database service at '" + path + "'");
}
ShellClient client = ShellLobby.newClient(server, getSessionVariablesFromArgs(args), new SystemOutput(out), signalHandler);
grabPromptOrJustExecuteCommand(client, args);
shutdownIfNecessary(server);
}
use of org.neo4j.shell.kernel.GraphDatabaseShellServer 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.kernel.GraphDatabaseShellServer 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));
}
Aggregations