File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Resource Filtering issue

 
Jaaouane Aymen
Greenhorn
Posts: 29
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

I have a properties file wich will contain the adresses of the servers that i will send requests to . The properties file will have the good values only when packaging because maven will fill them thanks to its profiles.
So my file looks like this:
travelfusion.ip=${travelfusion.ip}
amadeus.ip=${amadeus.ip}.

So far all is good, but the problem is that i am writing a unit test which must read the ip from the properties file. the test fails because it can not connect to the server because the ${travelfusion.ip} will be returned and not a good value. i am launching the unit test from Eclipse so maven is not in the process and the variables are not replaced by good values.

Must i launch unit tests only by maven? or there is a way to keep the variables in the properties file and writing unit tests which can read good values from the properties file?

Thank you in advance,
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33691
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I feel like there should be a more direct way to do what you want, but one alternative is to read a different physical "dev" file for unit testing. Or have a test more. Or pass the properties into your code.
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would run the test via Maven. In Eclipse you can do Run As | Maven Package, that will both compile the code and run the unit tests, and the filter will have happened.

And I really like the fact that with Maven you don't have to have two sets of properties files, that profiles will handle the differences between production, test and development.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic