Skip to content

Commit b857e44

Browse files
committed
Fixed findAndModify test to work with stricter error checking in server > 2.1
1 parent db1f12e commit b857e44

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/test/com/mongodb/JavaClientTest.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -849,15 +849,20 @@ public void testFindAndModify(){
849849
// test exception throwing
850850
c.insert( new BasicDBObject( "a" , 1 ) );
851851
try {
852-
dbObj = c.findAndModify( null, null );
853-
assertTrue(false, "Exception not thrown when no update nor remove");
852+
c.findAndModify( null, null );
853+
fail("Exception not thrown when no update nor remove");
854854
} catch (MongoException e) {
855855
}
856856

857857
try {
858858
dbObj = c.findAndModify( new BasicDBObject("a", "noexist"), null );
859+
if (!serverIsAtLeastVersion(2.1)) {
860+
assertNull(dbObj);
861+
}
859862
} catch (MongoException e) {
860-
assertTrue(false, "Exception thrown when matching record");
863+
if (!serverIsAtLeastVersion(2.1)) {
864+
fail("Exception thrown when matching record");
865+
}
861866
}
862867
}
863868

0 commit comments

Comments
 (0)