use of org.bson.json.JsonReader in project mongo-java-driver by mongodb.
the class StringCodecTest method testDecodeOnStringWithObjectIdRep.
@Test(expected = BsonInvalidOperationException.class)
public void testDecodeOnStringWithObjectIdRep() {
BsonReader reader = new JsonReader("{'name': 'Brian'");
reader.readStartDocument();
reader.readName();
child.decode(reader, decoderContext);
}
use of org.bson.json.JsonReader in project mongo-java-driver by mongodb.
the class StringCodecTest method testDecodeOnObjectIdWithStringRep.
@Test(expected = BsonInvalidOperationException.class)
public void testDecodeOnObjectIdWithStringRep() {
BsonReader reader = new JsonReader("{'_id': ObjectId('5f5a6cc03237b5e06d6b887b'), 'name': 'Brian'}");
reader.readStartDocument();
reader.readName();
parent.decode(reader, decoderContext);
}
use of org.bson.json.JsonReader in project mongo-java-driver by mongodb.
the class AbstractInsertBenchmark method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
MongoDatabase database = client.getDatabase(DATABASE_NAME);
collection = database.getCollection(COLLECTION_NAME, clazz);
database.drop();
bytes = readAllBytesFromRelativePath(resourcePath);
fileLength = bytes.length;
Codec<T> codec = collection.getCodecRegistry().get(clazz);
document = codec.decode(new JsonReader(new String(bytes, StandardCharsets.UTF_8)), DecoderContext.builder().build());
}
Aggregations