### Question:
AvroKeyRecordWriter extends RecordWriter<AvroKey<T>, NullWritable> implements Syncable { @Override public void write(AvroKey<T> record, NullWritable ignore) throws IOException { mAvroFileWriter.append(record.datum()); } AvroKeyRecordWriter(Schema writerSchema, GenericData dataModel, CodecFactory compressionCodec,
      OutputStream outputStream, int syncInterval);  AvroKeyRecordWriter(Schema writerSchema, GenericData dataModel, CodecFactory compressionCodec,
      OutputStream outputStream); @Override void write(AvroKey<T> record, NullWritable ignore); @Override void close(TaskAttemptContext context); @Override long sync();  }### Answer:
@Test public void testWrite() throws IOException { Schema writerSchema = Schema.create(Schema.Type.INT); GenericData dataModel = new ReflectData(); CodecFactory compressionCodec = CodecFactory.nullCodec(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); TaskAttemptContext context = createMock(TaskAttemptContext.class); replay(context); AvroKeyRecordWriter<Integer> recordWriter = new AvroKeyRecordWriter<>(writerSchema, dataModel, compressionCodec, outputStream); recordWriter.write(new AvroKey<>(1), NullWritable.get()); recordWriter.write(new AvroKey<>(2), NullWritable.get()); recordWriter.close(context); verify(context); InputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray()); Schema readerSchema = Schema.create(Schema.Type.INT); DatumReader<Integer> datumReader = new SpecificDatumReader<>(readerSchema); DataFileStream<Integer> dataFileReader = new DataFileStream<>(inputStream, datumReader); assertTrue(dataFileReader.hasNext()); assertEquals(1, dataFileReader.next().intValue()); assertTrue(dataFileReader.hasNext()); assertEquals(2, dataFileReader.next().intValue()); assertFalse(dataFileReader.hasNext()); dataFileReader.close(); }