News
Features
Changes
Todo
Contributors

Downloads

Installation
Configuration
Using
Servlet Sample
FAQ

Architecture

Ant integration
Servlet Engines

API Reference

Support
Statistics


J2EEUnit feature list


  • Integrates seamlessly with the JUnit testing framework. Your testing class just has to extend j2eeunit.ServletTestCase or j2eeunit.ServletTestCase (which themselves extends TestCase) instead of extending TestCase directly.
  • Execute your test methods in a servlet/JSP environment, i.e. you have access to the following implicit objects : request ( of type HttpServletRequest), response (of type HttpServletResponse), session (of type HttpSession), config (of type ServletConfig). Moreover you can also have access to 2 additional JSP implicit objects if you need them in your test class : pageContext (of type PageContext) and out (of type JspWriter).
  • Definition of a beginXXX() method for each testXXX() test method. This is for having a chance to initialize the following data that will be available in the HttpServletRequest object in your test method :
    • HTTP parameters,
    • HTTP headers,
    • HTTP cookies,
    • Simulated URL. You can simulate all the parts of a URL : server name, port, context path, servlet path, path info and the query string. The following methods will return the simulated parts :
      • HttpServletRequest.getServerName(),
      • HttpServletRequest.getServerPort(),
      • HttpServletRequest.getRequestURI(),
      • HttpServletRequest.getContextPath(),
      • HttpServletRequest.getServletPath(),
      • HttpServletRequest.getQueryString(),
      • HttpServletRequest.getPathInfo()
  • Definition of an endXXX() method for each testXXX() test method. This is for having a chance to check the following data from the returned HTTP response :
    • HTTP headers,
    • HTTP cookies
  • Predefined Ant 1.3 build scripts that show how to automate J2EEUnit unit tests (automatically starting your servlet engine, running the tests and stopping your server). There are scripts for the following Servlet engines :
    • Tomcat 3.2.1 (Servlet API 2.2)
    • Tomcat 4.0 (Servlet API 2.3)
    • Resin 1.2 (Servlet API 2.2)
    • Resin 1.3 (Servlet API 2.3)
    • WebLogic 5.1 (Servlet API 2.2)
    • Orion 1.4 (Servlet API 2.2 and 2.3)
  • Possibility to modify the URL to which the J2EEUnit Redirector servlet and Redirector JSP are mapped to (defined in a properties file)
  • Possibility to specify whether an HttpSession object will be automatically created or not for your test methods
  • Handles setUp() and tearDown() methods which work the same as for JUnit except that they are run on the server side before and after calling each testXXX() method
  • Integrated with JUnit 3.5
  • Support for Servlet API 2.2 and 2.3 (Support for Servlet API 2.1 has been dropped in J2EEUnit 0.8 because it is now too old).
  • Support for JDK 1.2 or greater.
  • Possibility to assert the returned servlet output stream from classes under test (in the endXXX() methods).
  • Helper classes to help assert cookies returned in the HTTP response, ...
  • Implicit objects are actually subclasses of standard servlet objects and provides additional methods to help unit test your code :
    • Using the config implicit object :
      • setInitParameter(String, String) : sets a parameter as if it were set in the web.xml file using an init-param tag,
      • setServletName(String) : sets the servlet name. This is the value that is returned by a call to getServletName()


Copyright © 2000-2001 Vincent Massol. All Rights Reserved.