Permalink
Browse files

check for correct interfaces instead of relying on string comparison …

…when deleting indexes on cleanup
  • Loading branch information...
1 parent 2a7ac1d commit 107eb26c2115260b6468acc2c82c1c0a1bcd74df @sarmbruster sarmbruster committed Sep 10, 2012
Showing with 9 additions and 4 deletions.
  1. +9 −4 src/test/java/org/neo4j/rest/graphdb/Neo4jDatabaseCleaner.java
@@ -28,7 +28,10 @@
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Relationship;
import org.neo4j.graphdb.Transaction;
+import org.neo4j.graphdb.index.Index;
import org.neo4j.graphdb.index.IndexManager;
+import org.neo4j.graphdb.index.ReadableIndex;
+import org.neo4j.graphdb.index.RelationshipIndex;
import org.neo4j.rest.graphdb.index.RestAutoIndexer;
import org.neo4j.tooling.GlobalGraphOperations;
@@ -79,13 +82,15 @@ private void clearIndex(Map<String, Object> result) {
result.put("node-indexes", Arrays.asList(indexManager.nodeIndexNames()));
result.put("relationship-indexes", Arrays.asList(indexManager.relationshipIndexNames()));
for (String ix : indexManager.nodeIndexNames()) {
- if (!(RestAutoIndexer.NODE_AUTO_INDEX).equals(ix)) { // autoindex is not deletable
- indexManager.forNodes(ix).delete();
+ Index<Node> nodeIndex = indexManager.forNodes(ix);
+ if (!(nodeIndex instanceof ReadableIndex)) {
+ nodeIndex.delete();
}
}
for (String ix : indexManager.relationshipIndexNames()) {
- if (!(RestAutoIndexer.RELATIONSHIP_AUTO_INDEX).equals(ix)) { // autoindex is not deletable
- indexManager.forRelationships(ix).delete();
+ RelationshipIndex relationshipIndex = indexManager.forRelationships(ix);
+ if (!(relationshipIndex instanceof ReadableIndex)) {
+ relationshipIndex.delete();
}
}
}

0 comments on commit 107eb26

Please sign in to comment.