Repository: incubator-rya Updated Branches: refs/heads/master 8431dfb78 -> 9c12630bb
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/e5738966/extras/indexing/src/test/java/org/apache/rya/indexing/mongo/MongoFreeTextIndexerTest.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/test/java/org/apache/rya/indexing/mongo/MongoFreeTextIndexerTest.java b/extras/indexing/src/test/java/org/apache/rya/indexing/mongo/MongoFreeTextIndexerTest.java index 4ac7707..1c712ca 100644 --- a/extras/indexing/src/test/java/org/apache/rya/indexing/mongo/MongoFreeTextIndexerTest.java +++ b/extras/indexing/src/test/java/org/apache/rya/indexing/mongo/MongoFreeTextIndexerTest.java @@ -29,10 +29,8 @@ import org.apache.rya.api.resolver.RyaToRdfConversions; import org.apache.rya.indexing.StatementConstraints; import org.apache.rya.indexing.accumulo.ConfigUtils; import org.apache.rya.indexing.mongodb.freetext.MongoFreeTextIndexer; -import org.apache.rya.mongodb.MongoDBRdfConfiguration; -import org.apache.rya.mongodb.MongoRyaTestBase; +import org.apache.rya.mongodb.MongoTestBase; import org.junit.Assert; -import org.junit.Before; import org.junit.Test; import org.openrdf.model.Statement; import org.openrdf.model.URI; @@ -46,24 +44,13 @@ import com.google.common.collect.Sets; import info.aduna.iteration.CloseableIteration; -public class MongoFreeTextIndexerTest extends MongoRyaTestBase { +public class MongoFreeTextIndexerTest extends MongoTestBase { private static final StatementConstraints EMPTY_CONSTRAINTS = new StatementConstraints(); - MongoDBRdfConfiguration conf; - - @Before - public void before() throws Exception { - conf = new MongoDBRdfConfiguration(); - conf.set(ConfigUtils.USE_MONGO, "true"); - conf.setMongoDBName(getDbName()); - conf.setCollectionName("rya_"); - conf.setTablePrefix("another_"); - } - @Test public void testSearch() throws Exception { try (MongoFreeTextIndexer f = new MongoFreeTextIndexer()) { - f.initIndexer(conf, mongoClient); + f.initIndexer(conf, super.getMongoClient()); final ValueFactory vf = new ValueFactoryImpl(); @@ -87,7 +74,7 @@ public class MongoFreeTextIndexerTest extends MongoRyaTestBase { @Test public void testDelete() throws Exception { try (MongoFreeTextIndexer f = new MongoFreeTextIndexer()) { - f.initIndexer(conf, mongoClient); + f.initIndexer(conf, super.getMongoClient()); final ValueFactory vf = new ValueFactoryImpl(); @@ -137,7 +124,7 @@ public class MongoFreeTextIndexerTest extends MongoRyaTestBase { conf.setStrings(ConfigUtils.FREETEXT_PREDICATES_LIST, "pred:1,pred:2"); try (MongoFreeTextIndexer f = new MongoFreeTextIndexer()) { - f.initIndexer(conf, mongoClient); + f.initIndexer(conf, super.getMongoClient()); // These should not be stored because they are not in the predicate list f.storeStatement(new RyaStatement(new RyaURI("foo:subj1"), new RyaURI(RDFS.LABEL.toString()), new RyaType("invalid"))); @@ -170,7 +157,7 @@ public class MongoFreeTextIndexerTest extends MongoRyaTestBase { @Test public void testContextSearch() throws Exception { try (MongoFreeTextIndexer f = new MongoFreeTextIndexer()) { - f.initIndexer(conf, mongoClient); + f.initIndexer(conf, super.getMongoClient()); final ValueFactory vf = new ValueFactoryImpl(); final URI subject = new URIImpl("foo:subj"); http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/e5738966/extras/indexing/src/test/java/org/apache/rya/indexing/mongo/MongoTemporalIndexerTest.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/test/java/org/apache/rya/indexing/mongo/MongoTemporalIndexerTest.java b/extras/indexing/src/test/java/org/apache/rya/indexing/mongo/MongoTemporalIndexerTest.java index 9069fdc..215e64c 100644 --- a/extras/indexing/src/test/java/org/apache/rya/indexing/mongo/MongoTemporalIndexerTest.java +++ b/extras/indexing/src/test/java/org/apache/rya/indexing/mongo/MongoTemporalIndexerTest.java @@ -39,9 +39,7 @@ import org.apache.rya.indexing.TemporalInterval; import org.apache.rya.indexing.accumulo.ConfigUtils; import org.apache.rya.indexing.mongodb.temporal.MongoTemporalIndexer; import org.apache.rya.mongodb.MongoDBRdfConfiguration; -import org.apache.rya.mongodb.MongoRyaTestBase; -import org.junit.After; -import org.junit.AfterClass; +import org.apache.rya.mongodb.MongoTestBase; import org.junit.Before; import org.junit.Test; import org.openrdf.model.Statement; @@ -81,10 +79,9 @@ import info.aduna.iteration.CloseableIteration; * And a few more. * */ -public final class MongoTemporalIndexerTest extends MongoRyaTestBase { - MongoDBRdfConfiguration conf; - MongoTemporalIndexer tIndexer; - DBCollection collection; +public final class MongoTemporalIndexerTest extends MongoTestBase { + private MongoTemporalIndexer tIndexer; + private DBCollection collection; private static final String URI_PROPERTY_EVENT_TIME = "Property:event:time"; private static final String URI_PROPERTY_CIRCA = "Property:circa"; @@ -163,24 +160,10 @@ public final class MongoTemporalIndexerTest extends MongoRyaTestBase { for (int i = 0; i < seriesTs.length; i++) { seriesSpo[i] = new StatementImpl(vf.createURI("foo:event0" + i), pred1_atTime, vf.createLiteral(seriesTs[i].getAsReadable())); } - - } - - /** - * @throws java.lang.Exception - */ - @AfterClass - public static void tearDownAfterClass() throws Exception { } @Before public void before() throws Exception { - conf = new MongoDBRdfConfiguration(); - conf.set(ConfigUtils.USE_MONGO, getDbName()); - conf.set(MongoDBRdfConfiguration.MONGO_DB_NAME, getDbName()); - conf.set(MongoDBRdfConfiguration.MONGO_COLLECTION_PREFIX, "rya_"); - conf.setTablePrefix("isthisused_"); - // This is from http://linkedevents.org/ontology // and http://motools.sourceforge.net/event/event.html conf.setStrings(ConfigUtils.TEMPORAL_PREDICATES_LIST, "" @@ -189,20 +172,12 @@ public final class MongoTemporalIndexerTest extends MongoRyaTestBase { + URI_PROPERTY_EVENT_TIME); tIndexer = new MongoTemporalIndexer(); - tIndexer.initIndexer(conf, mongoClient); - + tIndexer.initIndexer(conf, super.getMongoClient()); final String dbName = conf.get(MongoDBRdfConfiguration.MONGO_DB_NAME); - final DB db = mongoClient.getDB(dbName); + final DB db = super.getMongoClient().getDB(dbName); collection = db.getCollection(conf.get(MongoDBRdfConfiguration.MONGO_COLLECTION_PREFIX, "rya") + tIndexer.getCollectionName()); } - /** - * @throws java.lang.Exception - */ - @After - public void tearDown() throws Exception { - tIndexer.close(); - } /** * Test method for {@link MongoTemporalIndexer#storeStatement(convertStatement(org.openrdf.model.Statement)} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/e5738966/extras/indexing/src/test/java/org/apache/rya/indexing/smarturi/duplication/DuplicateDataDetectorTest.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/test/java/org/apache/rya/indexing/smarturi/duplication/DuplicateDataDetectorTest.java b/extras/indexing/src/test/java/org/apache/rya/indexing/smarturi/duplication/DuplicateDataDetectorTest.java index 3385285..c7e73ed 100644 --- a/extras/indexing/src/test/java/org/apache/rya/indexing/smarturi/duplication/DuplicateDataDetectorTest.java +++ b/extras/indexing/src/test/java/org/apache/rya/indexing/smarturi/duplication/DuplicateDataDetectorTest.java @@ -58,11 +58,11 @@ import org.apache.rya.indexing.entity.storage.EntityStorage.EntityStorageExcepti import org.apache.rya.indexing.entity.storage.TypeStorage; import org.apache.rya.indexing.entity.storage.TypeStorage.TypeStorageException; import org.apache.rya.indexing.entity.storage.mongo.MongoEntityStorage; -import org.apache.rya.indexing.entity.storage.mongo.MongoITBase; import org.apache.rya.indexing.entity.storage.mongo.MongoTypeStorage; import org.apache.rya.indexing.mongodb.update.RyaObjectStorage.ObjectStorageException; import org.apache.rya.indexing.smarturi.SmartUriException; import org.apache.rya.indexing.smarturi.duplication.conf.DuplicateDataConfig; +import org.apache.rya.mongodb.MongoTestBase; import org.joda.time.DateTime; import org.junit.Test; import org.openrdf.model.ValueFactory; @@ -76,7 +76,7 @@ import com.google.common.collect.Lists; /** * Tests the methods of {@link DuplicateDataDetector}. */ -public class DuplicateDataDetectorTest extends MongoITBase { +public class DuplicateDataDetectorTest extends MongoTestBase { private static final String RYA_INSTANCE_NAME = "testInstance"; private static final String NAMESPACE = RyaSchema.NAMESPACE; http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/e5738966/extras/indexing/src/test/java/org/apache/rya/indexing/statement/metadata/MongoStatementMetadataIT.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/test/java/org/apache/rya/indexing/statement/metadata/MongoStatementMetadataIT.java b/extras/indexing/src/test/java/org/apache/rya/indexing/statement/metadata/MongoStatementMetadataIT.java index 3ca37a6..2f3214d 100644 --- a/extras/indexing/src/test/java/org/apache/rya/indexing/statement/metadata/MongoStatementMetadataIT.java +++ b/extras/indexing/src/test/java/org/apache/rya/indexing/statement/metadata/MongoStatementMetadataIT.java @@ -1,5 +1,3 @@ -package org.apache.rya.indexing.statement.metadata; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -8,9 +6,9 @@ package org.apache.rya.indexing.statement.metadata; * 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 @@ -18,7 +16,8 @@ package org.apache.rya.indexing.statement.metadata; * specific language governing permissions and limitations * under the License. */ -import java.io.IOException; +package org.apache.rya.indexing.statement.metadata; + import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; @@ -30,13 +29,9 @@ import org.apache.rya.api.domain.RyaType; import org.apache.rya.api.domain.RyaURI; import org.apache.rya.api.domain.StatementMetadata; import org.apache.rya.api.persist.RyaDAOException; -import org.apache.rya.indexing.accumulo.ConfigUtils; -import org.apache.rya.mongodb.MockMongoFactory; -import org.apache.rya.mongodb.MongoConnectorFactory; -import org.apache.rya.mongodb.MongoDBRdfConfiguration; import org.apache.rya.mongodb.MongoDBRyaDAO; +import org.apache.rya.mongodb.MongoTestBase; import org.apache.rya.sail.config.RyaSailFactory; -import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -53,15 +48,8 @@ import org.openrdf.repository.sail.SailRepository; import org.openrdf.repository.sail.SailRepositoryConnection; import org.openrdf.sail.Sail; -import com.mongodb.MongoClient; - -import de.flapdoodle.embed.mongo.distribution.Version; - -public class MongoStatementMetadataIT { +public class MongoStatementMetadataIT extends MongoTestBase { - protected MockMongoFactory testsFactory; - protected MongoClient mongoClient; - private MongoDBRdfConfiguration conf; private Sail sail; private SailRepository repo; private SailRepositoryConnection conn; @@ -75,51 +63,36 @@ public class MongoStatementMetadataIT { @Before public void init() throws Exception { - testsFactory = MockMongoFactory.with(Version.Main.PRODUCTION); - mongoClient = testsFactory.newMongoClient(); - conf = getConf(); + final Set<RyaURI> propertySet = new HashSet<RyaURI>( + Arrays.asList(new RyaURI("http://createdBy"), new RyaURI("http://createdOn"))); + conf.setUseStatementMetadata(true); + conf.setStatementMetadataProperties(propertySet); + sail = RyaSailFactory.getInstance(conf); repo = new SailRepository(sail); conn = repo.getConnection(); - dao = new MongoDBRyaDAO(conf, mongoClient); + dao = new MongoDBRyaDAO(conf, super.getMongoClient()); dao.init(); } - @After - public void close() throws Exception { - conn.close(); - repo.shutDown(); - sail.shutDown(); - sail.shutDown(); - dao.destroy(); - - if (mongoClient != null) { - mongoClient.close(); - } - if (testsFactory != null) { - testsFactory.shutdown(); - } - MongoConnectorFactory.closeMongoClient(); - } - @Test public void simpleQueryWithoutBindingSet() throws Exception { - StatementMetadata metadata = new StatementMetadata(); + final StatementMetadata metadata = new StatementMetadata(); metadata.addMetadata(new RyaURI("http://createdBy"), new RyaType("Joe")); metadata.addMetadata(new RyaURI("http://createdOn"), new RyaType(XMLSchema.DATE, "2017-01-04")); - RyaStatement statement = new RyaStatement(new RyaURI("http://Joe"), new RyaURI("http://worksAt"), + final RyaStatement statement = new RyaStatement(new RyaURI("http://Joe"), new RyaURI("http://worksAt"), new RyaType("CoffeeShop"), new RyaURI("http://context"), "", metadata); dao.add(statement); - TupleQueryResult result = conn.prepareTupleQuery(QueryLanguage.SPARQL, query1).evaluate(); + final TupleQueryResult result = conn.prepareTupleQuery(QueryLanguage.SPARQL, query1).evaluate(); - QueryBindingSet bs = new QueryBindingSet(); + final QueryBindingSet bs = new QueryBindingSet(); bs.addBinding("x", new LiteralImpl("CoffeeShop")); bs.addBinding("y", new LiteralImpl("Joe")); - List<BindingSet> bsList = new ArrayList<>(); + final List<BindingSet> bsList = new ArrayList<>(); while (result.hasNext()) { bsList.add(result.next()); } @@ -134,24 +107,24 @@ public class MongoStatementMetadataIT { * Tests if results are filtered correctly using the metadata properties. In * this case, the date for the ingested RyaStatement differs from the date * specified in the query. - * + * * @throws MalformedQueryException * @throws QueryEvaluationException * @throws RyaDAOException */ @Test public void simpleQueryWithoutBindingSetInvalidProperty() throws Exception { - StatementMetadata metadata = new StatementMetadata(); + final StatementMetadata metadata = new StatementMetadata(); metadata.addMetadata(new RyaURI("http://createdBy"), new RyaType("Doug")); metadata.addMetadata(new RyaURI("http://createdOn"), new RyaType(XMLSchema.DATE, "2017-02-15")); - RyaStatement statement = new RyaStatement(new RyaURI("http://Joe"), new RyaURI("http://worksAt"), + final RyaStatement statement = new RyaStatement(new RyaURI("http://Joe"), new RyaURI("http://worksAt"), new RyaType("CoffeeShop"), new RyaURI("http://context"), "", metadata); dao.add(statement); - TupleQueryResult result = conn.prepareTupleQuery(QueryLanguage.SPARQL, query1).evaluate(); + final TupleQueryResult result = conn.prepareTupleQuery(QueryLanguage.SPARQL, query1).evaluate(); - List<BindingSet> bsList = new ArrayList<>(); + final List<BindingSet> bsList = new ArrayList<>(); while (result.hasNext()) { bsList.add(result.next()); } @@ -162,30 +135,30 @@ public class MongoStatementMetadataIT { @Test public void simpleQueryWithBindingSet() throws Exception { - StatementMetadata metadata = new StatementMetadata(); + final StatementMetadata metadata = new StatementMetadata(); metadata.addMetadata(new RyaURI("http://createdBy"), new RyaType("Joe")); metadata.addMetadata(new RyaURI("http://createdOn"), new RyaType(XMLSchema.DATE, "2017-01-04")); - RyaStatement statement1 = new RyaStatement(new RyaURI("http://Joe"), new RyaURI("http://worksAt"), + final RyaStatement statement1 = new RyaStatement(new RyaURI("http://Joe"), new RyaURI("http://worksAt"), new RyaType("CoffeeShop"), new RyaURI("http://context"), "", metadata); - RyaStatement statement2 = new RyaStatement(new RyaURI("http://Joe"), new RyaURI("http://worksAt"), + final RyaStatement statement2 = new RyaStatement(new RyaURI("http://Joe"), new RyaURI("http://worksAt"), new RyaType("HardwareStore"), new RyaURI("http://context"), "", metadata); dao.add(statement1); dao.add(statement2); - TupleQueryResult result = conn.prepareTupleQuery(QueryLanguage.SPARQL, query1).evaluate(); + final TupleQueryResult result = conn.prepareTupleQuery(QueryLanguage.SPARQL, query1).evaluate(); - Set<BindingSet> expected = new HashSet<>(); - QueryBindingSet expected1 = new QueryBindingSet(); + final Set<BindingSet> expected = new HashSet<>(); + final QueryBindingSet expected1 = new QueryBindingSet(); expected1.addBinding("x", new LiteralImpl("CoffeeShop")); expected1.addBinding("y", new LiteralImpl("Joe")); - QueryBindingSet expected2 = new QueryBindingSet(); + final QueryBindingSet expected2 = new QueryBindingSet(); expected2.addBinding("x", new LiteralImpl("HardwareStore")); expected2.addBinding("y", new LiteralImpl("Joe")); expected.add(expected1); expected.add(expected2); - Set<BindingSet> bsSet = new HashSet<>(); + final Set<BindingSet> bsSet = new HashSet<>(); while (result.hasNext()) { bsSet.add(result.next()); } @@ -212,36 +185,36 @@ public class MongoStatementMetadataIT { @Test public void simpleQueryWithBindingSetJoinPropertyToSubject() throws Exception { - StatementMetadata metadata1 = new StatementMetadata(); + final StatementMetadata metadata1 = new StatementMetadata(); metadata1.addMetadata(new RyaURI("http://createdBy"), new RyaURI("http://Doug")); metadata1.addMetadata(new RyaURI("http://createdOn"), new RyaType(XMLSchema.DATE, "2017-01-04")); - StatementMetadata metadata2 = new StatementMetadata(); + final StatementMetadata metadata2 = new StatementMetadata(); metadata2.addMetadata(new RyaURI("http://createdBy"), new RyaURI("http://Bob")); metadata2.addMetadata(new RyaURI("http://createdOn"), new RyaType(XMLSchema.DATE, "2017-02-04")); - RyaStatement statement1 = new RyaStatement(new RyaURI("http://Joe"), new RyaURI("http://worksAt"), + final RyaStatement statement1 = new RyaStatement(new RyaURI("http://Joe"), new RyaURI("http://worksAt"), new RyaURI("http://BurgerShack"), new RyaURI("http://context"), "", metadata1); - RyaStatement statement2 = new RyaStatement(new RyaURI("http://Joe"), new RyaURI("http://talksTo"), + final RyaStatement statement2 = new RyaStatement(new RyaURI("http://Joe"), new RyaURI("http://talksTo"), new RyaURI("http://Betty"), new RyaURI("http://context"), "", metadata1); - RyaStatement statement3 = new RyaStatement(new RyaURI("http://Fred"), new RyaURI("http://talksTo"), + final RyaStatement statement3 = new RyaStatement(new RyaURI("http://Fred"), new RyaURI("http://talksTo"), new RyaURI("http://Amanda"), new RyaURI("http://context"), "", metadata1); - RyaStatement statement4 = new RyaStatement(new RyaURI("http://Joe"), new RyaURI("http://talksTo"), + final RyaStatement statement4 = new RyaStatement(new RyaURI("http://Joe"), new RyaURI("http://talksTo"), new RyaURI("http://Wanda"), new RyaURI("http://context"), "", metadata2); dao.add(statement1); dao.add(statement2); dao.add(statement3); dao.add(statement4); - TupleQueryResult result = conn.prepareTupleQuery(QueryLanguage.SPARQL, query2).evaluate(); + final TupleQueryResult result = conn.prepareTupleQuery(QueryLanguage.SPARQL, query2).evaluate(); - Set<BindingSet> expected = new HashSet<>(); - QueryBindingSet expected1 = new QueryBindingSet(); + final Set<BindingSet> expected = new HashSet<>(); + final QueryBindingSet expected1 = new QueryBindingSet(); expected1.addBinding("b", new URIImpl("http://Betty")); expected1.addBinding("a", new URIImpl("http://Joe")); expected1.addBinding("c", new URIImpl("http://Doug")); expected.add(expected1); - Set<BindingSet> bsSet = new HashSet<>(); + final Set<BindingSet> bsSet = new HashSet<>(); while (result.hasNext()) { bsSet.add(result.next()); } @@ -253,23 +226,4 @@ public class MongoStatementMetadataIT { dao.delete(statement3, conf); dao.delete(statement4, conf); } - - private MongoDBRdfConfiguration getConf() throws IOException { - - String host = mongoClient.getServerAddressList().get(0).getHost(); - int port = mongoClient.getServerAddressList().get(0).getPort(); - Set<RyaURI> propertySet = new HashSet<RyaURI>( - Arrays.asList(new RyaURI("http://createdBy"), new RyaURI("http://createdOn"))); - MongoDBRdfConfiguration conf = new MongoDBRdfConfiguration(); - conf.set(ConfigUtils.USE_MONGO, "true"); - conf.setMongoInstance(host); - conf.setMongoPort(Integer.toString(port)); - conf.setMongoDBName("local"); - conf.setCollectionName("rya"); - conf.setTablePrefix("rya_"); - conf.setUseStatementMetadata(true); - conf.setStatementMetadataProperties(propertySet); - return conf; - } - } http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/e5738966/extras/indexing/src/test/java/org/apache/rya/indexing/statement/metadata/MongoStatementMetadataNodeTest.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/test/java/org/apache/rya/indexing/statement/metadata/MongoStatementMetadataNodeTest.java b/extras/indexing/src/test/java/org/apache/rya/indexing/statement/metadata/MongoStatementMetadataNodeTest.java index 36091ea..d005ce7 100644 --- a/extras/indexing/src/test/java/org/apache/rya/indexing/statement/metadata/MongoStatementMetadataNodeTest.java +++ b/extras/indexing/src/test/java/org/apache/rya/indexing/statement/metadata/MongoStatementMetadataNodeTest.java @@ -17,7 +17,6 @@ package org.apache.rya.indexing.statement.metadata; * specific language governing permissions and limitations * under the License. */ -import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; @@ -29,12 +28,10 @@ import org.apache.rya.api.domain.RyaType; import org.apache.rya.api.domain.RyaURI; import org.apache.rya.api.domain.StatementMetadata; import org.apache.rya.api.persist.RyaDAOException; -import org.apache.rya.indexing.accumulo.ConfigUtils; import org.apache.rya.indexing.statement.metadata.matching.StatementMetadataNode; -import org.apache.rya.mongodb.MockMongoFactory; -import org.apache.rya.mongodb.MongoConnectorFactory; import org.apache.rya.mongodb.MongoDBRdfConfiguration; import org.apache.rya.mongodb.MongoDBRyaDAO; +import org.apache.rya.mongodb.MongoTestBase; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -51,44 +48,23 @@ import org.openrdf.query.algebra.helpers.StatementPatternCollector; import org.openrdf.query.parser.ParsedQuery; import org.openrdf.query.parser.sparql.SPARQLParser; -import com.mongodb.MongoClient; - -import de.flapdoodle.embed.mongo.distribution.Version; import info.aduna.iteration.CloseableIteration; -public class MongoStatementMetadataNodeTest { - - protected MockMongoFactory testsFactory; - protected MongoClient mongoClient; - private MongoDBRdfConfiguration conf; +public class MongoStatementMetadataNodeTest extends MongoTestBase { private MongoDBRyaDAO dao; private final String query = "prefix owl: <http://www.w3.org/2002/07/owl#> prefix ano: <http://www.w3.org/2002/07/owl#annotated> prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> select ?x ?y where {_:blankNode rdf:type owl:Annotation; ano:Source <http://Joe>; " + "ano:Property <http://worksAt>; ano:Target ?x; <http://createdBy> ?y; <http://createdOn> \'2017-01-04\'^^xsd:date }"; private final String query2 = "prefix owl: <http://www.w3.org/2002/07/owl#> prefix ano: <http://www.w3.org/2002/07/owl#annotated> prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> select ?x ?y where {_:blankNode rdf:type owl:Annotation; ano:Source ?x; " + "ano:Property <http://worksAt>; ano:Target ?y; <http://createdBy> ?x; <http://createdOn> \'2017-01-04\'^^xsd:date }"; - @Before public void init() throws Exception { - testsFactory = MockMongoFactory.with(Version.Main.PRODUCTION); - mongoClient = testsFactory.newMongoClient(); - conf = getConf(); - - dao = new MongoDBRyaDAO(conf, mongoClient); - dao.init(); - } - - @After - public void close() throws RyaDAOException { - dao.destroy(); + final Set<RyaURI> propertySet = new HashSet<RyaURI>(Arrays.asList(new RyaURI("http://createdBy"), new RyaURI("http://createdOn"))); + conf.setUseStatementMetadata(true); + conf.setStatementMetadataProperties(propertySet); - if (mongoClient != null) { - mongoClient.close(); - } - if (testsFactory != null) { - testsFactory.shutdown(); - } - MongoConnectorFactory.closeMongoClient(); + dao = new MongoDBRyaDAO(conf, super.getMongoClient()); + dao.init(); } @Test @@ -378,22 +354,4 @@ public class MongoStatementMetadataNodeTest { dao.delete(statement1, conf); dao.delete(statement2, conf); } - - private MongoDBRdfConfiguration getConf() throws IOException { - - String host = mongoClient.getServerAddressList().get(0).getHost(); - int port = mongoClient.getServerAddressList().get(0).getPort(); - Set<RyaURI> propertySet = new HashSet<RyaURI>( - Arrays.asList(new RyaURI("http://createdBy"), new RyaURI("http://createdOn"))); - MongoDBRdfConfiguration conf = new MongoDBRdfConfiguration(); - conf.set(ConfigUtils.USE_MONGO, "true"); - conf.setMongoInstance(host); - conf.setMongoPort(Integer.toString(port)); - conf.setMongoDBName("local"); - conf.setCollectionName("rya"); - conf.setTablePrefix("rya_"); - conf.setUseStatementMetadata(true); - conf.setStatementMetadataProperties(propertySet); - return conf; - } } http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/e5738966/extras/indexingExample/src/main/java/MongoRyaDirectExample.java ---------------------------------------------------------------------- diff --git a/extras/indexingExample/src/main/java/MongoRyaDirectExample.java b/extras/indexingExample/src/main/java/MongoRyaDirectExample.java index a2611d0..7f0d308 100644 --- a/extras/indexingExample/src/main/java/MongoRyaDirectExample.java +++ b/extras/indexingExample/src/main/java/MongoRyaDirectExample.java @@ -63,6 +63,7 @@ import com.mongodb.ServerAddress; import info.aduna.iteration.Iterations; + public class MongoRyaDirectExample { private static final Logger log = Logger.getLogger(MongoRyaDirectExample.class); @@ -128,9 +129,6 @@ public class MongoRyaDirectExample { log.info("Shutting down"); closeQuietly(conn); closeQuietly(repository); - if (mock != null) { - mock.shutdown(); - } MongoConnectorFactory.closeMongoClient(); } } @@ -290,15 +288,13 @@ public class MongoRyaDirectExample { Validate.isTrue(tupleHandler.getCount() == 2); } - private static MockMongoFactory mock = null; private static Configuration getConf() throws IOException { MongoDBIndexingConfigBuilder builder = MongoIndexingConfiguration.builder() .setUseMockMongo(USE_MOCK).setUseInference(USE_INFER).setAuths("U"); if (USE_MOCK) { - mock = MockMongoFactory.newFactory(); - final MongoClient c = mock.newMongoClient(); + final MongoClient c = MockMongoFactory.newFactory().newMongoClient(); final ServerAddress address = c.getAddress(); final String url = address.getHost(); final String port = Integer.toString(address.getPort()); @@ -765,7 +761,7 @@ public class MongoRyaDirectExample { } public void resetCount() { - this.count = 0; + count = 0; } @Override http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/e5738966/extras/rya.geoindexing/src/test/java/org/apache/rya/indexing/geotemporal/model/EventQueryNodeTest.java ---------------------------------------------------------------------- diff --git a/extras/rya.geoindexing/src/test/java/org/apache/rya/indexing/geotemporal/model/EventQueryNodeTest.java b/extras/rya.geoindexing/src/test/java/org/apache/rya/indexing/geotemporal/model/EventQueryNodeTest.java index d9e0294..f35eeb7 100644 --- a/extras/rya.geoindexing/src/test/java/org/apache/rya/indexing/geotemporal/model/EventQueryNodeTest.java +++ b/extras/rya.geoindexing/src/test/java/org/apache/rya/indexing/geotemporal/model/EventQueryNodeTest.java @@ -32,10 +32,9 @@ import org.apache.rya.indexing.IndexingFunctionRegistry; import org.apache.rya.indexing.IndexingFunctionRegistry.FUNCTION_TYPE; import org.apache.rya.indexing.TemporalInstant; import org.apache.rya.indexing.TemporalInstantRfc3339; -import org.apache.rya.indexing.geotemporal.GeoTemporalTestBase; import org.apache.rya.indexing.geotemporal.mongo.MongoEventStorage; +import org.apache.rya.indexing.geotemporal.mongo.MongoITBase; import org.apache.rya.indexing.geotemporal.storage.EventStorage; -import org.apache.rya.mongodb.MockMongoFactory; import org.junit.Test; import org.openrdf.model.URI; import org.openrdf.model.Value; @@ -51,7 +50,6 @@ import org.openrdf.query.algebra.ValueExpr; import org.openrdf.query.algebra.Var; import org.openrdf.query.impl.MapBindingSet; -import com.mongodb.MongoClient; import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.GeometryFactory; @@ -62,7 +60,7 @@ import info.aduna.iteration.CloseableIteration; /** * Unit tests the methods of {@link EventQueryNode}. */ -public class EventQueryNodeTest extends GeoTemporalTestBase { +public class EventQueryNodeTest extends MongoITBase { private static final GeometryFactory GF = new GeometryFactory(new PrecisionModel(), 4326); private static final ValueFactory VF = ValueFactoryImpl.getInstance(); @@ -113,8 +111,7 @@ public class EventQueryNodeTest extends GeoTemporalTestBase { @Test public void evaluate_constantSubject() throws Exception { - final MongoClient client = MockMongoFactory.newFactory().newMongoClient(); - final EventStorage storage = new MongoEventStorage(client, "testDB"); + final EventStorage storage = new MongoEventStorage(super.getMongoClient(), "testDB"); RyaURI subject = new RyaURI("urn:event-1111"); final Geometry geo = GF.createPoint(new Coordinate(1, 1)); final TemporalInstant temp = new TemporalInstantRfc3339(2015, 12, 30, 12, 00, 0); @@ -163,8 +160,7 @@ public class EventQueryNodeTest extends GeoTemporalTestBase { @Test public void evaluate_variableSubject() throws Exception { - final MongoClient client = MockMongoFactory.newFactory().newMongoClient(); - final EventStorage storage = new MongoEventStorage(client, "testDB"); + final EventStorage storage = new MongoEventStorage(super.getMongoClient(), "testDB"); RyaURI subject = new RyaURI("urn:event-1111"); Geometry geo = GF.createPoint(new Coordinate(1, 1)); final TemporalInstant temp = new TemporalInstantRfc3339(2015, 12, 30, 12, 00, 0); @@ -218,8 +214,7 @@ public class EventQueryNodeTest extends GeoTemporalTestBase { @Test public void evaluate_variableSubject_existingBindingset() throws Exception { - final MongoClient client = MockMongoFactory.newFactory().newMongoClient(); - final EventStorage storage = new MongoEventStorage(client, "testDB"); + final EventStorage storage = new MongoEventStorage(super.getMongoClient(), "testDB"); RyaURI subject = new RyaURI("urn:event-1111"); Geometry geo = GF.createPoint(new Coordinate(1, 1)); final TemporalInstant temp = new TemporalInstantRfc3339(2015, 12, 30, 12, 00, 0); @@ -271,8 +266,7 @@ public class EventQueryNodeTest extends GeoTemporalTestBase { @Test public void evaluate_variableSubject_existingBindingsetWrongFilters() throws Exception { - final MongoClient client = MockMongoFactory.newFactory().newMongoClient(); - final EventStorage storage = new MongoEventStorage(client, "testDB"); + final EventStorage storage = new MongoEventStorage(super.getMongoClient(), "testDB"); RyaURI subject = new RyaURI("urn:event-1111"); Geometry geo = GF.createPoint(new Coordinate(1, 1)); final TemporalInstant temp = new TemporalInstantRfc3339(2015, 12, 30, 12, 00, 0); http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/e5738966/extras/rya.geoindexing/src/test/java/org/apache/rya/indexing/geotemporal/mongo/MongoGeoTemporalIndexerIT.java ---------------------------------------------------------------------- diff --git a/extras/rya.geoindexing/src/test/java/org/apache/rya/indexing/geotemporal/mongo/MongoGeoTemporalIndexerIT.java b/extras/rya.geoindexing/src/test/java/org/apache/rya/indexing/geotemporal/mongo/MongoGeoTemporalIndexerIT.java index 802e8c1..f2d0868 100644 --- a/extras/rya.geoindexing/src/test/java/org/apache/rya/indexing/geotemporal/mongo/MongoGeoTemporalIndexerIT.java +++ b/extras/rya.geoindexing/src/test/java/org/apache/rya/indexing/geotemporal/mongo/MongoGeoTemporalIndexerIT.java @@ -23,16 +23,12 @@ import static org.junit.Assert.assertTrue; import java.util.Optional; -import org.apache.rya.api.RdfCloudTripleStoreConfiguration; import org.apache.rya.api.domain.RyaStatement; import org.apache.rya.api.resolver.RdfToRyaConversions; import org.apache.rya.indexing.GeoConstants; import org.apache.rya.indexing.TemporalInstant; import org.apache.rya.indexing.geotemporal.model.Event; -import org.apache.rya.indexing.geotemporal.mongo.MongoGeoTemporalIndexer; import org.apache.rya.indexing.geotemporal.storage.EventStorage; -import org.apache.rya.mongodb.MockMongoFactory; -import org.apache.rya.mongodb.MongoDBRdfConfiguration; import org.junit.Before; import org.junit.Test; import org.openrdf.model.Resource; @@ -42,24 +38,17 @@ import org.openrdf.model.ValueFactory; import org.openrdf.model.impl.StatementImpl; import org.openrdf.model.impl.ValueFactoryImpl; -import com.mongodb.MongoClient; import com.vividsolutions.jts.geom.Geometry; /** * Integration tests the methods of {@link MongoGeoTemporalIndexer}. */ public class MongoGeoTemporalIndexerIT extends MongoITBase { - private MongoGeoTemporalIndexer indexer; @Before public void makeTestIndexer() throws Exception { - final MongoClient client = MockMongoFactory.newFactory().newMongoClient(); indexer = new MongoGeoTemporalIndexer(); - conf.setMongoDBName("GEO_TEMPORAL_INDEXER_TEST"); - conf.set(MongoDBRdfConfiguration.MONGO_DB_NAME, "GEO_TEMPORAL_INDEXER_TEST"); - conf.setMongoClient(client); - conf.set(RdfCloudTripleStoreConfiguration.CONF_TBL_PREFIX, "rya_"); indexer.setConf(conf); indexer.init(); } http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/e5738966/extras/rya.geoindexing/src/test/java/org/apache/rya/indexing/geotemporal/mongo/MongoITBase.java ---------------------------------------------------------------------- diff --git a/extras/rya.geoindexing/src/test/java/org/apache/rya/indexing/geotemporal/mongo/MongoITBase.java b/extras/rya.geoindexing/src/test/java/org/apache/rya/indexing/geotemporal/mongo/MongoITBase.java index bd7b5db..7488572 100644 --- a/extras/rya.geoindexing/src/test/java/org/apache/rya/indexing/geotemporal/mongo/MongoITBase.java +++ b/extras/rya.geoindexing/src/test/java/org/apache/rya/indexing/geotemporal/mongo/MongoITBase.java @@ -18,16 +18,11 @@ */ package org.apache.rya.indexing.geotemporal.mongo; -import java.util.HashSet; -import java.util.Set; - -import org.apache.hadoop.conf.Configuration; +import org.apache.rya.indexing.accumulo.ConfigUtils; import org.apache.rya.indexing.geotemporal.GeoTemporalTestBase; -import org.apache.rya.mongodb.MockMongoFactory; -import org.apache.rya.mongodb.MongoConnectorFactory; -import org.apache.rya.mongodb.MongoDBRdfConfiguration; +import org.apache.rya.indexing.mongodb.MongoIndexingConfiguration; +import org.apache.rya.mongodb.MockMongoSingleton; import org.junit.After; -import org.junit.AfterClass; import org.junit.Before; import com.mongodb.MongoClient; @@ -37,41 +32,29 @@ import com.mongodb.MongoClient; * use the JUnit framework. */ public class MongoITBase extends GeoTemporalTestBase { - protected final MongoDBRdfConfiguration conf = new MongoDBRdfConfiguration( new Configuration() ); - private MongoClient mongoClient = null; - private Set<String> originalDbNames = null; + private static MongoClient mongoClient = null; + protected static MongoIndexingConfiguration conf; @Before public void setupTest() throws Exception { - conf.setMongoDBName("testDB"); - conf.setMongoInstance("testDB"); - conf.setMongoPort("27017"); - - mongoClient = MockMongoFactory.newFactory().newMongoClient(); - conf.setMongoClient(mongoClient);; - // Store the names of the DBs that are present before running the test. - originalDbNames = new HashSet<>(); - for(final String name : mongoClient.listDatabaseNames()) { - originalDbNames.add(name); - } + mongoClient = MockMongoSingleton.getInstance(); + conf = MongoIndexingConfiguration.builder() + .setMongoCollectionPrefix("test_") + .setMongoDBName("testDB") + .build(); + conf.setBoolean(ConfigUtils.USE_MONGO, true); + conf.setMongoClient(mongoClient); } @After public void cleanupTest() { // Remove any DBs that were created by the test. for(final String dbName : mongoClient.listDatabaseNames()) { - if(!originalDbNames.contains(dbName)) { - mongoClient.dropDatabase(dbName); - } + mongoClient.dropDatabase(dbName); } } - @AfterClass - public static void shutdown() { - MongoConnectorFactory.closeMongoClient(); - } - /** * @return A {@link MongoClient} that is connected to the embedded instance of Mongo DB. */ http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/e5738966/extras/rya.geoindexing/src/test/java/org/apache/rya/indexing/mongo/MongoGeoIndexerSfTest.java ---------------------------------------------------------------------- diff --git a/extras/rya.geoindexing/src/test/java/org/apache/rya/indexing/mongo/MongoGeoIndexerSfTest.java b/extras/rya.geoindexing/src/test/java/org/apache/rya/indexing/mongo/MongoGeoIndexerSfTest.java index 0eefd3f..d05524f 100644 --- a/extras/rya.geoindexing/src/test/java/org/apache/rya/indexing/mongo/MongoGeoIndexerSfTest.java +++ b/extras/rya.geoindexing/src/test/java/org/apache/rya/indexing/mongo/MongoGeoIndexerSfTest.java @@ -22,7 +22,6 @@ import static org.apache.rya.indexing.GeoIndexingTestUtils.getSet; import java.util.Map; import java.util.Set; -import java.util.UUID; import org.apache.rya.api.domain.RyaStatement; import org.apache.rya.api.resolver.RdfToRyaConversions; @@ -31,9 +30,8 @@ import org.apache.rya.indexing.GeoConstants; import org.apache.rya.indexing.OptionalConfigUtils; import org.apache.rya.indexing.StatementConstraints; import org.apache.rya.indexing.accumulo.ConfigUtils; +import org.apache.rya.indexing.geotemporal.mongo.MongoITBase; import org.apache.rya.indexing.mongodb.geo.MongoGeoIndexer; -import org.apache.rya.mongodb.MongoDBRdfConfiguration; -import org.apache.rya.mongodb.MongoRyaTestBase; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -47,23 +45,19 @@ import org.openrdf.model.impl.ValueFactoryImpl; import com.google.common.collect.Maps; import com.google.common.collect.Sets; -import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.GeometryFactory; import com.vividsolutions.jts.geom.LineString; -import com.vividsolutions.jts.geom.LinearRing; import com.vividsolutions.jts.geom.Point; import com.vividsolutions.jts.geom.Polygon; import com.vividsolutions.jts.geom.PrecisionModel; -import com.vividsolutions.jts.geom.impl.PackedCoordinateSequence; import info.aduna.iteration.CloseableIteration; /** * Tests all of the "simple functions" of the geoindexer. */ -public class MongoGeoIndexerSfTest extends MongoRyaTestBase { - private MongoDBRdfConfiguration conf; +public class MongoGeoIndexerSfTest extends MongoITBase { private static GeometryFactory gf = new GeometryFactory(new PrecisionModel(), 4326); private static MongoGeoIndexer g; @@ -107,17 +101,11 @@ public class MongoGeoIndexerSfTest extends MongoRyaTestBase { @Before public void before() throws Exception { - System.out.println(UUID.randomUUID().toString()); - conf = new MongoDBRdfConfiguration(); - conf.set(ConfigUtils.USE_MONGO, "true"); - conf.set(MongoDBRdfConfiguration.MONGO_DB_NAME, getDbName()); - conf.set(MongoDBRdfConfiguration.MONGO_COLLECTION_PREFIX, "rya_"); conf.set(ConfigUtils.GEO_PREDICATES_LIST, "http://www.opengis.net/ont/geosparql#asWKT"); conf.set(OptionalConfigUtils.USE_GEO, "true"); - conf.setTablePrefix("rya_"); g = new MongoGeoIndexer(); - g.initIndexer(conf, mongoClient); + g.initIndexer(conf, super.getMongoClient()); g.storeStatement(statement(A)); g.storeStatement(statement(B)); g.storeStatement(statement(C)); @@ -135,24 +123,6 @@ public class MongoGeoIndexerSfTest extends MongoRyaTestBase { } - private static Point point(final double x, final double y) { - return gf.createPoint(new Coordinate(x, y)); - } - - private static LineString line(final double x1, final double y1, final double x2, final double y2) { - return new LineString(new PackedCoordinateSequence.Double(new double[] { x1, y1, x2, y2 }, 2), gf); - } - - private static Polygon poly(final double[] arr) { - final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(arr, 2)); - final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {}); - return p1; - } - - private static double[] bbox(final double x1, final double y1, final double x2, final double y2) { - return new double[] { x1, y1, x1, y2, x2, y2, x2, y1, x1, y1 }; - } - public void compare(final CloseableIteration<Statement, ?> actual, final Geometry... expected) throws Exception { final Set<Statement> expectedSet = Sets.newHashSet(); for (final Geometry geo : expected) { http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/e5738966/extras/rya.geoindexing/src/test/java/org/apache/rya/indexing/mongo/MongoGeoIndexerTest.java ---------------------------------------------------------------------- diff --git a/extras/rya.geoindexing/src/test/java/org/apache/rya/indexing/mongo/MongoGeoIndexerTest.java b/extras/rya.geoindexing/src/test/java/org/apache/rya/indexing/mongo/MongoGeoIndexerTest.java index 024c126..3506f5d 100644 --- a/extras/rya.geoindexing/src/test/java/org/apache/rya/indexing/mongo/MongoGeoIndexerTest.java +++ b/extras/rya.geoindexing/src/test/java/org/apache/rya/indexing/mongo/MongoGeoIndexerTest.java @@ -31,9 +31,8 @@ import org.apache.rya.indexing.GeoConstants; import org.apache.rya.indexing.OptionalConfigUtils; import org.apache.rya.indexing.StatementConstraints; import org.apache.rya.indexing.accumulo.ConfigUtils; +import org.apache.rya.indexing.geotemporal.mongo.MongoITBase; import org.apache.rya.indexing.mongodb.geo.MongoGeoIndexer; -import org.apache.rya.mongodb.MongoDBRdfConfiguration; -import org.apache.rya.mongodb.MongoRyaTestBase; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -55,29 +54,21 @@ import com.vividsolutions.jts.geom.Polygon; import com.vividsolutions.jts.geom.PrecisionModel; import com.vividsolutions.jts.geom.impl.PackedCoordinateSequence; -public class MongoGeoIndexerTest extends MongoRyaTestBase { - +public class MongoGeoIndexerTest extends MongoITBase { private static final StatementConstraints EMPTY_CONSTRAINTS = new StatementConstraints(); - - MongoDBRdfConfiguration conf; GeometryFactory gf = new GeometryFactory(new PrecisionModel(), 4326); @Before public void before() throws Exception { - conf = new MongoDBRdfConfiguration(); - conf.set(ConfigUtils.USE_MONGO, "true"); - conf.set(MongoDBRdfConfiguration.MONGO_DB_NAME, getDbName()); - conf.set(MongoDBRdfConfiguration.MONGO_COLLECTION_PREFIX, "rya_"); conf.set(ConfigUtils.GEO_PREDICATES_LIST, "http://www.opengis.net/ont/geosparql#asWKT"); conf.set(OptionalConfigUtils.USE_GEO, "true"); - conf.setTablePrefix("rya_"); } @Test public void testRestrictPredicatesSearch() throws Exception { conf.setStrings(ConfigUtils.GEO_PREDICATES_LIST, "pred:1,pred:2"); try (final MongoGeoIndexer f = new MongoGeoIndexer()) { - f.initIndexer(conf, mongoClient); + f.initIndexer(conf, super.getMongoClient()); final ValueFactory vf = new ValueFactoryImpl(); @@ -116,7 +107,7 @@ public class MongoGeoIndexerTest extends MongoRyaTestBase { @Test public void testPrimeMeridianSearch() throws Exception { try (final MongoGeoIndexer f = new MongoGeoIndexer()) { - f.initIndexer(conf, mongoClient); + f.initIndexer(conf, super.getMongoClient()); final ValueFactory vf = new ValueFactoryImpl(); final Resource subject = vf.createURI("foo:subj"); @@ -160,7 +151,7 @@ public class MongoGeoIndexerTest extends MongoRyaTestBase { public void testDcSearch() throws Exception { // test a ring around dc try (final MongoGeoIndexer f = new MongoGeoIndexer()) { - f.initIndexer(conf, mongoClient); + f.initIndexer(conf, super.getMongoClient()); final ValueFactory vf = new ValueFactoryImpl(); final Resource subject = vf.createURI("foo:subj"); @@ -189,7 +180,7 @@ public class MongoGeoIndexerTest extends MongoRyaTestBase { public void testDeleteSearch() throws Exception { // test a ring around dc try (final MongoGeoIndexer f = new MongoGeoIndexer()) { - f.initIndexer(conf, mongoClient); + f.initIndexer(conf, super.getMongoClient()); final ValueFactory vf = new ValueFactoryImpl(); final Resource subject = vf.createURI("foo:subj"); @@ -228,7 +219,7 @@ public class MongoGeoIndexerTest extends MongoRyaTestBase { public void testDcSearchWithContext() throws Exception { // test a ring around dc try (final MongoGeoIndexer f = new MongoGeoIndexer()) { - f.initIndexer(conf, mongoClient); + f.initIndexer(conf, super.getMongoClient()); final ValueFactory vf = new ValueFactoryImpl(); final Resource subject = vf.createURI("foo:subj"); @@ -257,7 +248,7 @@ public class MongoGeoIndexerTest extends MongoRyaTestBase { public void testDcSearchWithSubject() throws Exception { // test a ring around dc try (final MongoGeoIndexer f = new MongoGeoIndexer()) { - f.initIndexer(conf, mongoClient); + f.initIndexer(conf, super.getMongoClient()); final ValueFactory vf = new ValueFactoryImpl(); final Resource subject = vf.createURI("foo:subj"); @@ -285,7 +276,7 @@ public class MongoGeoIndexerTest extends MongoRyaTestBase { public void testDcSearchWithSubjectAndContext() throws Exception { // test a ring around dc try (final MongoGeoIndexer f = new MongoGeoIndexer()) { - f.initIndexer(conf, mongoClient); + f.initIndexer(conf, super.getMongoClient()); final ValueFactory vf = new ValueFactoryImpl(); final Resource subject = vf.createURI("foo:subj"); @@ -318,7 +309,7 @@ public class MongoGeoIndexerTest extends MongoRyaTestBase { public void testDcSearchWithPredicate() throws Exception { // test a ring around dc try (final MongoGeoIndexer f = new MongoGeoIndexer()) { - f.initIndexer(conf, mongoClient); + f.initIndexer(conf, super.getMongoClient()); final ValueFactory vf = new ValueFactoryImpl(); final Resource subject = vf.createURI("foo:subj"); @@ -348,7 +339,7 @@ public class MongoGeoIndexerTest extends MongoRyaTestBase { public void testAntiMeridianSearch() throws Exception { // verify that a search works if the bounding box crosses the anti meridian try (final MongoGeoIndexer f = new MongoGeoIndexer()) { - f.initIndexer(conf, mongoClient); + f.initIndexer(conf, super.getMongoClient()); final ValueFactory vf = new ValueFactoryImpl(); final Resource context = vf.createURI("foo:context"); http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/e5738966/extras/rya.geoindexing/src/test/java/org/apache/rya/indexing/mongo/MongoIndexerDeleteIT.java ---------------------------------------------------------------------- diff --git a/extras/rya.geoindexing/src/test/java/org/apache/rya/indexing/mongo/MongoIndexerDeleteIT.java b/extras/rya.geoindexing/src/test/java/org/apache/rya/indexing/mongo/MongoIndexerDeleteIT.java index 4b66b5b..7473261 100644 --- a/extras/rya.geoindexing/src/test/java/org/apache/rya/indexing/mongo/MongoIndexerDeleteIT.java +++ b/extras/rya.geoindexing/src/test/java/org/apache/rya/indexing/mongo/MongoIndexerDeleteIT.java @@ -30,8 +30,7 @@ import org.apache.rya.indexing.TemporalInstant; import org.apache.rya.indexing.TemporalInstantRfc3339; import org.apache.rya.indexing.accumulo.ConfigUtils; import org.apache.rya.indexing.mongodb.MongoIndexingConfiguration; -import org.apache.rya.mongodb.MockMongoFactory; -import org.apache.rya.mongodb.MongoConnectorFactory; +import org.apache.rya.mongodb.MockMongoSingleton; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -64,15 +63,14 @@ public class MongoIndexerDeleteIT { @Before public void before() throws Exception { final MongoIndexingConfiguration indxrConf = MongoIndexingConfiguration.builder() - .setMongoCollectionPrefix("rya_") - .setMongoDBName("indexerTests") + .setMongoCollectionPrefix("rya_").setMongoDBName("indexerTests") .setUseMongoFreetextIndex(true) .setUseMongoTemporalIndex(true) .setMongoFreeTextPredicates(RDFS.LABEL.stringValue()) .setMongoTemporalPredicates("Property:atTime") .build(); - client = MockMongoFactory.newFactory().newMongoClient(); + client = MockMongoSingleton.getInstance(); indxrConf.setBoolean(OptionalConfigUtils.USE_GEO, true); indxrConf.set(ConfigUtils.GEO_PREDICATES_LIST, "http://www.opengis.net/ont/geosparql#asWKT"); indxrConf.setBoolean(ConfigUtils.USE_MONGO, true); @@ -85,9 +83,6 @@ public class MongoIndexerDeleteIT { @After public void after() throws Exception { - if (client != null) { - MongoConnectorFactory.closeMongoClient(); - } if (conn != null) { conn.clear(); }