Search in sources :

Example 36 with BsonBinaryReader

use of org.bson.BsonBinaryReader in project disq by intelie.

the class DsonToBsonConverterTest method assertConversion.

private void assertConversion(Object input, Map<Object, Object> expected, byte[] control) {
    Buffer in = new Buffer();
    Buffer out = new Buffer();
    DsonSerializer.Instance dson = new DsonSerializer().create();
    dson.serialize(in, input);
    DsonToBsonConverter converter = new DsonToBsonConverter();
    converter.convert(in.read(), out.write());
    if (control != null)
        assertThat(out.toArray()).isEqualTo(control);
    Map decoded = codec.decode(new BsonBinaryReader(ByteBuffer.wrap(out.buf(), 0, out.count())), DecoderContext.builder().build());
    assertThat(decoded).isEqualTo(expected);
}
Also used : BasicOutputBuffer(org.bson.io.BasicOutputBuffer) ByteBuffer(java.nio.ByteBuffer) Buffer(net.intelie.disq.Buffer) BsonBinaryReader(org.bson.BsonBinaryReader) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Aggregations

BsonBinaryReader (org.bson.BsonBinaryReader)36 ByteBufferBsonInput (org.bson.io.ByteBufferBsonInput)17 BasicOutputBuffer (org.bson.io.BasicOutputBuffer)14 BsonBinaryWriter (org.bson.BsonBinaryWriter)12 Document (org.bson.Document)9 BsonDocumentCodec (org.bson.codecs.BsonDocumentCodec)8 BsonWriter (org.bson.BsonWriter)7 ByteBuf (org.bson.ByteBuf)6 Test (org.junit.Test)6 IOContext (com.fasterxml.jackson.core.io.IOContext)5 BufferRecycler (com.fasterxml.jackson.core.util.BufferRecycler)5 BsonInput (org.bson.io.BsonInput)5 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)4 BsonDocument (org.bson.BsonDocument)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 MongoClientException (com.mongodb.MongoClientException)2 SingleResultCallback (com.mongodb.internal.async.SingleResultCallback)2 SplittablePayloadBsonWriter (com.mongodb.internal.connection.SplittablePayloadBsonWriter)2 List (java.util.List)2 Map (java.util.Map)2