EverrestInitializedListener implements ServletContextListener { void initializeEverrestComponents(EverrestServletContextInitializer initializer, ServletContext servletContext) { EverrestProcessor processor = initializer.createEverrestProcessor(); processor.start(); servletContext.setAttribute(EverrestProcessor.class.getName(), processor); servletContext.setAttribute(EverrestConfiguration.class.getName(), initializer.createConfiguration()); servletContext.setAttribute(Application.class.getName(), processor.getApplication()); servletContext.setAttribute(DependencySupplier.class.getName(), processor.getDependencySupplier()); servletContext.setAttribute(ResourceBinder.class.getName(), processor.getResources()); servletContext.setAttribute(ApplicationProviderBinder.class.getName(), processor.getProviders()); }  @Override void contextDestroyed(ServletContextEvent sce); @Override void contextInitialized(ServletContextEvent sce);  }
@Test public void startsEverrestProcessorWhenServletContextInitialized() throws Exception { EverrestProcessor everrestProcessor = mock(EverrestProcessor.class); EverrestServletContextInitializer initializer = mock(EverrestServletContextInitializer.class); when(initializer.createEverrestProcessor()).thenReturn(everrestProcessor); EverrestInitializedListener everrestInitializedListener = new EverrestInitializedListener(); everrestInitializedListener.initializeEverrestComponents(initializer, servletContext); verify(everrestProcessor).start(); }