This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan 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 Android Security Essentials Live Lessons this week in the Android 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: 15960
    
  19

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/).


Customer surveys are for companies who didn't pay proper attention to begin with.
 
Don't get me started about those stupid light bulbs.
 
subject: (maven, junit) Read files from WEB-INF and test it
 
Similar Threads
Struts 2 tutorial errors
"Failed to load ApplicationContext" exception when trying to run JUnit Spring test
JUnit test for class dependent on being JAR'ed
mavn and specific jars
project structure for maven 2