WebappAuthenticatorFrameworkServiceComponent { @SuppressWarnings("unused") protected void activate(ComponentContext componentContext) { if (log.isDebugEnabled()) { log.debug("Starting Web Application Authenticator Framework Bundle"); } try { WebappAuthenticatorConfig.init(); WebappAuthenticatorRepository repository = new WebappAuthenticatorRepository(); for (AuthenticatorConfig config : WebappAuthenticatorConfig.getInstance().getAuthenticators()) { WebappAuthenticator authenticator = (WebappAuthenticator) Class.forName(config.getClassName()).newInstance(); if ((config.getParams() != null) && (!config.getParams().isEmpty())) { Properties properties = new Properties(); for (AuthenticatorConfig.Parameter param : config.getParams()) { properties.setProperty(param.getName(), param.getValue()); } authenticator.setProperties(properties); } authenticator.init(); repository.addAuthenticator(authenticator); } BundleContext bundleContext = componentContext.getBundleContext(); AuthenticatorConfigService authenticatorConfigService = new AuthenticatorConfigServiceImpl(); bundleContext.registerService(AuthenticatorConfigService.class.getName(), authenticatorConfigService, null); AuthenticatorFrameworkDataHolder.getInstance().setWebappAuthenticatorRepository(repository); List<CarbonTomcatValve> valves = new ArrayList<CarbonTomcatValve>(); valves.add(new WebappAuthenticationValve()); TomcatValveContainer.addValves(valves); if (log.isDebugEnabled()) { log.debug("Web Application Authenticator Framework Bundle has been started successfully"); } } catch (Throwable e) { log.error("Error occurred while initializing the bundle", e); } }    }
@Test(description = "This method tests whether the bundle activator does not throw any exceptions, even under " + "possible exception scenarios") public void testActivateWithException() { WebappAuthenticatorFrameworkServiceComponent webappAuthenticatorFrameworkServiceComponent = new WebappAuthenticatorFrameworkServiceComponent(); webappAuthenticatorFrameworkServiceComponent.activate(null); }
@Test(description = "This method tests whether bundle activation succeed with the proper confitions.") public void testActivateWithoutExceptions() { WebappAuthenticatorFrameworkServiceComponent webappAuthenticatorFrameworkServiceComponent = new WebappAuthenticatorFrameworkServiceComponent(); webappAuthenticatorFrameworkServiceComponent.activate(MockOsgi.newComponentContext()); }