예제 #1
0
 @After
 public void tearDown() throws IOException {
   mongo.dropDatabase(MONGO_DB_NAME);
   mongo.close();
   neo.shutdown();
   FileUtils.deleteDirectory(new File(NEO_DB_DIR));
 }
 public void verify(String dbPath) {
   EmbeddedGraphDatabase graphDb = new EmbeddedGraphDatabase(dbPath);
   assertEquals(
       "Reference node did not have zero relationships.",
       0,
       IteratorUtil.count(graphDb.getReferenceNode().getRelationships()));
   assertEquals("There was more than one node.", 1, IteratorUtil.count(graphDb.getAllNodes()));
   graphDb.shutdown();
 }
예제 #3
0
  @Override
  public void shutdown() {
    if (TRACK_UNCLOSED_DATABASE_INSTANCES) startedButNotYetClosed.remove(new File(getStoreDir()));

    super.shutdown();
  }
 public void shutdown() {
   inner.shutdown();
   deleteRecursively(new File(storeDir));
 }
  @Test
  public void testLowGrabSize() {
    Map<String, String> config = new HashMap<String, String>();
    config.put("relationship_grab_size", "1");
    EmbeddedGraphDatabase graphDb = new EmbeddedGraphDatabase(getStorePath("neo2"), config);
    Transaction tx = graphDb.beginTx();
    Node node1 = graphDb.createNode();
    Node node2 = graphDb.createNode();
    node1.createRelationshipTo(node2, MyRelTypes.TEST);
    node2.createRelationshipTo(node1, MyRelTypes.TEST2);
    node1.createRelationshipTo(node2, MyRelTypes.TEST_TRAVERSAL);
    tx.success();
    tx.finish();
    tx = graphDb.beginTx();
    Set<Relationship> rels = new HashSet<Relationship>();
    RelationshipType types[] =
        new RelationshipType[] {MyRelTypes.TEST, MyRelTypes.TEST2, MyRelTypes.TEST_TRAVERSAL};
    graphDb.getConfig().getGraphDbModule().getNodeManager().clearCache();

    for (Relationship rel : node1.getRelationships(types)) {
      assertTrue(rels.add(rel));
    }
    assertEquals(3, rels.size());
    rels.clear();
    graphDb.getConfig().getGraphDbModule().getNodeManager().clearCache();
    for (Relationship rel : node1.getRelationships()) {
      assertTrue(rels.add(rel));
    }
    assertEquals(3, rels.size());

    rels.clear();
    graphDb.getConfig().getGraphDbModule().getNodeManager().clearCache();
    for (Relationship rel : node2.getRelationships(types)) {
      assertTrue(rels.add(rel));
    }
    assertEquals(3, rels.size());
    rels.clear();
    graphDb.getConfig().getGraphDbModule().getNodeManager().clearCache();
    for (Relationship rel : node2.getRelationships()) {
      assertTrue(rels.add(rel));
    }
    assertEquals(3, rels.size());

    rels.clear();
    graphDb.getConfig().getGraphDbModule().getNodeManager().clearCache();
    for (Relationship rel : node1.getRelationships(Direction.OUTGOING)) {
      assertTrue(rels.add(rel));
    }
    assertEquals(2, rels.size());
    rels.clear();
    graphDb.getConfig().getGraphDbModule().getNodeManager().clearCache();
    for (Relationship rel : node1.getRelationships(Direction.INCOMING)) {
      assertTrue(rels.add(rel));
    }
    assertEquals(1, rels.size());

    rels.clear();
    graphDb.getConfig().getGraphDbModule().getNodeManager().clearCache();
    for (Relationship rel : node2.getRelationships(Direction.OUTGOING)) {
      assertTrue(rels.add(rel));
    }
    assertEquals(1, rels.size());
    rels.clear();
    graphDb.getConfig().getGraphDbModule().getNodeManager().clearCache();
    for (Relationship rel : node2.getRelationships(Direction.INCOMING)) {
      assertTrue(rels.add(rel));
    }
    assertEquals(2, rels.size());

    tx.success();
    tx.finish();
    graphDb.shutdown();
  }