@Override
  public void start() {
    if (realm != null) {
      try {
        LOG.info("Security realm: {}", realm.getName());
        realm.init();
        LOG.info("Security realm started");
      } catch (RuntimeException e) {
        if (ignoreStartupFailure) {
          LOG.error("IGNORED - Security realm fails to start: {}", e.getMessage());
        } else {
          throw new SonarException("Security realm fails to start: " + e.getMessage(), e);
        }
      }
    }
  }
@Test
  public void should_fail() {
    SecurityRealm realm = spy(new AlwaysFailsRealm());
    settings.setProperty("sonar.security.realm", realm.getName());

    try {
      new SecurityRealmFactory(settings.asConfig(), new SecurityRealm[] {realm}).start();
      fail();
    } catch (SonarException e) {
      assertThat(e.getCause()).isInstanceOf(IllegalStateException.class);
      assertThat(e.getMessage()).contains("Security realm fails to start");
    }
  }