Package org.springframework.mock.web.portlet

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


    MockActionResponse actionResponse = new MockActionResponse();
    actionRequest.setParameter("action", "form");
    actionRequest.setParameter("age", "29");
    simpleDispatcherPortlet.processAction(actionRequest, actionResponse);

    MockRenderRequest renderRequest = new MockRenderRequest();
    MockRenderResponse renderResponse = new MockRenderResponse();
    renderRequest.setSession(actionRequest.getPortletSession());
    renderRequest.setParameters(actionResponse.getRenderParameterMap());
    renderRequest.setParameter("action", "form");
    simpleDispatcherPortlet.doDispatch(renderRequest, renderResponse);
    assertEquals("finished44", renderResponse.getContentAsString());
  }
View Full Code Here


    MockActionResponse actionResponse = new MockActionResponse();
    actionRequest.setParameter("action", "form");
    actionRequest.setParameter("age", "XX");
    simpleDispatcherPortlet.processAction(actionRequest, actionResponse);

    MockRenderRequest renderRequest = new MockRenderRequest();
    MockRenderResponse renderResponse = new MockRenderResponse();
    renderRequest.setSession(actionRequest.getPortletSession());
    renderRequest.setParameters(actionResponse.getRenderParameterMap());
    renderRequest.setParameter("action", "form");
    simpleDispatcherPortlet.doDispatch(renderRequest, renderResponse);
    assertEquals("5", renderResponse.getContentAsString());
  }
View Full Code Here

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

  public void testSimpleInvalidRenderRequest() throws Exception {
    MockRenderRequest request = new MockRenderRequest();
    MockRenderResponse response = new MockRenderResponse();
    request.setParameter("action", "invalid");
    try {
      simpleDispatcherPortlet.doDispatch(request, response);
      fail("Should have thrown UnavailableException");
    }
    catch (UnavailableException ex) {
View Full Code Here

    assertNotNull(exceptionParam);
    assertTrue(exceptionParam.startsWith(UnavailableException.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(UnavailableException.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

    assertTrue(exceptionParam.startsWith(PortletException.class.getName()));
    assertTrue(exceptionParam.indexOf("No adapter for handler") != -1);
  }

  public void testUnknownHandlerRenderRequest() throws Exception {
    MockRenderRequest request = new MockRenderRequest();
    MockRenderResponse response = new MockRenderResponse();
    request.setParameter("myParam", "unknown");
    complexDispatcherPortlet.doDispatch(request, response);
    Map model = (Map) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE);
    Exception exception = (Exception)model.get("exception");
    assertTrue(exception.getClass().equals(PortletException.class));
    assertTrue(exception.getMessage().indexOf("No adapter for handler") != -1);
    InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE);
    assertEquals("failed-default-1", view.getBeanName());
  }
View Full Code Here

    DispatcherPortlet complexDispatcherPortlet = new DispatcherPortlet();
    complexDispatcherPortlet.setContextClass(ComplexPortletApplicationContext.class);
    complexDispatcherPortlet.setNamespace("test");
    complexDispatcherPortlet.setDetectAllHandlerMappings(false);
    complexDispatcherPortlet.init(new MockPortletConfig(getPortletContext(), "complex"));
    MockRenderRequest request = new MockRenderRequest();
    MockRenderResponse response = new MockRenderResponse();
    request.setParameter("myParam", "test1");
    complexDispatcherPortlet.doDispatch(request, response);
    Map model = (Map) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE);
    Exception exception = (Exception) model.get("exception");
    assertTrue(exception.getClass().equals(UnavailableException.class));
    InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE);
    assertEquals("failed-unavailable", view.getBeanName());
  }
View Full Code Here

        complexDispatcherPortlet.getPortletApplicationContext().getBean("testListener");
    assertEquals(1, listener.counter);
  }

  public void testRenderRequestHandledEvent() throws Exception {
    MockRenderRequest request = new MockRenderRequest();
    MockRenderResponse response = new MockRenderResponse();
    complexDispatcherPortlet.doDispatch(request, response);
    ComplexPortletApplicationContext.TestApplicationListener listener =
        (ComplexPortletApplicationContext.TestApplicationListener)
        complexDispatcherPortlet.getPortletApplicationContext().getBean("testListener");
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.