### Question:
AvroDeepCopier implements Serializable { public T deepCopy(T source) { ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream(); binaryEncoder = EncoderFactory.get().binaryEncoder(byteOutStream, binaryEncoder); T target = createCopyTarget(); try { datumWriter.write(source, binaryEncoder); binaryEncoder.flush(); binaryDecoder = DecoderFactory.get() .binaryDecoder(byteOutStream.toByteArray(), binaryDecoder); datumReader.read(target, binaryDecoder); } catch (Exception e) { throw new CrunchRuntimeException("Error while deep copying avro value " + source, e); } return target; } protected  AvroDeepCopier(DatumWriter<T> datumWriter, DatumReader<T> datumReader); T deepCopy(T source);  }### Answer:
@Test public void testDeepCopySpecific() { Person person = new Person(); person.setName("John Doe"); person.setAge(42); person.setSiblingnames(Lists.<CharSequence> newArrayList()); Person deepCopyPerson = new AvroSpecificDeepCopier<Person>(Person.class, Person.SCHEMA$) .deepCopy(person); assertEquals(person, deepCopyPerson); assertNotSame(person, deepCopyPerson); }
@Test public void testDeepCopyGeneric() { Record record = new Record(Person.SCHEMA$); record.put("name", "John Doe"); record.put("age", 42); record.put("siblingnames", Lists.newArrayList()); Record deepCopyRecord = new AvroDeepCopier.AvroGenericDeepCopier(Person.SCHEMA$) .deepCopy(record); assertEquals(record, deepCopyRecord); assertNotSame(record, deepCopyRecord); }
@Test public void testDeepCopyReflect() { Person person = new Person(); person.setName("John Doe"); person.setAge(42); person.setSiblingnames(Lists.<CharSequence> newArrayList()); Person deepCopyPerson = new AvroDeepCopier.AvroReflectDeepCopier<Person>(Person.class, Person.SCHEMA$).deepCopy(person); assertEquals(person, deepCopyPerson); assertNotSame(person, deepCopyPerson); }