In-process Web Integration Tests with Jetty and JWebUnit

Do you speak test? In that case: Hello web application:

This code runs with no application server, no separate deployment step, just like that.

If this looks interesting, see my full-sized article on java.net

Copyright © 2006 Johannes Brodwall. All Rights Reserved.

About Johannes Brodwall

Johannes is Principal Software Engineer in SopraSteria. In his spare time he likes to coach teams and developers on better coding, collaboration, planning and product understanding.
This entry was posted in Java, Software Development. Bookmark the permalink.
  • Kristoffer

    I can't get the example up and running from within my favourite IDE(A) after generating the project files with mvn idea:idea because web.xml is not conformant to the Servlet 2.4 specification.

    Ok, so I know this is a bit childish :) but I guess you've been using some other IDE of which doesn't provide proper XSD validation(?).

    Anyhow, the following fragment (slightly revised) is valid:

    <servlet-mapping>
    <servlet-name>my</servlet-name>
    <url-pattern>/my/*</url-pattern>
    </servlet-mapping>

  • Kristoffer

    I can’t get the example up and running from within my favourite IDE(A) after generating the project files with mvn idea:idea because web.xml is not conformant to the Servlet 2.4 specification.

    Ok, so I know this is a bit childish :) but I guess you’ve been using some other IDE of which doesn’t provide proper XSD validation(?).

    Anyhow, the following fragment (slightly revised) is valid:

    <servlet-mapping>
    <servlet-name>my</servlet-name>
    <url-pattern>/my/*</url-pattern>
    </servlet-mapping>

  • Kristoffer

    One thing worth mentioning (at least for IntelliJ users) is that if you implement tests like Johannes describes in the blog and put them into a sub-module in a multi-module Maven2 project, you will have to explicitly specify the working directory for that module when running the integration test(s). If not you will get FileNotFoundExceptions followed by HTTP 503s for whatever resource you try to hit afterwards.

  • Kristoffer

    One thing worth mentioning (at least for IntelliJ users) is that if you implement tests like Johannes describes in the blog and put them into a sub-module in a multi-module Maven2 project, you will have to explicitly specify the working directory for that module when running the integration test(s). If not you will get FileNotFoundExceptions followed by HTTP 503s for whatever resource you try to hit afterwards.

  • Pingback: Arnljot.com » Bark and CubicTest()

  • http://www.elevinmedia.com Web Development

    i liked you article, the one on java.net, thanks for sharing all the info

  • http://www.elevinmedia.com Web Development

    i guess you are using an IDE which doesn't provide proper XSD validation

  • http://www.brodwall.com/johannes/blog/ jhannes

    Thanks for your comment. XSD validation would indeed find some of the defects (like invalid syntax in JSPs), but leave others behind (like the wrong spelling of a bean property name).

    But more importantly: Discovering bugs is just one reasons to write tests. There are others, and more important ones.

  • http://www.compare-ink-cartridge-retailers.com Printer Supplies

    I hope there is less bugs after the test completion.

  • http://www.craps.fr/ Craps

    Thanks !

  • http://www.bet-way.fr/ Betway

    Thanks, good job !

  • http://www.kissingbearsbaskets.com/ Cartoon Bears

    In general, how often should unit testing, systems integration testing, systems testing and user acceptance testing be done? The scale of the project is a construction of a web portal

  • http://www.nimbuswebdesigns.com/ Web Designer

    I am playing around with this code to get it to work.

    The link to java.net was helpfull. I will post any errors I get.

    I am a noob at this :). So please bare with me.

  • http://www.facebook.com/wayneseymour Wayne Seymour

    I do speak test, and that rocks. I speak maven too, so I’m usually starting jetty with maven for integration testing with the failsafe plugin. This looks fast. Thanks man.

  • http://www.johannesbrodwall.com/ Johannes Brodwall

    Thank you for good feedback.