@Test
public void testBadECPolicy() 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>-1025</cellsize>");
  out.println("  </policy>");
  out.println("</policies>");
  out.println("</configuration>");
  out.close();
  ECPolicyLoader ecPolicyLoader = new ECPolicyLoader();
  try {
    ecPolicyLoader.loadPolicy(POLICY_FILE);
    fail("RuntimeException should be thrown for bad policy");
  } catch (RuntimeException e) {
    assertExceptionContains("Bad policy is found in EC policy"
        + " configuration file", e);
  }
}