Package org.springframework.mock.web.portlet

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


    ParameterHandlerMapping handlerMapping = new ParameterHandlerMapping();
    handlerMapping.setParameterName(param);
    ParameterMappingInterceptor interceptor = new ParameterMappingInterceptor();
    interceptor.setParameterName(param);
    Object handler = new Object();
    MockActionRequest request = new MockActionRequest();
    MockActionResponse response = new MockActionResponse();
    request.setParameter(param, value);
    assertNull(response.getRenderParameter(param));
    boolean shouldProceed = interceptor.preHandleAction(request, response, handler);
    assertTrue(shouldProceed);
    assertNull(response.getRenderParameter(ParameterHandlerMapping.DEFAULT_PARAMETER_NAME));
    assertNotNull(response.getRenderParameter(param));
View Full Code Here


  }
 
  public void testNoParameterValueSetWithDefaultParameterName() throws Exception {
    ParameterMappingInterceptor interceptor = new ParameterMappingInterceptor();
    Object handler = new Object();
    MockActionRequest request = new MockActionRequest();
    MockActionResponse response = new MockActionResponse();
    String param = ParameterHandlerMapping.DEFAULT_PARAMETER_NAME;
    assertNull(response.getRenderParameter(param));
    boolean shouldProceed = interceptor.preHandle(request, response, handler);
    assertTrue(shouldProceed);
View Full Code Here

  }
 
  public void testNoParameterValueSetWithNonDefaultParameterName() throws Exception {
    ParameterMappingInterceptor interceptor = new ParameterMappingInterceptor();
    Object handler = new Object();
    MockActionRequest request = new MockActionRequest();
    MockActionResponse response = new MockActionResponse();
    String param = "myParam";
    assertNull(response.getRenderParameter(param));
    boolean shouldProceed = interceptor.preHandle(request, response, handler);
    assertTrue(shouldProceed);
View Full Code Here

    ParameterHandlerMapping handlerMapping = new ParameterHandlerMapping();
    handlerMapping.setParameterName(param);
    ParameterMappingInterceptor interceptor = new ParameterMappingInterceptor();
    interceptor.setParameterName(param);
    Object handler = new Object();
    MockActionRequest request = new MockActionRequest();
    MockActionResponse response = new MockActionResponse();
    assertNull(response.getRenderParameter(param));
    boolean shouldProceed = interceptor.preHandle(request, response, handler);
    assertTrue(shouldProceed);
    assertNull(response.getRenderParameter(param));
View Full Code Here

    assertTrue("Context not published",
        getPortletContext().getAttribute(FrameworkPortlet.PORTLET_CONTEXT_PREFIX + "complex") == null);
  }

  public void testSimpleValidActionRequest() throws Exception {
    MockActionRequest request = new MockActionRequest();
    MockActionResponse response = new MockActionResponse();
    request.setParameter("action", "form");
    request.setParameter("age", "29");
    simpleDispatcherPortlet.processAction(request, response);
    String exceptionParam = response.getRenderParameter(DispatcherPortlet.ACTION_EXCEPTION_RENDER_PARAMETER);
    assertNull(exceptionParam);
    SimplePortletApplicationContext ac = (SimplePortletApplicationContext)simpleDispatcherPortlet.getPortletApplicationContext();
    String commandAttribute = ac.getRenderCommandSessionAttributeName();
    TestBean testBean = (TestBean) request.getPortletSession().getAttribute(commandAttribute);
    assertEquals(39, testBean.getAge());
  }
View Full Code Here

    TestBean testBean = (TestBean) request.getPortletSession().getAttribute(commandAttribute);
    assertEquals(39, testBean.getAge());
  }

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

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

  public void testSimpleFormViewWithSessionNoBindOnNewForm() throws Exception {
    MockActionRequest actionRequest = new MockActionRequest();
    MockActionResponse actionResponse = new MockActionResponse();
    actionRequest.setSession(new MockPortletSession());
    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

      // expected
    }
  }

  public void testSimpleFormSubmission() throws Exception {
    MockActionRequest actionRequest = new MockActionRequest();
    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

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

  public void testSimpleFormSubmissionWithValidationError() throws Exception {
    MockActionRequest actionRequest = new MockActionRequest();
    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

      // expected
    }
  }

  public void testPortletModeParameterMappingHelp1() throws Exception {
    MockActionRequest request = new MockActionRequest();
    MockActionResponse response = new MockActionResponse();
    request.setPortletMode(PortletMode.HELP);
    request.setParameter("action", "help1");
    complexDispatcherPortlet.processAction(request, response);
    String param = response.getRenderParameter("param");
    assertEquals("help1 was here", param);
  }
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.