Skip to content

Commit 7963728

Browse files
committed
Collection.isCapped() Compatability with Mongo 2.2.0
1 parent 4fd5f71 commit 7963728

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/main/com/mongodb/DBCollection.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1352,7 +1352,7 @@ public CommandResult getStats() {
13521352
public boolean isCapped() {
13531353
CommandResult stats = getStats();
13541354
Object capped = stats.get("capped");
1355-
return(capped != null && (Integer)capped == 1);
1355+
return(capped != null && ( capped.equals(1) || capped.equals(true) ) );
13561356
}
13571357

13581358
// ------

src/test/com/mongodb/DBCollectionTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,21 @@ public void testMultiInsert() {
4848
c.insert(new DBObject[] {inserted1,inserted2});
4949
}
5050

51+
@Test(groups = {"basic"})
52+
public void testCappedCollection() {
53+
String collectionName = "testCapped";
54+
int collectionSize = 1000;
55+
56+
DBCollection c = _db.getCollection(collectionName);
57+
c.drop();
58+
59+
DBObject options = new BasicDBObject("capped", true);
60+
options.put("size", collectionSize);
61+
c = _db.createCollection(collectionName, options);
62+
63+
assertEquals(c.isCapped(), true);
64+
}
65+
5166
@Test(groups = {"basic"})
5267
public void testDuplicateKeyException() {
5368
DBCollection c = _db.getCollection("testDuplicateKey");

0 commit comments

Comments
 (0)