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,
com.mongodb.MongoClient mongoClientIfReal) |
FongoRule(String dbName) |
FongoRule(String dbName,
boolean realMongo) |
FongoRule(String dbName,
boolean realMongo,
com.mongodb.MongoClient mongoClientIfReal)
Setup a rule with a real MongoDB.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
after() |
protected void |
before() |
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() |
com.mongodb.DBCollection |
insertFile(com.mongodb.DBCollection coll,
String filename) |
com.mongodb.DBCollection |
insertJSON(com.mongodb.DBCollection coll,
String json) |
boolean |
isRealMongo() |
com.mongodb.DBCollection |
newCollection() |
com.mongodb.DBCollection |
newCollection(String collectionName) |
<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, boolean realMongo, com.mongodb.MongoClient mongoClientIfReal)
dbName - the dbName to use.realMongo - set to true if you want to use a real mongoDB.mongoClientIfReal - real client to use if realMongo si true.public FongoRule()
public FongoRule(boolean realMongo)
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.DBCollection insertFile(com.mongodb.DBCollection 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 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.Mongo getMongo()
public static String randomName()
Copyright © 2016. All rights reserved.