aspose file tools*
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 Spring in Action this week in the Spring 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: 16140
    
  21

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: (maven, junit) Read files from WEB-INF and test it