From 244e9bc6d85983acca690113ddc988de87ebbd75 Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Tue, 16 Aug 2011 10:30:29 +0200 Subject: [PATCH] DATADOC-238 - Reverted change in test case that introduced side effects. --- ...positoryIndexCreationIntegrationTests.java | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/RepositoryIndexCreationIntegrationTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/RepositoryIndexCreationIntegrationTests.java index b1add200d..3fe00dc03 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/RepositoryIndexCreationIntegrationTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/RepositoryIndexCreationIntegrationTests.java @@ -37,7 +37,7 @@ import com.mongodb.MongoException; /** * Integration test for index creation for query methods. - * + * * @author Oliver Gierke */ @RunWith(SpringJUnit4ClassRunner.class) @@ -46,12 +46,25 @@ public class RepositoryIndexCreationIntegrationTests { @Autowired MongoOperations operations; - + @After public void tearDown() { - operations.dropCollection(Person.class); + operations.execute(Person.class, new CollectionCallback() { + + public Void doInCollection(DBCollection collection) throws MongoException, DataAccessException { + + for (DBObject index : collection.getIndexInfo()) { + String indexName = index.get("name").toString(); + if (indexName.startsWith("find")) { + collection.dropIndex(indexName); + } + } + + return null; + } + }); } - + @Test public void testname() { operations.execute(Person.class, new CollectionCallback() { @@ -62,12 +75,12 @@ public class RepositoryIndexCreationIntegrationTests { assertThat(indexInfo.isEmpty(), is(false)); assertThat(indexInfo.size(), is(greaterThan(2))); assertThat(getIndexNamesFrom(indexInfo), hasItems("findByLastname", "findByFirstnameNotIn")); - + return null; } }); } - + private static List getIndexNamesFrom(List indexes) { List result = new ArrayList(); for (DBObject dbObject : indexes) {