@Test
@TestDir
@TestJetty
@TestHdfs
public void testECPolicy() throws Exception {

  createHttpFSServer(false, false);
  final ErasureCodingPolicy ecPolicy = SystemErasureCodingPolicies
      .getByID(SystemErasureCodingPolicies.RS_3_2_POLICY_ID);
  final String ecPolicyName = ecPolicy.getName();
  // Create an EC dir and write a test file in it
  final Path ecDir = new Path("/ec");
  DistributedFileSystem dfs = (DistributedFileSystem) FileSystem
      .get(ecDir.toUri(), TestHdfsHelper.getHdfsConf());
  Path ecFile = new Path(ecDir, "ec_file.txt");
  dfs.mkdirs(ecDir);
  dfs.enableErasureCodingPolicy(ecPolicyName);
  dfs.setErasureCodingPolicy(ecDir, ecPolicyName);
  // Create a EC file
  DFSTestUtil.createFile(dfs, ecFile, 1024, (short) 1, 0);
  // Verify that ecPolicy is set in getFileStatus response for ecFile
  String getFileStatusResponse =
      getStatus(ecFile.toString(), "GETFILESTATUS");
  JSONParser parser = new JSONParser();
  JSONObject jsonObject = (JSONObject) parser.parse(getFileStatusResponse);
  JSONObject details = (JSONObject) jsonObject.get("FileStatus");
  String ecpolicyForECfile = (String) details.get("ecPolicy");
  assertEquals("EC policy for ecFile should match the set EC policy",
      ecpolicyForECfile, ecPolicyName);
  // Verify httpFs getFileStatus with WEBHDFS REST API
  WebHdfsFileSystem httpfsWebHdfs = (WebHdfsFileSystem) FileSystem.get(
      new URI("webhdfs://"
          + TestJettyHelper.getJettyURL().toURI().getAuthority()),
      TestHdfsHelper.getHdfsConf());
  HdfsFileStatus httpfsFileStatus =
      (HdfsFileStatus) httpfsWebHdfs.getFileStatus(ecFile);
  assertNotNull(httpfsFileStatus.getErasureCodingPolicy());
}