Skip to content

Commit

Permalink
added test to make sure all types are correctly encoded with BSON to/…
Browse files Browse the repository at this point in the history
…from db
  • Loading branch information
agirbal committed Mar 29, 2011
1 parent 018caec commit 815ca33
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/test/com/mongodb/JavaClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,17 @@ public void testBadKey(){
c.update(new BasicDBObject("a", 1), new BasicDBObject("$set", new BasicDBObject("a.b", 1)));
}

@Test
public void testAllTypes(){
DBCollection c = _db.getCollectionFromString( "foo" );
c.drop();
String json = "{ 'str' : 'asdfasd' , 'long' : 5 , 'float' : 0.4 , 'bool' : false , 'date' : { '$date' : '2011-05-18T18:56:00Z'} , 'pat' : { '$regex' : '.*' , '$options' : ''} , 'oid' : { '$oid' : '4d83ab3ea39562db9c1ae2ae'} , 'ref' : { '$ref' : 'test.test' , '$id' : { '$oid' : '4d83ab59a39562db9c1ae2af'}} , 'code' : { '$code' : 'asdfdsa'} , 'codews' : { '$code' : 'ggggg' , '$scope' : { }} , 'ts' : { '$ts' : 1300474885 , '$inc' : 10} , 'null' : null }";
BasicDBObject a = (BasicDBObject) JSON.parse(json);
c.insert(a);
DBObject b = c.findOne();
assertTrue(a.equals(b));
}

final Mongo _mongo;
final DB _db;

Expand Down

0 comments on commit 815ca33

Please sign in to comment.