SpringHawtioContextListener extends HawtioContextListener { @Override public void contextInitialized(final ServletContextEvent servletContextEvent) { super.contextInitialized(servletContextEvent); servletContextEvent.getServletContext() .setAttribute(HawtioProperty.SERVLET_PATH, this.servletPath); } SpringHawtioContextListener(final ConfigManager configManager,
            final String servletPath); @Override void contextInitialized(final ServletContextEvent servletContextEvent); final String servletPath; }
@Test public void testContextInitialized() { final ConfigManager configManager = Mockito.mock(ConfigManager.class); final ServletContextEvent event = Mockito.mock(ServletContextEvent.class); final ServletContext ctx = Mockito.mock(ServletContext.class); Mockito.when(event.getServletContext()).thenReturn(ctx); final SpringHawtioContextListener underTest = new SpringHawtioContextListener( configManager, "foobar"); underTest.contextInitialized(event); Mockito.verify(configManager).init(ctx); Mockito.verify(ctx).setAttribute("ConfigManager", configManager); Mockito.verify(ctx).setAttribute("hawtioServletPath", "foobar"); }