RYA-414 Code review. closes #256

Project: http://git-wip-us.apache.org/repos/asf/incubator-rya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-rya/commit/4576f556
Tree: http://git-wip-us.apache.org/repos/asf/incubator-rya/tree/4576f556
Diff: http://git-wip-us.apache.org/repos/asf/incubator-rya/diff/4576f556

Branch: refs/heads/master
Commit: 4576f556af04326b68d80679df233ccfb36d3382
Parents: 157c064
Author: kchilton2 <[email protected]>
Authored: Wed Jan 3 14:56:08 2018 -0500
Committer: David Lotts <[email protected]>
Committed: Thu Jan 4 17:05:04 2018 -0500

----------------------------------------------------------------------
 .../AbstractMongoDBRdfConfigurationBuilder.java |    2 +-
 .../rya/mongodb/EmbeddedMongoFactory.java       |   11 +-
 .../rya/mongodb/MongoDBRdfConfiguration.java    |    4 +-
 .../StatefulMongoDBRdfConfiguration.java        |    2 +-
 .../dao/SimpleMongoDBNamespaceManager.java      |    1 -
 .../rya/mongodb/EmbeddedMongoSingleton.java     |    3 +
 .../rya/mongodb/MongoDBQueryEngineIT.java       |  185 ++
 .../rya/mongodb/MongoDBQueryEngineTest.java     |  185 --
 .../rya/mongodb/MongoDBRyaBatchWriterIT.java    |    2 +-
 .../apache/rya/mongodb/MongoDBRyaDAO2IT.java    |  138 ++
 .../org/apache/rya/mongodb/MongoDBRyaDAOIT.java |   18 +-
 .../apache/rya/mongodb/MongoDBRyaDAOTest.java   |  138 --
 .../org/apache/rya/mongodb/MongoITBase.java     |   94 +
 .../org/apache/rya/mongodb/MongoTestBase.java   |   94 -
 .../instance/MongoRyaDetailsRepositoryIT.java   |    4 +-
 .../entity/update/mongo/MongoEntityIndexer.java |    4 +-
 .../matching/RyaQueryEngineFactory.java         |    3 +-
 .../entity/query/EntityQueryNodeIT.java         |  287 +++
 .../entity/query/EntityQueryNodeTest.java       |  287 ---
 .../storage/mongo/MongoEntityStorageIT.java     |    4 +-
 .../storage/mongo/MongoTypeStorageIT.java       |    4 +-
 .../update/mongo/MongoEntityIndexerIT.java      |    4 +-
 .../rya/indexing/mongo/MongoDbSmartUriIT.java   |    4 +-
 .../rya/indexing/mongo/MongoEntityIndex2IT.java |  248 +++
 .../rya/indexing/mongo/MongoEntityIndexIT.java  |    4 +-
 .../indexing/mongo/MongoEntityIndexTest.java    |  248 ---
 .../indexing/mongo/MongoFreeTextIndexerIT.java  |  188 ++
 .../mongo/MongoFreeTextIndexerTest.java         |  188 --
 .../indexing/mongo/MongoTemporalIndexerIT.java  |  722 ++++++
 .../mongo/MongoTemporalIndexerTest.java         |  722 ------
 .../duplication/DuplicateDataDetectorIT.java    | 2053 ++++++++++++++++++
 .../duplication/DuplicateDataDetectorTest.java  | 2053 ------------------
 .../metadata/MongoStatementMetadataIT.java      |    4 +-
 .../metadata/MongoStatementMetadataNodeIT.java  |  368 ++++
 .../MongoStatementMetadataNodeTest.java         |  368 ----
 .../geotemporal/GeoTemporalIndexer.java         |    2 +-
 .../geotemporal/GeoTemporalProviderTest.java    |    4 +-
 .../geotemporal/GeoTemporalTestUtils.java       |    7 +-
 .../geotemporal/MongoGeoTemporalIndexIT.java    |    4 +-
 .../geotemporal/model/EventQueryNode2IT.java    |  364 ++++
 .../geotemporal/model/EventQueryNodeTest.java   |  364 ----
 .../GeoTemporalMongoDBStorageStrategyTest.java  |    7 +-
 .../geotemporal/mongo/MongoEventStorageIT.java  |  198 ++
 .../mongo/MongoEventStorageTest.java            |  198 --
 .../mongo/MongoGeoTemporalIndexerIT.java        |    4 +-
 .../indexing/mongo/MongoGeoIndexerFilterIT.java |    4 +-
 .../rya/indexing/mongo/MongoGeoIndexerIT.java   |  377 ++++
 .../rya/indexing/mongo/MongoGeoIndexerSfIT.java |  262 +++
 .../indexing/mongo/MongoGeoIndexerSfTest.java   |  262 ---
 .../rya/indexing/mongo/MongoGeoIndexerTest.java |  377 ----
 .../indexing/mongo/MongoIndexerDeleteIT.java    |    4 +-
 .../rya/rdftriplestore/RdfCloudTripleStore.java |    7 +-
 52 files changed, 5549 insertions(+), 5540 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/4576f556/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/AbstractMongoDBRdfConfigurationBuilder.java
----------------------------------------------------------------------
diff --git 
a/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/AbstractMongoDBRdfConfigurationBuilder.java
 
b/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/AbstractMongoDBRdfConfigurationBuilder.java
index 277ba5e..bb14a39 100644
--- 
a/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/AbstractMongoDBRdfConfigurationBuilder.java
+++ 
b/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/AbstractMongoDBRdfConfigurationBuilder.java
@@ -121,7 +121,7 @@ public abstract class 
AbstractMongoDBRdfConfigurationBuilder<B extends AbstractM
      * an instance of MongoDB and will default to "rya_" is no value is
      * specified.
      *
