FileDocCategorySizeDatePackage
PreparatorServletTest.javaAPI DocExample2773Mon Jul 23 13:26:12 BST 2007org.apache.struts2.portlet.context

PreparatorServletTest

public class PreparatorServletTest extends org.apache.struts2.StrutsTestCase
Test for the {@link PreparatorServletTest}

Fields Summary
Constructors Summary
Methods Summary
public voidtestServiceHttpServletRequestHttpServletResponse()
Test that the service method stores the request, response and servlet context in the {@link com.opensymphony.xwork2.ActionContext}

        MockControl mockRequest = MockControl.createNiceControl(HttpServletRequest.class);
        MockControl mockResponse = MockControl.createNiceControl(HttpServletResponse.class);
        MockControl mockContext = MockControl.createNiceControl(ServletContext.class);
        MockControl mockConfig = MockControl.createNiceControl(ServletConfig.class);

        HttpServletRequest req = (HttpServletRequest)mockRequest.getMock();
        HttpServletResponse res = (HttpServletResponse)mockResponse.getMock();
        ServletContext context = (ServletContext)mockContext.getMock();
        ServletConfig config = (ServletConfig)mockConfig.getMock();

        mockConfig.expectAndDefaultReturn(config.getServletContext(), context);
        mockConfig.replay();

        PreparatorServlet servlet = new PreparatorServlet();
        servlet.init(config);
        servlet.service(req, res);
        assertSame(req, ServletActionContext.getRequest());
        assertSame(res, ServletActionContext.getResponse());
        assertSame(context, ServletActionContext.getServletContext());

        mockConfig.verify();