Package fr.gouv.vitam.common.mongo
Class MongoRule
- java.lang.Object
-
- org.junit.rules.ExternalResource
-
- fr.gouv.vitam.common.mongo.MongoRule
-
- All Implemented Interfaces:
org.junit.rules.TestRule
public class MongoRule extends org.junit.rules.ExternalResource
Launch a single instance of Mongo database, drop collection after each test
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
COUNTER
static java.lang.String
ID
static java.lang.String
MONGO_HOST
static java.lang.String
VITAM_DB
static java.lang.String
VITAM_SEQUENCE
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description MongoRule
addCollectionToBePurged(java.lang.String collectionName)
protected void
after()
void
close()
static java.lang.String
getDatabaseName()
static int
getDataBasePort()
com.mongodb.MongoClient
getMongoClient()
com.mongodb.client.MongoCollection<org.bson.Document>
getMongoCollection(java.lang.String collectionName)
<TDocument>
com.mongodb.client.MongoCollection<TDocument>getMongoCollection(java.lang.String collectionName, java.lang.Class<TDocument> clazz)
com.mongodb.client.MongoDatabase
getMongoDatabase()
void
handleAfter()
void
handleAfter(java.util.Set<java.lang.String> collections)
void
handleAfterClass()
Used when annotated @ClassRule
-
-
-
Field Detail
-
VITAM_DB
public static final java.lang.String VITAM_DB
- See Also:
- Constant Field Values
-
MONGO_HOST
public static final java.lang.String MONGO_HOST
- See Also:
- Constant Field Values
-
VITAM_SEQUENCE
public static final java.lang.String VITAM_SEQUENCE
- See Also:
- Constant Field Values
-
COUNTER
public static final java.lang.String COUNTER
- See Also:
- Constant Field Values
-
ID
public static final java.lang.String ID
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MongoRule
public MongoRule(com.mongodb.MongoClientOptions clientOptions, java.lang.String... collectionsToBePurged)
- Parameters:
clientOptions
-collectionsToBePurged
-
-
MongoRule
public MongoRule(java.lang.String dbName, com.mongodb.MongoClientOptions clientOptions, java.lang.String... collectionsToBePurged)
-
-
Method Detail
-
getDatabaseName
public static java.lang.String getDatabaseName()
-
after
protected void after()
- Overrides:
after
in classorg.junit.rules.ExternalResource
-
addCollectionToBePurged
public MongoRule addCollectionToBePurged(java.lang.String collectionName)
-
handleAfterClass
public void handleAfterClass()
Used when annotated @ClassRule
-
handleAfter
public void handleAfter()
-
getDataBasePort
public static int getDataBasePort()
-
getMongoClient
public com.mongodb.MongoClient getMongoClient()
-
getMongoDatabase
public com.mongodb.client.MongoDatabase getMongoDatabase()
-
getMongoCollection
public com.mongodb.client.MongoCollection<org.bson.Document> getMongoCollection(java.lang.String collectionName)
-
getMongoCollection
public <TDocument> com.mongodb.client.MongoCollection<TDocument> getMongoCollection(java.lang.String collectionName, java.lang.Class<TDocument> clazz)
-
handleAfter
public void handleAfter(java.util.Set<java.lang.String> collections)
-
close
public void close()
-
-