@Override
  public void setSchema(Schema actual) {
    // if expected is unset and actual is a specific record,
    // then default expected to schema of currently loaded class
    if (getExpected() == null && actual != null && actual.getType() == Schema.Type.RECORD) {
      SpecificData data = getSpecificData();
      Class c = data.getClass(actual);
      if (c != null && SpecificRecord.class.isAssignableFrom(c))
        setExpected(data.getSchema(c));
    }
    super.setSchema(actual);
  }
@Test
  void readMyData() throws IOException {
    // Check that method newInstanceFromString from SpecificDatumReader extension is
    // called.
    final EncoderFactory e_factory = new EncoderFactory().configureBufferSize(30);
    final DecoderFactory factory = new DecoderFactory().configureDecoderBufferSize(30);

    final MyReader reader = new MyReader();
    reader.setExpected(Schema.create(Schema.Type.STRING));
    reader.setSchema(Schema.create(Schema.Type.STRING));

    final ByteArrayOutputStream out = new ByteArrayOutputStream(30);
    final BinaryEncoder encoder = e_factory.binaryEncoder(out, null);
    encoder.writeString(new Utf8("Hello"));
    encoder.flush();

    final BinaryDecoder decoder = factory.binaryDecoder(out.toByteArray(), null);
    reader.getData().setFastReaderEnabled(false);
    final MyData read = reader.read(null, decoder);
    Assertions.assertNotNull(read, "MyReader.newInstanceFromString was not called");
    Assertions.assertEquals("Hello", read.getContent());
  }