Package org.springframework.mock.web.portlet

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


    String param = response.getRenderParameter("param");
    assertEquals("help1 was here", param);
  }

  public void testPortletModeParameterMappingHelp2() throws Exception {
    MockActionRequest request = new MockActionRequest();
    MockActionResponse response = new MockActionResponse();
    request.setPortletMode(PortletMode.HELP);
    request.setParameter("action", "help2");
    complexDispatcherPortlet.processAction(request, response);
    String param = response.getRenderParameter("param");
    assertEquals("help2 was here", param);
  }
View Full Code Here


    String param = response.getRenderParameter("param");
    assertEquals("help2 was here", param);
  }

  public void testPortletModeParameterMappingInvalidHelpActionRequest() throws Exception {
    MockActionRequest request = new MockActionRequest();
    MockActionResponse response = new MockActionResponse();
    request.setPortletMode(PortletMode.HELP);
    request.setParameter("action", "help3");
    complexDispatcherPortlet.processAction(request, response);
    String exceptionParam = response.getRenderParameter(DispatcherPortlet.ACTION_EXCEPTION_RENDER_PARAMETER);
    assertNotNull(exceptionParam);
    assertTrue(exceptionParam.startsWith(UnavailableException.class.getName()));
  }
View Full Code Here

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

  public void testPortletModeMappingValidEditActionRequest() throws Exception {
    MockActionRequest request = new MockActionRequest();
    MockActionResponse response = new MockActionResponse();
    request.setPortletMode(PortletMode.EDIT);
    request.addUserRole("role1");
    request.setParameter("action", "not mapped");
    request.setParameter("myParam", "not mapped");
    complexDispatcherPortlet.processAction(request, response);
    assertEquals("edit was here", response.getRenderParameter("param"));
  }
View Full Code Here

    complexDispatcherPortlet.processAction(request, response);
    assertEquals("edit was here", response.getRenderParameter("param"));
  }

  public void testPortletModeMappingEditActionRequestWithUnauthorizedUserRole() throws Exception {
    MockActionRequest request = new MockActionRequest();
    MockActionResponse response = new MockActionResponse();
    request.setPortletMode(PortletMode.EDIT);
    request.addUserRole("role3");
    request.setParameter("action", "not mapped");
    request.setParameter("myParam", "not mapped");
    complexDispatcherPortlet.processAction(request, response);
    String exception = response.getRenderParameter(DispatcherPortlet.ACTION_EXCEPTION_RENDER_PARAMETER);
    assertNotNull(exception);
    String name = PortletSecurityException.class.getName();
    assertTrue(exception.startsWith(name));
View Full Code Here

    InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE);
    assertEquals("failed-default-1", view.getBeanName());
  }

  public void testParameterMappingValidActionRequest() throws Exception {
    MockActionRequest request = new MockActionRequest();
    MockActionResponse response = new MockActionResponse();
    request.setPortletMode(PortletMode.EDIT);
    request.setParameter("action", "not mapped");
    request.setParameter("myParam", "test1");
    complexDispatcherPortlet.processAction(request, response);
    assertEquals("test1-action", response.getRenderParameter("result"));
  }
View Full Code Here

    complexDispatcherPortlet.doDispatch(request, response);
    assertEquals("test2-view", response.getProperty("result"));
  }

  public void testUnknownHandlerActionRequest() throws Exception {
    MockActionRequest request = new MockActionRequest();
    MockActionResponse response = new MockActionResponse();
    request.setParameter("myParam", "unknown");
    complexDispatcherPortlet.processAction(request, response);
    String exceptionParam = response.getRenderParameter(DispatcherPortlet.ACTION_EXCEPTION_RENDER_PARAMETER);
    assertNotNull(exceptionParam);
    assertTrue(exceptionParam.startsWith(PortletException.class.getName()));
    assertTrue(exceptionParam.indexOf("No adapter for handler") != -1);
View Full Code Here

    DispatcherPortlet complexDispatcherPortlet = new DispatcherPortlet();
    complexDispatcherPortlet.setContextClass(ComplexPortletApplicationContext.class);
    complexDispatcherPortlet.setNamespace("test");
    complexDispatcherPortlet.setDetectAllHandlerMappings(false);
    complexDispatcherPortlet.init(new MockPortletConfig(getPortletContext(), "complex"));
    MockActionRequest request = new MockActionRequest();
    MockActionResponse response = new MockActionResponse();
    request.setPortletMode(PortletMode.EDIT);
    complexDispatcherPortlet.processAction(request, response);
    String exceptionParam = response.getRenderParameter(DispatcherPortlet.ACTION_EXCEPTION_RENDER_PARAMETER);
    assertNotNull(exceptionParam);
    assertTrue(exceptionParam.startsWith(UnavailableException.class.getName()));
  }
View Full Code Here

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

  public void testExistingMultipartRequest() throws Exception {
    MockActionRequest request = new MockActionRequest();
    MockActionResponse response = new MockActionResponse();
    request.setPortletMode(PortletMode.EDIT);
    ComplexPortletApplicationContext.MockMultipartResolver multipartResolver =
        (ComplexPortletApplicationContext.MockMultipartResolver)
        complexDispatcherPortlet.getPortletApplicationContext().getBean("portletMultipartResolver");
    MultipartActionRequest multipartRequest = multipartResolver.resolveMultipart(request);
    complexDispatcherPortlet.processAction(multipartRequest, response);
    multipartResolver.cleanupMultipart(multipartRequest);
    assertNotNull(request.getAttribute("cleanedUp"));
  }
View Full Code Here

    multipartResolver.cleanupMultipart(multipartRequest);
    assertNotNull(request.getAttribute("cleanedUp"));
  }

  public void testMultipartResolutionFailed() throws Exception {
    MockActionRequest request = new MockActionRequest();
    MockActionResponse response = new MockActionResponse();
    request.setPortletMode(PortletMode.EDIT);
    request.addUserRole("role1");
    request.setAttribute("fail", Boolean.TRUE);
    complexDispatcherPortlet.processAction(request, response);
    String exception = response.getRenderParameter(DispatcherPortlet.ACTION_EXCEPTION_RENDER_PARAMETER);
    assertTrue(exception.startsWith(MaxUploadSizeExceededException.class.getName()));
  }
View Full Code Here

    String exception = response.getRenderParameter(DispatcherPortlet.ACTION_EXCEPTION_RENDER_PARAMETER);
    assertTrue(exception.startsWith(MaxUploadSizeExceededException.class.getName()));
  }

  public void testActionRequestHandledEvent() throws Exception {
    MockActionRequest request = new MockActionRequest();
    MockActionResponse response = new MockActionResponse();
    complexDispatcherPortlet.processAction(request, response);
    ComplexPortletApplicationContext.TestApplicationListener listener =
        (ComplexPortletApplicationContext.TestApplicationListener)
        complexDispatcherPortlet.getPortletApplicationContext().getBean("testListener");
View Full Code Here

TOP

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

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.