Skip to content

Commit

Permalink
Fixed tests for binary encoding and capped collection
Browse files Browse the repository at this point in the history
  • Loading branch information
agirbal committed Jun 8, 2011
1 parent 18eaaf3 commit 705029d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/test/com/mongodb/DBTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ public void testCreateCollection() {
DBCollection c = _db.createCollection("foo1", o1);

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

DBObject o3 = BasicDBObjectBuilder.start().add("capped", true)
.add("size", 1000).add("max", 2).get();
Expand Down
10 changes: 6 additions & 4 deletions src/test/com/mongodb/JavaClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,16 @@ public void testBinaryOld()
bb.put( "eliot".getBytes() );
out.put( "a" , new Binary( BSON.B_BINARY , "eliot".getBytes() ) );
c.save( out );


// objects of subtype B_BINARY or B_GENERAL should becomes byte[]
out = c.findOne();
Binary blah = (Binary)(out.get( "a" ) );
assertEquals( "eliot" , new String( blah.getData() ) );
// Binary blah = (Binary)(out.get( "a" ) );
byte[] bytes = (byte[]) out.get("a");
assertEquals( "eliot" , new String( bytes ) );

out.put( "a" , new Binary( (byte)111 , raw ) );
c.save( out );
blah = (Binary)c.findOne().get( "a" );
Binary blah = (Binary)c.findOne().get( "a" );
assertEquals( 111 , blah.getType() );
assertEquals( Util.toHex( raw ) , Util.toHex( blah.getData() ) );
}
Expand Down

0 comments on commit 705029d

Please sign in to comment.