Skip to content

Commit 4e02a28

Browse files
author
Ryan
committed
added getServerAddress tests.
1 parent f2a1301 commit 4e02a28

File tree

1 file changed

+49
-4
lines changed

1 file changed

+49
-4
lines changed

src/test/com/mongodb/DBCursorTest.java

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,58 @@
2727

2828
public class DBCursorTest extends TestCase {
2929

30-
public DBCursorTest()
31-
throws IOException , MongoException {
30+
public DBCursorTest() throws IOException , MongoException {
3231
super();
33-
cleanupMongo = new Mongo( "127.0.0.1" );
34-
cleanupDB = "com_mongodb_unittest_DBCursorTest";
32+
cleanupMongo = new Mongo( "127.0.0.1" );
33+
cleanupDB = "com_mongodb_unittest_DBCursorTest";
3534
_db = cleanupMongo.getDB( cleanupDB );
3635
}
3736

37+
@Test(groups = {"basic"})
38+
public void testGetServerAddressLoop() {
39+
40+
final DBCollection c = _db.getCollection("getServerAddress");
41+
c.drop();
42+
43+
// Insert some data.
44+
for (int i=0; i < 10; i++) c.insert(new BasicDBObject("one", "two"));
45+
46+
final DBCursor cur = c.find();
47+
48+
while (cur.hasNext()) {
49+
cur.next();
50+
assertNotNull(cur.getServerAddress());
51+
}
52+
53+
System.out.println("works in loop");
54+
}
55+
56+
@Test(groups = {"basic"})
57+
public void testGetServerAddressQuery() {
58+
59+
final DBCollection c = _db.getCollection("getServerAddress");
60+
c.drop();
61+
62+
// Insert some data.
63+
for (int i=0; i < 10; i++) c.insert(new BasicDBObject("one", "two"));
64+
65+
final DBCursor cur = c.find();
66+
assertNotNull(cur.getServerAddress());
67+
}
68+
69+
@Test(groups = {"basic"})
70+
public void testGetServerAddressQuery1() {
71+
72+
final DBCollection c = _db.getCollection("getServerAddress");
73+
c.drop();
74+
75+
// Insert some data.
76+
for (int i=0; i < 10; i++) c.insert(new BasicDBObject("one", i));
77+
78+
final DBCursor cur = c.find(new BasicDBObject("one", 9));
79+
assertNotNull(cur.getServerAddress());
80+
}
81+
3882
@Test(groups = {"basic"})
3983
public void testCount() {
4084
try {
@@ -96,6 +140,7 @@ public void testOptions() {
96140
// c.drop();
97141
// }
98142

143+
99144
@Test//(enabled = false)
100145
public void testTailable() {
101146
DBCollection c = _db.getCollection("tail1");

0 commit comments

Comments
 (0)