Created
December 20, 2013 15:07
-
-
Save trishagee/8056046 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test() | |
public void testSingleServer() { | |
MongoClientURI u = new MongoClientURI("mongodb://db.example.com"); | |
assertEquals(1, u.getHosts().size()); | |
assertEquals("db.example.com", u.getHosts().get(0)); | |
assertNull(u.getDatabase()); | |
assertNull(u.getCollection()); | |
assertNull( u.getUsername()); | |
assertEquals(null, u.getPassword()); | |
} | |
@Test() | |
public void testWithDatabase() { | |
MongoClientURI u = new MongoClientURI("mongodb://foo/bar"); | |
assertEquals(1, u.getHosts().size()); | |
assertEquals("foo", u.getHosts().get(0)); | |
assertEquals("bar", u.getDatabase()); | |
assertEquals(null, u.getCollection()); | |
assertEquals(null, u.getUsername()); | |
assertEquals(null, u.getPassword()); | |
} | |
@Test() | |
public void testWithCollection() { | |
MongoClientURI u = new MongoClientURI("mongodb://localhost/test.my.coll"); | |
assertEquals("test", u.getDatabase()); | |
assertEquals("my.coll", u.getCollection()); | |
} | |
@Test() | |
public void testBasic2() { | |
MongoClientURI u = new MongoClientURI("mongodb://foo/bar.goo"); | |
assertEquals(1, u.getHosts().size()); | |
assertEquals("foo", u.getHosts().get(0)); | |
assertEquals("bar", u.getDatabase()); | |
assertEquals("goo", u.getCollection()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment