@Test
  @SuppressWarnings("unchecked")
  public void testWriteJson() throws Exception {
    StringWriter sw = new StringWriter();
    ConfServlet.writeResponse(getTestConf(), sw, "json");
    String json = sw.toString();
    boolean foundSetting = false;
    Set<String> programSet = new HashSet<>();
    programSet.add("programatically");
    programSet.add("programmatically");
    Object parsed = JSON.parse(json);
    Object[] properties = ((Map<String, Object[]>) parsed).get("properties");
    for (Object o : properties) {
      Map<String, Object> propertyInfo = (Map<String, Object>) o;
      String key = (String) propertyInfo.get("key");
      String val = (String) propertyInfo.get("value");
      String resource = (String) propertyInfo.get("resource");
      System.err.println("k: " + key + " v: " + val + " r: " + resource);
      if (TEST_KEY.equals(key) && TEST_VAL.equals(val) && programSet.contains(resource)) {
        foundSetting = true;
      }
    }
    assertTrue(foundSetting);
  }
Basic test case that the ConfServlet can write configuration to its output in XML and JSON
format.
hbase-http/src/test/java/org/apache/hadoop/hbase/http/conf/TestConfServlet.java