@Test
public void testGetBagSubSchemaConfigured() throws Exception {

  // NOTE: pig-0.8 sets client system properties by actually getting the client
  // system properties. Starting in pig-0.9 you must pass the properties in.
  // When updating our pig dependency this will need updated.
  System.setProperty(HCatConstants.HCAT_PIG_INNER_TUPLE_NAME, "t");
  System.setProperty(HCatConstants.HCAT_PIG_INNER_FIELD_NAME, "FIELDNAME_tuple");
  UDFContext.getUDFContext().setClientSystemProps(System.getProperties());
  // Define the expected schema.
  ResourceFieldSchema[] bagSubFieldSchemas = new ResourceFieldSchema[1];
  bagSubFieldSchemas[0] = new ResourceFieldSchema().setName("t")
    .setDescription("The tuple in the bag").setType(DataType.TUPLE);
  ResourceFieldSchema[] innerTupleFieldSchemas = new ResourceFieldSchema[1];
  innerTupleFieldSchemas[0] =
    new ResourceFieldSchema().setName("llama_tuple").setType(DataType.CHARARRAY);
  bagSubFieldSchemas[0].setSchema(new ResourceSchema().setFields(innerTupleFieldSchemas));
  ResourceSchema expected = new ResourceSchema().setFields(bagSubFieldSchemas);
  // Get the actual converted schema.
  HCatSchema actualHCatSchema = new HCatSchema(Lists.newArrayList(
    new HCatFieldSchema("innerLlama", HCatFieldSchema.Type.STRING, null)));
  HCatFieldSchema actualHCatFieldSchema =
    new HCatFieldSchema("llama", HCatFieldSchema.Type.ARRAY, actualHCatSchema, null);
  ResourceSchema actual = PigHCatUtil.getBagSubSchema(actualHCatFieldSchema);
  Assert.assertEquals(expected.toString(), actual.toString());
  // Clean up System properties that were set by this test
  System.clearProperty(HCatConstants.HCAT_PIG_INNER_TUPLE_NAME);
  System.clearProperty(HCatConstants.HCAT_PIG_INNER_FIELD_NAME);
}