Package org.springframework.mock.web.portlet

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


    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(NoHandlerFoundException.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

  }


  @Test
  public void testActionRequest() throws Exception {
    MockActionRequest request = new MockActionRequest();
    MockActionResponse response = new MockActionResponse();
    request.setParameter("test", "test");
    controller.handleActionRequest(request, response);
    String result = response.getRenderParameter(RESULT_RENDER_PARAMETER_NAME);
    assertEquals("myPortlet-action", result);
  }
View Full Code Here

    assertEquals(RENDERED_RESPONSE_CONTENT, result);
  }

  @Test(expected=IllegalArgumentException.class)
  public void testActionRequestWithNoParameters() throws Exception {
    MockActionRequest request = new MockActionRequest();
    MockActionResponse response = new MockActionResponse();
    controller.handleActionRequest(request, response);
  }
View Full Code Here

    controller.destroy();
  }

  @Test
  public void testPortletName() throws Exception {
    MockActionRequest request = new MockActionRequest();
    MockActionResponse response = new MockActionResponse();
    request.setParameter(PORTLET_NAME_ACTION_REQUEST_PARAMETER_NAME, "test");
    controller.handleActionRequest(request, response);
    String result = response.getRenderParameter(RESULT_RENDER_PARAMETER_NAME);
    assertEquals("wrappedPortlet", result);
  }
View Full Code Here

  @Test
  public void testDelegationToMockPortletConfigIfSoConfigured() throws Exception {

    final String BEAN_NAME = "Sixpence None The Richer";

    MockActionRequest request = new MockActionRequest();
    MockActionResponse response = new MockActionResponse();

    PortletWrappingController controller = new PortletWrappingController();
    controller.setPortletClass(MyPortlet.class);
    controller.setUseSharedPortletConfig(false);
    controller.setBeanName(BEAN_NAME);
    controller.afterPropertiesSet();

    request.setParameter(PORTLET_NAME_ACTION_REQUEST_PARAMETER_NAME, "true");
    controller.handleActionRequest(request, response);

    String result = response.getRenderParameter(RESULT_RENDER_PARAMETER_NAME);
    assertEquals(BEAN_NAME, result);
  }
View Full Code Here

    }
  }

  public void testActionRequestNotHandled() throws Exception {
    ParameterizableViewController controller = new ParameterizableViewController();
    ActionRequest request = new MockActionRequest();
    ActionResponse response = new MockActionResponse();
    try {
      controller.handleActionRequest(request, response);
      fail("should have thrown PortletException");
    }
View Full Code Here

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

  public void testActionRequest() throws Exception {
    MockActionRequest request = new MockActionRequest();
    MockActionResponse response = new MockActionResponse();
    try {
      controller.handleActionRequest(request, response);
      fail("Should have thrown PortletException");
    }
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.