#190 filter-mapping with 2 url-pattern elements

open
Wolfgang Fahl
None
5
2012-09-13
2010-11-05
Anonymous
No

I'm using a web.xml with Servlet-Filters. My filter is definened in the following way:
<filter-mapping>
<filter-name>MyFilter</filter-name>
<url-pattern>/one.rpc</url-pattern>
<url-pattern>/another.rpc</url-pattern>
</filter-mapping>

If the Servlet Runner is initialized with the web.xml, a SAXException occurs.

Invocation:
new ServletRunner(new File("src/main/webapp/WEB-INF/web.xml"));

Exception StackTrace:
org.xml.sax.SAXException: Node <filter-mapping> has no child named <url-pattern>
at com.meterware.servletunit.XMLUtils.getChildNodeValue(XMLUtils.java:46)
at com.meterware.servletunit.XMLUtils.getChildNodeValue(XMLUtils.java:37)
at com.meterware.servletunit.WebApplication.registerFilter(WebApplication.java:435)
at com.meterware.servletunit.WebApplication.registerFilters(WebApplication.java:419)
at com.meterware.servletunit.WebApplication.<init>(WebApplication.java:132)
at com.meterware.servletunit.WebApplication.<init>(WebApplication.java:109)
at com.meterware.servletunit.ServletRunner.<init>(ServletRunner.java:66)

If I remove one url-pattern element, ServletRunner is initialized successfully. After looking up the implementation of com.meterware.servletunit.WebApplication.registerFilter in HttpUnit, I'm pretty sure that HttpUnit does not expect more than one url-pattern and can only handle one url-pattern per filter. Because the element count is != '1', the exception is thrown.

It would be very nice to see HttpUnit expanded, so I could test my servlets.

Discussion

  • Wolfgang Fahl
    Wolfgang Fahl
    2012-09-13

    Dear httpunit user!

    Thank you for your bug report. We appreciate the time and effort you are putting into this.

    Please supply a testcase with the expected result for the bug report that you are asking a solution for and we'll look into implementing it. For a start you might want to get the trunk version from the subversion repository (see https://sourceforge.net/svn/?group_id=6550\)
    and have a look at the source code of some of the more than 700 JUnit based testcase in there.

    If you do not use or have subversion tool you can still directly browse our test cases via:
    http://httpunit.svn.sourceforge.net/viewvc/httpunit/trunk/httpunit/test/com/meterware/httpunit/
    Looking into one or more of the Junit Java source files
    should give you a clue on what a proper testcase for httpunit looks like, often you will probably only have to "clone" an existing testcase and modify it slightly to your needs.

    When you are ready you might want to attach the testcase (and if you already have started implementing a solution for it it also the actual code) to the patch section of the sourceforge.net tracker for patches of the httpunit project at
    https://sourceforge.net/tracker/?atid=306550&group_id=6550&func=browse.

    The main communication about further details of the development is via the httpunit developer mailinglist. You are most welcome to sign up via
    https://lists.sourceforge.net/lists/listinfo/httpunit-develop

    Yours
    The httpunit developer team

    (Russell, Wolfgang, Mark, Patrick and Tim as of 2008-04)

     
  • Wolfgang Fahl
    Wolfgang Fahl
    2012-09-13

    • assigned_to: nobody --> wolfgang_fahl
     
  • Wolfgang Fahl
    Wolfgang Fahl
    2012-09-13

    Dear httpunit User

    thank you for your bug report. I'll happily commit the necessary changes. Please supply a testcase and patch as outlined in our developer FAQ.

    Yours
    Wolfgang