Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Juri Glass
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 17987
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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/).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic