This week's book giveaway is in the JavaFX forum.
We're giving away four copies of Introducing JavaFX 8 Programming and have Herbert Schildt on-line!
See this thread for details.
The moose likes Ant, Maven and Other Build Tools and the fly likes (maven, junit) Read files from WEB-INF and test it Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Introducing JavaFX 8 Programming this week in the JavaFX forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "(maven, junit) Read files from WEB-INF and test it" Watch "(maven, junit) Read files from WEB-INF and test it" New topic
Author

(maven, junit) Read files from WEB-INF and test it

Juri Glass
Greenhorn

Joined: Jul 01, 2009
Posts: 6
Hi

I have a maven2 project which builds me a war file to run in a glassfish. Now I want to read from a file located in WEB-INF (can be moved if necessary).

In a servlet I can do:

How to test that with a JUnit 4.7 testcase?
How to refer to the files in WEB-INF in the JUnit tests? How do I set the context?

The maven project has this structure (shortened):

Best Juri

EDIT: Typo
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17142
    
  27

You don't have a webapp context in jUnit. For that you either need to be running in a J2EE container or something that simulates one.

You might want to look at Cactus (http://jakarta.apache.org/cactus/).


An IDE is no substitute for an Intelligent Developer.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: (maven, junit) Read files from WEB-INF and test it
 
It's not a secret anymore!