Package org.springframework.mock.web.portlet

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


    assertEquals(1, listener.counter);
  }

  public void testPublishEventsOff() throws Exception {
    complexDispatcherPortlet.setPublishEvents(false);
    MockActionRequest request = new MockActionRequest();
    MockActionResponse response = new MockActionResponse();
    request.setParameter("action", "checker");
    complexDispatcherPortlet.processAction(request, response);
    ComplexPortletApplicationContext.TestApplicationListener listener =
        (ComplexPortletApplicationContext.TestApplicationListener)
        complexDispatcherPortlet.getPortletApplicationContext().getBean("testListener");
    assertEquals(0, listener.counter);
View Full Code Here


    InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE);
    assertNull(view);
  }

  public void testParameterMappingInterceptorWithCorrectParam() throws Exception {
    MockActionRequest request = new MockActionRequest();
    MockActionResponse response = new MockActionResponse();
    request.setPortletMode(PortletMode.VIEW);
    request.addUserRole("role1");
    request.addParameter("interceptingParam", "test1");
    complexDispatcherPortlet.processAction(request, response);
    assertEquals("test1", response.getRenderParameter("interceptingParam"));
  }
View Full Code Here

    complexDispatcherPortlet.processAction(request, response);
    assertEquals("test1", response.getRenderParameter("interceptingParam"));
  }

  public void testParameterMappingInterceptorWithIncorrectParam() throws Exception {
    MockActionRequest request = new MockActionRequest();
    MockActionResponse response = new MockActionResponse();
    request.setPortletMode(PortletMode.VIEW);
    request.addUserRole("role1");
    request.addParameter("incorrect", "test1");
    complexDispatcherPortlet.processAction(request, response);
    assertNull(response.getRenderParameter("incorrect"));
    assertNull(response.getRenderParameter("interceptingParam"));
  }
View Full Code Here

    assertNull(response.getRenderParameter("incorrect"));
    assertNull(response.getRenderParameter("interceptingParam"));
  }

  public void testPortletHandlerAdapterActionRequest() throws Exception {
    MockActionRequest request = new MockActionRequest();
    MockActionResponse response = new MockActionResponse();
    request.setParameter("myParam", "myPortlet");
    complexDispatcherPortlet.processAction(request, response);
    assertEquals("myPortlet action called", response.getRenderParameter("result"));
    ComplexPortletApplicationContext.MyPortlet myPortlet =
      (ComplexPortletApplicationContext.MyPortlet) complexDispatcherPortlet.getPortletApplicationContext().getBean("myPortlet");
    assertEquals("complex", myPortlet.getPortletConfig().getPortletName());
View Full Code Here

      RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(httpRequest));

      LocaleContext servletLocaleContext = LocaleContextHolder.getLocaleContext();
      RequestAttributes servletRequestAttrs = RequestContextHolder.getRequestAttributes();

      MockActionRequest request = new MockActionRequest();
      MockActionResponse response = new MockActionResponse();
      request.setParameter("action", "form");
      request.setParameter("age", "29");
      simpleDispatcherPortlet.processAction(request, response);

      assertSame(servletLocaleContext, LocaleContextHolder.getLocaleContext());
      assertSame(servletRequestAttrs, RequestContextHolder.getRequestAttributes());
    }
View Full Code Here

      RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(httpRequest));

      LocaleContext servletLocaleContext = LocaleContextHolder.getLocaleContext();
      RequestAttributes servletRequestAttrs = RequestContextHolder.getRequestAttributes();

      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); // ensure that an exceptional condition occured

      assertSame(servletLocaleContext, LocaleContextHolder.getLocaleContext());
View Full Code Here

        return wac;
      }
    };
    portlet.init(new MockPortletConfig());

    MockActionRequest actionRequest = new MockActionRequest(PortletMode.VIEW);
    MockActionResponse actionResponse = new MockActionResponse();
    portlet.processAction(actionRequest, actionResponse);
    assertEquals("value", actionResponse.getRenderParameter("test"));

    MockRenderRequest request = new MockRenderRequest(PortletMode.EDIT);
View Full Code Here

    }
   
    public void testMultipartRequest_parametersAreCopiedToActionInvocation() throws Exception {
      MockPortletContext ctx = new MockPortletContext();
      ctx.setAttribute("javax.servlet.context.tempdir", new File("target").getAbsoluteFile());
      MockActionRequest request = new MockActionRequest(ctx);
      request.setContent(MULTIPART_REQUEST.getBytes("US-ASCII"));
      request.setContentType("multipart/form-data; boundary=---------------------------4827543632391");
      request.setProperty("Content-Length", "" + MULTIPART_REQUEST.length());
      MockActionResponse response = new MockActionResponse();
      Map<String, Object> requestMap = new HashMap<String, Object>();
      Map<String, String[]> paramMap = new HashMap<String, String[]>();
      Map<String, Object> sessionMap = new HashMap<String, Object>();
      Map<String, Object> applicationMap = new HashMap<String, Object>();
View Full Code Here

  }

  public void testMultipartRequest_parametersAreCopiedToActionInvocation() throws Exception {
    MockPortletContext ctx = new MockPortletContext();
    ctx.setAttribute("javax.servlet.context.tempdir", new File("target").getAbsoluteFile());
    MockActionRequest request = new MockActionRequest(ctx);
    request.setContent(MULTIPART_REQUEST.getBytes("US-ASCII"));
    request.setContentType("multipart/form-data; boundary=---------------------------4827543632391");
    request.setProperty("Content-Length", "" + MULTIPART_REQUEST.length());
    MockActionResponse response = new MockActionResponse();
    Map<String, Object> requestMap = new HashMap<String, Object>();
    Map<String, String[]> paramMap = new HashMap<String, String[]>();
    Map<String, Object> sessionMap = new HashMap<String, Object>();
    Map<String, Object> applicationMap = new HashMap<String, Object>();
View Full Code Here

    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

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.