Skip to content

Commit 705029d

Browse files
committed
Fixed tests for binary encoding and capped collection
1 parent 18eaaf3 commit 705029d

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/test/com/mongodb/DBTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ public void testCreateCollection() {
4545
DBCollection c = _db.createCollection("foo1", o1);
4646

4747
DBObject o2 = BasicDBObjectBuilder.start().add("capped", true)
48-
.add("size", 100).get();
48+
.add("max", 10).get();
4949
c = _db.createCollection("foo2", o2);
5050
for (int i=0; i<30; i++) {
5151
c.insert(new BasicDBObject("x", i));
5252
}
53-
assertTrue(c.find().count() < 10);
53+
assertTrue(c.find().count() <= 10);
5454

5555
DBObject o3 = BasicDBObjectBuilder.start().add("capped", true)
5656
.add("size", 1000).add("max", 2).get();

src/test/com/mongodb/JavaClientTest.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,14 +220,16 @@ public void testBinaryOld()
220220
bb.put( "eliot".getBytes() );
221221
out.put( "a" , new Binary( BSON.B_BINARY , "eliot".getBytes() ) );
222222
c.save( out );
223-
223+
224+
// objects of subtype B_BINARY or B_GENERAL should becomes byte[]
224225
out = c.findOne();
225-
Binary blah = (Binary)(out.get( "a" ) );
226-
assertEquals( "eliot" , new String( blah.getData() ) );
226+
// Binary blah = (Binary)(out.get( "a" ) );
227+
byte[] bytes = (byte[]) out.get("a");
228+
assertEquals( "eliot" , new String( bytes ) );
227229

228230
out.put( "a" , new Binary( (byte)111 , raw ) );
229231
c.save( out );
230-
blah = (Binary)c.findOne().get( "a" );
232+
Binary blah = (Binary)c.findOne().get( "a" );
231233
assertEquals( 111 , blah.getType() );
232234
assertEquals( Util.toHex( raw ) , Util.toHex( blah.getData() ) );
233235
}

0 commit comments

Comments
 (0)