*
* @return true if SpecificData can be properly read using a
* ReflectDatumReader
*/
static boolean canDecodeSpecificSchemaWithReflectDatumReader() {
ReflectDatumReader<Record> datumReader = new ReflectDatumReader(Record.SCHEMA$);
ReflectDatumWriter<Record> datumWriter = new ReflectDatumWriter(Record.SCHEMA$);
Record record = new Record();
record.subrecords = Lists.<CharSequence> newArrayList("a", "b");
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
BinaryEncoder encoder = EncoderFactory.get().binaryEncoder(byteArrayOutputStream, null);
try {
datumWriter.write(record, encoder);
encoder.flush();
BinaryDecoder decoder = DecoderFactory.get().binaryDecoder(
byteArrayOutputStream.toByteArray(), null);
datumReader.read(record, decoder);
} catch (IOException ioe) {
throw new RuntimeException("Error performing specific schema test", ioe);
} catch (ClassCastException cce) {
// This indicates that we're using a pre-1.7.0 version of Avro, as the
// ReflectDatumReader in those versions could not correctly handle an