@Test(groups = "dev") public void dbTest() { DB db = mongo.getDB(DBNAME); db.getCollectionNames(); List<String> names = mongo.getDatabaseNames(); assertNotNull(names); boolean hit = false; for (String name : names) { if (DBNAME.equals(name)) { hit = true; break; } } assertTrue(hit); }
@Test(groups = "dev") public void collectionTest() { DB db = mongo.getDB(DBNAME); DBCollection myCollection = db.getCollection("myCollection"); myCollection.save( new BasicDBObject( MapUtils.putAll(new HashMap(), new Object[] {"name", "leon", "age", 33}))); myCollection.findOne(); Set<String> names = db.getCollectionNames(); assertNotNull(names); boolean hit = false; for (String name : names) { if ("myCollection".equals(name)) { hit = true; break; } } assertTrue(hit); }