Github user kchilton2 commented on a diff in the pull request:

    https://github.com/apache/incubator-rya/pull/256#discussion_r159509027
  
    --- Diff: 
dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoTestBase.java ---
    @@ -33,27 +34,43 @@
      */
     public class MongoTestBase {
     
    -    private static MongoClient mongoClient = null;
    -    protected static MongoDBRdfConfiguration conf;
    +    private MongoClient mongoClient = null;
    +    protected StatefulMongoDBRdfConfiguration conf;
     
         @Before
         public void setupTest() throws Exception {
    -        conf = new MongoDBRdfConfiguration( new Configuration() );
    +        // 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");
    -        mongoClient = EmbeddedMongoSingleton.getInstance();
    -        conf.setMongoClient(mongoClient);
    -    }
    +        
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);
     
    -    @After
    -    public void cleanupTest() {
    -        // Remove any DBs that were created by the test.
    +        // 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) 
{
    --- End diff --
    
    Yes. Most of them.


---

Reply via email to