use of org.bson.io.OutputBuffer in project mongo-java-driver by mongodb.
the class CodecTestCase method roundTripWithRegistry.
@SuppressWarnings("unchecked")
<T> void roundTripWithRegistry(final T value, final Comparator<T> comparator, final CodecRegistry codecRegistry) {
Codec<T> codec = (Codec<T>) codecRegistry.get(value.getClass());
OutputBuffer encoded = encode(codec, value);
T decoded = decode(codec, encoded);
comparator.apply(decoded);
}
use of org.bson.io.OutputBuffer in project mongo-java-driver by mongodb.
the class LazyDBEncoderTest method testEncodingObject.
@Test
public void testEncodingObject() {
byte[] bytes = new byte[] { 12, 0, 0, 0, 16, 97, 0, 1, 0, 0, 0, 0 };
DBObject document = new LazyDBObject(bytes, new LazyDBCallback(null));
OutputBuffer buffer = new BasicOutputBuffer();
new LazyDBEncoder().writeObject(buffer, document);
assertArrayEquals(bytes, buffer.toByteArray());
}
Aggregations