Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JUnit test load .properties file when building with ant

807580Apr 25 2010 — edited Apr 26 2010
Hello,

can anyone tell me how could I do unit tests with ant, so that unit test class files could load my .properties file.

My app works great in eclipse, tests and all, but when I am doing ant build, then it fails on unit tests, because it can not locate .properties file.

Myproject
---------+WEB-INF
------------------conf
----------------------+my.properties
------------------classes
------------------------+com.myproj.test.ConfTest.java
------------------------+com.myproj.Conf.Conf.java
------------------myfiles
------------------------+example.xml
Now when I run from eclipse I can get my.properties in Conf class easily.
Other classes get InputStreams to files from Conf class which is utility class.

When working with ant, then those paths don't work.
The only way I got my.properties file was to give path like:
String path = "../../../system.properties"
That means all files should come with "../../../example.xml"
But those paths won-t work in eclipse, only during ant building.

Please help me on this. How can I solve this?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 24 2010
Added on Apr 25 2010
2 comments
2,041 views