Skip to content

Commit fd39425

Browse files
committed
Massage DBCursor assertions to be compatibile with behavioral changes in the 3.4 server
1 parent 900c0de commit fd39425

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/test/com/mongodb/DBCursorTest.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,11 @@ public void testCountAndHint() {
136136
} else {
137137
assertEquals(1, c.find(new BasicDBObject("i", 1)).hint( "x_1" ).count());
138138
}
139-
assertEquals( 2, collection.find().hint( "x_1" ).count());
139+
if (serverIsAtLeastVersion(3.3)) {
140+
assertEquals(0, collection.find().hint("x_1").count()); // see https://jira.mongodb.org/browse/SERVER-22041
141+
} else {
142+
assertEquals(2, collection.find().hint("x_1").count());
143+
}
140144
}
141145

142146
@Test
@@ -387,7 +391,11 @@ public void testBig() {
387391

388392
// negative limit works like negative batch size, for legacy reason
389393
int x = c.find().limit(-800).toArray().size();
390-
assertTrue(x < 800);
394+
if (serverIsAtLeastVersion(3.3)) {
395+
assertEquals(800, x); // MongoDB 3.4 creates a 12MB OP_REPLY that fits all 800 documents
396+
} else {
397+
assertTrue(x < 800); // Previous versions cut off the OP_REPLY at 4MB
398+
}
391399

392400
DBCursor a = c.find();
393401
assertEquals(numToInsert, a.itcount());

0 commit comments

Comments
 (0)