Package org.springframework.mock.web.portlet

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


    controller.setApplicationContext(new StaticWebApplicationContext());
    portletContext = new MockPortletContext();
    controller.setPortletContext(portletContext);
    controller.afterPropertiesSet();

    actionRequest = new MockActionRequest();
    actionResponse = new MockActionResponse();
    renderRequest = new MockRenderRequest();
    renderResponse = new MockRenderResponse();
    actionContext = new PortletExternalContext(portletContext, actionRequest, actionResponse, controller
        .getFlowUrlHandler());
View Full Code Here


  private PortletExternalContext renderContext;

  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

                   scriptPortlet.getScriptSourceLastEvaluated() > scriptSourceLastEvaluated);
    }
   
    public void testProcessAction() throws Exception
    {
        MockActionRequest request = new MockActionRequest(portletContext);
        MockPortletPreferences preferences = new MockPortletPreferences();
       
        if (scriptPortlet.getValidatorInstance() != null)
        {
            preferences.setPreferencesValidator(scriptPortlet.getValidatorInstance());
        }
       
        request.setPreferences(preferences);
        request.addLocale(Locale.ENGLISH);
       
        MockActionResponse response = new MockActionResponse();
       
        try
        {
            scriptPortlet.processAction(request, response);
            fail("Validator exception should occur here!!!");
        }
        catch (Exception e)
        {
            // expected ...
        }
       
        request.addParameter("message", "hello");
       
        scriptPortlet.processAction(request, response);
    }
View Full Code Here

    assertEquals("Expiration-cache should be set to 30 seconds", "30", cacheProperty);
  }
 
  public void testActionRequest() throws Exception {
    TestController tc = new TestController();
    MockActionRequest request = new MockActionRequest();
    MockActionResponse response = new MockActionResponse();
    tc.handleActionRequest(request, response);
    TestBean command = (TestBean)request.getPortletSession().getAttribute(tc.getRenderCommandSessionAttributeName());
    assertTrue(command.isJedi());
  }
View Full Code Here

      }
    }.runTest();
  }

  public void testPassAllParametersToRenderPhase() throws Exception {
    MockActionRequest request = new MockActionRequest();
    request.setParameter("William", "Baskerville");
    request.setParameter("Adso", "Melk");
    MockActionResponse response = new MockActionResponse();
    PortletUtils.passAllParametersToRenderPhase(request, response);
    assertEquals("The render parameters map is obviously not being populated with the request parameters.",
        request.getParameterMap().size(), response.getRenderParameterMap().size());
  }
View Full Code Here

      }
    }.runTest();
  }

  public void testPassAllParametersToRenderPhaseDoesNotPropagateExceptionIfRedirectAlreadySentAtTimeOfCall() throws Exception {
    MockActionRequest request = new MockActionRequest();
    request.setParameter("William", "Baskerville");
    request.setParameter("Adso", "Melk");
    MockActionResponse response = new MockActionResponse() {
      public void setRenderParameter(String key, String[] values) {
        throw new IllegalStateException();
      }
    };
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

public class ParameterMappingInterceptorTests extends TestCase {

  public void testDefaultParameterMapped() throws Exception {
    ParameterMappingInterceptor interceptor = new ParameterMappingInterceptor();
    Object handler = new Object();
    MockActionRequest request = new MockActionRequest();
    MockActionResponse response = new MockActionResponse();
    String param = ParameterHandlerMapping.DEFAULT_PARAMETER_NAME;
    String value = "someValue";
    request.setParameter(param, value);
    assertNull(response.getRenderParameter(param));
    boolean shouldProceed = interceptor.preHandleAction(request, response, handler);
    assertTrue(shouldProceed);
    assertNotNull(response.getRenderParameter(param));
    assertEquals(value, response.getRenderParameter(param));
View Full Code Here

  }
 
  public void testNonDefaultParameterNotMapped() throws Exception {
    ParameterMappingInterceptor interceptor = new ParameterMappingInterceptor();
    Object handler = new Object();
    MockActionRequest request = new MockActionRequest();
    MockActionResponse response = new MockActionResponse();
    String param = "myParam";
    String value = "someValue";
    request.setParameter(param, value);
    assertNull(response.getRenderParameter(param));
    boolean shouldProceed = interceptor.preHandle(request, response, handler);
    assertTrue(shouldProceed);
    assertNull(response.getRenderParameter(param));
    assertNull(response.getRenderParameter(ParameterHandlerMapping.DEFAULT_PARAMETER_NAME));
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.