-     * @param name - name of Collection to connect to
+     * @param prefix - name of Collection to connect to
      * @return specified builder for chaining method invocations
      */
     public B setMongoCollectionPrefix(String prefix) {

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/4576f556/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/EmbeddedMongoFactory.java
----------------------------------------------------------------------
diff --git 
a/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/EmbeddedMongoFactory.java
 
b/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/EmbeddedMongoFactory.java
index ced8aa5..b3cfaa4 100644
--- 
a/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/EmbeddedMongoFactory.java
+++ 
b/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/EmbeddedMongoFactory.java
@@ -67,7 +67,7 @@ public class EmbeddedMongoFactory {
     }
 
     private IMongodConfig newMongodConfig(final IFeatureAwareVersion version) 
throws UnknownHostException, IOException {
-        Net net = new Net(findRandomOpenPortOnAllLocalInterfaces(), false);
+        final Net net = new Net(findRandomOpenPortOnAllLocalInterfaces(), 
false);
         return new MongodConfigBuilder().version(version).net(net).build();
     }
 
@@ -78,17 +78,16 @@ public class EmbeddedMongoFactory {
     }
 
     /**
-     * Creates a new Mongo connection.
-     *
-     * @throws MongoException
-     * @throws UnknownHostException
+     * @return A new Mongo client that is connected to the embedded MongoDB 
Server.
+     * @throws UnknownHostException The hostname used was unknown.
+     * @throws MongoException Couldn't create the client.
      */
     public MongoClient newMongoClient() throws UnknownHostException, 
MongoException {
         return new MongoClient(new 
ServerAddress(mongodProcess.getConfig().net().getServerAddress(), 
mongodProcess.getConfig().net().getPort()));
     }
 
     /**
-     * Gives access to the process configuration.
+     * @return The process configuration.
      *
      */
     public IMongodConfig getMongoServerDetails() {

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/4576f556/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/MongoDBRdfConfiguration.java
----------------------------------------------------------------------
diff --git 
a/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/MongoDBRdfConfiguration.java
 
b/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/MongoDBRdfConfiguration.java
index 269a73c..835ed27 100644
--- 
a/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/MongoDBRdfConfiguration.java
+++ 
b/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/MongoDBRdfConfiguration.java
@@ -97,7 +97,7 @@ public class MongoDBRdfConfiguration extends 
RdfCloudTripleStoreConfiguration {
      * Set whether the Rya client should spin up an embedded MongoDB instance 
and connect to that
      * or if it should connect to a MongoDB Server that is running somewhere.
      *
-     * @param useMock - {@true} to use an embedded Mongo DB instance; {@code 
false} to connect to a real server.
+     * @param useMock - {@code true} to use an embedded Mongo DB instance; 
{@code false} to connect to a real server.
      */
     public void setUseMock(final boolean useMock) {
         this.setBoolean(USE_MOCK_MONGO, useMock);
@@ -107,7 +107,7 @@ public class MongoDBRdfConfiguration extends 
RdfCloudTripleStoreConfiguration {
      * Indicates whether the Rya client should spin up an embedded MongoDB 
instance and connect to that
      * or if it should connect to a MongoDB Server that is running somewhere.
      *
-     * @return {@true} to use an embedded Mongo DB instance; {@code false} to 
connect to a real server.
+     * @return {@code true} to use an embedded Mongo DB instance; {@code 
false} to connect to a real server.
      */
     public boolean getUseMock() {
         return getBoolean(USE_MOCK_MONGO, false);

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/4576f556/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/StatefulMongoDBRdfConfiguration.java
----------------------------------------------------------------------
diff --git 
a/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/StatefulMongoDBRdfConfiguration.java
 
b/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/StatefulMongoDBRdfConfiguration.java
index 61c349e..e334194 100644
--- 
a/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/StatefulMongoDBRdfConfiguration.java
+++ 
b/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/StatefulMongoDBRdfConfiguration.java
@@ -33,7 +33,7 @@ import edu.umd.cs.findbugs.annotations.NonNull;
 /**
  * A {@link MongoDBRdfConfiguration} that is used to hold onto state that is 
pass into Rya components that accept
  * {@link Configuration} objects.
- * </p>
+ * <p>
  * HACK:
  * This class is part of a hack to get around how Rya uses reflection to 
initialize indexers, optimizers, etc.
  * Those classes have empty constructors, so they are not able to receive 
Mongo specific components at construction

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/4576f556/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/dao/SimpleMongoDBNamespaceManager.java
----------------------------------------------------------------------
diff --git 
a/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/dao/SimpleMongoDBNamespaceManager.java
 
b/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/dao/SimpleMongoDBNamespaceManager.java
index 91ee064..2be0785 100644
--- 
a/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/dao/SimpleMongoDBNamespaceManager.java
+++ 
b/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/dao/SimpleMongoDBNamespaceManager.java
@@ -142,7 +142,6 @@ public class SimpleMongoDBNamespaceManager implements 
MongoDBNamespaceManager {
             final MessageDigest digest = MessageDigest.getInstance("SHA-1");
             bytes = digest.digest(bytes);
         } catch (final NoSuchAlgorithmException e) {
-            // TODO Auto-generated catch block
             e.printStackTrace();
         }
         final BasicDBObject doc = new BasicDBObject(ID, new 
String(Hex.encodeHex(bytes)))

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/4576f556/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/EmbeddedMongoSingleton.java
----------------------------------------------------------------------
diff --git 
a/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/EmbeddedMongoSingleton.java
 
b/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/EmbeddedMongoSingleton.java
index a481ccf..235d0c5 100644
--- 
a/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/EmbeddedMongoSingleton.java
+++ 
b/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/EmbeddedMongoSingleton.java
@@ -54,6 +54,9 @@ public class EmbeddedMongoSingleton {
         return client;
     }
 
+    /**
+     * @return The singleton Mongo DB instance's server details.
+     */
     public static IMongodConfig getMongodConfig() {
         return InstanceHolder.SINGLETON.mongodConfig;
     }

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/4576f556/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBQueryEngineIT.java
----------------------------------------------------------------------
diff --git 
a/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBQueryEngineIT.java
 
b/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBQueryEngineIT.java
new file mode 100644
index 0000000..3a216ec
--- /dev/null
+++ 
b/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBQueryEngineIT.java
@@ -0,0 +1,185 @@
+/*
+* * 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.
+ */
+package org.apache.rya.mongodb;
+
+import static org.junit.Assert.assertEquals;
+
+/*
+ * 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 org.apache.rya.api.RdfCloudTripleStoreUtils;
+import org.apache.rya.api.domain.RyaStatement;
+import org.apache.rya.api.domain.RyaStatement.RyaStatementBuilder;
+import org.apache.rya.api.domain.RyaURI;
+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 info.aduna.iteration.CloseableIteration;
+/**
+ * Integration tests the methods of {@link MongoDBQueryEngine}.
+ */
+public class MongoDBQueryEngineIT extends MongoITBase {
+
+    private RyaStatement getStatement(final String s, final String p, final 
String o) {
+        final 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(final CloseableIteration<?, ?> iter) throws Exception {
+        int i = 0;
+        while (iter.hasNext()) {
+            i++;
+            iter.next();
+        }
+        return i;
+    }
+
+    @Test
+    public void statementQuery() throws Exception {
+        final MongoDBRyaDAO dao = new MongoDBRyaDAO();
+        try(final MongoDBQueryEngine engine =new MongoDBQueryEngine()) {
+            engine.setConf(conf);
+
+            // Add data.
+            dao.setConf(conf);
+            dao.init();
+            dao.add(getStatement("u:a", "u:tt", "u:b"));
+            dao.add(getStatement("u:a", "u:tt", "u:c"));
+
+            final RyaStatement s = getStatement("u:a", null, null);
+            assertEquals(2, size(engine.query(s, conf)));
+        } finally {
+            dao.destroy();
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    @Test
+    public void batchbindingSetsQuery() throws Exception {
+        final MongoDBRyaDAO dao = new MongoDBRyaDAO();
+        try(final MongoDBQueryEngine engine =new MongoDBQueryEngine()) {
+            engine.setConf(conf);
+
+            // Add data.
+            dao.setConf(conf);
+            dao.init();
+            dao.add(getStatement("u:a", "u:tt", "u:b"));
+            dao.add(getStatement("u:a", "u:tt", "u:c"));
+
+            // Run the test.
+            final RyaStatement s1 = getStatement(null, null, "u:b");
+
+            final MapBindingSet bs1 = new MapBindingSet();
+            bs1.addBinding("foo", new URIImpl("u:x"));
+
+            final Map.Entry<RyaStatement, BindingSet> e1 = new 
RdfCloudTripleStoreUtils.CustomEntry<>(s1, bs1);
+            final Collection<Entry<RyaStatement, BindingSet>> stmts1 = 
Lists.newArrayList(e1);
+            assertEquals(1, size(engine.queryWithBindingSet(stmts1, conf)));
+
+
+            final MapBindingSet bs2 = new MapBindingSet();
+            bs2.addBinding("foo", new URIImpl("u:y"));
+
+            final RyaStatement s2 = getStatement(null, null, "u:c");
+
+            final Map.Entry<RyaStatement, BindingSet> e2 = new 
RdfCloudTripleStoreUtils.CustomEntry<>(s2, bs2);
+
+            final Collection<Entry<RyaStatement, BindingSet>> stmts2 = 
Lists.newArrayList(e1, e2);
+            assertEquals(2, size(engine.queryWithBindingSet(stmts2, conf)));
+
+
+            final Map.Entry<RyaStatement, BindingSet> e3 = new 
RdfCloudTripleStoreUtils.CustomEntry<>(s2, bs1);
+            final Map.Entry<RyaStatement, BindingSet> e4 = new 
RdfCloudTripleStoreUtils.CustomEntry<>(s1, bs2);
+
+            final Collection<Entry<RyaStatement, BindingSet>> stmts3 = 
Lists.newArrayList(e1, e2, e3, e4);
+            assertEquals(4, size(engine.queryWithBindingSet(stmts3, conf)));
+        } finally {
+            dao.destroy();
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    @Test
+    public void bindingSetsQuery() throws Exception {
+        final MongoDBRyaDAO dao = new MongoDBRyaDAO();
+        try(final MongoDBQueryEngine engine =new MongoDBQueryEngine()) {
+            engine.setConf(conf);
+
+            // Add data.
+            dao.setConf(conf);
+            dao.init();
+            dao.add(getStatement("u:a", "u:tt", "u:b"));
+            dao.add(getStatement("u:a", "u:tt", "u:c"));
+
+            // Run the test.
+            final RyaStatement s = getStatement("u:a", null, null);
+
+            final MapBindingSet bs1 = new MapBindingSet();
+            bs1.addBinding("foo", new URIImpl("u:x"));
+
+            final Map.Entry<RyaStatement, BindingSet> e1 = new 
RdfCloudTripleStoreUtils.CustomEntry<>(s, bs1);
+            final Collection<Entry<RyaStatement, BindingSet>> stmts1 = 
Lists.newArrayList(e1);
+            assertEquals(2, size(engine.queryWithBindingSet(stmts1, conf)));
+
+
+            final MapBindingSet bs2 = new MapBindingSet();
+            bs2.addBinding("foo", new URIImpl("u:y"));
+
+            final Map.Entry<RyaStatement, BindingSet> e2 = new 
RdfCloudTripleStoreUtils.CustomEntry<>(s, bs2);
+
+            final Collection<Entry<RyaStatement, BindingSet>> stmts2 = 
Lists.newArrayList(e1, e2);
+            assertEquals(4, size(engine.queryWithBindingSet(stmts2, conf)));
+        } finally {
+            dao.destroy();
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/4576f556/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
deleted file mode 100644
index f7235a6..0000000
--- 
a/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBQueryEngineTest.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
-* * 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.
- */
-package org.apache.rya.mongodb;
-
-import static org.junit.Assert.assertEquals;
-
-/*
- * 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 org.apache.rya.api.RdfCloudTripleStoreUtils;
-import org.apache.rya.api.domain.RyaStatement;
-import org.apache.rya.api.domain.RyaStatement.RyaStatementBuilder;
-import org.apache.rya.api.domain.RyaURI;
-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 info.aduna.iteration.CloseableIteration;
-/**
- * Integration tests the methods of {@link MongoDBQueryEngine}.
- */
-public class MongoDBQueryEngineTest extends MongoTestBase {
-
-    private RyaStatement getStatement(final String s, final String p, final 
String o) {
-        final 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(final CloseableIteration<?, ?> iter) throws Exception {
-        int i = 0;
-        while (iter.hasNext()) {
-            i++;
-            iter.next();
-        }
-        return i;
-    }
-
-    @Test
-    public void statementQuery() throws Exception {
-        final MongoDBRyaDAO dao = new MongoDBRyaDAO();
-        try(final MongoDBQueryEngine engine =new MongoDBQueryEngine()) {
-            engine.setConf(conf);
-
-            // Add data.
-            dao.setConf(conf);
-            dao.init();
-            dao.add(getStatement("u:a", "u:tt", "u:b"));
-            dao.add(getStatement("u:a", "u:tt", "u:c"));
-
-            final RyaStatement s = getStatement("u:a", null, null);
-            assertEquals(2, size(engine.query(s, conf)));
-        } finally {
-            dao.destroy();
-        }
-    }
-
-    @SuppressWarnings("unchecked")
-    @Test
-    public void batchbindingSetsQuery() throws Exception {
-        final MongoDBRyaDAO dao = new MongoDBRyaDAO();
-        try(final MongoDBQueryEngine engine =new MongoDBQueryEngine()) {
-            engine.setConf(conf);
-
-            // Add data.
-            dao.setConf(conf);
-            dao.init();
-            dao.add(getStatement("u:a", "u:tt", "u:b"));
-            dao.add(getStatement("u:a", "u:tt", "u:c"));
-
-            // Run the test.
-            final RyaStatement s1 = getStatement(null, null, "u:b");
-
-            final MapBindingSet bs1 = new MapBindingSet();
-            bs1.addBinding("foo", new URIImpl("u:x"));
-
-            final Map.Entry<RyaStatement, BindingSet> e1 = new 
RdfCloudTripleStoreUtils.CustomEntry<>(s1, bs1);
-            final Collection<Entry<RyaStatement, BindingSet>> stmts1 = 
Lists.newArrayList(e1);
-            assertEquals(1, size(engine.queryWithBindingSet(stmts1, conf)));
-
-
-            final MapBindingSet bs2 = new MapBindingSet();
-            bs2.addBinding("foo", new URIImpl("u:y"));
-
-            final RyaStatement s2 = getStatement(null, null, "u:c");
-
-            final Map.Entry<RyaStatement, BindingSet> e2 = new 
RdfCloudTripleStoreUtils.CustomEntry<>(s2, bs2);
-
-            final Collection<Entry<RyaStatement, BindingSet>> stmts2 = 
Lists.newArrayList(e1, e2);
-            assertEquals(2, size(engine.queryWithBindingSet(stmts2, conf)));
-
-
-            final Map.Entry<RyaStatement, BindingSet> e3 = new 
RdfCloudTripleStoreUtils.CustomEntry<>(s2, bs1);
-            final Map.Entry<RyaStatement, BindingSet> e4 = new 
RdfCloudTripleStoreUtils.CustomEntry<>(s1, bs2);
-
-            final Collection<Entry<RyaStatement, BindingSet>> stmts3 = 
Lists.newArrayList(e1, e2, e3, e4);
-            assertEquals(4, size(engine.queryWithBindingSet(stmts3, conf)));
-        } finally {
-            dao.destroy();
-        }
-    }
-
-    @SuppressWarnings("unchecked")
-    @Test
-    public void bindingSetsQuery() throws Exception {
-        final MongoDBRyaDAO dao = new MongoDBRyaDAO();
-        try(final MongoDBQueryEngine engine =new MongoDBQueryEngine()) {
-            engine.setConf(conf);
-
-            // Add data.
-            dao.setConf(conf);
-            dao.init();
-            dao.add(getStatement("u:a", "u:tt", "u:b"));
-            dao.add(getStatement("u:a", "u:tt", "u:c"));
-
-            // Run the test.
-            final RyaStatement s = getStatement("u:a", null, null);
-
-            final MapBindingSet bs1 = new MapBindingSet();
-            bs1.addBinding("foo", new URIImpl("u:x"));
-
-            final Map.Entry<RyaStatement, BindingSet> e1 = new 
RdfCloudTripleStoreUtils.CustomEntry<>(s, bs1);
-            final Collection<Entry<RyaStatement, BindingSet>> stmts1 = 
Lists.newArrayList(e1);
-            assertEquals(2, size(engine.queryWithBindingSet(stmts1, conf)));
-
-
-            final MapBindingSet bs2 = new MapBindingSet();
-            bs2.addBinding("foo", new URIImpl("u:y"));
-
-            final Map.Entry<RyaStatement, BindingSet> e2 = new 
RdfCloudTripleStoreUtils.CustomEntry<>(s, bs2);
-
-            final Collection<Entry<RyaStatement, BindingSet>> stmts2 = 
Lists.newArrayList(e1, e2);
-            assertEquals(4, size(engine.queryWithBindingSet(stmts2, conf)));
-        } finally {
-            dao.destroy();
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/4576f556/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBRyaBatchWriterIT.java
----------------------------------------------------------------------
diff --git 
a/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBRyaBatchWriterIT.java
 
b/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBRyaBatchWriterIT.java
index afd7308..d024cc4 100644
--- 
a/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBRyaBatchWriterIT.java
+++ 
b/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBRyaBatchWriterIT.java
@@ -44,7 +44,7 @@ import com.mongodb.DBObject;
 /**
  * Integration tests for the {@link MongoDbBatchWriter}.
  */
-public class MongoDBRyaBatchWriterIT extends MongoTestBase {
+public class MongoDBRyaBatchWriterIT extends MongoITBase {
 
     private static void setupLogging() {
         BasicConfigurator.configure();

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/4576f556/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBRyaDAO2IT.java
----------------------------------------------------------------------
diff --git 
a/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBRyaDAO2IT.java 
b/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBRyaDAO2IT.java
new file mode 100644
index 0000000..f2d24ad
--- /dev/null
+++ b/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBRyaDAO2IT.java
@@ -0,0 +1,138 @@
+/**
+ * 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.
+ */
+package org.apache.rya.mongodb;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+
+import org.apache.rya.api.domain.RyaStatement;
+import org.apache.rya.api.domain.RyaStatement.RyaStatementBuilder;
+import org.apache.rya.api.domain.RyaURI;
+import org.apache.rya.api.persist.RyaDAOException;
+import org.bson.Document;
+import org.junit.Test;
+
+import com.mongodb.MongoException;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.MongoDatabase;
+
+/**
+ * Integration tests the methods of {@link MongoDBRyaDAO}.
+ */
+public class MongoDBRyaDAO2IT extends MongoITBase {
+
+    @Test
+    public void testDeleteWildcard() throws RyaDAOException {
+        MongoDBRyaDAO dao = new MongoDBRyaDAO();
+        try {
+            dao.setConf(conf);
+            dao.init();
+
+            final RyaStatementBuilder builder = new RyaStatementBuilder();
+            builder.setPredicate(new RyaURI("http://temp.com";));
+            dao.delete(builder.build(), conf);
+        } finally {
+            dao.destroy();
+        }
+    }
+
+
+    @Test
+    public void testAdd() throws RyaDAOException, MongoException, IOException {
+        MongoDBRyaDAO dao = new MongoDBRyaDAO();
+        try {
+            dao.setConf(conf);
+            dao.init();
+
+            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 MongoDatabase db = 
conf.getMongoClient().getDatabase(conf.get(MongoDBRdfConfiguration.MONGO_DB_NAME));
+            final MongoCollection<Document> coll = 
db.getCollection(conf.getTriplesCollectionName());
+
+            dao.add(builder.build());
+
+            assertEquals(coll.count(),1);
+        }  finally {
+            dao.destroy();
+        }
+    }
+
+    @Test
+    public void testDelete() throws RyaDAOException, MongoException, 
IOException {
+        MongoDBRyaDAO dao = new MongoDBRyaDAO();
+        try {
+            dao.setConf(conf);
+            dao.init();
+
+            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 MongoDatabase db = 
conf.getMongoClient().getDatabase(conf.get(MongoDBRdfConfiguration.MONGO_DB_NAME));
+            final MongoCollection<Document> coll = 
db.getCollection(conf.getTriplesCollectionName());
+
+            dao.add(statement);
+            assertEquals(coll.count(),1);
+
+            dao.delete(statement, conf);
+            assertEquals(coll.count(),0);
+        } finally {
+            dao.destroy();
+        }
+    }
+
+    @Test
+    public void testDeleteWildcardSubjectWithContext() throws RyaDAOException, 
MongoException, IOException {
+        MongoDBRyaDAO dao = new MongoDBRyaDAO();
+        try {
+            dao.setConf(conf);
+            dao.init();
+
+            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 MongoDatabase db = 
conf.getMongoClient().getDatabase(conf.get(MongoDBRdfConfiguration.MONGO_DB_NAME));
+            final MongoCollection<Document> coll = 
db.getCollection(conf.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, conf);
+            assertEquals(coll.count(),1);
+        } finally {
+            dao.destroy();
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/4576f556/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
index 7043870..a05393c 100644
--- 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
@@ -42,7 +42,7 @@ import com.mongodb.MongoException;
 import com.mongodb.client.MongoCollection;
 import com.mongodb.client.MongoDatabase;
 
-public class MongoDBRyaDAOIT extends MongoTestBase {
+public class MongoDBRyaDAOIT extends MongoITBase {
 
     @Override
     protected void updateConfiguration(final MongoDBRdfConfiguration conf) {
@@ -51,7 +51,7 @@ public class MongoDBRyaDAOIT extends MongoTestBase {
 
     @Test
     public void testDeleteWildcard() throws RyaDAOException {
-        MongoDBRyaDAO dao = new MongoDBRyaDAO();
+        final MongoDBRyaDAO dao = new MongoDBRyaDAO();
         try {
             dao.setConf(conf);
             dao.init();
@@ -67,7 +67,7 @@ public class MongoDBRyaDAOIT extends MongoTestBase {
 
     @Test
     public void testAdd() throws RyaDAOException, MongoException, IOException {
-        MongoDBRyaDAO dao = new MongoDBRyaDAO();
+        final MongoDBRyaDAO dao = new MongoDBRyaDAO();
         try {
             dao.setConf(conf);
             dao.init();
@@ -95,7 +95,7 @@ public class MongoDBRyaDAOIT extends MongoTestBase {
 
     @Test
     public void testDelete() throws RyaDAOException, MongoException, 
IOException {
-        MongoDBRyaDAO dao = new MongoDBRyaDAO();
+        final MongoDBRyaDAO dao = new MongoDBRyaDAO();
         try {
             dao.setConf(conf);
             dao.init();
@@ -121,7 +121,7 @@ public class MongoDBRyaDAOIT extends MongoTestBase {
 
     @Test
     public void testDeleteWildcardSubjectWithContext() throws RyaDAOException, 
MongoException, IOException {
-        MongoDBRyaDAO dao = new MongoDBRyaDAO();
+        final MongoDBRyaDAO dao = new MongoDBRyaDAO();
         try {
             dao.setConf(conf);
             dao.init();
@@ -155,7 +155,7 @@ public class MongoDBRyaDAOIT extends MongoTestBase {
 
     @Test
     public void testVisibility() throws RyaDAOException, MongoException, 
IOException {
-        MongoDBRyaDAO dao = new MongoDBRyaDAO();
+        final MongoDBRyaDAO dao = new MongoDBRyaDAO();
         try {
             dao.setConf(conf);
             dao.init();
@@ -519,9 +519,11 @@ public class MongoDBRyaDAOIT extends MongoTestBase {
     /**
      * Generates a test statement with the provided document visibility to
      * determine if the specified user authorization can view the statement.
-     * @param documentVisibility the document visibility boolean expression
+     *
+     * @param dao - The DAO that will be used by the test.
+     * @param documentVisibility - The document visibility boolean expression
      * string.
-     * @param userAuthorizations the user authorization strings.
+     * @param userAuthorizations - The user authorization strings.
      * @return {@code true} if provided authorization could access the document
      * in the collection. {@code false} otherwise.
      * @throws RyaDAOException

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/4576f556/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
deleted file mode 100644
index 200be9a..0000000
--- 
a/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBRyaDAOTest.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/**
- * 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.
- */
-package org.apache.rya.mongodb;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.IOException;
-
-import org.apache.rya.api.domain.RyaStatement;
-import org.apache.rya.api.domain.RyaStatement.RyaStatementBuilder;
-import org.apache.rya.api.domain.RyaURI;
-import org.apache.rya.api.persist.RyaDAOException;
-import org.bson.Document;
-import org.junit.Test;
-
-import com.mongodb.MongoException;
-import com.mongodb.client.MongoCollection;
-import com.mongodb.client.MongoDatabase;
-
-/**
- * Integration tests the methods of {@link MongoDBRyaDAO}.
- */
-public class MongoDBRyaDAOTest extends MongoTestBase {
-
-    @Test
-    public void testDeleteWildcard() throws RyaDAOException {
-        MongoDBRyaDAO dao = new MongoDBRyaDAO();
-        try {
-            dao.setConf(conf);
-            dao.init();
-
-            final RyaStatementBuilder builder = new RyaStatementBuilder();
-            builder.setPredicate(new RyaURI("http://temp.com";));
-            dao.delete(builder.build(), conf);
-        } finally {
-            dao.destroy();
-        }
-    }
-
-
-    @Test
-    public void testAdd() throws RyaDAOException, MongoException, IOException {
-        MongoDBRyaDAO dao = new MongoDBRyaDAO();
-        try {
-            dao.setConf(conf);
-            dao.init();
-
-            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 MongoDatabase db = 
conf.getMongoClient().getDatabase(conf.get(MongoDBRdfConfiguration.MONGO_DB_NAME));
-            final MongoCollection<Document> coll = 
db.getCollection(conf.getTriplesCollectionName());
-
-            dao.add(builder.build());
-
-            assertEquals(coll.count(),1);
-        }  finally {
-            dao.destroy();
-        }
-    }
-
-    @Test
-    public void testDelete() throws RyaDAOException, MongoException, 
IOException {
-        MongoDBRyaDAO dao = new MongoDBRyaDAO();
-        try {
-            dao.setConf(conf);
-            dao.init();
-
-            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 MongoDatabase db = 
conf.getMongoClient().getDatabase(conf.get(MongoDBRdfConfiguration.MONGO_DB_NAME));
-            final MongoCollection<Document> coll = 
db.getCollection(conf.getTriplesCollectionName());
-
-            dao.add(statement);
-            assertEquals(coll.count(),1);
-
-            dao.delete(statement, conf);
-            assertEquals(coll.count(),0);
-        } finally {
-            dao.destroy();
-        }
-    }
-
-    @Test
-    public void testDeleteWildcardSubjectWithContext() throws RyaDAOException, 
MongoException, IOException {
-        MongoDBRyaDAO dao = new MongoDBRyaDAO();
-        try {
-            dao.setConf(conf);
-            dao.init();
-
-            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 MongoDatabase db = 
conf.getMongoClient().getDatabase(conf.get(MongoDBRdfConfiguration.MONGO_DB_NAME));
-            final MongoCollection<Document> coll = 
db.getCollection(conf.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, conf);
-            assertEquals(coll.count(),1);
-        } finally {
-            dao.destroy();
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/4576f556/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoITBase.java
----------------------------------------------------------------------
diff --git 
a/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoITBase.java 
b/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoITBase.java
new file mode 100644
index 0000000..1aaf6c2
--- /dev/null
+++ b/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoITBase.java
@@ -0,0 +1,94 @@
+/**
+ * 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.
+ */
+package org.apache.rya.mongodb;
+
+import java.util.List;
+
+import org.apache.hadoop.conf.Configuration;
+import org.bson.Document;
+import org.junit.Before;
+
+import com.mongodb.DBCollection;
+import com.mongodb.MongoClient;
+import com.mongodb.client.MongoCollection;
+
+/**
+ * A base class that may be used when implementing Mongo DB tests that use the
+ * JUnit framework.
+ */
+public class MongoITBase {
+
+    private MongoClient mongoClient = null;
+    protected StatefulMongoDBRdfConfiguration conf;
+
+    @Before
+    public void setupTest() throws Exception {
+        // Setup the configuration that will be used within the test.
+        final MongoDBRdfConfiguration conf = new MongoDBRdfConfiguration( new 
Configuration() );
+        conf.setBoolean("sc.useMongo", true);
+        conf.setTablePrefix("test_");
+        conf.setMongoDBName("testDB");
+        
conf.setMongoHostname(EmbeddedMongoSingleton.getMongodConfig().net().getServerAddress().getHostAddress());
+        
conf.setMongoPort(Integer.toString(EmbeddedMongoSingleton.getMongodConfig().net().getPort()));
+
+        // Let tests update the configuration.
+        updateConfiguration(conf);
+
+        // Create the stateful configuration object.
+        mongoClient = EmbeddedMongoSingleton.getNewMongoClient();
+        final List<MongoSecondaryIndex> indexers = 
conf.getInstances("ac.additional.indexers", MongoSecondaryIndex.class);
+        this.conf = new StatefulMongoDBRdfConfiguration(conf, mongoClient, 
indexers);
+
+        // Remove any DBs that were created by previous tests.
+        for(final String dbName : mongoClient.listDatabaseNames()) {
+            mongoClient.dropDatabase(dbName);
+        }
+    }
+
+    /**
+     * Override this method if you would like to augment the configuration 
object that
+     * will be used to initialize indexers and create the mongo client prior 
to running a test.
+     *
+     * @param conf - The configuration object that may be updated. (not null)
+     */
+    protected void updateConfiguration(final MongoDBRdfConfiguration conf) {
+        // By default, do nothing.
+    }
+
+    /**
+     * @return A {@link MongoClient} that is connected to the embedded 
instance of Mongo DB.
+     */
+    public MongoClient getMongoClient() {
+        return mongoClient;
+    }
+
+    /**
+     * @return The Rya triples {@link MongoCollection}.
+     */
+    public MongoCollection<Document> getRyaCollection() {
+        return 
mongoClient.getDatabase(conf.getMongoDBName()).getCollection(conf.getTriplesCollectionName());
+    }
+
+    /**
+     * @return The Rya triples {@link DBCollection}.
+     */
+    public DBCollection getRyaDbCollection() {
+        return 
mongoClient.getDB(conf.getMongoDBName()).getCollection(conf.getTriplesCollectionName());
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/4576f556/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoTestBase.java
----------------------------------------------------------------------
diff --git 
a/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoTestBase.java 
b/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoTestBase.java
deleted file mode 100644
index 6dbd19b..0000000
--- a/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoTestBase.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/**
- * 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.
- */
-package org.apache.rya.mongodb;
-
-import java.util.List;
-
-import org.apache.hadoop.conf.Configuration;
-import org.bson.Document;
-import org.junit.Before;
-
-import com.mongodb.DBCollection;
-import com.mongodb.MongoClient;
-import com.mongodb.client.MongoCollection;
-
-/**
- * A base class that may be used when implementing Mongo DB tests that use the
- * JUnit framework.
- */
-public class MongoTestBase {
-
-    private MongoClient mongoClient = null;
-    protected StatefulMongoDBRdfConfiguration conf;
-
-    @Before
-    public void setupTest() throws Exception {
-        // Setup the configuration that will be used within the test.
-        final MongoDBRdfConfiguration conf = new MongoDBRdfConfiguration( new 
Configuration() );
-        conf.setBoolean("sc.useMongo", true);
-        conf.setTablePrefix("test_");
-        conf.setMongoDBName("testDB");
-        
conf.setMongoHostname(EmbeddedMongoSingleton.getMongodConfig().net().getServerAddress().getHostAddress());
-        
conf.setMongoPort(Integer.toString(EmbeddedMongoSingleton.getMongodConfig().net().getPort()));
-
-        // Let tests update the configuration.
-        updateConfiguration(conf);
-
-        // Create the stateful configuration object.
-        mongoClient = EmbeddedMongoSingleton.getNewMongoClient();
-        final List<MongoSecondaryIndex> indexers = 
conf.getInstances("ac.additional.indexers", MongoSecondaryIndex.class);
-        this.conf = new StatefulMongoDBRdfConfiguration(conf, mongoClient, 
indexers);
-
-        // Remove any DBs that were created by previous tests.
-        for(final String dbName : mongoClient.listDatabaseNames()) {
-            mongoClient.dropDatabase(dbName);
-        }
-    }
-
-    /**
-     * Override this method if you would like to augment the configuration 
object that
-     * will be used to initialize indexers and create the mongo client prior 
to running a test.
-     *
-     * @param conf - The configuration object that may be updated. (not null)
-     */
-    protected void updateConfiguration(final MongoDBRdfConfiguration conf) {
-        // By default, do nothing.
-    }
-
-    /**
-     * @return A {@link MongoClient} that is connected to the embedded 
instance of Mongo DB.
-     */
-    public MongoClient getMongoClient() {
-        return mongoClient;
-    }
-
-    /**
-     * @return The Rya triples {@link MongoCollection}.
-     */
-    public MongoCollection<Document> getRyaCollection() {
-        return 
mongoClient.getDatabase(conf.getMongoDBName()).getCollection(conf.getTriplesCollectionName());
-    }
-
-    /**
-     * @return The Rya triples {@link DBCollection}.
-     */
-    public DBCollection getRyaDbCollection() {
-        return 
mongoClient.getDB(conf.getMongoDBName()).getCollection(conf.getTriplesCollectionName());
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/4576f556/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/instance/MongoRyaDetailsRepositoryIT.java
----------------------------------------------------------------------
diff --git 
a/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/instance/MongoRyaDetailsRepositoryIT.java
 
b/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/instance/MongoRyaDetailsRepositoryIT.java
index cb276cb..dd5088e 100644
--- 
a/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/instance/MongoRyaDetailsRepositoryIT.java
+++ 
b/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/instance/MongoRyaDetailsRepositoryIT.java
@@ -40,7 +40,7 @@ import 
org.apache.rya.api.instance.RyaDetailsRepository.AlreadyInitializedExcept
 import 
org.apache.rya.api.instance.RyaDetailsRepository.ConcurrentUpdateException;
 import 
org.apache.rya.api.instance.RyaDetailsRepository.NotInitializedException;
 import 
org.apache.rya.api.instance.RyaDetailsRepository.RyaDetailsRepositoryException;
-import org.apache.rya.mongodb.MongoTestBase;
+import org.apache.rya.mongodb.MongoITBase;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -50,7 +50,7 @@ import com.mongodb.MongoClient;
 /**
  * Tests the methods of {@link AccumuloRyaDetailsRepository} by using a {@link 
MiniAccumuloCluster}.
  */
-public class MongoRyaDetailsRepositoryIT extends MongoTestBase {
+public class MongoRyaDetailsRepositoryIT extends MongoITBase {
     private MongoClient client;
 
     @Before

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/4576f556/extras/indexing/src/main/java/org/apache/rya/indexing/entity/update/mongo/MongoEntityIndexer.java
----------------------------------------------------------------------
diff --git 
a/extras/indexing/src/main/java/org/apache/rya/indexing/entity/update/mongo/MongoEntityIndexer.java
 
b/extras/indexing/src/main/java/org/apache/rya/indexing/entity/update/mongo/MongoEntityIndexer.java
index a850557..1507e98 100644
--- 
a/extras/indexing/src/main/java/org/apache/rya/indexing/entity/update/mongo/MongoEntityIndexer.java
+++ 
b/extras/indexing/src/main/java/org/apache/rya/indexing/entity/update/mongo/MongoEntityIndexer.java
@@ -38,13 +38,13 @@ public class MongoEntityIndexer extends BaseEntityIndexer {
 
     @Override
     public EntityStorage getEntityStorage() throws EntityStorageException {
-       final StatefulMongoDBRdfConfiguration conf = super.configuration.get();
+        final StatefulMongoDBRdfConfiguration conf = super.configuration.get();
         return new MongoEntityStorage(conf.getMongoClient(), 
conf.getRyaInstanceName());
     }
 
     @Override
     public TypeStorage getTypeStorage() {
-       final StatefulMongoDBRdfConfiguration conf = super.configuration.get();
+        final StatefulMongoDBRdfConfiguration conf = super.configuration.get();
         return new MongoTypeStorage(conf.getMongoClient(), 
conf.getRyaInstanceName());
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/4576f556/extras/indexing/src/main/java/org/apache/rya/indexing/statement/metadata/matching/RyaQueryEngineFactory.java
----------------------------------------------------------------------
diff --git 
a/extras/indexing/src/main/java/org/apache/rya/indexing/statement/metadata/matching/RyaQueryEngineFactory.java
 
b/extras/indexing/src/main/java/org/apache/rya/indexing/statement/metadata/matching/RyaQueryEngineFactory.java
index 1025537..eb35aac 100644
--- 
a/extras/indexing/src/main/java/org/apache/rya/indexing/statement/metadata/matching/RyaQueryEngineFactory.java
+++ 
b/extras/indexing/src/main/java/org/apache/rya/indexing/statement/metadata/matching/RyaQueryEngineFactory.java
@@ -29,6 +29,7 @@ import org.apache.rya.accumulo.AccumuloRdfConfiguration;
 import org.apache.rya.accumulo.query.AccumuloRyaQueryEngine;
 import org.apache.rya.api.RdfCloudTripleStoreConfiguration;
 import org.apache.rya.api.persist.query.RyaQueryEngine;
+import org.apache.rya.indexing.accumulo.ConfigUtils;
 import org.apache.rya.mongodb.MongoDBQueryEngine;
 import org.apache.rya.mongodb.StatefulMongoDBRdfConfiguration;
 
@@ -60,7 +61,7 @@ public class RyaQueryEngineFactory {
                 throw new RuntimeException(e);
             }
             return (RyaQueryEngine<C>) new AccumuloRyaQueryEngine(conn, aConf);
-        } else if(conf instanceof StatefulMongoDBRdfConfiguration && 
conf.getBoolean("sc.useMongo", false)) {
+        } else if(conf instanceof StatefulMongoDBRdfConfiguration && 
ConfigUtils.getUseMongo(conf)) {
             StatefulMongoDBRdfConfiguration mongoConf = 
(StatefulMongoDBRdfConfiguration)conf;
             MongoDBQueryEngine mongoQueryEngine = new MongoDBQueryEngine();
             mongoQueryEngine.setConf(mongoConf);

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/4576f556/extras/indexing/src/test/java/org/apache/rya/indexing/entity/query/EntityQueryNodeIT.java
----------------------------------------------------------------------
diff --git 
a/extras/indexing/src/test/java/org/apache/rya/indexing/entity/query/EntityQueryNodeIT.java
 
b/extras/indexing/src/test/java/org/apache/rya/indexing/entity/query/EntityQueryNodeIT.java
new file mode 100644
index 0000000..66b79ef
--- /dev/null
+++ 
b/extras/indexing/src/test/java/org/apache/rya/indexing/entity/query/EntityQueryNodeIT.java
@@ -0,0 +1,287 @@
+/**
+ * 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.
+ */
+package org.apache.rya.indexing.entity.query;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.rya.api.domain.RyaURI;
+import org.apache.rya.api.resolver.RdfToRyaConversions;
+import org.apache.rya.indexing.entity.model.Entity;
+import org.apache.rya.indexing.entity.model.Property;
+import org.apache.rya.indexing.entity.model.Type;
+import org.apache.rya.indexing.entity.storage.EntityStorage;
+import org.apache.rya.indexing.entity.storage.mongo.MongoEntityStorage;
+import org.apache.rya.mongodb.MongoITBase;
+import org.junit.Test;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.model.impl.ValueFactoryImpl;
+import org.openrdf.model.vocabulary.RDF;
+import org.openrdf.query.BindingSet;
+import org.openrdf.query.MalformedQueryException;
+import org.openrdf.query.QueryEvaluationException;
+import org.openrdf.query.algebra.StatementPattern;
+import org.openrdf.query.algebra.helpers.StatementPatternCollector;
+import org.openrdf.query.impl.MapBindingSet;
+import org.openrdf.query.parser.sparql.SPARQLParser;
+
+import com.google.common.collect.ImmutableSet;
+
+import info.aduna.iteration.CloseableIteration;
+
+/**
+ * Integration tests the methods of {@link EntityQueryNode}.
+ */
+public class EntityQueryNodeIT extends MongoITBase {
+
+    private static final Type PERSON_TYPE =
+            new Type(new RyaURI("urn:person"),
+                ImmutableSet.<RyaURI>builder()
+                    .add(new RyaURI("urn:name"))
+                    .add(new RyaURI("urn:age"))
+                    .add(new RyaURI("urn:eye"))
+                    .build());
+
+    private static final Type EMPLOYEE_TYPE =
+            new Type(new RyaURI("urn:employee"),
+                ImmutableSet.<RyaURI>builder()
+                    .add(new RyaURI("urn:name"))
+                    .add(new RyaURI("urn:hoursPerWeek"))
+                    .build());
+
+    @Test(expected = IllegalStateException.class)
+    public void constructor_differentSubjects() throws Exception {
+        // A pattern that has two different subjects.
+        final List<StatementPattern> patterns = getSPs(
+                "SELECT * WHERE { " +
+                    "<urn:SSN:111-11-1111> <" + RDF.TYPE + "> <urn:person> ."+
+                    "<urn:SSN:111-11-1111> <urn:age> ?age . " +
+                    "<urn:SSN:111-11-1111> <urn:eye> ?eye . " +
+                    "<urn:SSN:111-11-1111> <urn:name> ?name . " +
+                    "<urn:SSN:222-22-2222> <urn:age> ?age . " +
+                    "<urn:SSN:222-22-2222> <urn:eye> ?eye . " +
+                    "<urn:SSN:222-22-2222> <urn:name> ?name . " +
+                "}");
+
+
+        // This will fail.
+        new EntityQueryNode(PERSON_TYPE, patterns, mock(EntityStorage.class));
+    }
+
+    @Test(expected = IllegalStateException.class)
+    public void constructor_variablePredicate() throws Exception {
+        // A pattern that has a variable for its predicate.
+        final List<StatementPattern> patterns = getSPs(
+                "SELECT * WHERE { " +
+                    "?subject <" + RDF.TYPE + "> <urn:person> ."+
+                    "?subject ?variableProperty ?value . " +
+                    "?subject <urn:eye> ?eye . " +
+                    "?subject <urn:name> ?name . " +
+                "}");
+
+
+        // This will fail.
+        new EntityQueryNode(PERSON_TYPE, patterns, mock(EntityStorage.class));
+    }
+
+    @Test(expected = IllegalStateException.class)
+    public void constructor_predicateNotPartOfType() throws Exception {
+        // A pattern that does uses a predicate that is not part of the type.
+        final List<StatementPattern> patterns = getSPs(
+                "SELECT * WHERE { " +
+                    "?subject <" + RDF.TYPE + "> <urn:person> ."+
+                    "?subject <urn:age> ?age . " +
+                    "?subject <urn:eye> ?eye . " +
+                    "?subject <urn:name> ?name . " +
+                    "?subject <urn:notPartOfType> ?value . " +
+                "}");
+
+        // This will fail.
+        new EntityQueryNode(PERSON_TYPE, patterns, mock(EntityStorage.class));
+    }
+
+    @Test(expected = IllegalStateException.class)
+    public void constructor_typeMissing() throws Exception {
+        // A pattern that does uses a predicate that is not part of the type.
+        final List<StatementPattern> patterns = getSPs(
+                "SELECT * WHERE { " +
+                    "?subject <urn:age> ?age . " +
+                    "?subject <urn:eye> ?eye . " +
+                    "?subject <urn:name> ?name . " +
+                "}");
+
+        // This will fail.
+        new EntityQueryNode(PERSON_TYPE, patterns, mock(EntityStorage.class));
+    }
+
+    @Test(expected = IllegalStateException.class)
+    public void constructor_wrongType() throws Exception {
+        // A pattern that does uses a predicate that is not part of the type.
+        final List<StatementPattern> patterns = getSPs(
+                "SELECT * WHERE { " +
+                    "?subject <" + RDF.TYPE + "> <urn:person> ."+
+                    "?subject <urn:age> ?age . " +
+                    "?subject <urn:eye> ?eye . " +
+                    "?subject <urn:name> ?name . " +
+                "}");
+
+        // This will fail.
+        new EntityQueryNode(EMPLOYEE_TYPE, patterns, 
mock(EntityStorage.class));
+    }
+
+    @Test
+    public void evaluate_constantSubject() throws Exception {
+        final EntityStorage storage = new 
MongoEntityStorage(super.getMongoClient(), "testDB");
+        final ValueFactory vf = ValueFactoryImpl.getInstance();
+        final RyaURI subject = new RyaURI("urn:SSN:111-11-1111");
+        final Entity entity = Entity.builder()
+            .setSubject(subject)
+            .setExplicitType(PERSON_TYPE.getId())
+            .setProperty(PERSON_TYPE.getId(), new Property(new 
RyaURI("urn:age"), RdfToRyaConversions.convertLiteral(vf.createLiteral(20))))
+            .setProperty(PERSON_TYPE.getId(), new Property(new 
RyaURI("urn:eye"), 
RdfToRyaConversions.convertLiteral(vf.createLiteral("blue"))))
+            .setProperty(PERSON_TYPE.getId(), new Property(new 
RyaURI("urn:name"), 
RdfToRyaConversions.convertLiteral(vf.createLiteral("Bob"))))
+            .build();
+
+        storage.create(entity);
+        // A set of patterns that match a sepecific Entity subject.
+        final List<StatementPattern> patterns = getSPs(
+                "SELECT * WHERE { " +
+                    "<urn:SSN:111-11-1111> <" + RDF.TYPE + "> <urn:person> ."+
+                    "<urn:SSN:111-11-1111> <urn:age> ?age . " +
+                    "<urn:SSN:111-11-1111> <urn:eye> ?eye . " +
+                    "<urn:SSN:111-11-1111> <urn:name> ?name . " +
+                "}");
+
+        final EntityQueryNode node = new EntityQueryNode(PERSON_TYPE, 
patterns, storage);
+        final CloseableIteration<BindingSet, QueryEvaluationException> rez = 
node.evaluate(new MapBindingSet());
+        final MapBindingSet expected = new MapBindingSet();
+        expected.addBinding("age", vf.createLiteral("20"));
+        expected.addBinding("eye", vf.createLiteral("blue"));
+        expected.addBinding("name", vf.createLiteral("Bob"));
+        while(rez.hasNext()) {
+            assertEquals(expected, rez.next());
+            break;
+        }
+    }
+
+    @Test
+    public void evaluate_variableSubject() throws Exception {
+        final EntityStorage storage = new 
MongoEntityStorage(super.getMongoClient(), "testDB");
+        final ValueFactory vf = ValueFactoryImpl.getInstance();
+        RyaURI subject = new RyaURI("urn:SSN:111-11-1111");
+        final Entity bob = Entity.builder()
+                .setSubject(subject)
+                .setExplicitType(PERSON_TYPE.getId())
+                .setProperty(PERSON_TYPE.getId(), new Property(new 
RyaURI("urn:age"), RdfToRyaConversions.convertLiteral(vf.createLiteral(20))))
+                .setProperty(PERSON_TYPE.getId(), new Property(new 
RyaURI("urn:eye"), 
RdfToRyaConversions.convertLiteral(vf.createLiteral("blue"))))
+                .setProperty(PERSON_TYPE.getId(), new Property(new 
RyaURI("urn:name"), 
RdfToRyaConversions.convertLiteral(vf.createLiteral("Bob"))))
+                .build();
+
+        subject = new RyaURI("urn:SSN:222-22-2222");
+        final Entity fred = Entity.builder()
+                .setSubject(subject)
+                .setExplicitType(PERSON_TYPE.getId())
+                .setProperty(PERSON_TYPE.getId(), new Property(new 
RyaURI("urn:age"), RdfToRyaConversions.convertLiteral(vf.createLiteral(25))))
+                .setProperty(PERSON_TYPE.getId(), new Property(new 
RyaURI("urn:eye"), 
RdfToRyaConversions.convertLiteral(vf.createLiteral("brown"))))
+                .setProperty(PERSON_TYPE.getId(), new Property(new 
RyaURI("urn:name"), 
RdfToRyaConversions.convertLiteral(vf.createLiteral("Fred"))))
+                .build();
+
+        storage.create(bob);
+        storage.create(fred);
+        // A set of patterns that match a sepecific Entity subject.
+        final List<StatementPattern> patterns = getSPs(
+                "SELECT * WHERE { " +
+                    "?ssn <" + RDF.TYPE + "> <urn:person> ."+
+                    "?ssn <urn:age> ?age . " +
+                    "?ssn <urn:eye> ?eye . " +
+                    "?ssn <urn:name> ?name . " +
+                "}");
+
+        final EntityQueryNode node = new EntityQueryNode(PERSON_TYPE, 
patterns, storage);
+        final CloseableIteration<BindingSet, QueryEvaluationException> rez = 
node.evaluate(new MapBindingSet());
+        final List<BindingSet> expectedBindings = new ArrayList<>();
+        final MapBindingSet expectedBob = new MapBindingSet();
+        expectedBob.addBinding("age", vf.createLiteral("20"));
+        expectedBob.addBinding("eye", vf.createLiteral("blue"));
+        expectedBob.addBinding("name", vf.createLiteral("Bob"));
+
+        final MapBindingSet expectedFred = new MapBindingSet();
+        expectedFred.addBinding("age", vf.createLiteral("25"));
+        expectedFred.addBinding("eye", vf.createLiteral("brown"));
+        expectedFred.addBinding("name", vf.createLiteral("Fred"));
+        expectedBindings.add(expectedBob);
+        expectedBindings.add(expectedFred);
+        while(rez.hasNext()) {
+            final BindingSet bs = rez.next();
+            assertTrue(expectedBindings.contains(bs));
+        }
+    }
+
+    @Test
+    public void evaluate_constantObject() throws Exception {
+        final EntityStorage storage = new 
MongoEntityStorage(super.getMongoClient(), "testDB");
+        final ValueFactory vf = ValueFactoryImpl.getInstance();
+        final RyaURI subject = new RyaURI("urn:SSN:111-11-1111");
+        final Entity entity = Entity.builder()
+            .setSubject(subject)
+            .setExplicitType(PERSON_TYPE.getId())
+            .setProperty(PERSON_TYPE.getId(), new Property(new 
RyaURI("urn:age"), RdfToRyaConversions.convertLiteral(vf.createLiteral(20))))
+            .setProperty(PERSON_TYPE.getId(), new Property(new 
RyaURI("urn:eye"), 
RdfToRyaConversions.convertLiteral(vf.createLiteral("blue"))))
+            .setProperty(PERSON_TYPE.getId(), new Property(new 
RyaURI("urn:name"), 
RdfToRyaConversions.convertLiteral(vf.createLiteral("Bob"))))
+            .build();
+
+        storage.create(entity);
+        // A set of patterns that match a sepecific Entity subject.
+        final List<StatementPattern> patterns = getSPs(
+                "SELECT * WHERE { " +
+                    "<urn:SSN:111-11-1111> <" + RDF.TYPE + "> <urn:person> ."+
+                    "<urn:SSN:111-11-1111> <urn:age> ?age . " +
+                    "<urn:SSN:111-11-1111> <urn:eye> \"blue\" . " +
+                    "<urn:SSN:111-11-1111> <urn:name> ?name . " +
+                "}");
+
+        final EntityQueryNode node = new EntityQueryNode(PERSON_TYPE, 
patterns, storage);
+        final CloseableIteration<BindingSet, QueryEvaluationException> rez = 
node.evaluate(new MapBindingSet());
+        final MapBindingSet expected = new MapBindingSet();
+        expected.addBinding("age", vf.createLiteral("20"));
+        expected.addBinding("-const-blue", vf.createLiteral("blue"));
+        expected.addBinding("name", vf.createLiteral("Bob"));
+        while(rez.hasNext()) {
+            assertEquals(expected, rez.next());
+            break;
+        }
+    }
+
+    /**
+     * TODO doc
+     *
+     * @param sparql
+     * @return
+     * @throws MalformedQueryException
+     */
+    private static List<StatementPattern> getSPs(final String sparql) throws 
MalformedQueryException {
+        final StatementPatternCollector spCollector = new 
StatementPatternCollector();
+        new SPARQLParser().parseQuery(sparql, 
null).getTupleExpr().visit(spCollector);
+        return spCollector.getStatementPatterns();
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/4576f556/extras/indexing/src/test/java/org/apache/rya/indexing/entity/query/EntityQueryNodeTest.java
----------------------------------------------------------------------
diff --git 
a/extras/indexing/src/test/java/org/apache/rya/indexing/entity/query/EntityQueryNodeTest.java
 
b/extras/indexing/src/test/java/org/apache/rya/indexing/entity/query/EntityQueryNodeTest.java
deleted file mode 100644
index 874a40e..0000000
--- 
a/extras/indexing/src/test/java/org/apache/rya/indexing/entity/query/EntityQueryNodeTest.java
+++ /dev/null
@@ -1,287 +0,0 @@
-/**
- * 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.
- */
-package org.apache.rya.indexing.entity.query;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.rya.api.domain.RyaURI;
-import org.apache.rya.api.resolver.RdfToRyaConversions;
-import org.apache.rya.indexing.entity.model.Entity;
-import org.apache.rya.indexing.entity.model.Property;
-import org.apache.rya.indexing.entity.model.Type;
-import org.apache.rya.indexing.entity.storage.EntityStorage;
-import org.apache.rya.indexing.entity.storage.mongo.MongoEntityStorage;
-import org.apache.rya.mongodb.MongoTestBase;
-import org.junit.Test;
-import org.openrdf.model.ValueFactory;
-import org.openrdf.model.impl.ValueFactoryImpl;
-import org.openrdf.model.vocabulary.RDF;
-import org.openrdf.query.BindingSet;
-import org.openrdf.query.MalformedQueryException;
-import org.openrdf.query.QueryEvaluationException;
-import org.openrdf.query.algebra.StatementPattern;
-import org.openrdf.query.algebra.helpers.StatementPatternCollector;
-import org.openrdf.query.impl.MapBindingSet;
-import org.openrdf.query.parser.sparql.SPARQLParser;
-
-import com.google.common.collect.ImmutableSet;
-
-import info.aduna.iteration.CloseableIteration;
-
-/**
- * Unit tests the methods of {@link EntityQueryNode}.
- */
-public class EntityQueryNodeTest extends MongoTestBase {
-
-    private static final Type PERSON_TYPE =
-            new Type(new RyaURI("urn:person"),
-                ImmutableSet.<RyaURI>builder()
-                    .add(new RyaURI("urn:name"))
-                    .add(new RyaURI("urn:age"))
-                    .add(new RyaURI("urn:eye"))
-                    .build());
-
-    private static final Type EMPLOYEE_TYPE =
-            new Type(new RyaURI("urn:employee"),
-                ImmutableSet.<RyaURI>builder()
-                    .add(new RyaURI("urn:name"))
-                    .add(new RyaURI("urn:hoursPerWeek"))
-                    .build());
-
-    @Test(expected = IllegalStateException.class)
-    public void constructor_differentSubjects() throws Exception {
-        // A pattern that has two different subjects.
-        final List<StatementPattern> patterns = getSPs(
-                "SELECT * WHERE { " +
-                    "<urn:SSN:111-11-1111> <" + RDF.TYPE + "> <urn:person> ."+
-                    "<urn:SSN:111-11-1111> <urn:age> ?age . " +
-                    "<urn:SSN:111-11-1111> <urn:eye> ?eye . " +
-                    "<urn:SSN:111-11-1111> <urn:name> ?name . " +
-                    "<urn:SSN:222-22-2222> <urn:age> ?age . " +
-                    "<urn:SSN:222-22-2222> <urn:eye> ?eye . " +
-                    "<urn:SSN:222-22-2222> <urn:name> ?name . " +
-                "}");
-
-
-        // This will fail.
-        new EntityQueryNode(PERSON_TYPE, patterns, mock(EntityStorage.class));
-    }
-
-    @Test(expected = IllegalStateException.class)
-    public void constructor_variablePredicate() throws Exception {
-        // A pattern that has a variable for its predicate.
-        final List<StatementPattern> patterns = getSPs(
-                "SELECT * WHERE { " +
-                    "?subject <" + RDF.TYPE + "> <urn:person> ."+
-                    "?subject ?variableProperty ?value . " +
-                    "?subject <urn:eye> ?eye . " +
-                    "?subject <urn:name> ?name . " +
-                "}");
-
-
-        // This will fail.
-        new EntityQueryNode(PERSON_TYPE, patterns, mock(EntityStorage.class));
-    }
-
-    @Test(expected = IllegalStateException.class)
-    public void constructor_predicateNotPartOfType() throws Exception {
-        // A pattern that does uses a predicate that is not part of the type.
-        final List<StatementPattern> patterns = getSPs(
-                "SELECT * WHERE { " +
-                    "?subject <" + RDF.TYPE + "> <urn:person> ."+
-                    "?subject <urn:age> ?age . " +
-                    "?subject <urn:eye> ?eye . " +
-                    "?subject <urn:name> ?name . " +
-                    "?subject <urn:notPartOfType> ?value . " +
-                "}");
-
-        // This will fail.
-        new EntityQueryNode(PERSON_TYPE, patterns, mock(EntityStorage.class));
-    }
-
-    @Test(expected = IllegalStateException.class)
-    public void constructor_typeMissing() throws Exception {
-        // A pattern that does uses a predicate that is not part of the type.
-        final List<StatementPattern> patterns = getSPs(
-                "SELECT * WHERE { " +
-                    "?subject <urn:age> ?age . " +
-                    "?subject <urn:eye> ?eye . " +
-                    "?subject <urn:name> ?name . " +
-                "}");
-
-        // This will fail.
-        new EntityQueryNode(PERSON_TYPE, patterns, mock(EntityStorage.class));
-    }
-
-    @Test(expected = IllegalStateException.class)
-    public void constructor_wrongType() throws Exception {
-        // A pattern that does uses a predicate that is not part of the type.
-        final List<StatementPattern> patterns = getSPs(
-                "SELECT * WHERE { " +
-                    "?subject <" + RDF.TYPE + "> <urn:person> ."+
-                    "?subject <urn:age> ?age . " +
-                    "?subject <urn:eye> ?eye . " +
-                    "?subject <urn:name> ?name . " +
-                "}");
-
-        // This will fail.
-        new EntityQueryNode(EMPLOYEE_TYPE, patterns, 
mock(EntityStorage.class));
-    }
-
-    @Test
-    public void evaluate_constantSubject() throws Exception {
-        final EntityStorage storage = new 
MongoEntityStorage(super.getMongoClient(), "testDB");
-        final ValueFactory vf = ValueFactoryImpl.getInstance();
-        final RyaURI subject = new RyaURI("urn:SSN:111-11-1111");
-        final Entity entity = Entity.builder()
-            .setSubject(subject)
-            .setExplicitType(PERSON_TYPE.getId())
-            .setProperty(PERSON_TYPE.getId(), new Property(new 
RyaURI("urn:age"), RdfToRyaConversions.convertLiteral(vf.createLiteral(20))))
-            .setProperty(PERSON_TYPE.getId(), new Property(new 
RyaURI("urn:eye"), 
RdfToRyaConversions.convertLiteral(vf.createLiteral("blue"))))
-            .setProperty(PERSON_TYPE.getId(), new Property(new 
RyaURI("urn:name"), 
RdfToRyaConversions.convertLiteral(vf.createLiteral("Bob"))))
-            .build();
-
-        storage.create(entity);
-        // A set of patterns that match a sepecific Entity subject.
-        final List<StatementPattern> patterns = getSPs(
-                "SELECT * WHERE { " +
-                    "<urn:SSN:111-11-1111> <" + RDF.TYPE + "> <urn:person> ."+
-                    "<urn:SSN:111-11-1111> <urn:age> ?age . " +
-                    "<urn:SSN:111-11-1111> <urn:eye> ?eye . " +
-                    "<urn:SSN:111-11-1111> <urn:name> ?name . " +
-                "}");
-
-        final EntityQueryNode node = new EntityQueryNode(PERSON_TYPE, 
patterns, storage);
-        final CloseableIteration<BindingSet, QueryEvaluationException> rez = 
node.evaluate(new MapBindingSet());
-        final MapBindingSet expected = new MapBindingSet();
-        expected.addBinding("age", vf.createLiteral("20"));
-        expected.addBinding("eye", vf.createLiteral("blue"));
-        expected.addBinding("name", vf.createLiteral("Bob"));
-        while(rez.hasNext()) {
-            assertEquals(expected, rez.next());
-            break;
-        }
-    }
-
-    @Test
-    public void evaluate_variableSubject() throws Exception {
-        final EntityStorage storage = new 
MongoEntityStorage(super.getMongoClient(), "testDB");
-        final ValueFactory vf = ValueFactoryImpl.getInstance();
-        RyaURI subject = new RyaURI("urn:SSN:111-11-1111");
-        final Entity bob = Entity.builder()
-                .setSubject(subject)
-                .setExplicitType(PERSON_TYPE.getId())
-                .setProperty(PERSON_TYPE.getId(), new Property(new 
RyaURI("urn:age"), RdfToRyaConversions.convertLiteral(vf.createLiteral(20))))
-                .setProperty(PERSON_TYPE.getId(), new Property(new 
RyaURI("urn:eye"), 
RdfToRyaConversions.convertLiteral(vf.createLiteral("blue"))))
-                .setProperty(PERSON_TYPE.getId(), new Property(new 
RyaURI("urn:name"), 
RdfToRyaConversions.convertLiteral(vf.createLiteral("Bob"))))
-                .build();
-
-        subject = new RyaURI("urn:SSN:222-22-2222");
-        final Entity fred = Entity.builder()
-                .setSubject(subject)
-                .setExplicitType(PERSON_TYPE.getId())
-                .setProperty(PERSON_TYPE.getId(), new Property(new 
RyaURI("urn:age"), RdfToRyaConversions.convertLiteral(vf.createLiteral(25))))
-                .setProperty(PERSON_TYPE.getId(), new Property(new 
RyaURI("urn:eye"), 
RdfToRyaConversions.convertLiteral(vf.createLiteral("brown"))))
-                .setProperty(PERSON_TYPE.getId(), new Property(new 
RyaURI("urn:name"), 
RdfToRyaConversions.convertLiteral(vf.createLiteral("Fred"))))
-                .build();
-
-        storage.create(bob);
-        storage.create(fred);
-        // A set of patterns that match a sepecific Entity subject.
-        final List<StatementPattern> patterns = getSPs(
-                "SELECT * WHERE { " +
-                    "?ssn <" + RDF.TYPE + "> <urn:person> ."+
-                    "?ssn <urn:age> ?age . " +
-                    "?ssn <urn:eye> ?eye . " +
-                    "?ssn <urn:name> ?name . " +
-                "}");
-
-        final EntityQueryNode node = new EntityQueryNode(PERSON_TYPE, 
patterns, storage);
-        final CloseableIteration<BindingSet, QueryEvaluationException> rez = 
node.evaluate(new MapBindingSet());
-        final List<BindingSet> expectedBindings = new ArrayList<>();
-        final MapBindingSet expectedBob = new MapBindingSet();
-        expectedBob.addBinding("age", vf.createLiteral("20"));
-        expectedBob.addBinding("eye", vf.createLiteral("blue"));
-        expectedBob.addBinding("name", vf.createLiteral("Bob"));
-
-        final MapBindingSet expectedFred = new MapBindingSet();
-        expectedFred.addBinding("age", vf.createLiteral("25"));
-        expectedFred.addBinding("eye", vf.createLiteral("brown"));
-        expectedFred.addBinding("name", vf.createLiteral("Fred"));
-        expectedBindings.add(expectedBob);
-        expectedBindings.add(expectedFred);
-        while(rez.hasNext()) {
-            final BindingSet bs = rez.next();
-            assertTrue(expectedBindings.contains(bs));
-        }
-    }
-
-    @Test
-    public void evaluate_constantObject() throws Exception {
-        final EntityStorage storage = new 
MongoEntityStorage(super.getMongoClient(), "testDB");
-        final ValueFactory vf = ValueFactoryImpl.getInstance();
-        final RyaURI subject = new RyaURI("urn:SSN:111-11-1111");
-        final Entity entity = Entity.builder()
-            .setSubject(subject)
-            .setExplicitType(PERSON_TYPE.getId())
-            .setProperty(PERSON_TYPE.getId(), new Property(new 
RyaURI("urn:age"), RdfToRyaConversions.convertLiteral(vf.createLiteral(20))))
-            .setProperty(PERSON_TYPE.getId(), new Property(new 
RyaURI("urn:eye"), 
RdfToRyaConversions.convertLiteral(vf.createLiteral("blue"))))
-            .setProperty(PERSON_TYPE.getId(), new Property(new 
RyaURI("urn:name"), 
RdfToRyaConversions.convertLiteral(vf.createLiteral("Bob"))))
-            .build();
-
-        storage.create(entity);
-        // A set of patterns that match a sepecific Entity subject.
-        final List<StatementPattern> patterns = getSPs(
-                "SELECT * WHERE { " +
-                    "<urn:SSN:111-11-1111> <" + RDF.TYPE + "> <urn:person> ."+
-                    "<urn:SSN:111-11-1111> <urn:age> ?age . " +
-                    "<urn:SSN:111-11-1111> <urn:eye> \"blue\" . " +
-                    "<urn:SSN:111-11-1111> <urn:name> ?name . " +
-                "}");
-
-        final EntityQueryNode node = new EntityQueryNode(PERSON_TYPE, 
patterns, storage);
-        final CloseableIteration<BindingSet, QueryEvaluationException> rez = 
node.evaluate(new MapBindingSet());
-        final MapBindingSet expected = new MapBindingSet();
-        expected.addBinding("age", vf.createLiteral("20"));
-        expected.addBinding("-const-blue", vf.createLiteral("blue"));
-        expected.addBinding("name", vf.createLiteral("Bob"));
-        while(rez.hasNext()) {
-            assertEquals(expected, rez.next());
-            break;
-        }
-    }
-
-    /**
-     * TODO doc
-     *
-     * @param sparql
-     * @return
-     * @throws MalformedQueryException
-     */
-    private static List<StatementPattern> getSPs(final String sparql) throws 
MalformedQueryException {
-        final StatementPatternCollector spCollector = new 
StatementPatternCollector();
-        new SPARQLParser().parseQuery(sparql, 
null).getTupleExpr().visit(spCollector);
-        return spCollector.getStatementPatterns();
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/4576f556/extras/indexing/src/test/java/org/apache/rya/indexing/entity/storage/mongo/MongoEntityStorageIT.java
----------------------------------------------------------------------
diff --git 
a/extras/indexing/src/test/java/org/apache/rya/indexing/entity/storage/mongo/MongoEntityStorageIT.java
 
b/extras/indexing/src/test/java/org/apache/rya/indexing/entity/storage/mongo/MongoEntityStorageIT.java
index d8856fe..8e33d37 100644
--- 
a/extras/indexing/src/test/java/org/apache/rya/indexing/entity/storage/mongo/MongoEntityStorageIT.java
+++ 
b/extras/indexing/src/test/java/org/apache/rya/indexing/entity/storage/mongo/MongoEntityStorageIT.java
@@ -36,7 +36,7 @@ import org.apache.rya.indexing.entity.storage.EntityStorage;
 import 
org.apache.rya.indexing.entity.storage.EntityStorage.EntityAlreadyExistsException;
 import 
org.apache.rya.indexing.entity.storage.EntityStorage.EntityStorageException;
 import 
org.apache.rya.indexing.entity.storage.EntityStorage.StaleUpdateException;
-import org.apache.rya.mongodb.MongoTestBase;
+import org.apache.rya.mongodb.MongoITBase;
 import org.junit.Test;
 import org.openrdf.model.vocabulary.XMLSchema;
 
@@ -46,7 +46,7 @@ import com.google.common.collect.Sets;
 /**
  * Integration tests the methods of {@link MongoEntityStorage}.
  */
-public class MongoEntityStorageIT extends MongoTestBase {
+public class MongoEntityStorageIT extends MongoITBase {
 
     private static final String RYA_INSTANCE_NAME = "testInstance";
 

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/4576f556/extras/indexing/src/test/java/org/apache/rya/indexing/entity/storage/mongo/MongoTypeStorageIT.java
----------------------------------------------------------------------
diff --git 
a/extras/indexing/src/test/java/org/apache/rya/indexing/entity/storage/mongo/MongoTypeStorageIT.java
 
b/extras/indexing/src/test/java/org/apache/rya/indexing/entity/storage/mongo/MongoTypeStorageIT.java
index cff4f26..8212dbf 100644
--- 
a/extras/indexing/src/test/java/org/apache/rya/indexing/entity/storage/mongo/MongoTypeStorageIT.java
+++ 
b/extras/indexing/src/test/java/org/apache/rya/indexing/entity/storage/mongo/MongoTypeStorageIT.java
@@ -30,7 +30,7 @@ import org.apache.rya.api.domain.RyaURI;
 import org.apache.rya.indexing.entity.model.Type;
 import org.apache.rya.indexing.entity.storage.TypeStorage;
 import org.apache.rya.indexing.entity.storage.TypeStorage.TypeStorageException;
-import org.apache.rya.mongodb.MongoTestBase;
+import org.apache.rya.mongodb.MongoITBase;
 import org.junit.Test;
 
 import com.google.common.collect.ImmutableSet;
@@ -39,7 +39,7 @@ import com.google.common.collect.Sets;
 /**
  * Integration tests the methods of {@link MongoTypeStorage}.
  */
-public class MongoTypeStorageIT extends MongoTestBase {
+public class MongoTypeStorageIT extends MongoITBase {
 
     private static final String RYA_INSTANCE_NAME = "testInstance";
 

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/4576f556/extras/indexing/src/test/java/org/apache/rya/indexing/entity/update/mongo/MongoEntityIndexerIT.java
----------------------------------------------------------------------
diff --git 
a/extras/indexing/src/test/java/org/apache/rya/indexing/entity/update/mongo/MongoEntityIndexerIT.java
 
b/extras/indexing/src/test/java/org/apache/rya/indexing/entity/update/mongo/MongoEntityIndexerIT.java
index 8b62a57..28fd330 100644
--- 
a/extras/indexing/src/test/java/org/apache/rya/indexing/entity/update/mongo/MongoEntityIndexerIT.java
+++ 
b/extras/indexing/src/test/java/org/apache/rya/indexing/entity/update/mongo/MongoEntityIndexerIT.java
@@ -32,7 +32,7 @@ import org.apache.rya.indexing.entity.storage.EntityStorage;
 import org.apache.rya.indexing.entity.storage.TypeStorage;
 import org.apache.rya.indexing.entity.storage.mongo.MongoEntityStorage;
 import org.apache.rya.indexing.entity.storage.mongo.MongoTypeStorage;
-import org.apache.rya.mongodb.MongoTestBase;
+import org.apache.rya.mongodb.MongoITBase;
 import org.junit.Test;
 import org.openrdf.model.vocabulary.RDF;
 import org.openrdf.model.vocabulary.XMLSchema;
@@ -43,7 +43,7 @@ import com.google.common.collect.Sets;
 /**
  * Integration tests the methods of {@link MongoEntityIndexer}.
  */
-public class MongoEntityIndexerIT extends MongoTestBase {
+public class MongoEntityIndexerIT extends MongoITBase {
 
     private static final Type PERSON_TYPE =
             new Type(new RyaURI("urn:person"),


Reply via email to