@Test(timeout = 50000)
public void testFilterOverrides() throws Exception {

  String filterInitializerConfKey = "hadoop.http.filter.initializers";
  String[] filterInitializers =
      {
          AuthenticationFilterInitializer.class.getName(),
          RMAuthenticationFilterInitializer.class.getName(),
          AuthenticationFilterInitializer.class.getName() + ","
              + RMAuthenticationFilterInitializer.class.getName(),
          AuthenticationFilterInitializer.class.getName() + ", "
              + RMAuthenticationFilterInitializer.class.getName(),
          AuthenticationFilterInitializer.class.getName() + ", "
              + this.getClass().getName() };
  for (String filterInitializer : filterInitializers) {
    resourceManager = new ResourceManager() {
      @Override
      protected void doSecureLogin() throws IOException {
        // Skip the login.
      }
    };
    Configuration conf = new YarnConfiguration();
    conf.set(filterInitializerConfKey, filterInitializer);
    conf.set("hadoop.security.authentication", "kerberos");
    conf.set("hadoop.http.authentication.type", "kerberos");
    try {
      try {
        UserGroupInformation.setConfiguration(conf);
      } catch (Exception e) {
        // ignore we just care about getting true for
        // isSecurityEnabled()
        LOG.info("Got expected exception");
      }
      resourceManager.init(conf);
      resourceManager.startWepApp();
    } catch (RuntimeException e) {
      // Exceptions are expected because we didn't setup everything
      // just want to test filter settings
      String tmp = resourceManager.getConfig().get(filterInitializerConfKey);
      if (filterInitializer.contains(this.getClass().getName())) {
        Assert.assertEquals(RMAuthenticationFilterInitializer.class.getName()
            + "," + this.getClass().getName(), tmp);
      } else {
        Assert.assertEquals(
          RMAuthenticationFilterInitializer.class.getName(), tmp);
      }
      resourceManager.stop();
    }
  }
  // simple mode overrides
  String[] simpleFilterInitializers =
      { "", StaticUserWebFilter.class.getName() };
  for (String filterInitializer : simpleFilterInitializers) {
    resourceManager = new ResourceManager();
    Configuration conf = new YarnConfiguration();
    conf.set(filterInitializerConfKey, filterInitializer);
    try {
      UserGroupInformation.setConfiguration(conf);
      resourceManager.init(conf);
      resourceManager.startWepApp();
    } catch (RuntimeException e) {
      // Exceptions are expected because we didn't setup everything
      // just want to test filter settings
      String tmp = resourceManager.getConfig().get(filterInitializerConfKey);
      if (filterInitializer.equals(StaticUserWebFilter.class.getName())) {
        Assert.assertEquals(RMAuthenticationFilterInitializer.class.getName()
            + "," + StaticUserWebFilter.class.getName(), tmp);
      } else {
        Assert.assertEquals(
          RMAuthenticationFilterInitializer.class.getName(), tmp);
      }
      resourceManager.stop();
    }
  }
}