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
 private Neo4jMatchers.Deferred<Label> labels(final Node myNode) {
   return new Neo4jMatchers.Deferred<Label>(dbRule.getGraphDatabaseService()) {
     @Override
     protected Iterable<Label> manifest() {
       return myNode.getLabels();
     }
   };
 }
  @Before
  public void setup() throws Exception {
    databaseDirectory = createTempDir();

    dbFactory = mock(LifecycleManagingDatabase.GraphFactory.class);
    when(dbFactory.newGraphDatabase(any(String.class), any(Map.class), any(Dependencies.class)))
        .thenReturn(dbRule.getGraphDatabaseAPI());
    theDatabase = newDatabase();
  }
Ejemplo n.º 4
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;
   }
 }
Ejemplo n.º 5
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();
    }
  }
Ejemplo n.º 6
0
 @Before
 public void clearDb() throws Throwable {
   createLinkedList(LIST_LENGTH, dbRule.getGraphDatabaseService());
 }