Package org.springframework.mock.web.portlet

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


        complexDispatcherPortlet.getPortletApplicationContext().getBean("testListener");
    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


    complexDispatcherPortlet.doDispatch(request, response);
    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");
    assertTrue(exception.getClass().equals(PortletException.class));
    assertEquals("Incorrect Locale in RenderRequest", exception.getMessage());
    InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE);
    assertEquals("failed-default-1", view.getBeanName());
  }
View Full Code Here

  }

  public void testNoEffectForRenderRequest() throws Exception {
    ParameterMappingInterceptor interceptor = new ParameterMappingInterceptor();
    Object handler = new Object();
    MockRenderRequest request = new MockRenderRequest();
    MockRenderResponse response = new MockRenderResponse();
    String param = ParameterHandlerMapping.DEFAULT_PARAMETER_NAME;
    String value = "someValue";
    request.setParameter(param, value);
    boolean shouldProceed = interceptor.preHandle(request, response, handler);
    assertTrue(shouldProceed);
  }
View Full Code Here

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

    MockRenderRequest request = new MockRenderRequest(PortletMode.VIEW);
    MockRenderResponse response = new MockRenderResponse();
    portlet.render(request, response);
    assertEquals("test", response.getContentAsString());
  }
View Full Code Here

    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);
    request.addParameter("param1", "value1");
    request.addParameter("param2", "2");
    MockRenderResponse response = new MockRenderResponse();
    portlet.render(request, response);
    assertEquals("test-value1-2", response.getContentAsString());

    request = new MockRenderRequest(PortletMode.HELP);
    request.addParameter("name", "name1");
    request.addParameter("age", "2");
    response = new MockRenderResponse();
    portlet.render(request, response);
    assertEquals("test-name1-2", response.getContentAsString());

    request = new MockRenderRequest(PortletMode.VIEW);
    request.addParameter("name", "name1");
    request.addParameter("age", "value2");
    response = new MockRenderResponse();
    portlet.render(request, response);
    assertEquals("test-name1-typeMismatch", response.getContentAsString());
  }
View Full Code Here

        new TestView().render(mv.getViewName(), mv.getModel(), request, response);
      }
    };
    portlet.init(new MockPortletConfig());

    MockRenderRequest request = new MockRenderRequest(PortletMode.VIEW);
    request.addParameter("name", "name1");
    request.addParameter("age", "value2");
    MockRenderResponse response = new MockRenderResponse();
    portlet.render(request, response);
    assertEquals("myView-name1-typeMismatch-tb1-myValue", response.getContentAsString());
  }
View Full Code Here

        new TestView().render(mv.getViewName(), mv.getModel(), request, response);
      }
    };
    portlet.init(new MockPortletConfig());

    MockRenderRequest request = new MockRenderRequest(PortletMode.VIEW);
    request.addParameter("name", "name1");
    request.addParameter("age", "value2");
    MockRenderResponse response = new MockRenderResponse();
    portlet.render(request, response);
    assertEquals("myView-name1-typeMismatch-tb1-myValue", response.getContentAsString());
  }
View Full Code Here

        new TestView().render(mv.getViewName(), mv.getModel(), request, response);
      }
    };
    portlet.init(new MockPortletConfig());

    MockRenderRequest request = new MockRenderRequest(PortletMode.VIEW);
    request.addParameter("defaultName", "myDefaultName");
    request.addParameter("age", "value2");
    request.addParameter("date", "2007-10-02");
    MockRenderResponse response = new MockRenderResponse();
    portlet.render(request, response);
    assertEquals("myView-String:myDefaultName-typeMismatch-tb1-myOriginalValue", response.getContentAsString());
  }
View Full Code Here

        new TestView().render(mv.getViewName(), mv.getModel(), request, response);
      }
    };
    portlet.init(new MockPortletConfig());

    MockRenderRequest request = new MockRenderRequest(PortletMode.VIEW);
    request.addParameter("myParam", "myValue");
    request.addParameter("defaultName", "10");
    request.addParameter("age", "value2");
    request.addParameter("date", "2007-10-02");
    MockRenderResponse response = new MockRenderResponse();
    portlet.render(request, response);
    assertEquals("myView-Integer:10-typeMismatch-tb1-myOriginalValue", response.getContentAsString());

    request = new MockRenderRequest(PortletMode.VIEW);
    request.addParameter("myParam", "myOtherValue");
    request.addParameter("defaultName", "10");
    request.addParameter("age", "value2");
    request.addParameter("date", "2007-10-02");
    response = new MockRenderResponse();
    portlet.render(request, response);
    assertEquals("myOtherView-Integer:10-typeMismatch-tb1-myOriginalValue", response.getContentAsString());

    request = new MockRenderRequest(PortletMode.EDIT);
    request.addParameter("myParam", "myValue");
    request.addParameter("defaultName", "10");
    request.addParameter("age", "value2");
    request.addParameter("date", "2007-10-02");
    response = new MockRenderResponse();
    portlet.render(request, response);
    assertEquals("myView-myName-typeMismatch-tb1-myOriginalValue", response.getContentAsString());
  }
View Full Code Here

        new TestView().render(mv.getViewName(), mv.getModel(), request, response);
      }
    };
    portlet.init(new MockPortletConfig());

    MockRenderRequest request = new MockRenderRequest(PortletMode.VIEW);
    request.addParameter("defaultName", "myDefaultName");
    request.addParameter("age", "value2");
    request.addParameter("date", "2007-10-02");
    MockRenderResponse response = new MockRenderResponse();
    portlet.render(request, response);
    assertEquals("myView-String:myDefaultName-typeMismatch-tb1-myOriginalValue", response.getContentAsString());
  }
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.