|
27 | 27 |
|
28 | 28 | public class DBCursorTest extends TestCase { |
29 | 29 |
|
30 | | - public DBCursorTest() |
31 | | - throws IOException , MongoException { |
| 30 | + public DBCursorTest() throws IOException , MongoException { |
32 | 31 | 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"; |
35 | 34 | _db = cleanupMongo.getDB( cleanupDB ); |
36 | 35 | } |
37 | 36 |
|
| 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 | + |
38 | 82 | @Test(groups = {"basic"}) |
39 | 83 | public void testCount() { |
40 | 84 | try { |
@@ -96,6 +140,7 @@ public void testOptions() { |
96 | 140 | // c.drop(); |
97 | 141 | // } |
98 | 142 |
|
| 143 | + |
99 | 144 | @Test//(enabled = false) |
100 | 145 | public void testTailable() { |
101 | 146 | DBCollection c = _db.getCollection("tail1"); |
|
0 commit comments