Ejemplo n.º 1
0
  @Test
  public void givenShellClientWhenOpenFileThenExecuteFileCommands() {
    // Given
    // an empty database

    // When
    StartClient.main(new String[] {"-file", getClass().getResource("/testshell.txt").getFile()});

    // Then
    try (Transaction tx = db.getGraphDatabaseService().beginTx()) {
      assertThat(
          (String) db.getGraphDatabaseService().getNodeById(0).getProperty("foo"), equalTo("bar"));
      tx.success();
    }
  }
Ejemplo n.º 2
0
  @Test
  public void givenShellClientWhenReadFromStdinThenExecutePipedCommands() throws IOException {
    // Given
    // an empty database

    // When
    InputStream realStdin = System.in;
    try {
      System.setIn(new ByteArrayInputStream("CREATE (n {foo:'bar'});".getBytes()));
      StartClient.main(new String[] {"-file", "-"});
    } finally {
      System.setIn(realStdin);
    }

    // Then
    try (Transaction tx = db.getGraphDatabaseService().beginTx()) {
      assertThat(
          (String) db.getGraphDatabaseService().getNodeById(0).getProperty("foo"), equalTo("bar"));
      tx.success();
    }
  }