Package org.springframework.mock.web.portlet

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


import org.springframework.webflow.test.MockRequestContext;

public class PortletMvcViewTests extends TestCase {

  public void testRender() throws Exception {
    RenderRequest request = new MockRenderRequest();
    RenderResponse response = new MockRenderResponse();
    MockRequestContext context = new MockRequestContext();
    context.getMockExternalContext().setNativeContext(new MockPortletContext());
    context.getMockExternalContext().setNativeRequest(request);
    context.getMockExternalContext().setNativeResponse(response);
    context.getMockFlowExecutionContext().setKey(new MockFlowExecutionKey("c1v1"));
    org.springframework.web.servlet.View mvcView = (org.springframework.web.servlet.View) EasyMock
        .createMock(org.springframework.web.servlet.View.class);
    AbstractMvcView view = new PortletMvcView(mvcView, context);
    view.render();
    assertNotNull(request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE));
    assertNotNull(request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE));
  }
View Full Code Here


    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());
    renderContext = new PortletExternalContext(portletContext, renderRequest, renderResponse, controller
        .getFlowUrlHandler());
View Full Code Here

  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

        }
    }
   
    public void testRender() throws Exception
    {
        MockRenderRequest request = new MockRenderRequest(portletContext);
        MockPortletPreferences preferences = new MockPortletPreferences();
        request.setPreferences(preferences);
        request.addLocale(Locale.ENGLISH);
       
        MockRenderResponse response = new MockRenderResponse();
       
        scriptPortlet.render(request, response);
        assertFalse("The script is refreshed " +
View Full Code Here

 
  private static final String ERRORS_KEY = "errors";

  public void testRenderRequestWithNoParams() throws Exception {
    TestController tc = new TestController();
    MockRenderRequest request = new MockRenderRequest();
    MockRenderResponse response = new MockRenderResponse();
    request.setContextPath("test");
    ModelAndView mav = tc.handleRenderRequest(request, response);
    assertEquals("test-view", mav.getViewName());
    assertNotNull(mav.getModel().get(tc.getCommandName()));
    BindException errors = (BindException)mav.getModel().get(ERRORS_KEY);
    assertNotNull(errors);
View Full Code Here

    assertEquals("There should be no errors", 0, errors.getErrorCount());
  }

  public void testRenderRequestWithParams() throws Exception {
    TestController tc = new TestController();
    MockRenderRequest request = new MockRenderRequest();   
    MockRenderResponse response = new MockRenderResponse();
    String name = "test";
    int age = 30;
    request.addParameter("name", name);
    request.addParameter("age", "" + age);
    request.setContextPath("test");
    ModelAndView mav = tc.handleRenderRequest(request, response);
    assertEquals("test-view", mav.getViewName());
    TestBean command = (TestBean)mav.getModel().get(tc.getCommandName());
    assertEquals("Name should be bound", name, command.getName());
    assertEquals("Age should be bound", age, command.getAge());
View Full Code Here

    assertEquals("There should be no errors", 0, errors.getErrorCount());
  }
 
  public void testRenderRequestWithMismatch() throws Exception {
    TestController tc = new TestController();
    MockRenderRequest request = new MockRenderRequest();   
    MockRenderResponse response = new MockRenderResponse();
    String name = "test";
    request.addParameter("name", name);
    request.addParameter("age", "zzz");
    request.setContextPath("test");
    ModelAndView mav = tc.handleRenderRequest(request, response);
    assertEquals("test-view", mav.getViewName());
    TestBean command = (TestBean)mav.getModel().get(tc.getCommandName());
    assertNotNull(command);
    assertEquals("Name should be bound", name, command.getName());
View Full Code Here

  }
 
  public void testRenderWhenMinimizedReturnsNull() throws Exception {
    TestController tc = new TestController();
    assertFalse(tc.isRenderWhenMinimized());
    MockRenderRequest request = new MockRenderRequest();
    request.setWindowState(WindowState.MINIMIZED);
    MockRenderResponse response = new MockRenderResponse();
    ModelAndView mav = tc.handleRenderRequest(request, response);
    assertNull("ModelAndView should be null", mav);
  }
View Full Code Here

  }

  public void testAllowRenderWhenMinimized() throws Exception {
    TestController tc = new TestController();
    tc.setRenderWhenMinimized(true);
    MockRenderRequest request = new MockRenderRequest();
    request.setWindowState(WindowState.MINIMIZED);
    request.setContextPath("test");
    MockRenderResponse response = new MockRenderResponse();
    ModelAndView mav = tc.handleRenderRequest(request, response);
    assertNotNull("ModelAndView should not be null", mav);   
    assertEquals("test-view", mav.getViewName());
    assertNotNull(mav.getModel().get(tc.getCommandName()));
View Full Code Here

  }
 
  public void testRequiresSessionWithoutSession() throws Exception {
    TestController tc = new TestController();
    tc.setRequireSession(true);
    MockRenderRequest request = new MockRenderRequest();
    MockRenderResponse response = new MockRenderResponse();
    try {
      tc.handleRenderRequest(request, response);
      fail("Should have thrown PortletSessionRequiredException");
    }
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.