int numberOfRuns,
final boolean getValue,
final boolean introspectStringValues ) throws Exception {
assert testData != null;
// Read the JSON into in-memory ...
Document doc = new JsonReader().read(testData, introspectStringValues);
// Write the in-memory out to BSON ...
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
new BsonWriter().write(doc, bytes);
final byte[] bsonBytes = bytes.toByteArray();
final BsonReader bsonReader = new BsonReader();
final AtomicReference<Exception> error = new AtomicReference<Exception>();
final String key = "key";
runTest("BsonReader.read(InputStream)", numberOfRuns, testData.length(), print, new Runnable() {
@Override
public void run() {
try {
ByteArrayInputStream input = new ByteArrayInputStream(bsonBytes);
Document doc = bsonReader.read(input);
doc.get(key);
} catch (Exception t) {
error.compareAndSet(null, t);
}
}
});