Announcement Announcement Module
Collapse
No announcement yet.
How to make tests using 'file:' resources work in project Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to make tests using 'file:' resources work in project

    I am using AbstractDependencyInjectionSpringContextTests for Unit testing, see section 20.2.2. Dependency Injection of test class instances, in the reference manual. Also the application context files use "file:conf/run.properties" to get the properties file for post processing with PropertyPlaceholderConfigurer. So my intent is to just do a ant test at the root of the project and have these tests run.

    The problem is that the structiure of the source tree is different then the deploy structure, so the file: reference is invalid. How is this usually handled? I don't want to change the context files, that would invalidate the tests, and I don't want to change the source structure. Is the only option to 'deploy' to a target structure and then have separate ant build scripts for that purpose?

  • #2
    What is your build environment, Ant, Maven, Eclipse IntelliJ ... Jbuilder ..?

    Have you tried ResourceUtils as well?

    Comment


    • #3
      One thing you could do is use a slightly different PropertyPlaceHolderConfigurer just for the purpose of the test. This is pretty easy to do by adding another XML file fragment to the existing frament(s) making up the definition. If the test one is last, a bean definition inside it will override a definition with the same name in a file that comes ahead of it.

      Comment


      • #4
        Thanks to all. I am going the application xml override. It works.

        Of course, now I'm facing the same issue discussed here: http://forum.springframework.org/viewtopic.php?t=4321 :?

        Comment


        • #5
          that ResourceUtils sounds interesting. One thing I'm wondering is if it is possible to set a 'base path' to a run; then all references are based on that, whether tests or actual runtime. For this to work invisibly it would have to be done deep in the resource handling stuff.

          Originally posted by khagel
          What is your build environment, Ant, Maven, Eclipse IntelliJ ... Jbuilder ..?

          Have you tried ResourceUtils as well?

          Comment

          Working...
          X