ServletUtil { public static ApplicationContext getApplicationContext(ServletContext servletContext) { return (ApplicationContext) servletContext .getAttribute(ApplicationAccess.APPLICATION_CONTEXT_ATTRIBUTE); } private  ServletUtil(); static IOException wrapServletException(ServletException ex,
            String message); static ApplicationContext getApplicationContext(ServletContext servletContext); static ServletRequest getServletRequest(Request request); static ServletContext getServletContext(ApplicationContext applicationContext);  }
@Test public void testGetApplicationContext() { ServletContext servletContext = createMock(ServletContext.class); ApplicationContext applicationContext = createMock(ApplicationContext.class); expect(servletContext.getAttribute(ApplicationAccess .APPLICATION_CONTEXT_ATTRIBUTE)).andReturn(applicationContext); replay(servletContext, applicationContext); assertEquals(applicationContext, ServletUtil.getApplicationContext(servletContext)); verify(servletContext, applicationContext); }