Skip to content

Commit f813e22

Browse files
committed
maxTime getMore test
Added a test to ensure that getMore triggers a MongoExecutionTimeoutException
1 parent 0e624da commit f813e22

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/test/com/mongodb/DBCursorTest.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,32 @@ public void testMaxTimeForIterator() {
499499
}
500500
}
501501

502+
@Test
503+
public void testMaxTimeDuringGetMore() {
504+
assumeFalse(isSharded(getMongoClient()));
505+
checkServerVersion(2.5);
506+
for (int i=0; i < 20; i++) {
507+
collection.insert(new BasicDBObject("x", 1));
508+
}
509+
510+
DBCursor cursor = new DBCursor(collection, new BasicDBObject("x", 1), new BasicDBObject(), ReadPreference.primary());
511+
cursor.batchSize(10);
512+
cursor.maxTime(1, SECONDS);
513+
cursor.next();
514+
515+
enableMaxTimeFailPoint();
516+
try {
517+
while(cursor.hasNext()) {
518+
cursor.next();
519+
}
520+
fail("Show have thrown");
521+
} catch (MongoExecutionTimeoutException e) {
522+
assertEquals(50, e.getCode());
523+
} finally {
524+
disableMaxTimeFailPoint();
525+
}
526+
}
527+
502528
@Test
503529
public void testMaxTimeForIterable() {
504530
assumeFalse(isSharded(getMongoClient()));

0 commit comments

Comments
 (0)