Package org.springframework.mock.web

Examples of org.springframework.mock.web.MockHttpServletRequest


   * Testing reading from invalid request.
   */
  public void testFormInvalidRequestReading() throws Exception {
    FormWidget testForm = makeUsualForm();

    MockHttpServletRequest invalidRequest = new MockHttpServletRequest();

    invalidRequest.addParameter("testForm.__present", "true");
    invalidRequest.addParameter("testForm.myCheckBox", "ksjf");
    invalidRequest.addParameter("testForm.myDateTime.date", "HA-HA");
    invalidRequest.addParameter("testForm.myDateTime.time", "BLAH");
    invalidRequest.addParameter("testForm.hierarchyTest.myTextarea", "");   

    //Testing that invalid requests are read right
    StandardServletInputData input = new StandardServletInputData(invalidRequest);
    input.pushScope("testForm");
    testForm._getWidget().update(input);
View Full Code Here


   */
  public void testFormMandatoryMissingRequestReading() throws Exception {

    FormWidget testForm = makeUsualForm();

    MockHttpServletRequest mandatoryMissingRequest = new MockHttpServletRequest();

    mandatoryMissingRequest.addParameter("testForm.__present", "true");
    mandatoryMissingRequest.addParameter("testForm.myCheckBox", "true");
    mandatoryMissingRequest.addParameter("testForm.myLongText", "108");
    mandatoryMissingRequest.addParameter("testForm.myDateTime.date", "11.10.2015");
    mandatoryMissingRequest.addParameter("testForm.myDateTime.time", "01:01");
    mandatoryMissingRequest.addParameter("testForm.hierarchyTest.mySelect", "2");

    //Testing that mandatory items are processed right
    StandardServletInputData input = new StandardServletInputData(mandatoryMissingRequest);
    input.pushScope("testForm");
    testForm._getWidget().update(input);
View Full Code Here

   */
  public void testFormNotMandatoryMissingRequestReading() throws Exception {

    FormWidget testForm = makeUsualForm();

    MockHttpServletRequest notMandatoryMissingRequest = new MockHttpServletRequest();

    notMandatoryMissingRequest.addParameter("testForm.__present", "true");
    notMandatoryMissingRequest.addParameter("testForm.myCheckBox", (String) null);
    notMandatoryMissingRequest.addParameter("testForm.myLongText", "108");
    notMandatoryMissingRequest.addParameter("testForm.hierarchyTest.myTextarea", "blah");
    notMandatoryMissingRequest.addParameter("testForm.hierarchyTest.mySelect", "2");

    StandardServletInputData input = new StandardServletInputData(notMandatoryMissingRequest);
    input.pushScope("testForm");
    testForm._getWidget().update(input);
   
View Full Code Here

   */
  public void testFormActiveGroupedConstraintInvalidates() throws Exception {

    FormWidget testForm = makeUsualForm();

    MockHttpServletRequest notMandatoryMissingRequest = new MockHttpServletRequest();

    notMandatoryMissingRequest.addParameter("testForm.__present", "true");
    notMandatoryMissingRequest.addParameter("testForm.myCheckBox", "true");
    notMandatoryMissingRequest.addParameter("testForm.myLongText", "108");
    notMandatoryMissingRequest.addParameter("testForm.myDateTime", (String) null);
    notMandatoryMissingRequest.addParameter("testForm.hierarchyTest.myTextarea", "blah");
    notMandatoryMissingRequest.addParameter("testForm.hierarchyTest.mySelect", "2");

    // create helper
    ConstraintGroupHelper groupHelper = new ConstraintGroupHelper();
    testForm.getElement("myDateTime").setConstraint(
        groupHelper.createGroupedConstraint(new NotEmptyConstraint(), "active"));
View Full Code Here

   */
  public void testFormActiveGroupedConstraintValidates() throws Exception {

    FormWidget testForm = makeUsualForm();

    MockHttpServletRequest notMandatoryMissingRequest = new MockHttpServletRequest();

    notMandatoryMissingRequest.addParameter("testForm.__present", "true");
    notMandatoryMissingRequest.addParameter("testForm.myCheckBox", "true");
    notMandatoryMissingRequest.addParameter("testForm.myLongText", "108");   
    notMandatoryMissingRequest.addParameter("testForm.myDateTime.date", "11.10.2015");
    notMandatoryMissingRequest.addParameter("testForm.myDateTime.time", "01:01")
    notMandatoryMissingRequest.addParameter("testForm.hierarchyTest.myTextarea", "blah");
    notMandatoryMissingRequest.addParameter("testForm.hierarchyTest.mySelect", "2");

    // create helper
    ConstraintGroupHelper groupHelper = new ConstraintGroupHelper();   
    testForm.getElement("myDateTime").setConstraint(groupHelper.createGroupedConstraint(new NotEmptyConstraint(), "active"));
   
View Full Code Here

   */
  public void testFormInactiveGroupedConstraintValidates() throws Exception {

    FormWidget testForm = makeUsualForm();

    MockHttpServletRequest notMandatoryMissingRequest = new MockHttpServletRequest();

    notMandatoryMissingRequest.addParameter("testForm.__present", "true");
    notMandatoryMissingRequest.addParameter("testForm.myCheckBox", "true");
    notMandatoryMissingRequest.addParameter("testForm.myLongText", "108");   
    notMandatoryMissingRequest.addParameter("testForm.myDateTime.date", "11.10.2015");
    notMandatoryMissingRequest.addParameter("testForm.myDateTime.time", "01:01")
    notMandatoryMissingRequest.addParameter("testForm.hierarchyTest.myTextarea", "blah");
    notMandatoryMissingRequest.addParameter("testForm.hierarchyTest.mySelect", "2");

    // create helper
    ConstraintGroupHelper groupHelper = new ConstraintGroupHelper();   
    testForm.getElement("myDateTime").setConstraint(groupHelper.createGroupedConstraint(new NotEmptyConstraint(), "active"));
   
View Full Code Here

    service = new StandardSynchronizingFilterService();
    child = new MockEventfulBaseService();
    service.setChildService(child);
    MockLifeCycle.begin(service);
   
    req = new MockHttpServletRequest();
    res = new MockHttpServletResponse();
   
    input = new StandardServletInputData(req);
    output = new StandardServletOutputData(req, res);
  }
View Full Code Here

  }
 
  public void setUp() throws Exception {
    servlet  = new MockServlet();
   
    req = new MockHttpServletRequest();
    resp = new MockHttpServletResponse();
  }
View Full Code Here

        expect(wContext.getBean(ScriptManager.class)).andReturn(scriptManager).anyTimes();
        replay(wContext);
        ServletContext servletContext = createNiceMock(ServletContext.class);
        expect(servletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE)).andReturn(wContext).anyTimes();
        replay(servletContext);
        ServletRequest request = new MockHttpServletRequest();
        request.setAttribute("_RENDER_CONTEXT", context);
        pageContext = createNiceMock(PageContext.class);
        expect(pageContext.getServletContext()).andReturn(servletContext).anyTimes();
        expect(pageContext.getRequest()).andReturn(request).anyTimes();
        tag = new RegionWidgetTag();
        tag.setPageContext(pageContext);
View Full Code Here

    }

    @SuppressWarnings("unchecked")
    @Test
    public void testPostHandle() throws Exception {
        MockHttpServletRequest request = new MockHttpServletRequest();
        MockHttpServletResponse response = new MockHttpServletResponse();
        Object handler = null;
        ModelAndView modelAndView = new ModelAndView();

        Map<String, PortalPreference> preferenceMap = new HashMap<String, PortalPreference>();
View Full Code Here

TOP

Related Classes of org.springframework.mock.web.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.