@Test public void testDropDatabaseFromFongoWithMultipleCollectionsDropsBothCollections() throws Exception { Fongo fongo = newFongo(); DB db = fongo.getDB("db"); DBCollection collection1 = db.getCollection("coll1"); DBCollection collection2 = db.getCollection("coll2"); db.dropDatabase(); assertFalse("Collection 1 shouldn't exist in DB", db.collectionExists(collection1.getName())); assertFalse("Collection 2 shouldn't exist in DB", db.collectionExists(collection2.getName())); assertFalse("DB shouldn't exist in fongo", fongo.getDatabaseNames().contains("db")); }
public static void doit() { Fongo fongo = new Fongo("fongo"); for (int i = 0; i < 1; i++) { DB db = fongo.getDB("db"); DBCollection collection = db.getCollection("coll"); for (int k = 0; k < 10000; k++) { collection.insert(new BasicDBObject("_id", k).append("n", new BasicDBObject("a", 1))); collection.findOne(new BasicDBObject("_id", k)); } db.dropDatabase(); } }
public static void main(String[] args) throws Exception { if (args.length < 4) { System.out.println("MongoBenchmark <host> <port> <db> <max>"); System.exit(-1); } String host = args[0]; int port = StringUtil.toInt(args[1], 27017); String database = args[2]; int max = StringUtil.toInt(args[3], 1); System.out.println("Connect to " + host + ":" + port + " db: " + database + ", max: " + max); Mongo mongo = new Mongo(host, port); System.out.println( "First compare Mongo native ObjectId, our customized ObjectId and String Id"); DB db = null; // db = mongo.getDB(database+1); // db.dropDatabase(); // testMongoUserId(max, db); // // db = mongo.getDB(database+2); // db.dropDatabase(); // testMyUserId(max, db); // // db = mongo.getDB(database+3); // db.dropDatabase(); // testStringUserId(max, db); System.out.println("Second: compare Mongo BasicDBObject and our MapDBObject"); db = mongo.getDB(database + 4); db.dropDatabase(); testBasicBson(max, db); db = mongo.getDB(database + 5); db.dropDatabase(); testMapDBObject(max, db); }
@Override protected MongoGraphDatabase createDatabase(Platform platform) throws Exception { IniMongoProperties properties = new IniMongoProperties(); String host = properties.get("mongo.host", String.class).or("localhost"); int port = properties.get("mongodb.port", Integer.class).or(27017); MongoClient client = new MongoClient(host, Integer.valueOf(port)); DB db = client.getDB("geogit"); db.dropDatabase(); MongoConnectionManager manager = new MongoConnectionManager(); ConfigDatabase config = new TestConfigDatabase(platform); MongoGraphDatabase mongoGraphDatabase = new MongoGraphDatabase(platform, manager, config); return mongoGraphDatabase; }
@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; }
@AfterClass public void cleanUp() { // super.deleteRiver(); logger.info("Drop database " + mongoDB.getName()); mongoDB.dropDatabase(); }
public static void clearDBData() { DB db = MongoDBTestRunner.getDB(); if (db != null) { db.dropDatabase(); } }
@After public void after() { database.dropDatabase(); }
private void cleanUp() { super.deleteRiver(); logger.info("Drop database " + mongoDB.getName()); mongoDB.dropDatabase(); }