@Test
public void testLoadECPolicy() throws Exception {

  PrintWriter out = new PrintWriter(new FileWriter(POLICY_FILE));
  out.println("<?xml version=\"1.0\"?>");
  out.println("<configuration>");
  out.println("<layoutversion>1</layoutversion>");
  out.println("<schemas>");
  out.println("  <schema id=\"RSk12m4\">");
  out.println("    <codec>rs</codec>");
  out.println("    <k>12</k>");
  out.println("    <m>4</m>");
  out.println("  </schema>");
  out.println("  <schema id=\"RS-legacyk12m4\">");
  out.println("    <codec>rs-legacy</codec>");
  out.println("    <k>12</k>");
  out.println("    <m>4</m>");
  out.println("  </schema>");
  out.println("</schemas>");
  out.println("<policies>");
  out.println("  <policy>");
  out.println("    <schema>RSk12m4</schema>");
  out.println("    <cellsize>131072</cellsize>");
  out.println("  </policy>");
  out.println("  <policy>");
  out.println("    <schema>RS-legacyk12m4</schema>");
  out.println("    <cellsize>262144</cellsize>");
  out.println("  </policy>");
  out.println("</policies>");
  out.println("</configuration>");
  out.close();
  ECPolicyLoader ecPolicyLoader = new ECPolicyLoader();
  List<ErasureCodingPolicy> policies
      = ecPolicyLoader.loadPolicy(POLICY_FILE);
  assertEquals(2, policies.size());
  ErasureCodingPolicy policy1 = policies.get(0);
  ECSchema schema1 = policy1.getSchema();
  assertEquals(131072, policy1.getCellSize());
  assertEquals(0, schema1.getExtraOptions().size());
  assertEquals(12, schema1.getNumDataUnits());
  assertEquals(4, schema1.getNumParityUnits());
  assertEquals("rs", schema1.getCodecName());
  ErasureCodingPolicy policy2 = policies.get(1);
  ECSchema schema2 = policy2.getSchema();
  assertEquals(262144, policy2.getCellSize());
  assertEquals(0, schema2.getExtraOptions().size());
  assertEquals(12, schema2.getNumDataUnits());
  assertEquals(4, schema2.getNumParityUnits());
  assertEquals("rs-legacy", schema2.getCodecName());
}