Ejemplo n.º 1
0
  void _test(BSONObject o, int size, String hash) throws IOException {
    BSONEncoder e = new BSONEncoder();
    OutputBuffer buf = new BasicOutputBuffer();
    e.set(buf);
    e.putObject(o);
    assertEquals(size, buf.size());
    assertEquals(hash, buf.md5());
    e.done();

    BSONDecoder d = new BSONDecoder();
    BasicBSONCallback cb = new BasicBSONCallback();
    int s = d.decode(new ByteArrayInputStream(buf.toByteArray()), cb);
    assertEquals(size, s);

    OutputBuffer buf2 = new BasicOutputBuffer();
    e.set(buf2);
    e.putObject((BSONObject) cb.get());
    assertEquals(size, buf2.size());
    assertEquals(hash, buf2.md5());
  }
 public void objectStart(boolean array, String name) {
   _lastArray = array;
   super.objectStart(array, name);
 }