[ http://jira.codehaus.org/browse/MNG-635?page=comments#action_43306 ] 

Brett Porter commented on MNG-635:
----------------------------------

the test classpath is under target/test-classes, or a goal can add additional 
directories to it, but the point I wanted to make here is that it is not really 
the usual way to access WEB-INF. Under a servlet container, you need to use 
getServletContext().getResource instead of getClass().getResource (which looks 
under WEB-INF/classes), so I think it is a good idea to behave similarly here.

Actually, I don't understand how httpunit constructs a whole context with just 
the web.xml file - shouldn't it need the base directory of the whole webapp?

While I usually recommend using classpath resources instead of File's so that 
it runs identically in an IDE, it may be better to pass the location of the 
webapp in to the test using a system property 
(http://maven.apache.org/maven2/plugins/maven-surefire-plugin/test-mojo.html).

Please let me know if I can close this.





> Webapp Resources Not Available to Unit Tests
> --------------------------------------------
>
>          Key: MNG-635
>          URL: http://jira.codehaus.org/browse/MNG-635
>      Project: Maven 2
>         Type: Bug
>   Components: maven-plugins
>     Versions: 2.0-beta-1
>  Environment: Maven version: 2.0-beta-1-SNAPSHOT
> Windows XP
> java version "1.5.0_02"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_02-b09)
> Java HotSpot(TM) Client VM (build 1.5.0_02-b09, mixed mode, sharing) 
>     Reporter: Rod Coffin
>     Priority: Blocker
>  Attachments: MNG-635.txt
>
>
> Unit tests that depend on resources in the webapp directory fail because 
> those resources are not available during the test phase.  This makes it 
> impossible to write tests using tools like HttpUnit that rely on information 
> in web.xml file:
> Ex:
> InputStream webXML = 
> GreeterServlet.class.getResourceAsStream("/WEB-INF/web.xml");
> ServletRunner sr = new ServletRunner(webXML);

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to