public class FongoRule
extends org.junit.rules.ExternalResource
@Rule public FongoRule rule = new FongoRule().
Note than you can switch to a real mongodb on your localhost (for now).
WARNING : database is dropped after the test !!
| Constructor and Description |
|---|
FongoRule() |
FongoRule(boolean realMongo) |
FongoRule(boolean realMongo,
org.bson.codecs.configuration.CodecRegistry codecRegistry) |
FongoRule(boolean realMongo,
com.mongodb.MongoClient mongoClientIfReal) |
FongoRule(boolean realMongo,
com.mongodb.connection.ServerVersion serverVersion) |
FongoRule(org.bson.codecs.configuration.CodecRegistry codecRegistry) |
FongoRule(com.mongodb.connection.ServerVersion serverVersion) |
FongoRule(String dbName) |
FongoRule(String dbName,
boolean realMongo) |
FongoRule(String dbName,
com.mongodb.connection.ServerVersion serverVersion,
boolean realMongo,
com.mongodb.MongoClient mongoClientIfReal) |
FongoRule(String dbName,
com.mongodb.connection.ServerVersion serverVersion,
boolean realMongo,
com.mongodb.MongoClient mongoClientIfReal,
org.bson.codecs.configuration.CodecRegistry codecRegistry)
Setup a rule with a real MongoDB.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
after() |
protected void |
before() |
com.mongodb.client.MongoDatabase |
getDatabase() |
com.mongodb.client.MongoDatabase |
getDatabase(String name) |
com.mongodb.DB |
getDb()
Deprecated.
|
com.mongodb.DB |
getDB() |
com.mongodb.DB |
getDb(String name)
Deprecated.
|
com.mongodb.DB |
getDB(String name) |
Fongo |
getFongo() |
com.mongodb.Mongo |
getMongo()
Deprecated.
|
com.mongodb.MongoClient |
getMongoClient() |
com.mongodb.connection.ServerVersion |
getServerVersion() |
com.mongodb.client.MongoCollection<org.bson.Document> |
insertDocumentsFromFile(com.mongodb.client.MongoCollection<org.bson.Document> coll,
String filename) |
com.mongodb.client.MongoCollection<org.bson.Document> |
insertDocumentsFromFile(String filename) |
com.mongodb.DBCollection |
insertFile(com.mongodb.DBCollection coll,
String filename) |
com.mongodb.DBCollection |
insertJSON(com.mongodb.DBCollection coll,
String json) |
com.mongodb.client.MongoCollection |
insertJSON(com.mongodb.client.MongoCollection coll,
String json) |
boolean |
isRealMongo() |
boolean |
mustContainsSystemIndexes() |
com.mongodb.DBCollection |
newCollection() |
com.mongodb.DBCollection |
newCollection(String collectionName) |
protected Fongo |
newFongo(com.mongodb.connection.ServerVersion serverVersion,
org.bson.codecs.configuration.CodecRegistry codecRegistry) |
com.mongodb.client.MongoCollection<org.bson.Document> |
newMongoCollection() |
<T> com.mongodb.client.MongoCollection<T> |
newMongoCollection(Class<T> documentClass) |
com.mongodb.client.MongoCollection<org.bson.Document> |
newMongoCollection(String collectionName) |
<T> com.mongodb.client.MongoCollection<T> |
newMongoCollection(String collectionName,
Class<T> documentClass) |
<T> T |
parse(String json) |
com.mongodb.DBObject |
parseDBObject(String json) |
List<com.mongodb.DBObject> |
parseList(String json) |
static String |
randomName() |
static String |
randomName(String prefix) |
public FongoRule(String dbName, com.mongodb.connection.ServerVersion serverVersion, boolean realMongo, com.mongodb.MongoClient mongoClientIfReal, org.bson.codecs.configuration.CodecRegistry codecRegistry)
dbName - the dbName to use.serverVersion - version of the server to use for fongo.realMongo - set to true if you want to use a real mongoDB.mongoClientIfReal - real client to use if realMongo si true.public FongoRule(String dbName, com.mongodb.connection.ServerVersion serverVersion, boolean realMongo, com.mongodb.MongoClient mongoClientIfReal)
public FongoRule()
public FongoRule(org.bson.codecs.configuration.CodecRegistry codecRegistry)
public FongoRule(com.mongodb.connection.ServerVersion serverVersion)
public FongoRule(boolean realMongo)
public FongoRule(boolean realMongo,
org.bson.codecs.configuration.CodecRegistry codecRegistry)
public FongoRule(boolean realMongo,
com.mongodb.connection.ServerVersion serverVersion)
public FongoRule(boolean realMongo,
com.mongodb.MongoClient mongoClientIfReal)
public FongoRule(String dbName, boolean realMongo)
public FongoRule(String dbName)
public boolean isRealMongo()
protected void before()
throws UnknownHostException
before in class org.junit.rules.ExternalResourceUnknownHostExceptionprotected void after()
after in class org.junit.rules.ExternalResourcepublic com.mongodb.DBCollection insertJSON(com.mongodb.DBCollection coll,
String json)
public com.mongodb.client.MongoCollection insertJSON(com.mongodb.client.MongoCollection coll,
String json)
public com.mongodb.DBCollection insertFile(com.mongodb.DBCollection coll,
String filename)
throws IOException
IOExceptionpublic com.mongodb.client.MongoCollection<org.bson.Document> insertDocumentsFromFile(String filename) throws IOException
IOExceptionpublic com.mongodb.client.MongoCollection<org.bson.Document> insertDocumentsFromFile(com.mongodb.client.MongoCollection<org.bson.Document> coll,
String filename)
throws IOException
IOExceptionpublic com.mongodb.DBObject parseDBObject(String json)
public <T> T parse(String json)
public com.mongodb.DBCollection newCollection()
public com.mongodb.DBCollection newCollection(String collectionName)
public com.mongodb.client.MongoCollection<org.bson.Document> newMongoCollection()
public com.mongodb.client.MongoCollection<org.bson.Document> newMongoCollection(String collectionName)
public <T> com.mongodb.client.MongoCollection<T> newMongoCollection(Class<T> documentClass)
public <T> com.mongodb.client.MongoCollection<T> newMongoCollection(String collectionName, Class<T> documentClass)
protected Fongo newFongo(com.mongodb.connection.ServerVersion serverVersion, org.bson.codecs.configuration.CodecRegistry codecRegistry)
public Fongo getFongo()
@Deprecated public com.mongodb.DB getDb()
@Deprecated public com.mongodb.DB getDb(String name)
public com.mongodb.DB getDB()
public com.mongodb.DB getDB(String name)
public com.mongodb.client.MongoDatabase getDatabase(String name)
public com.mongodb.client.MongoDatabase getDatabase()
@Deprecated public com.mongodb.Mongo getMongo()
public com.mongodb.MongoClient getMongoClient()
public static String randomName()
public boolean mustContainsSystemIndexes()
public com.mongodb.connection.ServerVersion getServerVersion()
Copyright © 2018. All rights reserved.