@Test(expected = ServletException.class)
public void constructorWithRegistryAsArgumentUsesServletConfigWhenNullButWrongTypeInContext() throws Exception {

    final ServletContext servletContext = mock(ServletContext.class);
    final ServletConfig servletConfig = mock(ServletConfig.class);
    when(servletConfig.getServletContext()).thenReturn(servletContext);
    when(servletContext.getAttribute(eq(HealthCheckServlet.HEALTH_CHECK_REGISTRY)))
            .thenReturn("IRELLEVANT_STRING");
    final HealthCheckServlet healthCheckServlet = new HealthCheckServlet(null);
    healthCheckServlet.init(servletConfig);
}