* @throws IOException If something goes wrong.
* @throws ServletException If something goes wrong.
*/
@Test
public void testWrite() throws IOException, ServletException {
ApplicationContext applicationContext = createMock(ServletApplicationContext.class);
ServletContext servletContext = createMock(ServletContext.class);
GenericServlet servlet = createMockBuilder(GenericServlet.class).createMock();
ServletConfig servletConfig = createMock(ServletConfig.class);
ObjectWrapper objectWrapper = createMock(ObjectWrapper.class);
expect(servletConfig.getServletContext()).andReturn(servletContext);
replay(servlet, servletConfig);
servlet.init(servletConfig);
ServletContextHashModel servletContextHashModel = new ServletContextHashModel(servlet, objectWrapper);
expect(applicationContext.getContext()).andReturn(servletContext).anyTimes();
expect(servletContext.getRealPath(isA(String.class))).andReturn(null).anyTimes();
URL resource = getClass().getResource("/test.ftl");
expect(servletContext.getResource(isA(String.class))).andReturn(resource).anyTimes();
expect(servletContext.getAttribute(ATTR_APPLICATION_MODEL)).andReturn(servletContextHashModel);
expect(servletContext.getAttribute(ATTR_JSP_TAGLIBS_MODEL)).andReturn(null);