Package org.apache.struts.mock

Examples of org.apache.struts.mock.MockHttpServletRequest


        // -- 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());
    }
View Full Code Here


        super(_name);
    }

    /* setUp method for test case */
    protected void setUp() throws Exception {
        this.request = new MockHttpServletRequest();
        this.principal =
            new MockPrincipal("Mr. Macri", new String[] { "administrator" });
        this.request.setUserPrincipal(principal);

        MockServletConfig servletConfig = new MockServletConfig();
View Full Code Here

    protected void tearDown() {
    }

    public void testSetOriginalURI()
        throws Exception {
        MockHttpServletRequest request =
            new MockHttpServletRequest("foo/", "bar.do", null, null);
        MockServletConfig servletConfig = new MockServletConfig();
        MockServletContext servletContext = new MockServletContext();
        MockActionServlet servlet =
            new MockActionServlet(servletContext, servletConfig);

        servlet.initInternal();

        ServletActionContext saContext =
            new ServletActionContext(servletContext, request,
                new MockHttpServletResponse());

        saContext.setActionServlet(servlet);

        boolean result = command.execute(saContext);

        assertTrue(!result);

        String uri = (String) request.getAttribute(Globals.ORIGINAL_URI_KEY);

        assertTrue("Original uri not correct: " + uri, "bar.do".equals(uri));

        request.setPathElements("foo/", "bar2.do", null, null);
        uri = (String) request.getAttribute(Globals.ORIGINAL_URI_KEY);
        assertTrue("Original uri not correct: " + uri, "bar.do".equals(uri));
    }
View Full Code Here

        super(_name);
    }

    /* setUp method for test case */
    protected void setUp() throws Exception {
        this.request = new MockHttpServletRequest();
        this.principal =
            new MockPrincipal("Mr. Macri", new String[] { "administrator" });
        this.request.setUserPrincipal(principal);

        MockServletConfig servletConfig = new MockServletConfig();
View Full Code Here

    // ----public ModuleConfig getModuleConfig(PageContext pageContext)
    public void testModuleConfig_getModuleConfig_PageContext() {
        MockServletConfig mockServletConfig = new MockServletConfig();
        ModuleConfig moduleConfig = new ModuleConfigImpl("");
        MockServletContext mockServletContext = new MockServletContext();
        MockHttpServletRequest mockHttpServletRequest =
            new MockHttpServletRequest();
        MockHttpServletResponse mockHttpServletResponse =
            new MockHttpServletResponse();

        mockServletConfig.setServletContext(mockServletContext);

        MockPageContext mockPageContext =
            new MockPageContext(mockServletConfig, mockHttpServletRequest,
                mockHttpServletResponse);

        ModuleConfig foundModuleConfig = null;

        try {
            foundModuleConfig = tagutils.getModuleConfig(mockPageContext);
            fail("Expected ModuleConfig to not be found");
        } catch (NullPointerException ignore) {
            // expected result
        }

        mockHttpServletRequest.setAttribute(Globals.MODULE_KEY, moduleConfig);

        mockPageContext.getServletContext().setAttribute(Globals.MODULE_KEY,
            mockPageContext);

        foundModuleConfig = tagutils.getModuleConfig(mockPageContext);
View Full Code Here

  protected PageContext createMockPageContext(String mockSiteUrl) {
   
    MockServletContext servlet = new JSOMockServletContext(mockSiteUrl);
    MockServletConfig config = new MockServletConfig(servlet);
    MockHttpSession session = new MockHttpSession(servlet);
    MockHttpServletRequest request = new MockHttpServletRequest("/JSOTest","/JSOUnit",null,null,session);
    MockHttpServletResponse response = new MockHttpServletResponse();
    MockPageContext pageContext = new JSOMockPageContext(config, request, response);
   
    return pageContext;
   
View Full Code Here

  private HttpServletRequest req;
  private SparqlEndpoint sparqlEndpoint;
 
  @Before
  public void setup() {
    req = new MockHttpServletRequest();
    sparqlEndpoint = EndpointFactory.createDefaultSparqlEndpoint();
  }
View Full Code Here

        dynaForm.set("booleanSecond", Boolean.FALSE);
        dynaForm.set("doubleProperty", new Double(456.0));
        dynaForm.set("floatProperty", new Float((float) 456.0));
        dynaForm.set("intProperty", new Integer(456));

        MockHttpServletRequest request = new MockHttpServletRequest();

        request.setMethod("GET");
        dynaForm.reset(mapping, request);

        assertEquals("booleanProperty should be reset", Boolean.TRUE,
            (Boolean) dynaForm.get("booleanProperty"));
        assertEquals("booleanSecond should be reset", Boolean.TRUE,
View Full Code Here

        dynaForm.set("booleanSecond", Boolean.FALSE);
        dynaForm.set("doubleProperty", new Double(456.0));
        dynaForm.set("floatProperty", new Float((float) 456.0));
        dynaForm.set("intProperty", new Integer(456));

        MockHttpServletRequest request = new MockHttpServletRequest();

        request.setMethod("POST");
        dynaForm.reset(mapping, request);

        assertEquals("booleanProperty should be reset", Boolean.TRUE,
            (Boolean) dynaForm.get("booleanProperty"));
        assertEquals("booleanSecond should be reset", Boolean.TRUE,
View Full Code Here

        // -- 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());
    }
View Full Code Here

TOP

Related Classes of org.apache.struts.mock.MockHttpServletRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.