Package org.springframework.mock.web.portlet

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


  public void testNoDetectAllHandlerMappingsWithParameterRenderRequest() throws Exception {
    DispatcherPortlet complexDispatcherPortlet = new DispatcherPortlet();
    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);
View Full Code Here


  public void testDispatcherPortletRefresh() throws PortletException {
    MockPortletContext portletContext = new MockPortletContext("org/springframework/web/portlet/context");
    DispatcherPortlet portlet = new DispatcherPortlet();

    portlet.init(new MockPortletConfig(portletContext, "empty"));
    PortletContextAwareBean contextBean = (PortletContextAwareBean)
        portlet.getPortletApplicationContext().getBean("portletContextAwareBean");
    PortletConfigAwareBean configBean = (PortletConfigAwareBean)
        portlet.getPortletApplicationContext().getBean("portletConfigAwareBean");
    assertSame(portletContext, contextBean.getPortletContext());
View Full Code Here

  public void testDispatcherPortletContextRefresh() throws PortletException {
    MockPortletContext portletContext = new MockPortletContext("org/springframework/web/portlet/context");
    DispatcherPortlet portlet = new DispatcherPortlet();

    portlet.init(new MockPortletConfig(portletContext, "empty"));
    PortletContextAwareBean contextBean = (PortletContextAwareBean)
        portlet.getPortletApplicationContext().getBean("portletContextAwareBean");
    PortletConfigAwareBean configBean = (PortletConfigAwareBean)
        portlet.getPortletApplicationContext().getBean("portletConfigAwareBean");
    assertSame(portletContext, contextBean.getPortletContext());
View Full Code Here

  @Override
  protected ConfigurableApplicationContext createContext() throws Exception {
    root = new XmlPortletApplicationContext();
    PortletContext portletContext = new MockPortletContext();
    PortletConfig portletConfig = new MockPortletConfig(portletContext);
    root.setPortletConfig(portletConfig);
    root.setConfigLocations(new String[] {"/org/springframework/web/portlet/context/WEB-INF/applicationContext.xml"});
    root.addBeanFactoryPostProcessor(new BeanFactoryPostProcessor() {
      @Override
      public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
View Full Code Here

   * Overridden in order to use MockPortletConfig
   * @see org.springframework.web.context.XmlWebApplicationContextTests#testWithoutMessageSource()
   */
  public void testWithoutMessageSource() throws Exception {
    MockPortletContext portletContext = new MockPortletContext("");
    MockPortletConfig portletConfig = new MockPortletConfig(portletContext);
    XmlPortletApplicationContext pac = new XmlPortletApplicationContext();
    pac.setParent(root);
    pac.setPortletConfig(portletConfig);
    pac.setNamespace("testNamespace");
    pac.setConfigLocations(new String[] {"/org/springframework/web/portlet/context/WEB-INF/test-portlet.xml"});
View Full Code Here

*/
public class GenericPortletBeanTests extends TestCase {

  public void testInitParameterSet() throws Exception {
    PortletContext portletContext = new MockPortletContext();
    MockPortletConfig portletConfig = new MockPortletConfig(portletContext);
    String testValue = "testValue";
    portletConfig.addInitParameter("testParam", testValue);
    TestPortletBean portletBean = new TestPortletBean();
    assertNull(portletBean.getTestParam());
    portletBean.init(portletConfig);
    assertNotNull(portletBean.getTestParam());
    assertEquals(testValue, portletBean.getTestParam());
View Full Code Here

    assertEquals(testValue, portletBean.getTestParam());
  }

  public void testInitParameterNotSet() throws Exception {
    PortletContext portletContext = new MockPortletContext();
    MockPortletConfig portletConfig = new MockPortletConfig(portletContext);
    TestPortletBean portletBean = new TestPortletBean();
    assertNull(portletBean.getTestParam());
    portletBean.init(portletConfig);
    assertNull(portletBean.getTestParam());
  }
View Full Code Here

    assertNull(portletBean.getTestParam());
  }

  public void testMultipleInitParametersSet() throws Exception {
    PortletContext portletContext = new MockPortletContext();
    MockPortletConfig portletConfig = new MockPortletConfig(portletContext);
    String testValue = "testValue";
    String anotherValue = "anotherValue";
    portletConfig.addInitParameter("testParam", testValue);
    portletConfig.addInitParameter("anotherParam", anotherValue);
    portletConfig.addInitParameter("unknownParam", "unknownValue");
    TestPortletBean portletBean = new TestPortletBean();
    assertNull(portletBean.getTestParam());
    assertNull(portletBean.getAnotherParam());
    portletBean.init(portletConfig);
    assertNotNull(portletBean.getTestParam());
View Full Code Here

    assertEquals(anotherValue, portletBean.getAnotherParam());
  }

  public void testMultipleInitParametersOnlyOneSet() throws Exception {
    PortletContext portletContext = new MockPortletContext();
    MockPortletConfig portletConfig = new MockPortletConfig(portletContext);
    String testValue = "testValue";
    portletConfig.addInitParameter("testParam", testValue);
    portletConfig.addInitParameter("unknownParam", "unknownValue");
    TestPortletBean portletBean = new TestPortletBean();
    assertNull(portletBean.getTestParam());
    assertNull(portletBean.getAnotherParam());
    portletBean.init(portletConfig);
    assertNotNull(portletBean.getTestParam());
View Full Code Here

    assertNull(portletBean.getAnotherParam());
  }

  public void testRequiredInitParameterSet() throws Exception {
    PortletContext portletContext = new MockPortletContext();
    MockPortletConfig portletConfig = new MockPortletConfig(portletContext);
    String testParam = "testParam";
    String testValue = "testValue";
    portletConfig.addInitParameter(testParam, testValue);
    TestPortletBean portletBean = new TestPortletBean();
    portletBean.addRequiredProperty(testParam);
    assertNull(portletBean.getTestParam());
    portletBean.init(portletConfig);
    assertNotNull(portletBean.getTestParam());
View Full Code Here

TOP

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

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.