예제 #1
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());
 }
예제 #2
0
 /** {@inheritDoc} */
 @Override
 public String toString() {
   BSONEncoder enc = new BSONEncoder();
   BasicOutputBuffer buf = new BasicOutputBuffer();
   enc.set(buf);
   enc.putObject(_doc);
   enc.done();
   String str = buf.asString();
   log.debug("Output As String: '" + str + "'");
   return str;
 }
예제 #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());
  }