Package com.mongodb

Examples of com.mongodb.MongoURI.connect()


    }
   
    MongoURI uri = new MongoURI(inputUri);
    Mongo mongo = null;
    try {
      mongo = uri.connect();
    } catch (UnknownHostException e) {
      throw new IllegalStateException( " Unable to connect to MongoDB at '" + uri + "'", e);
    }
        DB db = mongo.getDB(uri.getDatabase());
        DBCollection coll = db.getCollection(uri.getCollection());
View Full Code Here


  @Test
  public void mongo() throws Exception {
    Mongo mongo = createMock(Mongo.class);

    MongoURI uri = createMock(MongoURI.class);
    expect(uri.connect()).andReturn(mongo);

    replay(uri, mongo);

    Mongo result = new MongoModule().mongo(uri);
    assertEquals(mongo, result);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.