@Test
  public void testContextSpecificServletFilterWhenInitThrowsException() throws Exception {
    Configuration conf = new Configuration();
    HttpServer http = createTestServer(conf);
    HttpServer.defineFilter(http.webAppContext, "ErrorFilter", ErrorFilter.class.getName(), null,
      null);
    try {
      http.start();
      fail("expecting exception");
    } catch (IOException e) {
      assertExceptionContains("Unable to initialize WebAppContext", e);
    }
  }
Similar to the above test case, except that it uses a different API to add the filter.
Regression test for HADOOP-8786.
hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestServletFilter.java