@Test
  public void canSerializeNullableRecords() throws SerDeException, IOException {
    String field = "{ \"name\":\"nullableStruct\", \"type\": [\"null\", {\"type\":\"record\", " +
            "\"name\":\"struct1_name\", \"fields\": [\n" +
              "{ \"name\":\"sInt\", \"type\":\"int\" }, " +
              "{ \"name\":\"sBoolean\", \"type\":\"boolean\" }, " +
              "{ \"name\":\"sString\", \"type\":\"string\" } ] }] }";

    Schema s = buildSchema(field);
    Schema nullable = s.getField("nullableStruct").schema();
    assertTrue(AvroSerdeUtils.isNullableType(nullable));
    GenericData.Record innerRecord =
            new GenericData.Record(AvroSerdeUtils.getOtherTypeFromNullableType(nullable));

    innerRecord.put("sInt", 77);
    innerRecord.put("sBoolean", false);
    innerRecord.put("sString", "tedious");

    GenericRecord r = serializeAndDeserialize(field, "nullableStruct", innerRecord);
    Object result = r.get("nullableStruct");
    assertNotSame(innerRecord, result);
    assertEquals(innerRecord, result);

    r = serializeAndDeserialize(field, "nullableStruct", null);
    assertNull(r.get("nullableStruct"));
  }
Verify that we can serialize an avro value by taking one, running it through
the deser process and then serialize it again.
serde/src/test/org/apache/hadoop/hive/serde2/avro/TestAvroSerializer.java