I have a Java Spring project, configured with Maven. As the amount of unit tests and their configuration files is adding up rapidly, I'm trying to centralize the test configurations to one properties file (the same one, which is used in building the project).
The unit tests are located (relative to the project path, of course) in tree
src/test/java/com (...)
The resource files for those tests are in
src/test/resources(...)
And lastly, the properties file, which the resource file should read, is in directory
src/main/filters
Now, I have a Junit class where I specify the configuration file location like this:
@ContextConfiguration(locations = { "classpath:com/initrode/quartz/SyncManagerJobTest-context.xml"})
In the configuration file SyncManagerJobTest-context.xml there is a line
<context:property-placeholder location="/src/main/filters/deploy.local.properties"/>
This results in the properties file to be read from directory . What I'd like to read is the properties file, which is located under src/main/filters. I tried using ../../ to traverse the directory upwards, but that didn't help. Using classpath: didn't work out either. I could use an absolute path with "file:", but that would require every developer in the project to modify the configuration, which is not good either.
To summarize, the question is: how can I force the configuration file in src/test/resources/ to read the properties file in src/main/filters?
And a related bonus question: when handling files in Java environment, are there other modifiers than "file:" and "classpath:"?