Пример #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();
    }
  }
Пример #2
0
 private Neo4jMatchers.Deferred<Label> labels(final Node myNode) {
   return new Neo4jMatchers.Deferred<Label>(dbRule.getGraphDatabaseService()) {
     @Override
     protected Iterable<Label> manifest() {
       return myNode.getLabels();
     }
   };
 }
Пример #3
0
 @SuppressWarnings("unused")
 private int iterateThroughPagedTraverser(PagedTraverser traversalPager) {
   try (Transaction transaction = dbRule.getGraphDatabaseService().beginTx()) {
     int count = 0;
     for (List<Path> paths : traversalPager) {
       count++;
     }
     transaction.success();
     return count;
   }
 }
Пример #4
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();
    }
  }
Пример #5
0
 @Before
 public void clearDb() throws Throwable {
   createLinkedList(LIST_LENGTH, dbRule.getGraphDatabaseService());
 }