Search in sources :

Example 1 with SystemOutput

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

the class DontShutdownClient method main.

public static void main(String[] args) throws Exception {
    File path = new File(args[0]);
    File configFile = createDefaultConfigFile(path);
    GraphDatabaseShellServer server = new GraphDatabaseShellServer(path, false, configFile.getAbsolutePath());
    new SameJvmClient(new HashMap<>(), server, /* Temporary, switch back to SilentOutput once flaky test is resolved. */
    new SystemOutput(), InterruptSignalHandler.getHandler());
    server.shutdown();
// Intentionally don't shutdown the client
}
Also used : SameJvmClient(org.neo4j.shell.impl.SameJvmClient) GraphDatabaseShellServer(org.neo4j.shell.kernel.GraphDatabaseShellServer) SystemOutput(org.neo4j.shell.impl.SystemOutput) RmiPublicationIT.createDefaultConfigFile(org.neo4j.shell.RmiPublicationIT.createDefaultConfigFile) File(java.io.File)

Example 2 with SystemOutput

use of org.neo4j.shell.impl.SystemOutput 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);
}
Also used : Statement(org.junit.runners.model.Statement) TestRule(org.junit.rules.TestRule) EphemeralFileSystemRule(org.neo4j.test.rule.fs.EphemeralFileSystemRule) Settings(org.neo4j.kernel.configuration.Settings) ShellLobby(org.neo4j.shell.ShellLobby) HashMap(java.util.HashMap) GraphDatabaseFactory(org.neo4j.graphdb.factory.GraphDatabaseFactory) DatabaseRule(org.neo4j.test.rule.DatabaseRule) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) Assert.assertThat(org.junit.Assert.assertThat) GraphDatabaseBuilder(org.neo4j.graphdb.factory.GraphDatabaseBuilder) GraphDatabaseShellServer(org.neo4j.shell.kernel.GraphDatabaseShellServer) After(org.junit.After) SystemOutput(org.neo4j.shell.impl.SystemOutput) QueryLoggerIT.readAllLines(org.neo4j.kernel.impl.query.QueryLoggerIT.readAllLines) Transaction(org.neo4j.graphdb.Transaction) Before(org.junit.Before) PrintWriter(java.io.PrintWriter) ImpermanentDatabaseRule(org.neo4j.test.rule.ImpermanentDatabaseRule) Result(org.neo4j.graphdb.Result) Matchers.allOf(org.hamcrest.Matchers.allOf) StringWriter(java.io.StringWriter) TestDirectory(org.neo4j.test.rule.TestDirectory) IOException(java.io.IOException) Test(org.junit.Test) File(java.io.File) List(java.util.List) Rule(org.junit.Rule) ShellException(org.neo4j.shell.ShellException) Matchers.contains(org.hamcrest.Matchers.contains) ShellClient(org.neo4j.shell.ShellClient) GraphDatabaseSettings(org.neo4j.graphdb.factory.GraphDatabaseSettings) RuleChain.outerRule(org.junit.rules.RuleChain.outerRule) Matchers.containsString(org.hamcrest.Matchers.containsString) GraphDatabaseShellServer(org.neo4j.shell.kernel.GraphDatabaseShellServer) SystemOutput(org.neo4j.shell.impl.SystemOutput) HashMap(java.util.HashMap) PrintWriter(java.io.PrintWriter) Before(org.junit.Before)

Example 3 with SystemOutput

use of org.neo4j.shell.impl.SystemOutput 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);
}
Also used : GraphDatabaseShellServer(org.neo4j.shell.kernel.GraphDatabaseShellServer) SystemOutput(org.neo4j.shell.impl.SystemOutput)

Example 4 with SystemOutput

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

the class OutputAsWriterTest method setUp.

@Before
public void setUp() throws Exception {
    out = System.out;
    buffer = new ByteArrayOutputStream();
    System.setOut(new PrintStream(buffer));
    output = new SystemOutput();
    writer = new OutputAsWriter(output);
}
Also used : PrintStream(java.io.PrintStream) SystemOutput(org.neo4j.shell.impl.SystemOutput) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Before(org.junit.Before)

Aggregations

SystemOutput (org.neo4j.shell.impl.SystemOutput)4 GraphDatabaseShellServer (org.neo4j.shell.kernel.GraphDatabaseShellServer)3 File (java.io.File)2 Before (org.junit.Before)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 PrintStream (java.io.PrintStream)1 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Matchers.allOf (org.hamcrest.Matchers.allOf)1 Matchers.contains (org.hamcrest.Matchers.contains)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 After (org.junit.After)1 Assert.assertThat (org.junit.Assert.assertThat)1 Rule (org.junit.Rule)1 Test (org.junit.Test)1 RuleChain.outerRule (org.junit.rules.RuleChain.outerRule)1 TestRule (org.junit.rules.TestRule)1