Announcement Announcement Module
Collapse
No announcement yet.
Spring 1.1.2 - MockServletContext.getResourcePaths broken Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring 1.1.2 - MockServletContext.getResourcePaths broken

    I have the following in a TestCase's setUp() method. It works fine in 1.1.1:

    Code:
    // initialize Spring
    MockServletContext sc = new MockServletContext("");
    sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM,
                        "/WEB-INF/applicationContext*.xml");
    ServletContextListener contextListener = new ContextLoaderListener();
    ServletContextEvent event = new ServletContextEvent(sc);
    contextListener.contextInitialized(event);
    However, in 1.1.2 it results in the following error:

    Code:
        [junit] java.lang.UnsupportedOperationException: getResourcePaths
        [junit]     at org.springframework.mock.web.MockServletContext.getResourcePaths(MockServletContext.java:128)
        [junit]     at org.springframework.web.context.support.ServletContextResourcePatternResolver.doRetrieveMatchingServletContextResources(ServletContextResourcePatternResolver.java:100)
        [junit]     at org.springframework.web.context.support.ServletContextResourcePatternResolver.doFindPathMatchingFileResources(ServletContextResourcePatternResolver.java:79)
        [junit]     at org.springframework.core.io.support.PathMatchingResourcePatternResolver.findPathMatchingFileResources(PathMatchingResourcePatternResolver.java:192)
        [junit]     at org.springframework.core.io.support.PathMatchingResourcePatternResolver.getResources(PathMatchingResourcePatternResolver.java:145)
        [junit]     at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:142)

  • #2
    Thanks for spotting this, Matt!

    This is caused by a refinement in pattern matching within web applications, namely matching via the ServletContext itself rather than via resolution as files (which works in unexpanded WARs too).

    Unfortunately, MockServletContext has not provided an implementation of "getResourcePaths" yet. I've just added such an implementation; will commit it promptly.

    Please give a current snapshot a try!

    Juergen

    Comment


    • #3
      Works great - thanks Juergen.

      Matt

      Comment

      Working...
      X