jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1410265 - in /jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk: AbstractMongoConnectionTest.java multitenancy/MultiTenancyTest.java
Date Fri, 16 Nov 2012 09:31:00 GMT
Author: jukka
Date: Fri Nov 16 09:30:59 2012
New Revision: 1410265

URL: http://svn.apache.org/viewvc?rev=1410265&view=rev
Log:
OAK-293: MongoDB-based MicroKernel

Speed up test cleanup as suggested by Mete

Modified:
    jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/AbstractMongoConnectionTest.java
    jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/multitenancy/MultiTenancyTest.java

Modified: jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/AbstractMongoConnectionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/AbstractMongoConnectionTest.java?rev=1410265&r1=1410264&r2=1410265&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/AbstractMongoConnectionTest.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/AbstractMongoConnectionTest.java
Fri Nov 16 09:30:59 2012
@@ -23,6 +23,7 @@ import org.junit.Before;
 import org.junit.BeforeClass;
 
 import com.mongodb.BasicDBObject;
+import com.mongodb.DB;
 
 /**
  * Base class for test cases that need a {@link MongoConnection}
@@ -59,13 +60,20 @@ public class AbstractMongoConnectionTest
 
     @Before
     public void setUpConnection() throws Exception {
-        // the database will get automatically recreated
-        mongoConnection.getDB().dropDatabase(); 
+        dropCollections(mongoConnection.getDB());
     }
 
     @After
     public void tearDownConnection() throws Exception {
-        mongoConnection.getDB().dropDatabase();
+        dropCollections(mongoConnection.getDB());
+    }
+
+    protected void dropCollections(DB db) throws Exception {
+        for (String name : db.getCollectionNames()) {
+            if (!name.startsWith("system.")) {
+                db.getCollection(name).drop();
+            }
+        }
     }
 
 }

Modified: jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/multitenancy/MultiTenancyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/multitenancy/MultiTenancyTest.java?rev=1410265&r1=1410264&r2=1410265&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/multitenancy/MultiTenancyTest.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/multitenancy/MultiTenancyTest.java
Fri Nov 16 09:30:59 2012
@@ -74,8 +74,8 @@ public class MultiTenancyTest extends Ab
     }
 
     @After
-    public void dropDatabases() throws Exception {
-        mongoConnection2.getDB().dropDatabase();
+    public void dropCollections() throws Exception {
+        dropCollections(mongoConnection2.getDB());
         // DB1 handled by the AbstractMongoConnectionTest
     }
 



Mime
View raw message