Results 1 to 5 of 5

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

  1. #1
    Join Date
    Aug 2004
    Location
    u.s.a
    Posts
    399

    Default 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. #2
    Join Date
    Nov 2004
    Location
    St. Louis, Missouri USA
    Posts
    33

    Default

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

    Have you tried ResourceUtils as well?

  3. #3
    Join Date
    Aug 2004
    Location
    Toronto, Canada
    Posts
    736

    Default

    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.
    Colin Sampaleanu
    SpringSource - http://www.springsource.com

  4. #4
    Join Date
    Aug 2004
    Location
    u.s.a
    Posts
    399

    Default

    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 :?

  5. #5
    Join Date
    Aug 2004
    Location
    u.s.a
    Posts
    399

    Default

    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.

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

    Have you tried ResourceUtils as well?

Similar Threads

  1. Replies: 5
    Last Post: Mar 17th, 2010, 04:32 AM
  2. Import classpath*:... in xml file does not work
    By swisswheel in forum Container
    Replies: 7
    Last Post: Jun 21st, 2007, 10:39 AM
  3. Saving large files to a db using hibernate?
    By Dan Washusen in forum Data
    Replies: 10
    Last Post: Sep 20th, 2006, 12:18 PM
  4. Cannot reference my spring config files from another project
    By lorelia in forum SpringSource Tool Suite
    Replies: 4
    Last Post: Aug 30th, 2005, 01:52 AM
  5. Replies: 1
    Last Post: Jun 12th, 2005, 08:46 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •