@Test public void stopsEverrestProcessorWhenServletContextDestroyed() throws Exception { EverrestProcessor everrestProcessor = mock(EverrestProcessor.class); when(servletContext.getAttribute(EverrestProcessor.class.getName())).thenReturn(everrestProcessor); EverrestInitializedListener everrestInitializedListener = new EverrestInitializedListener(); ServletContextEvent servletContextEvent = new ServletContextEvent(servletContext); everrestInitializedListener.contextDestroyed(servletContextEvent); verify(everrestProcessor).stop(); }
@Override public void contextDestroyed(ServletContextEvent sce) { makeFileCollectorDestroyer().stopFileCollector(); ServletContext servletContext = sce.getServletContext(); EverrestProcessor processor = (EverrestProcessor)servletContext.getAttribute(EverrestProcessor.class.getName()); if (processor != null) { processor.stop(); } servletContext.removeAttribute(EverrestProcessor.class.getName()); servletContext.removeAttribute(EverrestConfiguration.class.getName()); servletContext.removeAttribute(Application.class.getName()); servletContext.removeAttribute(DependencySupplier.class.getName()); servletContext.removeAttribute(ResourceBinder.class.getName()); servletContext.removeAttribute(ApplicationProviderBinder.class.getName()); }
EverrestInitializedListener implements ServletContextListener { @Override public void contextDestroyed(ServletContextEvent sce) { makeFileCollectorDestroyer().stopFileCollector(); ServletContext servletContext = sce.getServletContext(); EverrestProcessor processor = (EverrestProcessor)servletContext.getAttribute(EverrestProcessor.class.getName()); if (processor != null) { processor.stop(); } servletContext.removeAttribute(EverrestProcessor.class.getName()); servletContext.removeAttribute(EverrestConfiguration.class.getName()); servletContext.removeAttribute(Application.class.getName()); servletContext.removeAttribute(DependencySupplier.class.getName()); servletContext.removeAttribute(ResourceBinder.class.getName()); servletContext.removeAttribute(ApplicationProviderBinder.class.getName()); } }
EverrestInitializedListener implements ServletContextListener { @Override public void contextDestroyed(ServletContextEvent sce) { makeFileCollectorDestroyer().stopFileCollector(); ServletContext servletContext = sce.getServletContext(); EverrestProcessor processor = (EverrestProcessor)servletContext.getAttribute(EverrestProcessor.class.getName()); if (processor != null) { processor.stop(); } servletContext.removeAttribute(EverrestProcessor.class.getName()); servletContext.removeAttribute(EverrestConfiguration.class.getName()); servletContext.removeAttribute(Application.class.getName()); servletContext.removeAttribute(DependencySupplier.class.getName()); servletContext.removeAttribute(ResourceBinder.class.getName()); servletContext.removeAttribute(ApplicationProviderBinder.class.getName()); }  }
EverrestInitializedListener implements ServletContextListener { @Override public void contextDestroyed(ServletContextEvent sce) { makeFileCollectorDestroyer().stopFileCollector(); ServletContext servletContext = sce.getServletContext(); EverrestProcessor processor = (EverrestProcessor)servletContext.getAttribute(EverrestProcessor.class.getName()); if (processor != null) { processor.stop(); } servletContext.removeAttribute(EverrestProcessor.class.getName()); servletContext.removeAttribute(EverrestConfiguration.class.getName()); servletContext.removeAttribute(Application.class.getName()); servletContext.removeAttribute(DependencySupplier.class.getName()); servletContext.removeAttribute(ResourceBinder.class.getName()); servletContext.removeAttribute(ApplicationProviderBinder.class.getName()); }  @Override void contextDestroyed(ServletContextEvent sce); @Override void contextInitialized(ServletContextEvent sce); }
EverrestInitializedListener implements ServletContextListener { @Override public void contextDestroyed(ServletContextEvent sce) { makeFileCollectorDestroyer().stopFileCollector(); ServletContext servletContext = sce.getServletContext(); EverrestProcessor processor = (EverrestProcessor)servletContext.getAttribute(EverrestProcessor.class.getName()); if (processor != null) { processor.stop(); } servletContext.removeAttribute(EverrestProcessor.class.getName()); servletContext.removeAttribute(EverrestConfiguration.class.getName()); servletContext.removeAttribute(Application.class.getName()); servletContext.removeAttribute(DependencySupplier.class.getName()); servletContext.removeAttribute(ResourceBinder.class.getName()); servletContext.removeAttribute(ApplicationProviderBinder.class.getName()); }  @Override void contextDestroyed(ServletContextEvent sce); @Override void contextInitialized(ServletContextEvent sce);  }