diff --git a/spring-data-neo4j-rest/src/test/java/org/springframework/data/neo4j/rest/support/Neo4jDatabaseCleaner.java b/spring-data-neo4j-rest/src/test/java/org/springframework/data/neo4j/rest/support/Neo4jDatabaseCleaner.java index 8c333894b..7dcde2ba2 100644 --- a/spring-data-neo4j-rest/src/test/java/org/springframework/data/neo4j/rest/support/Neo4jDatabaseCleaner.java +++ b/spring-data-neo4j-rest/src/test/java/org/springframework/data/neo4j/rest/support/Neo4jDatabaseCleaner.java @@ -36,10 +36,13 @@ public class Neo4jDatabaseCleaner { public Map cleanDb() { Map result = new HashMap(); - try (Transaction tx = graph.beginTx()) { + Transaction tx = graph.beginTx(); + try { removeNodes(result); clearIndex(result); tx.success(); + } finally { + tx.finish(); } return result; } diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/support/mapping/EntityRemoverTest.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/support/mapping/EntityRemoverTest.java index a35aced9c..c685bfc1c 100644 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/support/mapping/EntityRemoverTest.java +++ b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/support/mapping/EntityRemoverTest.java @@ -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 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 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(); } } }