Package org.springframework.mock.web.portlet

Examples of org.springframework.mock.web.portlet.MockRenderRequest


      RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(httpRequest));

      LocaleContext servletLocaleContext = LocaleContextHolder.getLocaleContext();
      RequestAttributes servletRequestAttrs = RequestContextHolder.getRequestAttributes();

      MockRenderRequest request = new MockRenderRequest();
      MockRenderResponse response = new MockRenderResponse();
      try {
        simpleDispatcherPortlet.doDispatch(request, response);
        fail("should have failed to find a handler and raised an UnavailableException");
      }
View Full Code Here


  public void testRenderRequestWithViewNameSet() throws Exception {
    ParameterizableViewController controller = new ParameterizableViewController();
    String viewName = "testView";
    controller.setViewName(viewName);
    RenderRequest request = new MockRenderRequest();
    RenderResponse response = new MockRenderResponse();
    ModelAndView mav = controller.handleRenderRequest(request, response);
    assertEquals(viewName, mav.getViewName());
  }
View Full Code Here

  public void setUp() {
    controller = new PortletModeNameViewController();
  }
 
  public void testEditPortletMode() throws Exception {
    MockRenderRequest request = new MockRenderRequest();
    MockRenderResponse response = new MockRenderResponse();
    request.setPortletMode(PortletMode.EDIT);
    ModelAndView mav = controller.handleRenderRequest(request, response);
    assertEquals("edit", mav.getViewName());
  }
View Full Code Here

    ModelAndView mav = controller.handleRenderRequest(request, response);
    assertEquals("edit", mav.getViewName());
  }

  public void testHelpPortletMode() throws Exception {
    MockRenderRequest request = new MockRenderRequest();
    MockRenderResponse response = new MockRenderResponse();
    request.setPortletMode(PortletMode.HELP);
    ModelAndView mav = controller.handleRenderRequest(request, response);
    assertEquals("help", mav.getViewName());
  }
View Full Code Here

    ModelAndView mav = controller.handleRenderRequest(request, response);
    assertEquals("help", mav.getViewName());
  }
 
  public void testViewPortletMode() throws Exception {
    MockRenderRequest request = new MockRenderRequest();
    MockRenderResponse response = new MockRenderResponse();
    request.setPortletMode(PortletMode.VIEW);
    ModelAndView mav = controller.handleRenderRequest(request, response);
    assertEquals("view", mav.getViewName());
  }
View Full Code Here

    assertNotNull(exceptionParam);
    assertTrue(exceptionParam.startsWith(UnavailableException.class.getName()));
  }

  public void testSimpleFormViewNoBindOnNewForm() throws Exception {
    MockRenderRequest request = new MockRenderRequest();
    MockRenderResponse response = new MockRenderResponse();
    request.setParameter("action", "form");
    request.setParameter("age", "29");
    simpleDispatcherPortlet.doDispatch(request, response);
    assertEquals("5", response.getContentAsString());
  }
View Full Code Here

    simpleDispatcherPortlet.doDispatch(request, response);
    assertEquals("5", response.getContentAsString());
  }

  public void testSimpleFormViewBindOnNewForm() throws Exception {
    MockRenderRequest request = new MockRenderRequest();
    MockRenderResponse response = new MockRenderResponse();
    request.setParameter("action", "form-bind");
    request.setParameter("age", "29");
    simpleDispatcherPortlet.doDispatch(request, response);
    assertEquals("34", response.getContentAsString());
  }
View Full Code Here

    simpleDispatcherPortlet.doDispatch(request, response);
    assertEquals("34", response.getContentAsString());
  }

  public void testSimpleFormViewWithSessionAndBindOnNewForm() throws Exception {
    MockRenderRequest renderRequest = new MockRenderRequest();
    MockRenderResponse renderResponse = new MockRenderResponse();
    renderRequest.setParameter("action", "form-session-bind");
    renderRequest.setParameter("age", "30");
    TestBean testBean = new TestBean();
    testBean.setAge(40);
    SimplePortletApplicationContext ac =
        (SimplePortletApplicationContext)simpleDispatcherPortlet.getPortletApplicationContext();
    String formAttribute = ac.getFormSessionAttributeName();
    PortletSession session = new MockPortletSession();
    session.setAttribute(formAttribute, testBean);
    renderRequest.setSession(session);
    simpleDispatcherPortlet.doDispatch(renderRequest, renderResponse);
    assertEquals("35", renderResponse.getContentAsString());
  }
View Full Code Here

    actionRequest.setParameter("action", "form-session-nobind");
    actionRequest.setParameter("age", "27");
    simpleDispatcherPortlet.processAction(actionRequest, actionResponse);
    Map renderParameters = actionResponse.getRenderParameterMap();

    MockRenderRequest renderRequest = new MockRenderRequest();
    MockRenderResponse renderResponse = new MockRenderResponse();
    renderRequest.setParameters(renderParameters);
    renderRequest.setParameter("action", "form-session-nobind");
    renderRequest.setParameter("age", "30");
    renderRequest.setSession(actionRequest.getPortletSession());
    simpleDispatcherPortlet.doDispatch(renderRequest, renderResponse);
    assertEquals("finished42", renderResponse.getContentAsString());
  }
View Full Code Here

    simpleDispatcherPortlet.doDispatch(renderRequest, renderResponse);
    assertEquals("finished42", renderResponse.getContentAsString());
  }

  public void testSimpleRequiredSessionFormWithoutSession() throws Exception {
    MockRenderRequest request = new MockRenderRequest();
    MockRenderResponse response = new MockRenderResponse();
    request.setParameter("action", "form-session-bind");
    try {
      simpleDispatcherPortlet.doDispatch(request, response);
      fail("Should have thrown PortletSessionRequiredException");
    }
    catch (PortletSessionRequiredException ex) {
View Full Code Here

TOP

Related Classes of org.springframework.mock.web.portlet.MockRenderRequest

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.