Example usage for org.springframework.mock.web MockPageContext MockPageContext

List of usage examples for org.springframework.mock.web MockPageContext MockPageContext

Introduction

In this page you can find the example usage for org.springframework.mock.web MockPageContext MockPageContext.

Prototype

public MockPageContext(@Nullable ServletContext servletContext, @Nullable HttpServletRequest request,
        @Nullable HttpServletResponse response) 

Source Link

Document

Create new MockPageContext with a MockServletConfig.

Usage

From source file:org.apache.struts2.StrutsJUnit4TestCase.java

protected void initServletMockObjects() {
    servletContext = new MockServletContext(resourceLoader);
    response = new MockHttpServletResponse();
    request = new MockHttpServletRequest();
    pageContext = new MockPageContext(servletContext, request, response);
}

From source file:org.apache.struts2.StrutsJUnit4TestCase.java

public void finishExecution() {
    HttpSession session = this.request.getSession();
    Enumeration attributeNames = session.getAttributeNames();

    MockHttpServletRequest nextRequest = new MockHttpServletRequest();

    while (attributeNames.hasMoreElements()) {
        String key = (String) attributeNames.nextElement();
        Object attribute = session.getAttribute(key);
        nextRequest.getSession().setAttribute(key, attribute);
    }//from  ww  w .  java  2  s  .co  m

    this.response = new MockHttpServletResponse();
    this.request = nextRequest;
    this.pageContext = new MockPageContext(servletContext, request, response);
}