org.apache.cactus
Class ServletTestCase

java.lang.Object
  extended byjunit.framework.Assert
      extended byjunit.framework.TestCase
          extended byorg.apache.cactus.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.

Version:
$Id: ServletTestCase.java,v 1.15 2003/07/12 19:31:41 vmassol Exp $
Author:
Vincent Massol

Field Summary
 ServletConfigWrapper config
          Valid ServletConfig object that you can access from the testXXX(), setUp and tearDown() methods.
 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()
          Default constructor defined in order to allow creating Test Case without needing to define constructor (new feature in JUnit 3.8.1).
ServletTestCase(java.lang.String theName)
          Constructs a JUnit test case with the given name.
ServletTestCase(java.lang.String theName, junit.framework.Test theTest)
          Wraps a pure JUnit Test Case in a Cactus Test Case.
 
Method Summary
 void runBare()
          Runs the bare test (either on the client side or on the server side).
protected  void runTest()
          Runs a test case.
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, setName, setUp, tearDown, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, 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.

Constructor Detail

ServletTestCase

public ServletTestCase()
Default constructor defined in order to allow creating Test Case without needing to define constructor (new feature in JUnit 3.8.1). Should only be used with JUnit 3.8.1 or greater.

Since:
1.5

ServletTestCase

public ServletTestCase(java.lang.String theName)
Constructs a JUnit test case with the given name.

Parameters:
theName - the name of the test case

ServletTestCase

public ServletTestCase(java.lang.String theName,
                       junit.framework.Test theTest)
Wraps a pure JUnit Test Case in a Cactus Test Case.

Parameters:
theName - the name of the test
theTest - the Test Case class to wrap
Since:
1.5
Method Detail

runBare

public void runBare()
             throws java.lang.Throwable
Runs the bare test (either on the client side or on the server side). This method is overridden from the JUnit TestCase class in order to prevent the latter to immediatly call the setUp() and tearDown() methods which, in our case, need to be executed on the server side.

Throws:
java.lang.Throwable - if any exception is thrown during the test. Any exception will be displayed by the JUnit Test Runner

runTest

protected void runTest()
                throws java.lang.Throwable
Runs a test case. This method is overriden from the JUnit TestCase class in order to seamlessly call the Cactus redirector on the client side and the test on the server side.

Throws:
java.lang.Throwable - if any error happens during the execution of the test


Copyright © 2000-2003 Apache Software Foundation. All Rights Reserved.