use of org.neo4j.shell.kernel.GraphDatabaseShellServer in project neo4j by neo4j.
the class ShellBootstrapTest method shouldPickUpAllConfigOptions.
@Test
public void shouldPickUpAllConfigOptions() throws Exception {
// GIVEN
String host = "test";
int port = 1234;
String name = "my shell";
Config config = Config.embeddedDefaults(stringMap(ShellSettings.remote_shell_host.name(), host, ShellSettings.remote_shell_port.name(), valueOf(port), ShellSettings.remote_shell_name.name(), name, ShellSettings.remote_shell_enabled.name(), TRUE.toString()));
GraphDatabaseShellServer server = mock(GraphDatabaseShellServer.class);
// WHEN
server = new ShellBootstrap(config).enable(server);
// THEN
verify(server).makeRemotelyAvailable(host, port, name);
}
use of org.neo4j.shell.kernel.GraphDatabaseShellServer in project neo4j by neo4j.
the class StartClientIT method testShellCloseAfterCommandExecution.
@Test
public void testShellCloseAfterCommandExecution() throws Exception {
PrintStream out = mock(PrintStream.class);
PrintStream err = mock(PrintStream.class);
CtrlCHandler ctrlCHandler = mock(CtrlCHandler.class);
final GraphDatabaseShellServer databaseShellServer = mock(GraphDatabaseShellServer.class);
when(databaseShellServer.welcome(anyMap())).thenReturn(new Welcome(StringUtils.EMPTY, 1, StringUtils.EMPTY));
when(databaseShellServer.interpretLine(any(Serializable.class), any(String.class), any(Output.class))).thenReturn(new Response(StringUtils.EMPTY, Continuation.INPUT_COMPLETE));
StartClient startClient = new StartClient(out, err) {
@Override
protected GraphDatabaseShellServer getGraphDatabaseShellServer(File path, boolean readOnly, String configFile) throws RemoteException {
return databaseShellServer;
}
};
// when
startClient.start(new String[] { "-path", db.getStoreDir(), "-c", "CREATE (n {foo:'bar'});" }, ctrlCHandler);
// verify
verify(databaseShellServer).shutdown();
}
use of org.neo4j.shell.kernel.GraphDatabaseShellServer 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);
}
use of org.neo4j.shell.kernel.GraphDatabaseShellServer in project neo4j by neo4j.
the class TransactionGuardIntegrationTest method getGraphDatabaseShellServer.
private GraphDatabaseShellServer getGraphDatabaseShellServer(GraphDatabaseAPI database) throws RemoteException {
GraphDatabaseShellServer shellServer = new GraphDatabaseShellServer(database);
cleanupRule.add(shellServer);
return shellServer;
}
use of org.neo4j.shell.kernel.GraphDatabaseShellServer in project neo4j by neo4j.
the class ShellQueryLoggingIT method setup.
@Before
public void setup() throws Exception {
server = new GraphDatabaseShellServer(db.getGraphDatabaseAPI());
SystemOutput output = new SystemOutput(new PrintWriter(out));
client = ShellLobby.newClient(server, new HashMap<>(), output, action -> () -> {
});
// clear the output (remove the welcome message)
out.getBuffer().setLength(0);
}
Aggregations