@VisibleForTesting
  int formatSchedulerConf(String webAppAddress, WebResource resource)
      throws Exception {
    ClientResponse response = null;
    resource = (resource != null) ? resource :
        initializeWebResource(webAppAddress);
    try {
      Builder builder;
      if (UserGroupInformation.isSecurityEnabled()) {
        builder = resource
            .path("ws").path("v1").path("cluster")
            .path("/scheduler-conf/format")
            .accept(MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON);
      } else {
        builder = resource
            .path("ws").path("v1").path("cluster")
            .path("/scheduler-conf/format").queryParam("user.name",
            UserGroupInformation.getCurrentUser().getShortUserName())
            .accept(MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON);
      }

      response = builder.get(ClientResponse.class);
      if (response != null) {
        if (response.getStatus() == Status.OK.getStatusCode()) {
          System.out.println(response.getEntity(String.class));
          return 0;
        } else {
          System.err.println("Failed to format scheduler configuration: " +
              response.getEntity(String.class));
        }
      } else {
        System.err.println("Failed to format scheduler configuration: " +
            "null response");
      }
      return -1;
    } finally {
      if (response != null) {
        response.close();
      }
      destroyClient();
    }
  }
@Test(timeout = 10000)
  public void testFormatSchedulerConf() throws Exception {
    try {
      super.setUp();
      GuiceServletConfig.setInjector(
          Guice.createInjector(new WebServletModule()));
      ResourceScheduler scheduler = rm.getResourceScheduler();
      MutableConfigurationProvider provider =
          ((MutableConfScheduler) scheduler).getMutableConfProvider();

      SchedConfUpdateInfo schedUpdateInfo = new SchedConfUpdateInfo();
      HashMap<String, String> globalUpdates = new HashMap<>();
      globalUpdates.put("schedKey1", "schedVal1");
      schedUpdateInfo.setGlobalParams(globalUpdates);

      LogMutation log = provider.logAndApplyMutation(
          UserGroupInformation.getCurrentUser(), schedUpdateInfo);
      rm.getRMContext().getRMAdminService().refreshQueues();
      provider.confirmPendingMutation(log, true);

      Configuration schedulerConf = provider.getConfiguration();
      assertEquals("schedVal1", schedulerConf.get("schedKey1"));

      int exitCode = cli.formatSchedulerConf("", resource());
      assertEquals(0, exitCode);

      schedulerConf = provider.getConfiguration();
      assertNull(schedulerConf.get("schedKey1"));
    } finally {
      cleanUp();
    }
  }