Package org.springframework.mock.web.portlet

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


  protected void setUp() {
    portletContext = new MockPortletContext();
    request = new MockActionRequest();
    response = new MockActionResponse();
    context = new PortletExternalContext(portletContext, request, response);
    renderRequest = new MockRenderRequest();
    renderResponse = new MockRenderResponse();
    renderContext = new PortletExternalContext(portletContext, renderRequest, renderResponse);
  }
View Full Code Here


import org.springframework.webflow.validation.WebFlowMessageCodesResolver;

public class PortletMvcViewTests extends TestCase {

  public void testRender() throws Exception {
    RenderRequest request = new MockRenderRequest();
    RenderResponse response = new MockRenderResponse();
    MockRequestContext context = new MockRequestContext();
    context.getMockExternalContext().setNativeContext(new MockPortletContext());
    context.getMockExternalContext().setNativeRequest(request);
    context.getMockExternalContext().setNativeResponse(response);
    context.getMockFlowExecutionContext().setKey(new MockFlowExecutionKey("c1v1"));
    org.springframework.web.servlet.View mvcView = EasyMock.createMock(org.springframework.web.servlet.View.class);
    AbstractMvcView view = new PortletMvcView(mvcView, context);
    view.render();
    assertNotNull(request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE));
    assertNotNull(request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE));
  }
View Full Code Here

    context = ActionContext.getContext();
    stack = context.getValueStack();

    portletContext = new MockPortletContext();
    renderRequest = new MockRenderRequest();
    renderRequest.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, stack);
    renderUrl = new MockPortletUrl("render");
    actionUrl = new MockPortletUrl("action");
    renderResponse = new MockRenderResponse() {
      @Override
View Full Code Here

    context = new MockPortletContext();
    renderUrl = new MockPortletURL(
        new MockPortalContext(), "render");
    actionUrl = new MockPortletURL(
        new MockPortalContext(), "action");
    request = new MockRenderRequest();
    response = new MockRenderResponse() {
      @Override
      public PortletURL createActionURL() {
        return actionUrl;
      }
View Full Code Here

    assertEquals(Locale.UK, request.getLocale());
  }

  @Test
  public void testNativeRequest() {
    MockRenderRequest portletRequest = new MockRenderRequest();
    MockRenderResponse portletResponse = new MockRenderResponse();
    PortletWebRequest request = new PortletWebRequest(portletRequest, portletResponse);
    assertSame(portletRequest, request.getNativeRequest());
    assertSame(portletRequest, request.getNativeRequest(PortletRequest.class));
    assertSame(portletRequest, request.getNativeRequest(RenderRequest.class));
View Full Code Here

    assertNull(request.getNativeResponse(MultipartRequest.class));
  }

  @Test
  public void testDecoratedNativeRequest() {
    MockRenderRequest portletRequest = new MockRenderRequest();
    MockRenderResponse portletResponse = new MockRenderResponse();
    PortletRequest decoratedRequest = new PortletRequestWrapper(portletRequest);
    PortletResponse decoratedResponse = new PortletResponseWrapper(portletResponse);
    PortletWebRequest request = new PortletWebRequest(decoratedRequest, decoratedResponse);
    assertSame(decoratedRequest, request.getNativeRequest());
View Full Code Here

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

  public void testPortletModeParameterMappingInvalidHelpRenderRequest() throws Exception {
    MockRenderRequest request = new MockRenderRequest();
    MockRenderResponse response = new MockRenderResponse();
    request.setPortletMode(PortletMode.HELP);
    request.setParameter("action", "help3");
    complexDispatcherPortlet.doDispatch(request, response);
    Map<?, ?> model = (Map<?, ?>) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE);
    assertTrue(model.get("exception").getClass().equals(NoHandlerFoundException.class));
    InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE);
    assertEquals("failed-unavailable", view.getBeanName());
  }
View Full Code Here

    String name = PortletSecurityException.class.getName();
    assertTrue(exception.startsWith(name));
  }

  public void testPortletModeMappingValidViewRenderRequest() throws Exception {
    MockRenderRequest request = new MockRenderRequest();
    MockRenderResponse response = new MockRenderResponse();
    request.setPortletMode(PortletMode.VIEW);
    request.addUserRole("role2");
    request.setParameter("action", "not mapped");
    request.setParameter("myParam", "not mapped");
    complexDispatcherPortlet.doDispatch(request, response);
    Map<?, ?> model = (Map<?, ?>) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE);
    assertEquals("view was here", model.get("result"));
    InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE);
    assertEquals("someViewName", view.getBeanName());
  }
View Full Code Here

    InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE);
    assertEquals("someViewName", view.getBeanName());
  }

  public void testPortletModeMappingViewRenderRequestWithUnauthorizedUserRole() throws Exception {
    MockRenderRequest request = new MockRenderRequest();
    MockRenderResponse response = new MockRenderResponse();
    request.setPortletMode(PortletMode.VIEW);
    request.addUserRole("role3");
    request.setParameter("action", "not mapped");
    request.setParameter("myParam", "not mapped");
    complexDispatcherPortlet.doDispatch(request, response);
    Map<?, ?> model = (Map<?, ?>) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE);
    Exception exception = (Exception) model.get("exception");
    assertNotNull(exception);
    assertTrue(exception.getClass().equals(PortletSecurityException.class));
    InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE);
    assertEquals("failed-default-1", view.getBeanName());
  }
View Full Code Here

    complexDispatcherPortlet.processAction(request, response);
    assertEquals("test1-action", response.getRenderParameter("result"));
  }

  public void testParameterMappingValidRenderRequest() throws Exception {
    MockRenderRequest request = new MockRenderRequest();
    MockRenderResponse response = new MockRenderResponse();
    request.setPortletMode(PortletMode.VIEW);
    request.setParameter("action", "not mapped");
    request.setParameter("myParam", "test2");
    complexDispatcherPortlet.doDispatch(request, response);
    assertEquals("test2-view", response.getProperty("result"));
  }
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.