Announcement Announcement Module
No announcement yet.
spring.handlers and spring.schemas in classpath w/o jar Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • spring.handlers and spring.schemas in classpath w/o jar


    I'm working on a spring-based project that uses the namespacing functionality in Spring 2.0. I'm trying to find the ideal unit testing strategy, but have hit a snag due to the spring.handlers and spring.schemas files on which Spring's namespacing functionality depends. My understanding is that these files become classpath resources when my codebase is put into a jar (they exist in META-INF). However, I'm trying to add JUnit tests within the same codebase, and to execute them from within the same context, without having to jar up the codebase and run the tests externally.

    I guess, then, I need to somehow have spring.handlers and spring.schemas as classpath resources when I'm running my tests. Is this possible? BTW, my test classes extend AbstractDependencyInjectionSpringContextTests (I know this is more for "integration testing," but the functionality I'm implementing can only be legitimately tested only using the contents of my spring config file). Anyway, I mention that because I looked into using the onSetUp() hook, but that kicks in only after the ApplicationContext is created-- or fails to load, in this case.

    Thanks in advance for the help-- this is my first post to the spring forums.

  • #2
    Split your test and main sources

    When your tests are in a seperate directory, you can always use your own test reseources (such as spring.schemas and spring.schemas).
    The default project directory structure of Maven 2 encourages this way of working.

    BTW. I am also playing with this namespacing functionallity, but I always get:
    org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'test:testBean'.

    any suggestion ?
    Last edited by pieter_degraeuwe; Jun 14th, 2006, 02:46 AM.


    • #3
      Thanks for the reply, Pieter-- my understanding from the JUnit reading I've been doing is that the preferred practice is to keep tests within the code to be tested (i.e., in a test package underneath the source package). That aside, I would argue that spring.schemas and spring.handlers are not test resources, since they're also required for the regular functioning of the codebase. Nevertheless, it sounds like what you're saying is that the only way for this to work is to have the code jarred up and in the classpath when the test is executed?

      As for the issue you raise, I found this, which might be related (similar stack trace):


      • #4
        I'm not entirely sure, but I think this blogpost ( ) may fix your 'wildcard is strict' problem.


        • #5
          Problem solved !

          Thx !
          The link ( ) was a great help.

          My problem was a mistake in the spring.schemas.

          It must map
          instead of