j2eeunit
Class ServletTestCase

java.lang.Object
  |
  +--junit.framework.Assert
        |
        +--junit.framework.TestCase
              |
              +--j2eeunit.ServletTestCase
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
JspTestCase

public class ServletTestCase
extends junit.framework.TestCase

Test classes that need access to valid Servlet implicit objects (such as the the HTTP request, the HTTP response, the servlet config, ...) must subclass this class. It also provides support for beginXXX and endXXX() methods.

Version:
0.9

Field Summary
 ServletConfigWrapper config
          Valid ServletConfig object that you can access from the testXXX(), setUp and tearDown() methods.
 java.lang.String currentTestMethod
          The name of the current test method being executed.
 HttpServletRequestWrapper request
          Valid HttpServletRequest object that you can access from the testXXX(), setUp and tearDown() methods.
 javax.servlet.http.HttpServletResponse response
          Valid HttpServletResponse object that you can access from the testXXX(), setUp and tearDown() methods.
 javax.servlet.http.HttpSession session
          Valid HttpSession object that you can access from the testXXX(), setUp and tearDown() methods.
 
Constructor Summary
ServletTestCase(java.lang.String theName)
          Constructs a JUnit test case with the given name.
 
Method Summary
 void runBare()
          Runs the bare test sequence.
 
Methods inherited from class junit.framework.TestCase
countTestCases, name, run, run, toString
 
Methods inherited from class junit.framework.Assert
assert, assert, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertNotNull, assertNotNull, assertNull, assertNull, assertSame, assertSame, fail, fail
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

request

public HttpServletRequestWrapper request
Valid HttpServletRequest object that you can access from the testXXX(), setUp and tearDown() methods. If you try to access it from either the beginXXX() or endXXX() methods it will have the null value.

response

public javax.servlet.http.HttpServletResponse response
Valid HttpServletResponse object that you can access from the testXXX(), setUp and tearDown() methods. If you try to access it from either the beginXXX() or endXXX() methods it will have the null value.

session

public javax.servlet.http.HttpSession session
Valid HttpSession object that you can access from the testXXX(), setUp and tearDown() methods. If you try to access it from either the beginXXX() or endXXX() methods it will have the null value.

config

public ServletConfigWrapper config
Valid ServletConfig object that you can access from the testXXX(), setUp and tearDown() methods. If you try to access it from either the beginXXX() or endXXX() methods it will have the null value.

currentTestMethod

public java.lang.String currentTestMethod
The name of the current test method being executed. This name is valid both on the client side and on the server side, meaning you can call it from a testXXX(), setUp() or tearDown() method, as well as from beginXXX() and endXXX() methods.
Constructor Detail

ServletTestCase

public ServletTestCase(java.lang.String theName)
Constructs a JUnit test case with the given name.
Parameters:
theName - the name of the test case
Method Detail

runBare

public void runBare()
             throws java.lang.Throwable
Runs the bare test sequence. This method is overridden from the JUnit TestCase class in order to prevent the latter to call the setUp() and tearDown() methods which, in our case, need to be ran in the servlet engine by the servlet redirector class.
Overrides:
runBare in class junit.framework.TestCase
Throws:
java.lang.Throwable - if any exception is thrown


Copyright © 2000-2001 Vincent Massol.