Package org.springframework.mock.web.portlet

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


  private DispatcherPortlet complexDispatcherPortlet;


  @Override
  protected void setUp() throws PortletException {
    complexPortletConfig = new MockPortletConfig(new MockPortletContext(), "complex");
    complexPortletConfig.addInitParameter("publishContext", "false");

    complexDispatcherPortlet = new DispatcherPortlet();
    complexDispatcherPortlet.setContextClass(ComplexPortletApplicationContext.class);
    complexDispatcherPortlet.setNamespace("test");
View Full Code Here


    String message = complexDispatcherPortlet.getPortletApplicationContext().getMessage("test.args", args, Locale.ENGLISH);
    assertEquals("test this and that", message);
  }

  public void testPortletApplicationContextLookup() {
    MockPortletContext portletContext = new MockPortletContext();
    ApplicationContext ac = PortletApplicationContextUtils.getWebApplicationContext(portletContext);
    assertNull(ac);
    try {
      ac = PortletApplicationContextUtils.getRequiredWebApplicationContext(portletContext);
      fail("Should have thrown IllegalStateException");
    }
    catch (IllegalStateException ex) {
// expected
    }
    portletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE,
        new StaticWebApplicationContext());
    try {
      ac = PortletApplicationContextUtils.getRequiredWebApplicationContext(portletContext);
      assertNotNull(ac);
    }
View Full Code Here

      fail("Should not have thrown IllegalStateException: " + ex.getMessage());
    }
  }

  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");
View Full Code Here

    portlet.destroy();
  }

  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");
View Full Code Here

  private ConfigurablePortletApplicationContext pac;

  @Override
  public void setUp() throws Exception {
    MockPortletContext portletContext = new MockPortletContext();
    pac = new XmlPortletApplicationContext();
    pac.setPortletContext(portletContext);
    pac.setConfigLocations(new String[] {CONF});
    pac.refresh();
  }
View Full Code Here

  private ConfigurablePortletApplicationContext root;

  @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
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");
View Full Code Here

  public void testGetTempDirWithNullPortletContext() throws Exception {
    PortletUtils.getTempDir(null);
  }

  public void testGetTempDirSunnyDay() throws Exception {
    MockPortletContext ctx = new MockPortletContext();
    Object expectedTempDir = new File("doesn't exist but that's ok in the context of this test");
    ctx.setAttribute(WebUtils.TEMP_DIR_CONTEXT_ATTRIBUTE, expectedTempDir);
    assertSame(expectedTempDir, PortletUtils.getTempDir(ctx));
  }
View Full Code Here

    PortletUtils.getRealPath(null, "/foo");
  }

  @Test(expected=NullPointerException.class)
  public void testGetRealPathWithNullPath() throws Exception {
    PortletUtils.getRealPath(new MockPortletContext(), null);
  }
View Full Code Here

    PortletUtils.getRealPath(new MockPortletContext(), null);
  }

  @Test(expected=FileNotFoundException.class)
  public void testGetRealPathWithPathThatCannotBeResolvedToFile() throws Exception {
    PortletUtils.getRealPath(new MockPortletContext() {
      @Override
      public String getRealPath(String path) {
        return null;
      }
    }, "/rubbish");
View Full Code Here

TOP

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

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.