From b28dbf2fc3ae972fbec4ce772e5a38a52be57e83 Mon Sep 17 00:00:00 2001 From: David Montag Date: Tue, 22 Mar 2011 15:08:54 -0700 Subject: [PATCH] Made test pass. --- .../support/IndexingNodeTypeStrategyTest.java | 37 +++++++++++++------ 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/IndexingNodeTypeStrategyTest.java b/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/IndexingNodeTypeStrategyTest.java index 3dda6dc42..29b7764e4 100644 --- a/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/IndexingNodeTypeStrategyTest.java +++ b/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/IndexingNodeTypeStrategyTest.java @@ -24,12 +24,11 @@ import java.util.HashSet; import java.util.Set; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertNull; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = {"classpath:org/springframework/data/graph/neo4j/support/Neo4jGraphPersistenceTest-context.xml", "classpath:org/springframework/data/graph/neo4j/support/IndexingNodeTypeStrategyOverride-context.xml"}) -//@Ignore public class IndexingNodeTypeStrategyTest { @Autowired @@ -65,28 +64,44 @@ public class IndexingNodeTypeStrategyTest { } @Test - @Ignore // TODO: Enable when indexing works properly. - @Transactional public void testPreEntityRemoval() throws Exception { + manualCleanDb(); + createThings(); Index typesIndex = graphDatabaseService.index().forNodes("__types__"); IndexHits thingHits; IndexHits subThingHits; - nodeTypeStrategy.preEntityRemoval(thing); + Transaction tx = graphDatabaseService.beginTx(); + try + { + nodeTypeStrategy.preEntityRemoval(thing); + tx.success(); + } + finally + { + tx.finish(); + } thingHits = typesIndex.get("className", thing.getClass().getName()); -// assertEquals(node(subThing), thingHits.getSingle()); // TODO: enable this when Neo4j indexing bug is fixed. - assertEquals(1, thingHits.size()); + assertEquals(node(subThing), thingHits.getSingle()); subThingHits = typesIndex.get("className", subThing.getClass().getName()); assertEquals(node(subThing), subThingHits.getSingle()); - nodeTypeStrategy.preEntityRemoval(subThing); + tx = graphDatabaseService.beginTx(); + try + { + nodeTypeStrategy.preEntityRemoval(subThing); + tx.success(); + } + finally + { + tx.finish(); + } thingHits = typesIndex.get("className", thing.getClass().getName()); - assertEquals( 0, thingHits.size()); + assertNull(thingHits.getSingle()); subThingHits = typesIndex.get("className", subThing.getClass().getName()); -// assertEquals( 0, subThingHits.size()); // TODO: enable this when Neo4j indexing bug is fixed. - assertTrue(subThingHits.size() <= 0); + assertNull(subThingHits.getSingle()); } @Test