use of org.bson.BsonBinary in project mongo-java-driver by mongodb.
the class JsonReaderTest method testLegacyBinaryWithNumericType.
@Test
public void testLegacyBinaryWithNumericType() {
String json = "{ \"$binary\" : \"AQID\", \"$type\" : 0 }";
testStringAndStream(json, bsonReader -> {
assertEquals(BsonType.BINARY, bsonReader.readBsonType());
BsonBinary binary = bsonReader.readBinaryData();
assertEquals(BsonBinarySubType.BINARY.getValue(), binary.getType());
assertArrayEquals(new byte[] { 1, 2, 3 }, binary.getData());
assertEquals(AbstractBsonReader.State.DONE, bsonReader.getState());
return null;
});
}
use of org.bson.BsonBinary in project mongo-java-driver by mongodb.
the class JsonReaderTest method testCanonicalExtendedJsonBinary.
@Test
public void testCanonicalExtendedJsonBinary() {
String json = "{ \"$binary\" : { \"base64\" : \"AQID\", \"subType\" : \"80\" } }";
testStringAndStream(json, bsonReader -> {
assertEquals(BsonType.BINARY, bsonReader.readBsonType());
BsonBinary binary = bsonReader.readBinaryData();
assertEquals(BsonBinarySubType.USER_DEFINED.getValue(), binary.getType());
assertArrayEquals(new byte[] { 1, 2, 3 }, binary.getData());
assertEquals(AbstractBsonReader.State.DONE, bsonReader.getState());
return null;
});
}
use of org.bson.BsonBinary in project mongo-java-driver by mongodb.
the class JsonReaderTest method testLegacyUserDefinedBinary.
@Test
public void testLegacyUserDefinedBinary() {
String json = "{ \"$binary\" : \"AQID\", \"$type\" : \"80\" }";
testStringAndStream(json, bsonReader -> {
assertEquals(BsonType.BINARY, bsonReader.readBsonType());
BsonBinary binary = bsonReader.readBinaryData();
assertEquals(BsonBinarySubType.USER_DEFINED.getValue(), binary.getType());
assertArrayEquals(new byte[] { 1, 2, 3 }, binary.getData());
assertEquals(AbstractBsonReader.State.DONE, bsonReader.getState());
return null;
});
}
use of org.bson.BsonBinary in project mongo-java-driver by mongodb.
the class JsonReaderTest method testHexData.
@Test
public void testHexData() {
final byte[] expectedBytes = new byte[] { 0x01, 0x23 };
String json = "HexData(0, \"0123\")";
testStringAndStream(json, bsonReader -> {
assertEquals(BsonType.BINARY, bsonReader.readBsonType());
BsonBinary binary = bsonReader.readBinaryData();
assertArrayEquals(expectedBytes, binary.getData());
assertEquals(AbstractBsonReader.State.DONE, bsonReader.getState());
return null;
});
}
use of org.bson.BsonBinary in project mongo-java-driver by mongodb.
the class JsonReaderTest method testHexDataWithNew.
@Test
public void testHexDataWithNew() {
final byte[] expectedBytes = new byte[] { 0x01, 0x23 };
String json = "new HexData(0, \"0123\")";
testStringAndStream(json, bsonReader -> {
assertEquals(BsonType.BINARY, bsonReader.readBsonType());
BsonBinary binary = bsonReader.readBinaryData();
assertArrayEquals(expectedBytes, binary.getData());
assertEquals(AbstractBsonReader.State.DONE, bsonReader.getState());
return null;
});
}
Aggregations