Search in sources :

Example 1 with MockHttpSession

use of org.apache.struts.mock.MockHttpSession in project sonarqube by SonarSource.

the class TagTestBase method setUp.

/**
     * Helper method that creates/configures a basic configuration of Mock
     * Objects.
     *
     *
     * PageContext ServletConfig ServletContext HttpServletRequest HttpSession
     * HttpServletResponse
     *
     * "/myapp", "/foo", null, null,
     */
public void setUp() {
    // -- default Module
    this.moduleConfig = new ModuleConfigImpl("");
    this.moduleConfig.addForwardConfig(new ForwardConfig("foo", "/bar.jsp", false));
    this.moduleConfig.addForwardConfig(new ForwardConfig("relative1", "relative.jsp", false));
    this.moduleConfig.addForwardConfig(new ForwardConfig("relative2", "relative.jsp", false));
    this.moduleConfig.addForwardConfig(new ForwardConfig("external", "http://struts.apache.org/", false));
    // -- module "/2"
    this.moduleConfig2 = new ModuleConfigImpl("/2");
    this.moduleConfig2.addForwardConfig(new ForwardConfig("foo", "/baz.jsp", false));
    this.moduleConfig2.addForwardConfig(new ForwardConfig("relative1", "relative.jsp", false));
    this.moduleConfig2.addForwardConfig(new ForwardConfig("relative2", "relative.jsp", false));
    this.moduleConfig2.addForwardConfig(new ForwardConfig("external", "http://struts.apache.org/", false));
    // -- module "/3"
    this.moduleConfig3 = new ModuleConfigImpl("/3");
    // -- configure the ServletContext
    this.servletContext = new MockServletContext();
    this.servletContext.setAttribute(Globals.MODULE_KEY, moduleConfig);
    this.servletContext.setAttribute(Globals.MODULE_KEY + "/2", moduleConfig2);
    this.servletContext.setAttribute(Globals.MODULE_KEY + "/3", moduleConfig3);
    // -- configure the ServletConfig
    this.servletConfig = new MockServletConfig();
    this.servletConfig.setServletContext(servletContext);
    // -- configure the request
    this.request = new MockHttpServletRequest(new MockHttpSession());
    pageContext = new MockPageContext(servletConfig, request, new MockHttpServletResponse());
}
Also used : MockHttpServletRequest(org.apache.struts.mock.MockHttpServletRequest) MockServletConfig(org.apache.struts.mock.MockServletConfig) MockHttpSession(org.apache.struts.mock.MockHttpSession) MockPageContext(org.apache.struts.mock.MockPageContext) ForwardConfig(org.apache.struts.config.ForwardConfig) ModuleConfigImpl(org.apache.struts.config.impl.ModuleConfigImpl) MockServletContext(org.apache.struts.mock.MockServletContext) MockHttpServletResponse(org.apache.struts.mock.MockHttpServletResponse)

Example 2 with MockHttpSession

use of org.apache.struts.mock.MockHttpSession in project sonar-java by SonarSource.

the class TagTestBase method setUp.

/**
 * Helper method that creates/configures a basic configuration of Mock
 * Objects.
 *
 * PageContext ServletConfig ServletContext HttpServletRequest HttpSession
 * HttpServletResponse
 *
 * "/myapp", "/foo", null, null,
 */
public void setUp() {
    // -- default Module
    this.moduleConfig = new ModuleConfigImpl("");
    this.moduleConfig.addForwardConfig(new ForwardConfig("foo", "/bar.jsp", false));
    this.moduleConfig.addForwardConfig(new ForwardConfig("relative1", "relative.jsp", false));
    this.moduleConfig.addForwardConfig(new ForwardConfig("relative2", "relative.jsp", false));
    this.moduleConfig.addForwardConfig(new ForwardConfig("external", "http://struts.apache.org/", false));
    // -- module "/2"
    this.moduleConfig2 = new ModuleConfigImpl("/2");
    this.moduleConfig2.addForwardConfig(new ForwardConfig("foo", "/baz.jsp", false));
    this.moduleConfig2.addForwardConfig(new ForwardConfig("relative1", "relative.jsp", false));
    this.moduleConfig2.addForwardConfig(new ForwardConfig("relative2", "relative.jsp", false));
    this.moduleConfig2.addForwardConfig(new ForwardConfig("external", "http://struts.apache.org/", false));
    // -- module "/3"
    this.moduleConfig3 = new ModuleConfigImpl("/3");
    // -- configure the ServletContext
    this.servletContext = new MockServletContext();
    this.servletContext.setAttribute(Globals.MODULE_KEY, moduleConfig);
    this.servletContext.setAttribute(Globals.MODULE_KEY + "/2", moduleConfig2);
    this.servletContext.setAttribute(Globals.MODULE_KEY + "/3", moduleConfig3);
    // -- configure the ServletConfig
    this.servletConfig = new MockServletConfig();
    this.servletConfig.setServletContext(servletContext);
    // -- configure the request
    this.request = new MockHttpServletRequest(new MockHttpSession());
    pageContext = new MockPageContext(servletConfig, request, new MockHttpServletResponse());
}
Also used : MockHttpServletRequest(org.apache.struts.mock.MockHttpServletRequest) MockServletConfig(org.apache.struts.mock.MockServletConfig) MockHttpSession(org.apache.struts.mock.MockHttpSession) MockPageContext(org.apache.struts.mock.MockPageContext) ForwardConfig(org.apache.struts.config.ForwardConfig) ModuleConfigImpl(org.apache.struts.config.impl.ModuleConfigImpl) MockServletContext(org.apache.struts.mock.MockServletContext) MockHttpServletResponse(org.apache.struts.mock.MockHttpServletResponse)

Aggregations

ForwardConfig (org.apache.struts.config.ForwardConfig)2 ModuleConfigImpl (org.apache.struts.config.impl.ModuleConfigImpl)2 MockHttpServletRequest (org.apache.struts.mock.MockHttpServletRequest)2 MockHttpServletResponse (org.apache.struts.mock.MockHttpServletResponse)2 MockHttpSession (org.apache.struts.mock.MockHttpSession)2 MockPageContext (org.apache.struts.mock.MockPageContext)2 MockServletConfig (org.apache.struts.mock.MockServletConfig)2 MockServletContext (org.apache.struts.mock.MockServletContext)2