• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Resource Filtering issue

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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,
 
author & internet detective
Posts: 41967
911
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
You guys wanna see my fabulous new place? Or do you wanna look at this tiny ad?
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic