public class Fongo extends Object implements com.mongodb.operation.OperationExecutor
This class doesn't implement Mongo, but does provide the same basic interface
Usage:
Fongo fongo = new Fongo("test server");
com.mongodb.DB db = fongo.getDB("mydb");
// if you need an instance of com.mongodb.Mongo
com.mongodb.MongoClient mongo = fongo.getMongo();
| Modifier and Type | Field and Description |
|---|---|
static com.mongodb.connection.ServerVersion |
DEFAULT_SERVER_VERSION |
static com.mongodb.connection.ServerVersion |
OLD_SERVER_VERSION |
| Constructor and Description |
|---|
Fongo(String name) |
Fongo(String name,
com.mongodb.connection.ServerVersion serverVersion) |
| Modifier and Type | Method and Description |
|---|---|
void |
dropDatabase(String dbName)
Drop db and all data from memory
|
<T> T |
execute(com.mongodb.operation.ReadOperation<T> operation,
com.mongodb.ReadPreference readPreference) |
<T> T |
execute(com.mongodb.operation.WriteOperation<T> operation) |
com.mongodb.client.MongoDatabase |
getDatabase(String databaseName) |
List<String> |
getDatabaseNames()
Get database names that have been used
|
com.mongodb.DB |
getDB(String dbname)
equivalent to getDB in driver
multiple calls to this method return the same DB instance
|
com.mongodb.MongoClient |
getMongo()
A mocked out instance of com.mongodb.Mongo
All methods calls are intercepted and execute associated Fongo method
|
com.mongodb.ServerAddress |
getServerAddress()
This will always be localhost:27017
|
com.mongodb.connection.ServerVersion |
getServerVersion() |
Collection<com.mongodb.DB> |
getUsedDatabases()
Get databases that have been used
|
com.mongodb.WriteConcern |
getWriteConcern() |
String |
toString() |
public static final com.mongodb.connection.ServerVersion DEFAULT_SERVER_VERSION
public static final com.mongodb.connection.ServerVersion OLD_SERVER_VERSION
public Fongo(String name)
name - Used only for a nice toString in case you have multiple instancespublic Fongo(String name, com.mongodb.connection.ServerVersion serverVersion)
name - Used only for a nice toString in case you have multiple instancespublic com.mongodb.DB getDB(String dbname)
dbname - name of the db.public com.mongodb.client.MongoDatabase getDatabase(String databaseName)
public Collection<com.mongodb.DB> getUsedDatabases()
public List<String> getDatabaseNames()
public void dropDatabase(String dbName)
dbName - name of the database.public com.mongodb.ServerAddress getServerAddress()
public com.mongodb.MongoClient getMongo()
public com.mongodb.WriteConcern getWriteConcern()
public <T> T execute(com.mongodb.operation.ReadOperation<T> operation,
com.mongodb.ReadPreference readPreference)
execute in interface com.mongodb.operation.OperationExecutorpublic <T> T execute(com.mongodb.operation.WriteOperation<T> operation)
execute in interface com.mongodb.operation.OperationExecutorpublic com.mongodb.connection.ServerVersion getServerVersion()
Copyright © 2015. All rights reserved.