Search in sources :

Example 81 with MongoClient

use of com.mongodb.MongoClient in project GeoGig by boundlessgeo.

the class MongoGraphDatabaseTest method createDatabase.

@Override
protected MongoGraphDatabase createDatabase(Platform platform) throws Exception {
    final IniMongoProperties properties = new IniMongoProperties();
    final String uri = properties.get("mongodb.uri", String.class).or("mongodb://localhost:27017/");
    final String database = properties.get("mongodb.database", String.class).or("geogig");
    MongoClient client = new MongoClient(new MongoClientURI(uri));
    DB db = client.getDB(database);
    db.dropDatabase();
    MongoConnectionManager manager = new MongoConnectionManager();
    ConfigDatabase config = new TestConfigDatabase(platform);
    MongoGraphDatabase mongoGraphDatabase = new MongoGraphDatabase(manager, config);
    return mongoGraphDatabase;
}
Also used : MongoClient(com.mongodb.MongoClient) MongoGraphDatabase(org.locationtech.geogig.storage.mongo.MongoGraphDatabase) ConfigDatabase(org.locationtech.geogig.storage.ConfigDatabase) MongoClientURI(com.mongodb.MongoClientURI) MongoConnectionManager(org.locationtech.geogig.storage.mongo.MongoConnectionManager) DB(com.mongodb.DB)

Aggregations

MongoClient (com.mongodb.MongoClient)81 MongoClientURI (com.mongodb.MongoClientURI)27 Test (org.junit.Test)20 Document (org.bson.Document)15 ServerAddress (com.mongodb.ServerAddress)13 MongoDatabase (com.mongodb.client.MongoDatabase)13 Before (org.junit.Before)10 BasicDBObject (com.mongodb.BasicDBObject)9 MongoCredential (com.mongodb.MongoCredential)8 ArrayList (java.util.ArrayList)8 DBCollection (com.mongodb.DBCollection)7 DB (com.mongodb.DB)6 DBObject (com.mongodb.DBObject)5 IOException (java.io.IOException)5 MongoClientURIBuilder (com.mongodb.hadoop.util.MongoClientURIBuilder)4 File (java.io.File)4 Closer (com.google.common.io.Closer)3 BasicDBList (com.mongodb.BasicDBList)3 MongoClientOptions (com.mongodb.MongoClientOptions)3 MongoException (com.mongodb.MongoException)3