DATAGRAPH-407 deleting entities with a read-only index

This commit is contained in:
Michael Hunger
2013-12-10 14:32:00 +01:00
parent 115ae5830a
commit 1f03bac49a
2 changed files with 12 additions and 3 deletions

View File

@@ -36,10 +36,13 @@ public class Neo4jDatabaseCleaner {
public Map<String, Object> cleanDb() {
Map<String, Object> result = new HashMap<String, Object>();
try (Transaction tx = graph.beginTx()) {
Transaction tx = graph.beginTx();
try {
removeNodes(result);
clearIndex(result);
tx.success();
} finally {
tx.finish();
}
return result;
}

View File

@@ -15,7 +15,8 @@ public class EntityRemoverTest {
@Test
public void testRemoveNodeEntityWithAutoIndex() throws Exception {
GraphDatabaseService db = new TestGraphDatabaseFactory().newImpermanentDatabase();
try (Transaction tx = db.beginTx()) {
Transaction tx = db.beginTx();
try {
AutoIndexer<Node> nodeAutoIndexer = db.index().getNodeAutoIndexer();
nodeAutoIndexer.setEnabled(true);
nodeAutoIndexer.startAutoIndexingProperty("foo");
@@ -27,12 +28,15 @@ public class EntityRemoverTest {
node.setProperty("foo", "bar");
infrastructure.getGraphDatabase().remove(node);
tx.success();
} finally {
tx.finish();
}
}
@Test
public void testRemoveRelationshipEntityWithAutoIndex() throws Exception {
GraphDatabaseService db = new TestGraphDatabaseFactory().newImpermanentDatabase();
try (Transaction tx = db.beginTx()) {
Transaction tx = db.beginTx();
try {
AutoIndexer<Relationship> autoIndexer = db.index().getRelationshipAutoIndexer();
autoIndexer.setEnabled(true);
autoIndexer.startAutoIndexingProperty("foo");
@@ -47,6 +51,8 @@ public class EntityRemoverTest {
relationship.setProperty("foo", "bar");
infrastructure.getGraphDatabase().remove(relationship);
tx.success();
} finally {
tx.finish();
}
}
}