You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rya.apache.org by mi...@apache.org on 2016/10/15 20:06:50 UTC

[30/69] [abbrv] [partial] incubator-rya git commit: RYA-198 Renaming Files

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/44a2dcf0/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/instance/MongoRyaInstanceDetailsRepository.java
----------------------------------------------------------------------
diff --git a/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/instance/MongoRyaInstanceDetailsRepository.java b/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/instance/MongoRyaInstanceDetailsRepository.java
new file mode 100644
index 0000000..dfefa8f
--- /dev/null
+++ b/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/instance/MongoRyaInstanceDetailsRepository.java
@@ -0,0 +1,144 @@
+package mvm.rya.mongodb.instance;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static java.util.Objects.requireNonNull;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
+import com.mongodb.BasicDBObject;
+import com.mongodb.DB;
+import com.mongodb.DBCollection;
+import com.mongodb.DBObject;
+import com.mongodb.MongoClient;
+import com.mongodb.WriteResult;
+
+import mvm.rya.api.instance.RyaDetails;
+import mvm.rya.api.instance.RyaDetailsRepository;
+import mvm.rya.mongodb.instance.MongoDetailsAdapter.MalformedRyaDetailsException;
+
+/**
+ * An implementation of {@link RyaDetailsRepository} that stores a Rya
+ * instance's {@link RyaDetails} in a Mongo document.
+ */
+@ParametersAreNonnullByDefault
+public class MongoRyaInstanceDetailsRepository implements RyaDetailsRepository {
+    private static final String INSTANCE_DETAILS_COLLECTION_NAME = "instance_details";
+
+    private final DB db;
+    private final String instanceName;
+
+    /**
+     * Constructs an instance of {@link MongoRyaInstanceDetailsRepository}.
+     *
+     * @param client - Connects to the instance of Mongo that hosts the Rya instance. (not null)
+     * @param instanceName - The name of the Rya instance this repository represents. (not null)
+     */
+    public MongoRyaInstanceDetailsRepository(final MongoClient client, final String instanceName) {
+        checkNotNull(client);
+        this.instanceName = requireNonNull( instanceName );
+        db = client.getDB(this.instanceName);
+    }
+
+    @Override
+    public boolean isInitialized() throws RyaDetailsRepositoryException {
+        final DBCollection col = db.getCollection(INSTANCE_DETAILS_COLLECTION_NAME);
+        return col.count() == 1;
+    }
+
+    @Override
+    public void initialize(final RyaDetails details) throws AlreadyInitializedException, RyaDetailsRepositoryException {
+        // Preconditions.
+        requireNonNull( details );
+
+        if(!details.getRyaInstanceName().equals( instanceName )) {
+            throw new RyaDetailsRepositoryException("The instance name that was in the provided 'details' does not match " +
+                    "the instance name that this repository is connected to. Make sure you're connected to the" +
+                    "correct Rya instance.");
+        }
+
+        if(isInitialized()) {
+            throw new AlreadyInitializedException("The repository has already been initialized for the Rya instance named '" +
+                    instanceName + "'.");
+        }
+
+        // Create the document that hosts the details if it has not been created yet.
+        final DBCollection col = db.createCollection(INSTANCE_DETAILS_COLLECTION_NAME, new BasicDBObject());
+
+        // Write the details to the collection.
+        col.insert(MongoDetailsAdapter.toDBObject(details));
+    }
+
+    @Override
+    public RyaDetails getRyaInstanceDetails() throws NotInitializedException, RyaDetailsRepositoryException {
+        // Preconditions.
+        if(!isInitialized()) {
+            throw new NotInitializedException("Could not fetch the details for the Rya instanced named '" +
+                    instanceName + "' because it has not been initialized yet.");
+        }
+
+        // Fetch the value from the collection.
+        final DBCollection col = db.getCollection(INSTANCE_DETAILS_COLLECTION_NAME);
+        //There should only be one document in the collection.
+        final DBObject mongoObj = col.findOne();
+
+        try{
+            // Deserialize it.
+            return MongoDetailsAdapter.toRyaDetails( mongoObj );
+        } catch (final MalformedRyaDetailsException e) {
+            throw new RyaDetailsRepositoryException("The existing details details are malformed.", e);
+        }
+    }
+
+    @Override
+    public void update(final RyaDetails oldDetails, final RyaDetails newDetails)
+            throws NotInitializedException, ConcurrentUpdateException, RyaDetailsRepositoryException {
+        // Preconditions.
+        requireNonNull(oldDetails);
+        requireNonNull(newDetails);
+
+        if(!newDetails.getRyaInstanceName().equals( instanceName )) {
+            throw new RyaDetailsRepositoryException("The instance name that was in the provided 'newDetails' does not match " +
+                    "the instance name that this repository is connected to. Make sure you're connected to the" +
+                    "correct Rya instance.");
+        }
+
+        if(!isInitialized()) {
+            throw new NotInitializedException("Could not update the details for the Rya instanced named '" +
+                    instanceName + "' because it has not been initialized yet.");
+        }
+
+        if(oldDetails.equals(newDetails)) {
+            return;
+        }
+
+        final DBCollection col = db.getCollection(INSTANCE_DETAILS_COLLECTION_NAME);
+        final DBObject oldObj = MongoDetailsAdapter.toDBObject(oldDetails);
+        final DBObject newObj = MongoDetailsAdapter.toDBObject(newDetails);
+        final WriteResult result = col.update(oldObj, newObj);
+
+        //since there is only 1 document, there should only be 1 update.
+        if(result.getN() != 1) {
+            throw new ConcurrentUpdateException("Could not update the details for the Rya instance named '" +
+                instanceName + "' because the old value is out of date.");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/44a2dcf0/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/iter/NonCloseableRyaStatementCursorIterator.java
----------------------------------------------------------------------
diff --git a/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/iter/NonCloseableRyaStatementCursorIterator.java b/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/iter/NonCloseableRyaStatementCursorIterator.java
new file mode 100644
index 0000000..ba37ca1
--- /dev/null
+++ b/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/iter/NonCloseableRyaStatementCursorIterator.java
@@ -0,0 +1,57 @@
+package mvm.rya.mongodb.iter;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+import java.util.Iterator;
+
+import mvm.rya.api.domain.RyaStatement;
+import mvm.rya.api.persist.RyaDAOException;
+
+public class NonCloseableRyaStatementCursorIterator implements Iterator<RyaStatement> {
+
+	RyaStatementCursorIterator iterator;
+	
+	@Override
+	public boolean hasNext() {
+		return iterator.hasNext();
+	}
+
+	@Override
+	public RyaStatement next() {
+		return iterator.next();
+	}
+
+	public NonCloseableRyaStatementCursorIterator(
+			RyaStatementCursorIterator iterator) {
+		this.iterator = iterator;
+	}
+
+	@Override
+	public void remove() {
+		try {
+			iterator.remove();
+		} catch (RyaDAOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/44a2dcf0/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/iter/RyaStatementBindingSetCursorIterator.java
----------------------------------------------------------------------
diff --git a/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/iter/RyaStatementBindingSetCursorIterator.java b/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/iter/RyaStatementBindingSetCursorIterator.java
new file mode 100644
index 0000000..d24cbdc
--- /dev/null
+++ b/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/iter/RyaStatementBindingSetCursorIterator.java
@@ -0,0 +1,125 @@
+package mvm.rya.mongodb.iter;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+import info.aduna.iteration.CloseableIteration;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map.Entry;
+
+import mvm.rya.api.RdfCloudTripleStoreUtils;
+import mvm.rya.api.domain.RyaStatement;
+import mvm.rya.api.persist.RyaDAOException;
+import mvm.rya.mongodb.dao.MongoDBStorageStrategy;
+
+import org.openrdf.query.BindingSet;
+
+import com.google.common.collect.Multimap;
+import com.mongodb.DBCollection;
+import com.mongodb.DBCursor;
+import com.mongodb.DBObject;
+
+public class RyaStatementBindingSetCursorIterator implements CloseableIteration<Entry<RyaStatement, BindingSet>, RyaDAOException> {
+
+	private DBCollection coll;
+	private Multimap<DBObject, BindingSet> rangeMap;
+	private Iterator<DBObject> queryIterator;
+	private Long maxResults;
+	private DBCursor resultCursor;
+	private RyaStatement currentStatement;
+	private Collection<BindingSet> currentBindingSetCollection;
+	private Iterator<BindingSet> currentBindingSetIterator;
+	private MongoDBStorageStrategy strategy;
+
+	public RyaStatementBindingSetCursorIterator(DBCollection coll,
+			Multimap<DBObject, BindingSet> rangeMap, MongoDBStorageStrategy strategy) {
+		this.coll = coll;
+		this.rangeMap = rangeMap;
+		this.queryIterator = rangeMap.keySet().iterator();
+		this.strategy = strategy;
+	}
+
+	@Override
+	public boolean hasNext() {
+		if (!currentBindingSetIteratorIsValid()) {
+			findNextResult();
+		}
+		return currentBindingSetIteratorIsValid();
+	}
+
+	@Override
+	public Entry<RyaStatement, BindingSet> next() {
+		if (!currentBindingSetIteratorIsValid()) {
+			findNextResult();
+		}
+		if (currentBindingSetIteratorIsValid()) {
+			BindingSet currentBindingSet = currentBindingSetIterator.next();
+			return new RdfCloudTripleStoreUtils.CustomEntry<RyaStatement, BindingSet>(currentStatement, currentBindingSet);
+		}
+		return null;
+	}
+	
+	private boolean currentBindingSetIteratorIsValid() {
+		return (currentBindingSetIterator != null) && currentBindingSetIterator.hasNext();
+	}
+
+	private void findNextResult() {
+		if (!currentResultCursorIsValid()) {
+			findNextValidResultCursor();
+		}
+		if (currentResultCursorIsValid()) {
+			// convert to Rya Statement
+			DBObject queryResult = resultCursor.next();
+			currentStatement = strategy.deserializeDBObject(queryResult);
+			currentBindingSetIterator = currentBindingSetCollection.iterator();
+		}
+	}
+
+	private void findNextValidResultCursor() {
+		while (queryIterator.hasNext()){
+			DBObject currentQuery = queryIterator.next();
+			resultCursor = coll.find(currentQuery);
+			currentBindingSetCollection = rangeMap.get(currentQuery);
+			if (resultCursor.hasNext()) return;
+		}
+	}
+	
+	private boolean currentResultCursorIsValid() {
+		return (resultCursor != null) && resultCursor.hasNext();
+	}
+
+
+	public void setMaxResults(Long maxResults) {
+		this.maxResults = maxResults;
+	}
+
+	@Override
+	public void close() throws RyaDAOException {
+		// TODO don't know what to do here
+	}
+
+	@Override
+	public void remove() throws RyaDAOException {
+		next();
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/44a2dcf0/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/iter/RyaStatementCursorIterable.java
----------------------------------------------------------------------
diff --git a/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/iter/RyaStatementCursorIterable.java b/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/iter/RyaStatementCursorIterable.java
new file mode 100644
index 0000000..83bd2d4
--- /dev/null
+++ b/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/iter/RyaStatementCursorIterable.java
@@ -0,0 +1,67 @@
+package mvm.rya.mongodb.iter;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+import info.aduna.iteration.CloseableIteration;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import mvm.rya.api.RdfCloudTripleStoreUtils;
+import mvm.rya.api.domain.RyaStatement;
+import mvm.rya.api.persist.RyaDAOException;
+
+import org.calrissian.mango.collect.CloseableIterable;
+import org.calrissian.mango.collect.CloseableIterator;
+import org.openrdf.query.BindingSet;
+
+import com.mongodb.DBCollection;
+import com.mongodb.DBCursor;
+import com.mongodb.DBObject;
+
+public class RyaStatementCursorIterable implements CloseableIterable<RyaStatement> {
+
+
+	private NonCloseableRyaStatementCursorIterator iterator;
+
+	public RyaStatementCursorIterable(NonCloseableRyaStatementCursorIterator iterator) {
+		this.iterator = iterator;
+	}
+
+	@Override
+	public Iterator<RyaStatement> iterator() {
+		// TODO Auto-generated method stub
+		return iterator;
+	}
+
+	@Override
+	public void closeQuietly() {
+		//TODO  don't know what to do here
+	}
+
+	@Override
+	public void close() throws IOException {
+		// TODO Auto-generated method stub
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/44a2dcf0/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/iter/RyaStatementCursorIterator.java
----------------------------------------------------------------------
diff --git a/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/iter/RyaStatementCursorIterator.java b/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/iter/RyaStatementCursorIterator.java
new file mode 100644
index 0000000..8df2c60
--- /dev/null
+++ b/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/iter/RyaStatementCursorIterator.java
@@ -0,0 +1,104 @@
+package mvm.rya.mongodb.iter;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+import info.aduna.iteration.CloseableIteration;
+
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import mvm.rya.api.RdfCloudTripleStoreUtils;
+import mvm.rya.api.domain.RyaStatement;
+import mvm.rya.api.persist.RyaDAOException;
+import mvm.rya.mongodb.dao.MongoDBStorageStrategy;
+
+import org.calrissian.mango.collect.CloseableIterable;
+import org.openrdf.query.BindingSet;
+
+import com.mongodb.DBCollection;
+import com.mongodb.DBCursor;
+import com.mongodb.DBObject;
+
+public class RyaStatementCursorIterator implements CloseableIteration<RyaStatement, RyaDAOException> {
+
+	private DBCollection coll;
+	private Iterator<DBObject> queryIterator;
+	private DBCursor currentCursor;
+	private MongoDBStorageStrategy strategy;
+	private Long maxResults;
+
+	public RyaStatementCursorIterator(DBCollection coll, Set<DBObject> queries, MongoDBStorageStrategy strategy) {
+		this.coll = coll;
+		this.queryIterator = queries.iterator();
+		this.strategy = strategy;
+	}
+
+	@Override
+	public boolean hasNext() {
+		if (!currentCursorIsValid()) {
+			findNextValidCursor();
+		}
+		return currentCursorIsValid();
+	}
+
+	@Override
+	public RyaStatement next() {
+		if (!currentCursorIsValid()) {
+			findNextValidCursor();
+		}
+		if (currentCursorIsValid()) {
+			// convert to Rya Statement
+			DBObject queryResult = currentCursor.next();
+			RyaStatement statement = strategy.deserializeDBObject(queryResult);
+			return statement;
+		}
+		return null;
+	}
+	
+	private void findNextValidCursor() {
+		while (queryIterator.hasNext()){
+			DBObject currentQuery = queryIterator.next();
+			currentCursor = coll.find(currentQuery);
+			if (currentCursor.hasNext()) break;
+		}
+	}
+	
+	private boolean currentCursorIsValid() {
+		return (currentCursor != null) && currentCursor.hasNext();
+	}
+
+
+	public void setMaxResults(Long maxResults) {
+		this.maxResults = maxResults;
+	}
+
+	@Override
+	public void close() throws RyaDAOException {
+		// TODO don't know what to do here
+	}
+
+	@Override
+	public void remove() throws RyaDAOException {
+		next();
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/44a2dcf0/dao/mongodb.rya/src/test/java/mvm/rya/mongodb/MongoDBQueryEngineTest.java
----------------------------------------------------------------------
diff --git a/dao/mongodb.rya/src/test/java/mvm/rya/mongodb/MongoDBQueryEngineTest.java b/dao/mongodb.rya/src/test/java/mvm/rya/mongodb/MongoDBQueryEngineTest.java
deleted file mode 100644
index 870115c..0000000
--- a/dao/mongodb.rya/src/test/java/mvm/rya/mongodb/MongoDBQueryEngineTest.java
+++ /dev/null
@@ -1,124 +0,0 @@
-package mvm.rya.mongodb;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *   http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import info.aduna.iteration.CloseableIteration;
-import mvm.rya.api.RdfCloudTripleStoreConfiguration;
-import mvm.rya.api.RdfCloudTripleStoreUtils;
-import mvm.rya.api.domain.RyaStatement;
-import mvm.rya.api.domain.RyaStatement.RyaStatementBuilder;
-import mvm.rya.api.domain.RyaURI;
-
-import org.apache.hadoop.conf.Configuration;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.openrdf.model.impl.URIImpl;
-import org.openrdf.query.BindingSet;
-import org.openrdf.query.impl.MapBindingSet;
-
-import com.google.common.collect.Lists;
-import com.mongodb.MongoClient;
-
-import de.flapdoodle.embed.mongo.distribution.Version;
-import de.flapdoodle.embed.mongo.tests.MongodForTestsFactory;
-
-public class MongoDBQueryEngineTest {
-
-    // private dao;
-    // private configuration;
-
-    private MongoDBQueryEngine engine;
-    private MongoDBRdfConfiguration configuration;
-
-    @Before
-    public void setUp() throws Exception {
-        // Set up Mongo/Rya
-        MongodForTestsFactory testsFactory = MongodForTestsFactory.with(Version.Main.PRODUCTION);
-        Configuration conf = new Configuration();
-        conf.set(MongoDBRdfConfiguration.USE_TEST_MONGO, "true");
-        conf.set(MongoDBRdfConfiguration.MONGO_DB_NAME, "test");
-        conf.set(MongoDBRdfConfiguration.MONGO_COLLECTION_PREFIX, "rya_");
-        conf.set(RdfCloudTripleStoreConfiguration.CONF_TBL_PREFIX, "rya_");
-        configuration = new MongoDBRdfConfiguration(conf);
-        MongoClient mongoClient = testsFactory.newMongo();
-        int port = mongoClient.getServerAddressList().get(0).getPort();
-        configuration.set(MongoDBRdfConfiguration.MONGO_INSTANCE_PORT, Integer.toString(port));
-
-        engine = new MongoDBQueryEngine(configuration, mongoClient);
-
-        // Add Data
-        MongoDBRyaDAO dao = new MongoDBRyaDAO(configuration, mongoClient);
-        dao.add(getStatement("u:a", "u:tt", "u:b"));
-        dao.add(getStatement("u:a", "u:tt", "u:c"));
-    }
-
-    private RyaStatement getStatement(String s, String p, String o) {
-        RyaStatementBuilder builder = new RyaStatementBuilder();
-        if (s != null)
-            builder.setSubject(new RyaURI(s));
-        if (p != null)
-            builder.setPredicate(new RyaURI(p));
-        if (o != null)
-            builder.setObject(new RyaURI(o));
-        return builder.build();
-    }
-
-    public int size(CloseableIteration<?, ?> iter) throws Exception {
-        int i = 0;
-        while (iter.hasNext()) {
-            i++;
-            iter.next();
-        }
-        return i;
-    }
-
-    @Test
-    public void statementQuery() throws Exception {
-        RyaStatement s = getStatement("u:a", null, null);
-        Assert.assertEquals(2, size(engine.query(s, configuration)));
-    }
-
-    @SuppressWarnings("unchecked")
-    @Test
-    public void bindingSetsQuery() throws Exception {
-        RyaStatement s = getStatement("u:a", null, null);
-        
-        MapBindingSet bs1 = new MapBindingSet();
-        bs1.addBinding("foo", new URIImpl("u:x"));
-
-        Map.Entry<RyaStatement, BindingSet> e1 = new RdfCloudTripleStoreUtils.CustomEntry<RyaStatement, BindingSet>(s, bs1);
-        Collection<Entry<RyaStatement, BindingSet>> stmts1 = Lists.newArrayList(e1);
-        Assert.assertEquals(2, size(engine.queryWithBindingSet(stmts1, configuration)));
-
-        
-        MapBindingSet bs2 = new MapBindingSet();
-        bs2.addBinding("foo", new URIImpl("u:y"));
-
-        Map.Entry<RyaStatement, BindingSet> e2 = new RdfCloudTripleStoreUtils.CustomEntry<RyaStatement, BindingSet>(s, bs2);
-
-        Collection<Entry<RyaStatement, BindingSet>> stmts2 = Lists.newArrayList(e1, e2);
-        Assert.assertEquals(4, size(engine.queryWithBindingSet(stmts2, configuration)));
-}
-}

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/44a2dcf0/dao/mongodb.rya/src/test/java/mvm/rya/mongodb/MongoDBRyaDAOIT.java
----------------------------------------------------------------------
diff --git a/dao/mongodb.rya/src/test/java/mvm/rya/mongodb/MongoDBRyaDAOIT.java b/dao/mongodb.rya/src/test/java/mvm/rya/mongodb/MongoDBRyaDAOIT.java
deleted file mode 100644
index 33531b5..0000000
--- a/dao/mongodb.rya/src/test/java/mvm/rya/mongodb/MongoDBRyaDAOIT.java
+++ /dev/null
@@ -1,139 +0,0 @@
-package mvm.rya.mongodb;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import static mvm.rya.mongodb.dao.SimpleMongoDBStorageStrategy.TIMESTAMP;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-
-import org.apache.hadoop.conf.Configuration;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.mongodb.DB;
-import com.mongodb.DBCollection;
-import com.mongodb.DBObject;
-import com.mongodb.MongoClient;
-import com.mongodb.MongoException;
-
-import de.flapdoodle.embed.mongo.distribution.Version;
-import de.flapdoodle.embed.mongo.tests.MongodForTestsFactory;
-import mvm.rya.api.RdfCloudTripleStoreConfiguration;
-import mvm.rya.api.domain.RyaStatement;
-import mvm.rya.api.domain.RyaStatement.RyaStatementBuilder;
-import mvm.rya.api.domain.RyaURI;
-import mvm.rya.api.persist.RyaDAOException;
-
-public class MongoDBRyaDAOIT {
-
-    private MongodForTestsFactory testsFactory;
-    private MongoDBRyaDAO dao;
-    private MongoDBRdfConfiguration configuration;
-    private MongoClient mongoClient;
-
-    @Before
-    public void setUp() throws IOException, RyaDAOException{
-        testsFactory = MongodForTestsFactory.with(Version.Main.PRODUCTION);
-           final Configuration conf = new Configuration();
-            conf.set(MongoDBRdfConfiguration.USE_TEST_MONGO, "true");
-            conf.set(MongoDBRdfConfiguration.MONGO_DB_NAME, "test");
-            conf.set(MongoDBRdfConfiguration.MONGO_COLLECTION_PREFIX, "rya_");
-            conf.set(RdfCloudTripleStoreConfiguration.CONF_TBL_PREFIX, "rya_");
-            configuration = new MongoDBRdfConfiguration(conf);
-            mongoClient = testsFactory.newMongo();
-            final int port = mongoClient.getServerAddressList().get(0).getPort();
-            configuration.set(MongoDBRdfConfiguration.MONGO_INSTANCE_PORT, Integer.toString(port));
-            dao = new MongoDBRyaDAO(configuration, mongoClient);
-    }
-
-    @Test
-    public void testDeleteWildcard() throws RyaDAOException {
-        final RyaStatementBuilder builder = new RyaStatementBuilder();
-        builder.setPredicate(new RyaURI("http://temp.com"));
-        dao.delete(builder.build(), configuration);
-    }
-
-
-    @Test
-    public void testAdd() throws RyaDAOException, MongoException, IOException {
-        final RyaStatementBuilder builder = new RyaStatementBuilder();
-        builder.setPredicate(new RyaURI("http://temp.com"));
-        builder.setSubject(new RyaURI("http://subject.com"));
-        builder.setObject(new RyaURI("http://object.com"));
-
-        final DB db = mongoClient.getDB(configuration.get(MongoDBRdfConfiguration.MONGO_DB_NAME));
-        final DBCollection coll = db.getCollection(configuration.getTriplesCollectionName());
-
-        dao.add(builder.build());
-
-        assertEquals(coll.count(),1);
-
-        final DBObject dbo = coll.findOne();
-        assertTrue(dbo.containsField(TIMESTAMP));
-    }
-
-    @Test
-    public void testDelete() throws RyaDAOException, MongoException, IOException {
-        final RyaStatementBuilder builder = new RyaStatementBuilder();
-        builder.setPredicate(new RyaURI("http://temp.com"));
-        builder.setSubject(new RyaURI("http://subject.com"));
-        builder.setObject(new RyaURI("http://object.com"));
-        final RyaStatement statement = builder.build();
-        final DB db = mongoClient.getDB(configuration.get(MongoDBRdfConfiguration.MONGO_DB_NAME));
-        final DBCollection coll = db.getCollection(configuration.getTriplesCollectionName());
-
-        dao.add(statement);
-
-        assertEquals(coll.count(),1);
-
-        dao.delete(statement, configuration);
-
-        assertEquals(coll.count(),0);
-
-    }
-
-    @Test
-    public void testDeleteWildcardSubjectWithContext() throws RyaDAOException, MongoException, IOException {
-        final RyaStatementBuilder builder = new RyaStatementBuilder();
-        builder.setPredicate(new RyaURI("http://temp.com"));
-        builder.setSubject(new RyaURI("http://subject.com"));
-        builder.setObject(new RyaURI("http://object.com"));
-        builder.setContext(new RyaURI("http://context.com"));
-        final RyaStatement statement = builder.build();
-
-        final DB db = mongoClient.getDB(configuration.get(MongoDBRdfConfiguration.MONGO_DB_NAME));
-        final DBCollection coll = db.getCollection(configuration.getTriplesCollectionName());
-
-        dao.add(statement);
-
-        assertEquals(coll.count(),1);
-
-        final RyaStatementBuilder builder2 = new RyaStatementBuilder();
-        builder2.setPredicate(new RyaURI("http://temp.com"));
-        builder2.setObject(new RyaURI("http://object.com"));
-        builder2.setContext(new RyaURI("http://context3.com"));
-        final RyaStatement query = builder2.build();
-
-        dao.delete(query, configuration);
-
-        assertEquals(coll.count(),1);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/44a2dcf0/dao/mongodb.rya/src/test/java/mvm/rya/mongodb/MongoDBRyaDAOTest.java
----------------------------------------------------------------------
diff --git a/dao/mongodb.rya/src/test/java/mvm/rya/mongodb/MongoDBRyaDAOTest.java b/dao/mongodb.rya/src/test/java/mvm/rya/mongodb/MongoDBRyaDAOTest.java
deleted file mode 100644
index dde0eda..0000000
--- a/dao/mongodb.rya/src/test/java/mvm/rya/mongodb/MongoDBRyaDAOTest.java
+++ /dev/null
@@ -1,137 +0,0 @@
-package mvm.rya.mongodb;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.IOException;
-
-import org.apache.hadoop.conf.Configuration;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.mongodb.DB;
-import com.mongodb.DBCollection;
-import com.mongodb.MongoClient;
-import com.mongodb.MongoException;
-
-import de.flapdoodle.embed.mongo.distribution.Version;
-import de.flapdoodle.embed.mongo.tests.MongodForTestsFactory;
-import mvm.rya.api.RdfCloudTripleStoreConfiguration;
-import mvm.rya.api.domain.RyaStatement;
-import mvm.rya.api.domain.RyaStatement.RyaStatementBuilder;
-import mvm.rya.api.domain.RyaURI;
-import mvm.rya.api.persist.RyaDAOException;
-
-public class MongoDBRyaDAOTest {
-
-	private MongodForTestsFactory testsFactory;
-	private MongoDBRyaDAO dao;
-	private MongoDBRdfConfiguration configuration;
-	private MongoClient mongoClient;
-
-	@Before
-	public void setUp() throws IOException, RyaDAOException{
-		testsFactory = MongodForTestsFactory.with(Version.Main.PRODUCTION);
-		final Configuration conf = new Configuration();
-        conf.set(MongoDBRdfConfiguration.USE_TEST_MONGO, "true");
-        conf.set(MongoDBRdfConfiguration.MONGO_DB_NAME, "test");
-        conf.set(MongoDBRdfConfiguration.MONGO_COLLECTION_PREFIX, "rya_");
-        conf.set(RdfCloudTripleStoreConfiguration.CONF_TBL_PREFIX, "rya_");
-        configuration = new MongoDBRdfConfiguration(conf);
-		mongoClient = testsFactory.newMongo();
-        final int port = mongoClient.getServerAddressList().get(0).getPort();
-        configuration.set(MongoDBRdfConfiguration.MONGO_INSTANCE_PORT, ""+port);
-		dao = new MongoDBRyaDAO(configuration, mongoClient);
-	}
-
-	@Test
-	public void testDeleteWildcard() throws RyaDAOException {
-		final RyaStatementBuilder builder = new RyaStatementBuilder();
-		builder.setPredicate(new RyaURI("http://temp.com"));
-		dao.delete(builder.build(), configuration);
-	}
-
-
-	@Test
-	public void testAdd() throws RyaDAOException, MongoException, IOException {
-		final RyaStatementBuilder builder = new RyaStatementBuilder();
-		builder.setPredicate(new RyaURI("http://temp.com"));
-		builder.setSubject(new RyaURI("http://subject.com"));
-		builder.setObject(new RyaURI("http://object.com"));
-
-		final DB db = mongoClient.getDB(configuration.get(MongoDBRdfConfiguration.MONGO_DB_NAME));
-        final DBCollection coll = db.getCollection(configuration.getTriplesCollectionName());
-
-		dao.add(builder.build());
-
-        assertEquals(coll.count(),1);
-
-	}
-
-	@Test
-	public void testDelete() throws RyaDAOException, MongoException, IOException {
-		final RyaStatementBuilder builder = new RyaStatementBuilder();
-		builder.setPredicate(new RyaURI("http://temp.com"));
-		builder.setSubject(new RyaURI("http://subject.com"));
-		builder.setObject(new RyaURI("http://object.com"));
-		final RyaStatement statement = builder.build();
-
-		final DB db = mongoClient.getDB(configuration.get(MongoDBRdfConfiguration.MONGO_DB_NAME));
-        final DBCollection coll = db.getCollection(configuration.getTriplesCollectionName());
-
-		dao.add(statement);
-
-        assertEquals(coll.count(),1);
-
-        dao.delete(statement, configuration);
-
-        assertEquals(coll.count(),0);
-
-	}
-
-	@Test
-	public void testDeleteWildcardSubjectWithContext() throws RyaDAOException, MongoException, IOException {
-		final RyaStatementBuilder builder = new RyaStatementBuilder();
-		builder.setPredicate(new RyaURI("http://temp.com"));
-		builder.setSubject(new RyaURI("http://subject.com"));
-		builder.setObject(new RyaURI("http://object.com"));
-		builder.setContext(new RyaURI("http://context.com"));
-		final RyaStatement statement = builder.build();
-
-		final DB db = mongoClient.getDB(configuration.get(MongoDBRdfConfiguration.MONGO_DB_NAME));
-        final DBCollection coll = db.getCollection(configuration.getTriplesCollectionName());
-
-		dao.add(statement);
-
-        assertEquals(coll.count(),1);
-
-		final RyaStatementBuilder builder2 = new RyaStatementBuilder();
-		builder2.setPredicate(new RyaURI("http://temp.com"));
-		builder2.setObject(new RyaURI("http://object.com"));
-		builder2.setContext(new RyaURI("http://context3.com"));
-		final RyaStatement query = builder2.build();
-
-        dao.delete(query, configuration);
-
-        assertEquals(coll.count(),1);
-
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/44a2dcf0/dao/mongodb.rya/src/test/java/mvm/rya/mongodb/SimpleMongoDBStorageStrategyTest.java
----------------------------------------------------------------------
diff --git a/dao/mongodb.rya/src/test/java/mvm/rya/mongodb/SimpleMongoDBStorageStrategyTest.java b/dao/mongodb.rya/src/test/java/mvm/rya/mongodb/SimpleMongoDBStorageStrategyTest.java
deleted file mode 100644
index be5fdb7..0000000
--- a/dao/mongodb.rya/src/test/java/mvm/rya/mongodb/SimpleMongoDBStorageStrategyTest.java
+++ /dev/null
@@ -1,85 +0,0 @@
-package mvm.rya.mongodb;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import static org.junit.Assert.assertEquals;
-import static org.openrdf.model.vocabulary.XMLSchema.ANYURI;
-
-import java.io.IOException;
-
-import org.junit.Test;
-
-import com.mongodb.BasicDBObject;
-import com.mongodb.DBObject;
-import com.mongodb.MongoException;
-
-import mvm.rya.api.domain.RyaStatement;
-import mvm.rya.api.domain.RyaStatement.RyaStatementBuilder;
-import mvm.rya.api.domain.RyaURI;
-import mvm.rya.api.persist.RyaDAOException;
-import mvm.rya.mongodb.dao.SimpleMongoDBStorageStrategy;
-
-public class SimpleMongoDBStorageStrategyTest {
-    private static final String SUBJECT = "http://subject.com";
-    private static final String PREDICATE = "http://temp.com";
-    private static final String OBJECT = "http://object.com";
-    private static final String CONTEXT = "http://context.com";
-
-    private static final RyaStatement testStatement;
-    private static final DBObject testDBO;
-    private final SimpleMongoDBStorageStrategy storageStrategy = new SimpleMongoDBStorageStrategy();
-
-    static {
-        final RyaStatementBuilder builder = new RyaStatementBuilder();
-        builder.setPredicate(new RyaURI(PREDICATE));
-        builder.setSubject(new RyaURI(SUBJECT));
-        builder.setObject(new RyaURI(OBJECT));
-        builder.setContext(new RyaURI(CONTEXT));
-        builder.setTimestamp(null);
-        testStatement = builder.build();
-
-        testDBO = new BasicDBObject();
-        testDBO.put("_id", "d5f8fea0e85300478da2c9b4e132c69502e21221");
-        testDBO.put("subject", SUBJECT);
-        testDBO.put("predicate", PREDICATE);
-        testDBO.put("object", OBJECT);
-        testDBO.put("objectType", ANYURI.stringValue());
-        testDBO.put("context", CONTEXT);
-        testDBO.put("insertTimestamp", null);
-    }
-
-    @Test
-    public void testSerializeStatementToDBO() throws RyaDAOException, MongoException, IOException {
-
-        final DBObject dbo = storageStrategy.serialize(testStatement);
-        assertEquals(testDBO, dbo);
-    }
-
-    @Test
-    public void testDeSerializeStatementToDBO() throws RyaDAOException, MongoException, IOException {
-        final RyaStatement statement = storageStrategy.deserializeDBObject(testDBO);
-        /**
-         * Since RyaStatement creates a timestamp using JVM time if the timestamp is null, we want to re-null it
-         * for this test.  Timestamp is created at insert time by the Server, this test
-         * can be found in the RyaDAO.
-         */
-        statement.setTimestamp(null);
-        assertEquals(testStatement, statement);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/44a2dcf0/dao/mongodb.rya/src/test/java/mvm/rya/mongodb/instance/MongoDetailsAdapterTest.java
----------------------------------------------------------------------
diff --git a/dao/mongodb.rya/src/test/java/mvm/rya/mongodb/instance/MongoDetailsAdapterTest.java b/dao/mongodb.rya/src/test/java/mvm/rya/mongodb/instance/MongoDetailsAdapterTest.java
deleted file mode 100644
index 9faa595..0000000
--- a/dao/mongodb.rya/src/test/java/mvm/rya/mongodb/instance/MongoDetailsAdapterTest.java
+++ /dev/null
@@ -1,296 +0,0 @@
-package mvm.rya.mongodb.instance;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.Date;
-
-import org.junit.Test;
-
-import com.google.common.base.Optional;
-import com.mongodb.BasicDBObject;
-import com.mongodb.DBObject;
-import com.mongodb.util.JSON;
-
-import mvm.rya.api.instance.RyaDetails;
-import mvm.rya.api.instance.RyaDetails.EntityCentricIndexDetails;
-import mvm.rya.api.instance.RyaDetails.FreeTextIndexDetails;
-import mvm.rya.api.instance.RyaDetails.GeoIndexDetails;
-import mvm.rya.api.instance.RyaDetails.JoinSelectivityDetails;
-import mvm.rya.api.instance.RyaDetails.PCJIndexDetails;
-import mvm.rya.api.instance.RyaDetails.PCJIndexDetails.FluoDetails;
-import mvm.rya.api.instance.RyaDetails.PCJIndexDetails.PCJDetails;
-import mvm.rya.api.instance.RyaDetails.PCJIndexDetails.PCJDetails.PCJUpdateStrategy;
-import mvm.rya.api.instance.RyaDetails.ProspectorDetails;
-import mvm.rya.api.instance.RyaDetails.TemporalIndexDetails;
-import mvm.rya.mongodb.instance.MongoDetailsAdapter.MalformedRyaDetailsException;
-
-/**
- * Tests the methods of {@link MongoDetailsAdapter}.
- */
-public class MongoDetailsAdapterTest {
-
-    @Test
-    public void ryaDetailsToMongoTest() {
-        // Convert the Details into a Mongo DB OBject.
-        final RyaDetails details = RyaDetails.builder()
-            .setRyaInstanceName("test")
-            .setRyaVersion("1")
-            .setEntityCentricIndexDetails(new EntityCentricIndexDetails(true))
-            .setGeoIndexDetails(new GeoIndexDetails(true))
-            .setPCJIndexDetails(
-                PCJIndexDetails.builder()
-                .setEnabled(true)
-                .setFluoDetails(new FluoDetails("fluo"))
-                .addPCJDetails(
-                        PCJDetails.builder()
-                        .setId("pcj_0")
-                        .setUpdateStrategy(PCJUpdateStrategy.BATCH)
-                        .setLastUpdateTime(new Date(0L)))
-                .addPCJDetails(
-                        PCJDetails.builder()
-                        .setId("pcj_1")
-                        .setUpdateStrategy(PCJUpdateStrategy.BATCH)
-                        .setLastUpdateTime(new Date(1L))))
-            .setTemporalIndexDetails(new TemporalIndexDetails(true))
-            .setFreeTextDetails(new FreeTextIndexDetails(true))
-            .setProspectorDetails(new ProspectorDetails(Optional.fromNullable(new Date(0L))))
-            .setJoinSelectivityDetails(new JoinSelectivityDetails(Optional.fromNullable(new Date(1L))))
-            .build();
-
-        final BasicDBObject actual = MongoDetailsAdapter.toDBObject(details);
-
-        // Ensure it matches the expected object.
-        final DBObject expected = (DBObject) JSON.parse(
-            "{ "
-            + "instanceName : \"test\","
-            + "version : \"1\","
-            + "entityCentricDetails : true,"
-            + "geoDetails : true,"
-            + "pcjDetails : {"
-            +    "enabled : true ,"
-            +    "fluoName : \"fluo\","
-            +    "pcjs : [ "
-            +       "{"
-            +          "id : \"pcj_0\","
-            +          "updateStrategy : \"BATCH\","
-            +          "lastUpdate : { $date : \"1970-01-01T00:00:00.000Z\"}"
-            +       "},"
-            +       "{"
-            +          "id : \"pcj_1\","
-            +          "updateStrategy : \"BATCH\","
-            +          "lastUpdate : { $date : \"1970-01-01T00:00:00.001Z\"}"
-            +       "}]"
-            + "},"
-            + "temporalDetails : true,"
-            + "freeTextDetails : true,"
-            + "prospectorDetails : { $date : \"1970-01-01T00:00:00.000Z\"},"
-            + "joinSelectivitiyDetails : { $date : \"1970-01-01T00:00:00.001Z\"}"
-          + "}"
-        );
-
-        assertEquals(expected.toString(), actual.toString());
-    }
-
-    @Test
-    public void mongoToRyaDetailsTest() throws MalformedRyaDetailsException {
-        // Convert the Mongo object into a RyaDetails.
-        final BasicDBObject mongo = (BasicDBObject) JSON.parse(
-            "{ "
-            + "instanceName : \"test\","
-            + "version : \"1\","
-            + "entityCentricDetails : true,"
-            + "geoDetails : true,"
-            + "pcjDetails : {"
-            +    "enabled : true ,"
-            +    "fluoName : \"fluo\","
-            +    "pcjs : [ "
-            +       "{"
-            +          "id : \"pcj_0\","
-            +          "updateStrategy : \"BATCH\","
-            +          "lastUpdate : { $date : \"1970-01-01T00:00:00.000Z\"}"
-            +       "},"
-            +       "{"
-            +          "id : \"pcj_1\","
-            +          "updateStrategy : \"BATCH\","
-            +          "lastUpdate : { $date : \"1970-01-01T00:00:00.001Z\"}"
-            +       "}]"
-            + "},"
-            + "temporalDetails : true,"
-            + "freeTextDetails : true,"
-            + "prospectorDetails : { $date : \"1970-01-01T00:00:00.000Z\"},"
-            + "joinSelectivitiyDetails : { $date : \"1970-01-01T00:00:00.001Z\"}"
-          + "}"
-        );
-
-        final RyaDetails actual = MongoDetailsAdapter.toRyaDetails(mongo);
-
-        // Ensure it matches the expected object.
-        final RyaDetails expected = RyaDetails.builder()
-            .setRyaInstanceName("test")
-            .setRyaVersion("1")
-            .setEntityCentricIndexDetails(new EntityCentricIndexDetails(true))
-            .setGeoIndexDetails(new GeoIndexDetails(true))
-            .setPCJIndexDetails(
-                PCJIndexDetails.builder()
-                    .setEnabled(true)
-                    .setFluoDetails(new FluoDetails("fluo"))
-                    .addPCJDetails(
-                        PCJDetails.builder()
-                            .setId("pcj_0")
-                            .setUpdateStrategy(PCJUpdateStrategy.BATCH)
-                            .setLastUpdateTime(new Date(0L)))
-                    .addPCJDetails(
-                            PCJDetails.builder()
-                                .setId("pcj_1")
-                                .setUpdateStrategy(PCJUpdateStrategy.BATCH)
-                                .setLastUpdateTime(new Date(1L))))
-            .setTemporalIndexDetails(new TemporalIndexDetails(true))
-            .setFreeTextDetails(new FreeTextIndexDetails(true))
-            .setProspectorDetails(new ProspectorDetails(Optional.<Date>fromNullable(new Date(0L))))
-            .setJoinSelectivityDetails(new JoinSelectivityDetails(Optional.<Date>fromNullable(new Date(1L))))
-            .build();
-
-        assertEquals(expected, actual);
-    }
-
-    @Test
-    public void absentOptionalToRyaDetailsTest() throws MalformedRyaDetailsException {
-        // Convert the Mongo object into a RyaDetails.
-        final BasicDBObject mongo = (BasicDBObject) JSON.parse(
-                "{ "
-                + "instanceName : \"test\","
-                + "version : \"1\","
-                + "entityCentricDetails : true,"
-                + "geoDetails : false,"
-                + "pcjDetails : {"
-                +    "enabled : false,"
-                +    "fluoName : \"fluo\","
-                +    "pcjs : [ "
-                +       "{"
-                +          "id : \"pcj_1\","
-                +       "}"
-                +    "]"
-                + "},"
-                + "temporalDetails : false,"
-                + "freeTextDetails : true,"
-                + "prospectorDetails : null,"
-                + "joinSelectivitiyDetails : null"
-              + "}"
-            );
-        final RyaDetails actual = MongoDetailsAdapter.toRyaDetails(mongo);
-
-        // Ensure it matches the expected object.
-        final RyaDetails expected = RyaDetails.builder()
-            .setRyaInstanceName("test")
-            .setRyaVersion("1")
-            .setEntityCentricIndexDetails(new EntityCentricIndexDetails(true))
-            .setGeoIndexDetails(new GeoIndexDetails(false))
-            .setPCJIndexDetails(
-                    PCJIndexDetails.builder()
-                    .setEnabled(false)
-                    .setFluoDetails(new FluoDetails("fluo"))
-                    .addPCJDetails(
-                        PCJDetails.builder()
-                            .setId("pcj_1")
-                            .setLastUpdateTime(null)))
-            .setTemporalIndexDetails(new TemporalIndexDetails(false))
-            .setFreeTextDetails(new FreeTextIndexDetails(true))
-            .setProspectorDetails(new ProspectorDetails(Optional.<Date>absent()))
-            .setJoinSelectivityDetails(new JoinSelectivityDetails(Optional.<Date>absent()))
-            .build();
-
-        assertEquals(expected, actual);
-    }
-
-    @Test
-    public void absentOptionalToMongoTest() {
-        // Convert the Details into a Mongo DB OBject.
-        final RyaDetails details = RyaDetails.builder()
-            .setRyaInstanceName("test")
-            .setRyaVersion("1")
-            .setEntityCentricIndexDetails(new EntityCentricIndexDetails(true))
-            .setGeoIndexDetails(new GeoIndexDetails(false))
-            .setPCJIndexDetails(
-                PCJIndexDetails.builder()
-                    .setEnabled(true)
-                    .setFluoDetails(new FluoDetails("fluo")))
-            .setTemporalIndexDetails(new TemporalIndexDetails(false))
-            .setFreeTextDetails(new FreeTextIndexDetails(true))
-            .setProspectorDetails(new ProspectorDetails(Optional.<Date>absent()))
-            .setJoinSelectivityDetails(new JoinSelectivityDetails(Optional.<Date>absent()))
-            .build();
-
-        final DBObject actual = MongoDetailsAdapter.toDBObject(details);
-
-        // Ensure it matches the expected object.
-        final BasicDBObject expected = (BasicDBObject) JSON.parse(
-                "{ "
-                + "instanceName : \"test\","
-                + "version : \"1\","
-                + "entityCentricDetails : true,"
-                + "geoDetails : false,"
-                + "pcjDetails : {"
-                +    "enabled : true,"
-                +    "fluoName : \"fluo\","
-                +    "pcjs : [ ]"
-                + "},"
-                + "temporalDetails : false,"
-                + "freeTextDetails : true"
-              + "}"
-            );
-        assertEquals(expected, actual);
-    }
-
-    @Test
-    public void toDBObject_pcjDetails() {
-        final PCJDetails details = PCJDetails.builder()
-                .setId("pcjId")
-                .setLastUpdateTime( new Date() )
-                .setUpdateStrategy( PCJUpdateStrategy.INCREMENTAL )
-                .build();
-
-        // Convert it into a Mongo DB Object.
-        final BasicDBObject dbo = (BasicDBObject) MongoDetailsAdapter.toDBObject(details);
-
-        // Convert the dbo back into the original object.
-        final PCJDetails restored = MongoDetailsAdapter.toPCJDetails(dbo).build();
-
-        // Ensure the restored value matches the original.
-        assertEquals(details, restored);
-    }
-
-    @Test
-    public void toDBObject_pcjDetails_missing_optionals() {
-        final PCJDetails details = PCJDetails.builder()
-                .setId("pcjId")
-                .build();
-
-        // Convert it into a Mongo DB Object.
-        final BasicDBObject dbo = (BasicDBObject) MongoDetailsAdapter.toDBObject(details);
-
-        // Convert the dbo back into the original object.
-        final PCJDetails restored = MongoDetailsAdapter.toPCJDetails(dbo).build();
-
-        // Ensure the restored value matches the original.
-        assertEquals(details, restored);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/44a2dcf0/dao/mongodb.rya/src/test/java/mvm/rya/mongodb/instance/MongoRyaDetailsRepositoryIT.java
----------------------------------------------------------------------
diff --git a/dao/mongodb.rya/src/test/java/mvm/rya/mongodb/instance/MongoRyaDetailsRepositoryIT.java b/dao/mongodb.rya/src/test/java/mvm/rya/mongodb/instance/MongoRyaDetailsRepositoryIT.java
deleted file mode 100644
index 2ce2e93..0000000
--- a/dao/mongodb.rya/src/test/java/mvm/rya/mongodb/instance/MongoRyaDetailsRepositoryIT.java
+++ /dev/null
@@ -1,307 +0,0 @@
-package mvm.rya.mongodb.instance;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-import java.util.Date;
-
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import com.google.common.base.Optional;
-import com.mongodb.MongoClient;
-import com.mongodb.MongoException;
-
-import de.flapdoodle.embed.mongo.tests.MongodForTestsFactory;
-import mvm.rya.api.instance.RyaDetails;
-import mvm.rya.api.instance.RyaDetails.EntityCentricIndexDetails;
-import mvm.rya.api.instance.RyaDetails.FreeTextIndexDetails;
-import mvm.rya.api.instance.RyaDetails.GeoIndexDetails;
-import mvm.rya.api.instance.RyaDetails.JoinSelectivityDetails;
-import mvm.rya.api.instance.RyaDetails.PCJIndexDetails;
-import mvm.rya.api.instance.RyaDetails.PCJIndexDetails.FluoDetails;
-import mvm.rya.api.instance.RyaDetails.PCJIndexDetails.PCJDetails;
-import mvm.rya.api.instance.RyaDetails.PCJIndexDetails.PCJDetails.PCJUpdateStrategy;
-import mvm.rya.api.instance.RyaDetails.ProspectorDetails;
-import mvm.rya.api.instance.RyaDetails.TemporalIndexDetails;
-import mvm.rya.api.instance.RyaDetailsRepository;
-import mvm.rya.api.instance.RyaDetailsRepository.AlreadyInitializedException;
-import mvm.rya.api.instance.RyaDetailsRepository.ConcurrentUpdateException;
-import mvm.rya.api.instance.RyaDetailsRepository.NotInitializedException;
-import mvm.rya.api.instance.RyaDetailsRepository.RyaDetailsRepositoryException;
-
-/**
- * Tests the methods of {@link AccumuloRyaDetailsRepository} by using a {@link MiniAccumuloCluster}.
- */
-public class MongoRyaDetailsRepositoryIT {
-
-    private static MongoClient client = null;
-
-    @BeforeClass
-    public static void startMiniAccumulo() throws MongoException, IOException {
-        final MongodForTestsFactory mongoFactory = new MongodForTestsFactory();
-        client = mongoFactory.newMongo();
-    }
-
-    @Before
-    public void clearLastTest() {
-        client.dropDatabase("testInstance");
-    }
-
-    @AfterClass
-    public static void stopMiniAccumulo() throws IOException, InterruptedException {
-        client.close();
-    }
-
-    @Test
-    public void initializeAndGet() throws AlreadyInitializedException, RyaDetailsRepositoryException {
-        final String instanceName = "testInstance";
-
-        // Create the metadata object the repository will be initialized with.
-        final RyaDetails details = RyaDetails.builder()
-            .setRyaInstanceName(instanceName)
-            .setRyaVersion("1.2.3.4")
-            .setEntityCentricIndexDetails( new EntityCentricIndexDetails(true) )
-            .setGeoIndexDetails( new GeoIndexDetails(true) )
-            .setTemporalIndexDetails( new TemporalIndexDetails(true) )
-            .setFreeTextDetails( new FreeTextIndexDetails(true) )
-            .setPCJIndexDetails(
-                    PCJIndexDetails.builder()
-                        .setEnabled(true)
-                        .setFluoDetails( new FluoDetails("test_instance_rya_pcj_updater") )
-                        .addPCJDetails(
-                                PCJDetails.builder()
-                                    .setId("pcj 1")
-                                    .setUpdateStrategy(PCJUpdateStrategy.BATCH)
-                                    .setLastUpdateTime( new Date() ))
-                        .addPCJDetails(
-                                PCJDetails.builder()
-                                    .setId("pcj 2")))
-            .setProspectorDetails( new ProspectorDetails(Optional.of(new Date())) )
-            .setJoinSelectivityDetails( new JoinSelectivityDetails(Optional.of(new Date())) )
-            .build();
-
-        // Setup the repository that will be tested using a mock instance of MongoDB.
-        final RyaDetailsRepository repo = new MongoRyaInstanceDetailsRepository(client, instanceName);
-
-        // Initialize the repository
-        repo.initialize(details);
-
-        // Fetch the stored details.
-        final RyaDetails stored = repo.getRyaInstanceDetails();
-
-        // Ensure the fetched object is equivalent to what was stored.
-        assertEquals(details, stored);
-    }
-
-    @Test(expected = AlreadyInitializedException.class)
-    public void initialize_alreadyInitialized() throws AlreadyInitializedException, RyaDetailsRepositoryException {
-        final String instanceName = "testInstance";
-
-        // Create the metadata object the repository will be initialized with.
-        final RyaDetails details = RyaDetails.builder()
-            .setRyaInstanceName(instanceName)
-            .setRyaVersion("1.2.3.4")
-            .setEntityCentricIndexDetails( new EntityCentricIndexDetails(true) )
-            .setGeoIndexDetails( new GeoIndexDetails(true) )
-            .setTemporalIndexDetails( new TemporalIndexDetails(true) )
-            .setFreeTextDetails( new FreeTextIndexDetails(true) )
-            .setPCJIndexDetails(
-                    PCJIndexDetails.builder()
-                        .setEnabled(true)
-                        .setFluoDetails( new FluoDetails("test_instance_rya_pcj_updater") )
-                        .addPCJDetails(
-                                PCJDetails.builder()
-                                    .setId("pcj 1")
-                                    .setUpdateStrategy(PCJUpdateStrategy.BATCH)
-                                    .setLastUpdateTime( new Date() ))
-                        .addPCJDetails(
-                                PCJDetails.builder()
-                                    .setId("pcj 2")))
-            .setProspectorDetails( new ProspectorDetails(Optional.of(new Date())) )
-            .setJoinSelectivityDetails( new JoinSelectivityDetails(Optional.of(new Date())) )
-            .build();
-
-        // Setup the repository that will be tested using a mock instance of MongoDB.
-        final RyaDetailsRepository repo = new MongoRyaInstanceDetailsRepository(client, instanceName);
-
-        // Initialize the repository
-        repo.initialize(details);
-
-        // Initialize it again.
-        repo.initialize(details);
-    }
-
-    @Test(expected = NotInitializedException.class)
-    public void getRyaInstance_notInitialized() throws NotInitializedException, RyaDetailsRepositoryException {
-        // Setup the repository that will be tested using a mock instance of Accumulo.
-        final RyaDetailsRepository repo = new MongoRyaInstanceDetailsRepository(client, "testInstance");
-
-        // Try to fetch the details from the uninitialized repository.
-        repo.getRyaInstanceDetails();
-    }
-
-    @Test
-    public void isInitialized_true() throws AlreadyInitializedException, RyaDetailsRepositoryException {
-        final String instanceName = "testInstance";
-
-        // Create the metadata object the repository will be initialized with.
-        final RyaDetails details = RyaDetails.builder()
-            .setRyaInstanceName(instanceName)
-            .setRyaVersion("1.2.3.4")
-            .setEntityCentricIndexDetails( new EntityCentricIndexDetails(true) )
-            .setGeoIndexDetails( new GeoIndexDetails(true) )
-            .setTemporalIndexDetails( new TemporalIndexDetails(true) )
-            .setFreeTextDetails( new FreeTextIndexDetails(true) )
-            .setPCJIndexDetails(
-                    PCJIndexDetails.builder()
-                        .setEnabled(true)
-                        .setFluoDetails( new FluoDetails("test_instance_rya_pcj_updater") )
-                        .addPCJDetails(
-                                PCJDetails.builder()
-                                    .setId("pcj 1")
-                                    .setUpdateStrategy(PCJUpdateStrategy.BATCH)
-                                    .setLastUpdateTime( new Date() ))
-                        .addPCJDetails(
-                                PCJDetails.builder()
-                                    .setId("pcj 2")))
-            .setProspectorDetails( new ProspectorDetails(Optional.of(new Date())) )
-            .setJoinSelectivityDetails( new JoinSelectivityDetails(Optional.of(new Date())) )
-            .build();
-
-        // Setup the repository that will be tested using a mock instance of MongoDB.
-        final RyaDetailsRepository repo = new MongoRyaInstanceDetailsRepository(client, "testInstance");
-
-        // Initialize the repository
-        repo.initialize(details);
-
-        // Ensure the repository reports that it has been initialized.
-        assertTrue( repo.isInitialized() );
-    }
-
-    @Test
-    public void isInitialized_false() throws RyaDetailsRepositoryException {
-        // Setup the repository that will be tested using a mock instance of MongoDB.
-        final RyaDetailsRepository repo = new MongoRyaInstanceDetailsRepository(client, "testInstance");
-
-        // Ensure the repository reports that is has not been initialized.
-        assertFalse( repo.isInitialized() );
-    }
-
-    @Test
-    public void update() throws AlreadyInitializedException, RyaDetailsRepositoryException {
-        final String instanceName = "testInstance";
-
-        // Create the metadata object the repository will be initialized with.
-        final RyaDetails details = RyaDetails.builder()
-            .setRyaInstanceName(instanceName)
-            .setRyaVersion("1.2.3.4")
-            .setEntityCentricIndexDetails( new EntityCentricIndexDetails(true) )
-            .setGeoIndexDetails( new GeoIndexDetails(true) )
-            .setTemporalIndexDetails( new TemporalIndexDetails(true) )
-            .setFreeTextDetails( new FreeTextIndexDetails(true) )
-            .setPCJIndexDetails(
-                    PCJIndexDetails.builder()
-                        .setEnabled(true)
-                        .setFluoDetails( new FluoDetails("test_instance_rya_pcj_updater") )
-                        .addPCJDetails(
-                                PCJDetails.builder()
-                                    .setId("pcj 1")
-                                    .setUpdateStrategy(PCJUpdateStrategy.BATCH)
-                                    .setLastUpdateTime( new Date() ))
-                        .addPCJDetails(
-                                PCJDetails.builder()
-                                    .setId("pcj 2")))
-            .setProspectorDetails( new ProspectorDetails(Optional.of(new Date())) )
-            .setJoinSelectivityDetails( new JoinSelectivityDetails(Optional.of(new Date())) )
-            .build();
-
-        // Setup the repository that will be tested using a mock instance of MongoDB.
-        final RyaDetailsRepository repo = new MongoRyaInstanceDetailsRepository(client, "testInstance");
-
-        // Initialize the repository
-        repo.initialize(details);
-
-        // Create a new state for the details.
-        final RyaDetails updated = new RyaDetails.Builder( details )
-                .setGeoIndexDetails( new GeoIndexDetails(false) )
-                .build();
-
-        // Execute the update.
-        repo.update(details, updated);
-
-        // Show the new state that is stored matches the updated state.
-        final RyaDetails fetched = repo.getRyaInstanceDetails();
-        assertEquals(updated, fetched);
-    }
-
-    @Test(expected = ConcurrentUpdateException.class)
-    public void update_outOfDate() throws AlreadyInitializedException, RyaDetailsRepositoryException {
-        final String instanceName = "testInstance";
-
-        // Create the metadata object the repository will be initialized with.
-        final RyaDetails details = RyaDetails.builder()
-            .setRyaInstanceName(instanceName)
-            .setRyaVersion("1.2.3.4")
-            .setEntityCentricIndexDetails( new EntityCentricIndexDetails(true) )
-            .setGeoIndexDetails( new GeoIndexDetails(true) )
-            .setTemporalIndexDetails( new TemporalIndexDetails(true) )
-            .setFreeTextDetails( new FreeTextIndexDetails(true) )
-            .setPCJIndexDetails(
-                    PCJIndexDetails.builder()
-                        .setEnabled(true)
-                        .setFluoDetails( new FluoDetails("test_instance_rya_pcj_updater") )
-                        .addPCJDetails(
-                                PCJDetails.builder()
-                                    .setId("pcj 1")
-                                    .setUpdateStrategy(PCJUpdateStrategy.BATCH)
-                                    .setLastUpdateTime( new Date() ))
-                        .addPCJDetails(
-                                PCJDetails.builder()
-                                    .setId("pcj 2")))
-            .setProspectorDetails( new ProspectorDetails(Optional.of(new Date())) )
-            .setJoinSelectivityDetails( new JoinSelectivityDetails(Optional.of(new Date())) )
-            .build();
-
-        // Setup the repository that will be tested using a mock instance of MongoDB.
-        final RyaDetailsRepository repo = new MongoRyaInstanceDetailsRepository(client, "testInstance");
-
-        // Initialize the repository
-        repo.initialize(details);
-
-        // Create a new state for the details.
-        final RyaDetails wrongOriginal = new RyaDetails.Builder( details )
-                .setTemporalIndexDetails( new TemporalIndexDetails(false) )
-                .build();
-
-        final RyaDetails updated = new RyaDetails.Builder( details )
-                .setGeoIndexDetails( new GeoIndexDetails(false) )
-                .build();
-
-        // Try to execute the update where the old state is not the currently stored state.
-        repo.update(wrongOriginal, updated);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/44a2dcf0/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBQueryEngineTest.java
----------------------------------------------------------------------
diff --git a/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBQueryEngineTest.java b/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBQueryEngineTest.java
new file mode 100644
index 0000000..870115c
--- /dev/null
+++ b/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBQueryEngineTest.java
@@ -0,0 +1,124 @@
+package mvm.rya.mongodb;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import info.aduna.iteration.CloseableIteration;
+import mvm.rya.api.RdfCloudTripleStoreConfiguration;
+import mvm.rya.api.RdfCloudTripleStoreUtils;
+import mvm.rya.api.domain.RyaStatement;
+import mvm.rya.api.domain.RyaStatement.RyaStatementBuilder;
+import mvm.rya.api.domain.RyaURI;
+
+import org.apache.hadoop.conf.Configuration;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.openrdf.model.impl.URIImpl;
+import org.openrdf.query.BindingSet;
+import org.openrdf.query.impl.MapBindingSet;
+
+import com.google.common.collect.Lists;
+import com.mongodb.MongoClient;
+
+import de.flapdoodle.embed.mongo.distribution.Version;
+import de.flapdoodle.embed.mongo.tests.MongodForTestsFactory;
+
+public class MongoDBQueryEngineTest {
+
+    // private dao;
+    // private configuration;
+
+    private MongoDBQueryEngine engine;
+    private MongoDBRdfConfiguration configuration;
+
+    @Before
+    public void setUp() throws Exception {
+        // Set up Mongo/Rya
+        MongodForTestsFactory testsFactory = MongodForTestsFactory.with(Version.Main.PRODUCTION);
+        Configuration conf = new Configuration();
+        conf.set(MongoDBRdfConfiguration.USE_TEST_MONGO, "true");
+        conf.set(MongoDBRdfConfiguration.MONGO_DB_NAME, "test");
+        conf.set(MongoDBRdfConfiguration.MONGO_COLLECTION_PREFIX, "rya_");
+        conf.set(RdfCloudTripleStoreConfiguration.CONF_TBL_PREFIX, "rya_");
+        configuration = new MongoDBRdfConfiguration(conf);
+        MongoClient mongoClient = testsFactory.newMongo();
+        int port = mongoClient.getServerAddressList().get(0).getPort();
+        configuration.set(MongoDBRdfConfiguration.MONGO_INSTANCE_PORT, Integer.toString(port));
+
+        engine = new MongoDBQueryEngine(configuration, mongoClient);
+
+        // Add Data
+        MongoDBRyaDAO dao = new MongoDBRyaDAO(configuration, mongoClient);
+        dao.add(getStatement("u:a", "u:tt", "u:b"));
+        dao.add(getStatement("u:a", "u:tt", "u:c"));
+    }
+
+    private RyaStatement getStatement(String s, String p, String o) {
+        RyaStatementBuilder builder = new RyaStatementBuilder();
+        if (s != null)
+            builder.setSubject(new RyaURI(s));
+        if (p != null)
+            builder.setPredicate(new RyaURI(p));
+        if (o != null)
+            builder.setObject(new RyaURI(o));
+        return builder.build();
+    }
+
+    public int size(CloseableIteration<?, ?> iter) throws Exception {
+        int i = 0;
+        while (iter.hasNext()) {
+            i++;
+            iter.next();
+        }
+        return i;
+    }
+
+    @Test
+    public void statementQuery() throws Exception {
+        RyaStatement s = getStatement("u:a", null, null);
+        Assert.assertEquals(2, size(engine.query(s, configuration)));
+    }
+
+    @SuppressWarnings("unchecked")
+    @Test
+    public void bindingSetsQuery() throws Exception {
+        RyaStatement s = getStatement("u:a", null, null);
+        
+        MapBindingSet bs1 = new MapBindingSet();
+        bs1.addBinding("foo", new URIImpl("u:x"));
+
+        Map.Entry<RyaStatement, BindingSet> e1 = new RdfCloudTripleStoreUtils.CustomEntry<RyaStatement, BindingSet>(s, bs1);
+        Collection<Entry<RyaStatement, BindingSet>> stmts1 = Lists.newArrayList(e1);
+        Assert.assertEquals(2, size(engine.queryWithBindingSet(stmts1, configuration)));
+
+        
+        MapBindingSet bs2 = new MapBindingSet();
+        bs2.addBinding("foo", new URIImpl("u:y"));
+
+        Map.Entry<RyaStatement, BindingSet> e2 = new RdfCloudTripleStoreUtils.CustomEntry<RyaStatement, BindingSet>(s, bs2);
+
+        Collection<Entry<RyaStatement, BindingSet>> stmts2 = Lists.newArrayList(e1, e2);
+        Assert.assertEquals(4, size(engine.queryWithBindingSet(stmts2, configuration)));
+}
+}

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/44a2dcf0/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBRyaDAOIT.java
----------------------------------------------------------------------
diff --git a/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBRyaDAOIT.java b/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBRyaDAOIT.java
new file mode 100644
index 0000000..33531b5
--- /dev/null
+++ b/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBRyaDAOIT.java
@@ -0,0 +1,139 @@
+package mvm.rya.mongodb;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import static mvm.rya.mongodb.dao.SimpleMongoDBStorageStrategy.TIMESTAMP;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+
+import org.apache.hadoop.conf.Configuration;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.mongodb.DB;
+import com.mongodb.DBCollection;
+import com.mongodb.DBObject;
+import com.mongodb.MongoClient;
+import com.mongodb.MongoException;
+
+import de.flapdoodle.embed.mongo.distribution.Version;
+import de.flapdoodle.embed.mongo.tests.MongodForTestsFactory;
+import mvm.rya.api.RdfCloudTripleStoreConfiguration;
+import mvm.rya.api.domain.RyaStatement;
+import mvm.rya.api.domain.RyaStatement.RyaStatementBuilder;
+import mvm.rya.api.domain.RyaURI;
+import mvm.rya.api.persist.RyaDAOException;
+
+public class MongoDBRyaDAOIT {
+
+    private MongodForTestsFactory testsFactory;
+    private MongoDBRyaDAO dao;
+    private MongoDBRdfConfiguration configuration;
+    private MongoClient mongoClient;
+
+    @Before
+    public void setUp() throws IOException, RyaDAOException{
+        testsFactory = MongodForTestsFactory.with(Version.Main.PRODUCTION);
+           final Configuration conf = new Configuration();
+            conf.set(MongoDBRdfConfiguration.USE_TEST_MONGO, "true");
+            conf.set(MongoDBRdfConfiguration.MONGO_DB_NAME, "test");
+            conf.set(MongoDBRdfConfiguration.MONGO_COLLECTION_PREFIX, "rya_");
+            conf.set(RdfCloudTripleStoreConfiguration.CONF_TBL_PREFIX, "rya_");
+            configuration = new MongoDBRdfConfiguration(conf);
+            mongoClient = testsFactory.newMongo();
+            final int port = mongoClient.getServerAddressList().get(0).getPort();
+            configuration.set(MongoDBRdfConfiguration.MONGO_INSTANCE_PORT, Integer.toString(port));
+            dao = new MongoDBRyaDAO(configuration, mongoClient);
+    }
+
+    @Test
+    public void testDeleteWildcard() throws RyaDAOException {
+        final RyaStatementBuilder builder = new RyaStatementBuilder();
+        builder.setPredicate(new RyaURI("http://temp.com"));
+        dao.delete(builder.build(), configuration);
+    }
+
+
+    @Test
+    public void testAdd() throws RyaDAOException, MongoException, IOException {
+        final RyaStatementBuilder builder = new RyaStatementBuilder();
+        builder.setPredicate(new RyaURI("http://temp.com"));
+        builder.setSubject(new RyaURI("http://subject.com"));
+        builder.setObject(new RyaURI("http://object.com"));
+
+        final DB db = mongoClient.getDB(configuration.get(MongoDBRdfConfiguration.MONGO_DB_NAME));
+        final DBCollection coll = db.getCollection(configuration.getTriplesCollectionName());
+
+        dao.add(builder.build());
+
+        assertEquals(coll.count(),1);
+
+        final DBObject dbo = coll.findOne();
+        assertTrue(dbo.containsField(TIMESTAMP));
+    }
+
+    @Test
+    public void testDelete() throws RyaDAOException, MongoException, IOException {
+        final RyaStatementBuilder builder = new RyaStatementBuilder();
+        builder.setPredicate(new RyaURI("http://temp.com"));
+        builder.setSubject(new RyaURI("http://subject.com"));
+        builder.setObject(new RyaURI("http://object.com"));
+        final RyaStatement statement = builder.build();
+        final DB db = mongoClient.getDB(configuration.get(MongoDBRdfConfiguration.MONGO_DB_NAME));
+        final DBCollection coll = db.getCollection(configuration.getTriplesCollectionName());
+
+        dao.add(statement);
+
+        assertEquals(coll.count(),1);
+
+        dao.delete(statement, configuration);
+
+        assertEquals(coll.count(),0);
+
+    }
+
+    @Test
+    public void testDeleteWildcardSubjectWithContext() throws RyaDAOException, MongoException, IOException {
+        final RyaStatementBuilder builder = new RyaStatementBuilder();
+        builder.setPredicate(new RyaURI("http://temp.com"));
+        builder.setSubject(new RyaURI("http://subject.com"));
+        builder.setObject(new RyaURI("http://object.com"));
+        builder.setContext(new RyaURI("http://context.com"));
+        final RyaStatement statement = builder.build();
+
+        final DB db = mongoClient.getDB(configuration.get(MongoDBRdfConfiguration.MONGO_DB_NAME));
+        final DBCollection coll = db.getCollection(configuration.getTriplesCollectionName());
+
+        dao.add(statement);
+
+        assertEquals(coll.count(),1);
+
+        final RyaStatementBuilder builder2 = new RyaStatementBuilder();
+        builder2.setPredicate(new RyaURI("http://temp.com"));
+        builder2.setObject(new RyaURI("http://object.com"));
+        builder2.setContext(new RyaURI("http://context3.com"));
+        final RyaStatement query = builder2.build();
+
+        dao.delete(query, configuration);
+
+        assertEquals(coll.count(),1);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/44a2dcf0/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBRyaDAOTest.java
----------------------------------------------------------------------
diff --git a/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBRyaDAOTest.java b/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBRyaDAOTest.java
new file mode 100644
index 0000000..dde0eda
--- /dev/null
+++ b/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBRyaDAOTest.java
@@ -0,0 +1,137 @@
+package mvm.rya.mongodb;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+
+import org.apache.hadoop.conf.Configuration;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.mongodb.DB;
+import com.mongodb.DBCollection;
+import com.mongodb.MongoClient;
+import com.mongodb.MongoException;
+
+import de.flapdoodle.embed.mongo.distribution.Version;
+import de.flapdoodle.embed.mongo.tests.MongodForTestsFactory;
+import mvm.rya.api.RdfCloudTripleStoreConfiguration;
+import mvm.rya.api.domain.RyaStatement;
+import mvm.rya.api.domain.RyaStatement.RyaStatementBuilder;
+import mvm.rya.api.domain.RyaURI;
+import mvm.rya.api.persist.RyaDAOException;
+
+public class MongoDBRyaDAOTest {
+
+	private MongodForTestsFactory testsFactory;
+	private MongoDBRyaDAO dao;
+	private MongoDBRdfConfiguration configuration;
+	private MongoClient mongoClient;
+
+	@Before
+	public void setUp() throws IOException, RyaDAOException{
+		testsFactory = MongodForTestsFactory.with(Version.Main.PRODUCTION);
+		final Configuration conf = new Configuration();
+        conf.set(MongoDBRdfConfiguration.USE_TEST_MONGO, "true");
+        conf.set(MongoDBRdfConfiguration.MONGO_DB_NAME, "test");
+        conf.set(MongoDBRdfConfiguration.MONGO_COLLECTION_PREFIX, "rya_");
+        conf.set(RdfCloudTripleStoreConfiguration.CONF_TBL_PREFIX, "rya_");
+        configuration = new MongoDBRdfConfiguration(conf);
+		mongoClient = testsFactory.newMongo();
+        final int port = mongoClient.getServerAddressList().get(0).getPort();
+        configuration.set(MongoDBRdfConfiguration.MONGO_INSTANCE_PORT, ""+port);
+		dao = new MongoDBRyaDAO(configuration, mongoClient);
+	}
+
+	@Test
+	public void testDeleteWildcard() throws RyaDAOException {
+		final RyaStatementBuilder builder = new RyaStatementBuilder();
+		builder.setPredicate(new RyaURI("http://temp.com"));
+		dao.delete(builder.build(), configuration);
+	}
+
+
+	@Test
+	public void testAdd() throws RyaDAOException, MongoException, IOException {
+		final RyaStatementBuilder builder = new RyaStatementBuilder();
+		builder.setPredicate(new RyaURI("http://temp.com"));
+		builder.setSubject(new RyaURI("http://subject.com"));
+		builder.setObject(new RyaURI("http://object.com"));
+
+		final DB db = mongoClient.getDB(configuration.get(MongoDBRdfConfiguration.MONGO_DB_NAME));
+        final DBCollection coll = db.getCollection(configuration.getTriplesCollectionName());
+
+		dao.add(builder.build());
+
+        assertEquals(coll.count(),1);
+
+	}
+
+	@Test
+	public void testDelete() throws RyaDAOException, MongoException, IOException {
+		final RyaStatementBuilder builder = new RyaStatementBuilder();
+		builder.setPredicate(new RyaURI("http://temp.com"));
+		builder.setSubject(new RyaURI("http://subject.com"));
+		builder.setObject(new RyaURI("http://object.com"));
+		final RyaStatement statement = builder.build();
+
+		final DB db = mongoClient.getDB(configuration.get(MongoDBRdfConfiguration.MONGO_DB_NAME));
+        final DBCollection coll = db.getCollection(configuration.getTriplesCollectionName());
+
+		dao.add(statement);
+
+        assertEquals(coll.count(),1);
+
+        dao.delete(statement, configuration);
+
+        assertEquals(coll.count(),0);
+
+	}
+
+	@Test
+	public void testDeleteWildcardSubjectWithContext() throws RyaDAOException, MongoException, IOException {
+		final RyaStatementBuilder builder = new RyaStatementBuilder();
+		builder.setPredicate(new RyaURI("http://temp.com"));
+		builder.setSubject(new RyaURI("http://subject.com"));
+		builder.setObject(new RyaURI("http://object.com"));
+		builder.setContext(new RyaURI("http://context.com"));
+		final RyaStatement statement = builder.build();
+
+		final DB db = mongoClient.getDB(configuration.get(MongoDBRdfConfiguration.MONGO_DB_NAME));
+        final DBCollection coll = db.getCollection(configuration.getTriplesCollectionName());
+
+		dao.add(statement);
+
+        assertEquals(coll.count(),1);
+
+		final RyaStatementBuilder builder2 = new RyaStatementBuilder();
+		builder2.setPredicate(new RyaURI("http://temp.com"));
+		builder2.setObject(new RyaURI("http://object.com"));
+		builder2.setContext(new RyaURI("http://context3.com"));
+		final RyaStatement query = builder2.build();
+
+        dao.delete(query, configuration);
+
+        assertEquals(coll.count(),1);
+
+	}
+
+}