Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2011-02-17 09:27:25 +0000
committerEike Stepper2011-02-17 09:27:25 +0000
commit952ba43620adc754d958fed730cc707d639b5b42 (patch)
treeaf4745619eded268462a079bfcbbd9c1a2684d98 /plugins/org.eclipse.emf.cdo.tests.mongodb
parent64fe8e0918c52f66279ab34ccd0cf8a26773c899 (diff)
downloadcdo-952ba43620adc754d958fed730cc707d639b5b42.tar.gz
cdo-952ba43620adc754d958fed730cc707d639b5b42.tar.xz
cdo-952ba43620adc754d958fed730cc707d639b5b42.zip
[337152] [Mongo] Create a MongoDBStore
https://bugs.eclipse.org/bugs/show_bug.cgi?id=337152
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.tests.mongodb')
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.mongodb/src/org/eclipse/emf/cdo/tests/mongodb/InitialTestMongoDB.java69
1 files changed, 68 insertions, 1 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests.mongodb/src/org/eclipse/emf/cdo/tests/mongodb/InitialTestMongoDB.java b/plugins/org.eclipse.emf.cdo.tests.mongodb/src/org/eclipse/emf/cdo/tests/mongodb/InitialTestMongoDB.java
index ba22af454a..13348870d0 100644
--- a/plugins/org.eclipse.emf.cdo.tests.mongodb/src/org/eclipse/emf/cdo/tests/mongodb/InitialTestMongoDB.java
+++ b/plugins/org.eclipse.emf.cdo.tests.mongodb/src/org/eclipse/emf/cdo/tests/mongodb/InitialTestMongoDB.java
@@ -11,6 +11,7 @@
package org.eclipse.emf.cdo.tests.mongodb;
import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.server.internal.mongodb.MongoDBStore;
import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.tests.AbstractCDOTest;
import org.eclipse.emf.cdo.tests.config.IScenario;
@@ -21,6 +22,15 @@ import org.eclipse.emf.cdo.tests.config.impl.SessionConfig.Net4j;
import org.eclipse.emf.cdo.tests.model1.Supplier;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.net4j.util.concurrent.ConcurrencyUtil;
+
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBCollection;
+import com.mongodb.DBCursor;
+import com.mongodb.DBObject;
+
+import java.io.PrintStream;
+
/**
* @author Eike Stepper
*/
@@ -37,7 +47,64 @@ public class InitialTestMongoDB extends AbstractCDOTest
resource.getContents().add(supplier);
transaction.commit();
- sleep(1000000L);
+ query(new BasicDBObject("revisions", new BasicDBObject("$elemMatch", new BasicDBObject("cdo_resource", 1))));
+ }
+
+ protected void query(DBObject query)
+ {
+ System.err.println();
+ System.err.println("Query:");
+ showDocument(query, "");
+ System.err.println();
+ System.err.println("Results:");
+
+ MongoDBStore store = (MongoDBStore)getRepository().getStore();
+ DBCollection collection = store.getCommitInfosCollection();
+ DBCursor cursor = collection.find(query);
+
+ int i = 0;
+ while (cursor.hasNext())
+ {
+ ++i;
+ System.out.println("" + i + " = ");
+ showDocument(cursor.next(), " ");
+ }
+
+ ConcurrencyUtil.sleep(1000000L);
+ }
+
+ protected void showDocument(DBObject doc, String level)
+ {
+ PrintStream pout = System.out;
+ for (String key : doc.keySet())
+ {
+ pout.print(level);
+ pout.print(key);
+ pout.print(" = ");
+
+ Object value = doc.get(key);
+ if (value instanceof DBObject)
+ {
+ DBObject child = (DBObject)value;
+ pout.println();
+ showDocument(child, level + " ");
+ }
+ else
+ {
+ if (value instanceof String)
+ {
+ pout.print("\"");
+ }
+
+ pout.print(value);
+ if (value instanceof String)
+ {
+ pout.print("\"");
+ }
+
+ pout.println();
+ }
+ }
}
@Override

Back to the top