示例#1
0
 public byte[] encode(BSONObject o) {
   BasicOutputBuffer buf = new BasicOutputBuffer();
   set(buf);
   putObject(o);
   done();
   return buf.toByteArray();
 }
示例#2
0
 @Test
 public void testOBBig1() {
   BasicOutputBuffer a = new BasicOutputBuffer();
   StringBuilder b = new StringBuilder();
   for (String x : _data) {
     a.write(x.getBytes());
     b.append(x);
   }
   assertEquals(a.asString(), b.toString());
 }
示例#3
0
  @Test
  public void testOB1() {
    BasicOutputBuffer buf = new BasicOutputBuffer();
    buf.write("eliot".getBytes());
    assertEquals(5, buf.getPosition());
    assertEquals(5, buf.size());

    assertEquals("eliot", buf.asString());

    buf.setPosition(2);
    buf.write("z".getBytes());
    assertEquals("elzot", buf.asString());

    buf.seekEnd();
    buf.write("foo".getBytes());
    assertEquals("elzotfoo", buf.asString());

    buf.seekStart();
    buf.write("bar".getBytes());
    assertEquals("barotfoo", buf.asString());
  }