Package org.springframework.mock.web.portlet

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


    assertEquals("someViewName", view.getBeanName());
  }

  public void testPortletModeMappingViewRenderRequestWithUnauthorizedUserRole() throws Exception {
    MockRenderRequest request = new MockRenderRequest();
    MockRenderResponse response = new MockRenderResponse();
    request.setPortletMode(PortletMode.VIEW);
    request.addUserRole("role3");
    request.setParameter("action", "not mapped");
    request.setParameter("myParam", "not mapped");
    complexDispatcherPortlet.doDispatch(request, response);
View Full Code Here


    assertEquals("test1-action", response.getRenderParameter("result"));
  }

  public void testParameterMappingValidRenderRequest() throws Exception {
    MockRenderRequest request = new MockRenderRequest();
    MockRenderResponse response = new MockRenderResponse();
    request.setPortletMode(PortletMode.VIEW);
    request.setParameter("action", "not mapped");
    request.setParameter("myParam", "test2");
    complexDispatcherPortlet.doDispatch(request, response);
    assertEquals("test2-view", response.getProperty("result"));
  }
View Full Code Here

    assertTrue(exceptionParam.indexOf("No adapter for handler") != -1);
  }

  public void testUnknownHandlerRenderRequest() throws Exception {
    MockRenderRequest request = new MockRenderRequest();
    MockRenderResponse response = new MockRenderResponse();
    request.setParameter("myParam", "unknown");
    complexDispatcherPortlet.doDispatch(request, response);
    Map model = (Map) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE);
    Exception exception = (Exception)model.get("exception");
    assertTrue(exception.getClass().equals(PortletException.class));
View Full Code Here

    complexDispatcherPortlet.setContextClass(ComplexPortletApplicationContext.class);
    complexDispatcherPortlet.setNamespace("test");
    complexDispatcherPortlet.setDetectAllHandlerMappings(false);
    complexDispatcherPortlet.init(new MockPortletConfig(getPortletContext(), "complex"));
    MockRenderRequest request = new MockRenderRequest();
    MockRenderResponse response = new MockRenderResponse();
    request.setParameter("myParam", "test1");
    complexDispatcherPortlet.doDispatch(request, response);
    Map model = (Map) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE);
    Exception exception = (Exception) model.get("exception");
    assertTrue(exception.getClass().equals(UnavailableException.class));
View Full Code Here

    assertEquals(1, listener.counter);
  }

  public void testRenderRequestHandledEvent() throws Exception {
    MockRenderRequest request = new MockRenderRequest();
    MockRenderResponse response = new MockRenderResponse();
    complexDispatcherPortlet.doDispatch(request, response);
    ComplexPortletApplicationContext.TestApplicationListener listener =
        (ComplexPortletApplicationContext.TestApplicationListener)
        complexDispatcherPortlet.getPortletApplicationContext().getBean("testListener");
    assertEquals(1, listener.counter);
View Full Code Here

    assertEquals(0, listener.counter);
  }

  public void testCorrectLocaleInRequest() throws Exception {
    MockRenderRequest request = new MockRenderRequest();
    MockRenderResponse response = new MockRenderResponse();
    request.setParameter("myParam", "requestLocaleChecker");
    request.addPreferredLocale(Locale.CANADA);
    complexDispatcherPortlet.doDispatch(request, response);
    assertEquals("locale-ok", response.getContentAsString());
  }
View Full Code Here

    assertEquals("locale-ok", response.getContentAsString());
  }

  public void testIncorrectLocaleInRequest() throws Exception {
    MockRenderRequest request = new MockRenderRequest();
    MockRenderResponse response = new MockRenderResponse();
    request.setParameter("myParam", "requestLocaleChecker");
    request.addPreferredLocale(Locale.ENGLISH);
    complexDispatcherPortlet.doDispatch(request, response);
    Map model = (Map) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE);
    Exception exception = (Exception) model.get("exception");
View Full Code Here

    assertEquals("failed-default-1", view.getBeanName());
  }

  public void testCorrectLocaleInLocaleContextHolder() throws Exception {
    MockRenderRequest request = new MockRenderRequest();
    MockRenderResponse response = new MockRenderResponse();
    request.setParameter("myParam", "contextLocaleChecker");
    request.addPreferredLocale(Locale.CANADA);
    complexDispatcherPortlet.doDispatch(request, response);
    assertEquals("locale-ok", response.getContentAsString());
  }
View Full Code Here

    assertEquals("locale-ok", response.getContentAsString());
  }

  public void testIncorrectLocaleInLocalContextHolder() throws Exception {
    MockRenderRequest request = new MockRenderRequest();
    MockRenderResponse response = new MockRenderResponse();
    request.setParameter("myParam", "contextLocaleChecker");
    request.addPreferredLocale(Locale.ENGLISH);
    complexDispatcherPortlet.doDispatch(request, response);
    Map model = (Map) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE);
    Exception exception = (Exception) model.get("exception");
View Full Code Here

    assertEquals("failed-default-1", view.getBeanName());
  }

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

TOP

Related Classes of org.springframework.mock.web.portlet.MockRenderResponse

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.