Package org.springframework.mock.web.portlet

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


    assertTrue(request.getAttribute("test2-remove-post") == null);
    assertTrue(request.getAttribute("test2-remove-after") == null);
  }

  public void testHandlerInterceptorAbort() throws Exception {
    MockRenderRequest request = new MockRenderRequest();
    MockRenderResponse response = new MockRenderResponse();
    request.setPortletMode(PortletMode.VIEW);
    request.addUserRole("role1");
    request.addParameter("abort", "true");
    complexDispatcherPortlet.doDispatch(request, response);
    assertTrue(request.getAttribute("test1-remove-never") != null);
    assertTrue(request.getAttribute("test1-remove-post") != null);
    assertTrue(request.getAttribute("test1-remove-after") == null);
    assertTrue(request.getAttribute("test2-remove-never") == null);
    assertTrue(request.getAttribute("test2-remove-post") == null);
    assertTrue(request.getAttribute("test2-remove-after") == null);
  }
View Full Code Here


  public void testRequestWithNoUserRoles() throws Exception {
    UserRoleAuthorizationInterceptor interceptor = new UserRoleAuthorizationInterceptor();
    String validRole = "allowed";
    interceptor.setAuthorizedRoles(new String[] {validRole});
    MockRenderRequest request = new MockRenderRequest();
    MockRenderResponse response = new MockRenderResponse();
    Object handler = new Object();
    assertFalse(request.isUserInRole(validRole));
    try {
      interceptor.preHandle(request, response, handler);
      fail("should have thrown PortletSecurityException");
    }
    catch (PortletSecurityException ex) {
View Full Code Here

    }
  }
 
  public void testInterceptorWithNoAuthorizedRoles() throws Exception {
    UserRoleAuthorizationInterceptor interceptor = new UserRoleAuthorizationInterceptor();
    MockRenderRequest request = new MockRenderRequest();
    MockRenderResponse response = new MockRenderResponse();
    Object handler = new Object();
    request.addUserRole("someRole");
    try {
      interceptor.preHandle(request, response, handler);
      fail("should have thrown PortletSecurityException");
    }
    catch (PortletSecurityException ex) {
View Full Code Here

    assertTrue(request.getAttribute("test2-remove-post") == null);
    assertTrue(request.getAttribute("test2-remove-after") == null);
  }

  public void testHandlerInterceptorNotClearingModelAndView() throws Exception {
    MockRenderRequest request = new MockRenderRequest();
    MockRenderResponse response = new MockRenderResponse();
    request.setPortletMode(PortletMode.VIEW);
    request.addUserRole("role1");
    request.addParameter("noView", "false");
    complexDispatcherPortlet.doDispatch(request, response);
    Map model = (Map) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE);
    assertEquals("view was here", model.get("result"));
    InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE);
    assertEquals("someViewName", view.getBeanName());
  }
View Full Code Here

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

  public void testHandlerInterceptorClearingModelAndView() throws Exception {
    MockRenderRequest request = new MockRenderRequest();
    MockRenderResponse response = new MockRenderResponse();
    request.setPortletMode(PortletMode.VIEW);
    request.addUserRole("role1");
    request.addParameter("noView", "true");
    complexDispatcherPortlet.doDispatch(request, response);
    Map model = (Map) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE);
    assertNull(model);
    InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE);
    assertNull(view);
  }
View Full Code Here

    complexDispatcherPortlet.destroy();
    assertNull(myPortlet.getPortletConfig());
  }

  public void testPortletHandlerAdapterRenderRequest() throws Exception {
    MockRenderRequest request = new MockRenderRequest();
    MockRenderResponse response = new MockRenderResponse();
    request.setParameter("myParam", "myPortlet");
    complexDispatcherPortlet.doDispatch(request, response);
    assertEquals("myPortlet was here", response.getContentAsString());
    ComplexPortletApplicationContext.MyPortlet myPortlet =
      (ComplexPortletApplicationContext.MyPortlet)
      complexDispatcherPortlet.getPortletApplicationContext().getBean("myPortlet");
View Full Code Here

    complexDispatcherPortlet.destroy();
    assertNull(myPortlet.getPortletConfig());
  }

  public void testModelAndViewDefiningExceptionInMappedHandler() throws Exception {
    MockRenderRequest request = new MockRenderRequest();
    request.setPortletMode(PortletMode.HELP);
    request.addParameter("myParam", "exception1");
    request.addParameter("fail", "yes");
    MockRenderResponse response = new MockRenderResponse();
    complexDispatcherPortlet.doDispatch(request, response);
    InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE);
    assertEquals("failed-modelandview", view.getBeanName());
  }
View Full Code Here

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

  public void testModelAndViewDefiningExceptionInUnmappedHandler() throws Exception {
    MockRenderRequest request = new MockRenderRequest();
    request.setPortletMode(PortletMode.HELP);
    request.addParameter("myParam", "exception2");
    request.addParameter("fail", "yes");
    MockRenderResponse response = new MockRenderResponse();
    complexDispatcherPortlet.doDispatch(request, response);
    InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE);
    assertEquals("failed-modelandview", view.getBeanName());
  }
View Full Code Here

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

  public void testIllegalAccessExceptionInMappedHandler() throws Exception {
    MockRenderRequest request = new MockRenderRequest();
    request.setPortletMode(PortletMode.HELP);
    request.addParameter("myParam", "exception1");
    request.addParameter("access", "illegal");
    MockRenderResponse response = new MockRenderResponse();
    complexDispatcherPortlet.doDispatch(request, response);
    InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE);
    assertEquals("failed-exception", view.getBeanName());
  }
View Full Code Here

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

  public void testIllegalAccessExceptionInUnmappedHandler() throws Exception {
    MockRenderRequest request = new MockRenderRequest();
    request.setPortletMode(PortletMode.HELP);
    request.addParameter("myParam", "exception2");
    request.addParameter("access", "illegal");
    MockRenderResponse response = new MockRenderResponse();
    complexDispatcherPortlet.doDispatch(request, response);
    InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE);
    assertEquals("failed-illegalaccess", view.getBeanName());
  }
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.