Class MongoDatabasePolicy
- java.lang.Object
-
- org.junit.rules.ExternalResource
-
- org.apache.calcite.adapter.mongodb.MongoDatabasePolicy
-
- All Implemented Interfaces:
org.junit.rules.TestRule
class MongoDatabasePolicy extends org.junit.rules.ExternalResource
Instantiates a new connection to Fongo (or Mongo) database depending on the current profile (unit or integration tests).By default, this rule is executed as part of a unit test and in-memory database Fongo 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
).
-
-
Constructor Summary
Constructors Modifier Constructor Description private
MongoDatabasePolicy(com.mongodb.MongoClient client)
-
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()
-
-
-
Field Detail
-
DB_NAME
private static final java.lang.String DB_NAME
- See Also:
- Constant Field Values
-
database
private final com.mongodb.client.MongoDatabase database
-
client
private final com.mongodb.MongoClient client
-
-
Method Detail
-
create
static MongoDatabasePolicy create()
Creates an instance based on current maven profile (as defined by-Pit
).- Returns:
- new instance of the policy to be used by unit tests
-
database
com.mongodb.client.MongoDatabase database()
-
after
protected void after()
- Overrides:
after
in classorg.junit.rules.ExternalResource
-
-