Class MongoDatabasePolicy

  • All Implemented Interfaces:

    class MongoDatabasePolicy
    extends org.junit.rules.ExternalResource
    Instantiates a new connection to a embedded (but fake) or real mongo database depending on current profile (unit or integration tests).

    By default, this rule is executed as part of a unit test and in-memory database is used.

    However, if the maven profile is set to IT (eg. via command line $ mvn -Pit install) this rule will connect to an existing (external) Mongo instance (localhost).

    • Field Summary

      Modifier and Type Field Description
      private com.mongodb.MongoClient client  
      private org.apache.calcite.util.Closer closer  
      private com.mongodb.client.MongoDatabase database  
      private static java.lang.String DB_NAME  
    • Constructor Summary

      Modifier Constructor Description
      private MongoDatabasePolicy​(com.mongodb.MongoClient client, org.apache.calcite.util.Closer closer)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void after()  
      (package private) static MongoDatabasePolicy create()
      Creates an instance based on current maven profile (as defined by -Pit).
      (package private) com.mongodb.client.MongoDatabase database()  
      • Methods inherited from class org.junit.rules.ExternalResource

        apply, before
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • database

        private final com.mongodb.client.MongoDatabase database
      • client

        private final com.mongodb.MongoClient client
      • closer

        private final org.apache.calcite.util.Closer closer
    • Constructor Detail

      • MongoDatabasePolicy

        private MongoDatabasePolicy​(com.mongodb.MongoClient client,
                                    org.apache.calcite.util.Closer closer)
    • Method Detail

      • create

        static MongoDatabasePolicy create()
        Creates an instance based on current maven profile (as defined by -Pit).
        new instance of the policy to be used by unit tests
      • database

        com.mongodb.client.MongoDatabase database()
      • after

        protected void after()
        after in class org.junit.rules.ExternalResource