Package org.springframework.mock.web.portlet

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


    assertTrue(exceptionParam.startsWith(UnavailableException.class.getName()));
  }

  public void testSimpleFormViewNoBindOnNewForm() throws Exception {
    MockRenderRequest request = new MockRenderRequest();
    MockRenderResponse response = new MockRenderResponse();
    request.setParameter("action", "form");
    request.setParameter("age", "29");
    simpleDispatcherPortlet.doDispatch(request, response);
    assertEquals("5", response.getContentAsString());
  }
View Full Code Here


    assertEquals("5", response.getContentAsString());
  }

  public void testSimpleFormViewBindOnNewForm() throws Exception {
    MockRenderRequest request = new MockRenderRequest();
    MockRenderResponse response = new MockRenderResponse();
    request.setParameter("action", "form-bind");
    request.setParameter("age", "29");
    simpleDispatcherPortlet.doDispatch(request, response);
    assertEquals("34", response.getContentAsString());
  }
View Full Code Here

    assertEquals("34", response.getContentAsString());
  }

  public void testSimpleFormViewWithSessionAndBindOnNewForm() throws Exception {
    MockRenderRequest renderRequest = new MockRenderRequest();
    MockRenderResponse renderResponse = new MockRenderResponse();
    renderRequest.setParameter("action", "form-session-bind");
    renderRequest.setParameter("age", "30");
    TestBean testBean = new TestBean();
    testBean.setAge(40);
    SimplePortletApplicationContext ac =
        (SimplePortletApplicationContext)simpleDispatcherPortlet.getPortletApplicationContext();
    String formAttribute = ac.getFormSessionAttributeName();
    PortletSession session = new MockPortletSession();
    session.setAttribute(formAttribute, testBean);
    renderRequest.setSession(session);
    simpleDispatcherPortlet.doDispatch(renderRequest, renderResponse);
    assertEquals("35", renderResponse.getContentAsString());
  }
View Full Code Here

    actionRequest.setParameter("age", "27");
    simpleDispatcherPortlet.processAction(actionRequest, actionResponse);
    Map renderParameters = actionResponse.getRenderParameterMap();

    MockRenderRequest renderRequest = new MockRenderRequest();
    MockRenderResponse renderResponse = new MockRenderResponse();
    renderRequest.setParameters(renderParameters);
    renderRequest.setParameter("action", "form-session-nobind");
    renderRequest.setParameter("age", "30");
    renderRequest.setSession(actionRequest.getPortletSession());
    simpleDispatcherPortlet.doDispatch(renderRequest, renderResponse);
    assertEquals("finished42", renderResponse.getContentAsString());
  }
View Full Code Here

    assertEquals("finished42", renderResponse.getContentAsString());
  }

  public void testSimpleRequiredSessionFormWithoutSession() throws Exception {
    MockRenderRequest request = new MockRenderRequest();
    MockRenderResponse response = new MockRenderResponse();
    request.setParameter("action", "form-session-bind");
    try {
      simpleDispatcherPortlet.doDispatch(request, response);
      fail("Should have thrown PortletSessionRequiredException");
    }
View Full Code Here

    actionRequest.setParameter("action", "form");
    actionRequest.setParameter("age", "29");
    simpleDispatcherPortlet.processAction(actionRequest, actionResponse);

    MockRenderRequest renderRequest = new MockRenderRequest();
    MockRenderResponse renderResponse = new MockRenderResponse();
    renderRequest.setSession(actionRequest.getPortletSession());
    renderRequest.setParameters(actionResponse.getRenderParameterMap());
    renderRequest.setParameter("action", "form");
    simpleDispatcherPortlet.doDispatch(renderRequest, renderResponse);
    assertEquals("finished44", renderResponse.getContentAsString());
  }
View Full Code Here

    actionRequest.setParameter("action", "form");
    actionRequest.setParameter("age", "XX");
    simpleDispatcherPortlet.processAction(actionRequest, actionResponse);

    MockRenderRequest renderRequest = new MockRenderRequest();
    MockRenderResponse renderResponse = new MockRenderResponse();
    renderRequest.setSession(actionRequest.getPortletSession());
    renderRequest.setParameters(actionResponse.getRenderParameterMap());
    renderRequest.setParameter("action", "form");
    simpleDispatcherPortlet.doDispatch(renderRequest, renderResponse);
    assertEquals("5", renderResponse.getContentAsString());
  }
View Full Code Here

    assertEquals("5", renderResponse.getContentAsString());
  }

  public void testSimpleInvalidRenderRequest() throws Exception {
    MockRenderRequest request = new MockRenderRequest();
    MockRenderResponse response = new MockRenderResponse();
    request.setParameter("action", "invalid");
    try {
      simpleDispatcherPortlet.doDispatch(request, response);
      fail("Should have thrown UnavailableException");
    }
View Full Code Here

    assertTrue(exceptionParam.startsWith(UnavailableException.class.getName()));
  }

  public void testPortletModeParameterMappingInvalidHelpRenderRequest() throws Exception {
    MockRenderRequest request = new MockRenderRequest();
    MockRenderResponse response = new MockRenderResponse();
    request.setPortletMode(PortletMode.HELP);
    request.setParameter("action", "help3");
    complexDispatcherPortlet.doDispatch(request, response);
    Map model = (Map) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE);
    assertTrue(model.get("exception").getClass().equals(UnavailableException.class));
View Full Code Here

    assertTrue(exception.startsWith(name));
  }

  public void testPortletModeMappingValidViewRenderRequest() throws Exception {
    MockRenderRequest request = new MockRenderRequest();
    MockRenderResponse response = new MockRenderResponse();
    request.setPortletMode(PortletMode.VIEW);
    request.addUserRole("role2");
    request.setParameter("action", "not mapped");
    request.setParameter("myParam", "not mapped");
    complexDispatcherPortlet.doDispatch(request, response);
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.