aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes Resource Filtering issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Resource Filtering issue" Watch "Resource Filtering issue" New topic
Author

Resource Filtering issue

Jaaouane Aymen
Greenhorn

Joined: Sep 22, 2009
Posts: 29
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30526
    
150

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5827
    
    7

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.


JBoss In Action
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Resource Filtering issue