org.apache.cactus.internal.client
Class ClientTestCaseCaller

java.lang.Object
  extended by junit.framework.Assert
      extended by org.apache.cactus.internal.client.ClientTestCaseCaller

public class ClientTestCaseCaller
extends junit.framework.Assert

Provides the ability to run common code before and after each test on the client side. All the methods provided are independent of any communication protocol between client side and server side (HTTP, JMS, etc). Any protocol dependent methods must be provided and implemented in the ProtocolHandler implementation class.

Version:
$Id: ClientTestCaseCaller.java 238991 2004-05-22 11:34:50Z vmassol $

Field Summary
protected static java.lang.String BEGIN_METHOD_PREFIX
          The prefix of a begin test method.
protected static java.lang.String CLIENT_GLOBAL_BEGIN_METHOD
          The name of the method that is called before each test on the client side (if it exists).
protected static java.lang.String CLIENT_GLOBAL_END_METHOD
          The name of the method that is called after each test on the client side (if it exists).
protected static java.lang.String END_METHOD_PREFIX
          The prefix of an end test method.
protected static java.lang.String TEST_METHOD_PREFIX
          The prefix of a test method.
 
Constructor Summary
ClientTestCaseCaller(junit.framework.Test theDelegatedTest, junit.framework.Test theWrappedTest, ProtocolHandler theProtocolHandler)
           
 
Method Summary
 void callBeginMethod(Request theRequest)
          Call the test case begin method.
 java.lang.Object callEndMethod(Request theRequest, ResponseObjectFactory theResponseFactory)
          Call the test case end method.
 void callGlobalBeginMethod(Request theRequest)
          Call the global begin method.
 org.apache.commons.logging.Log getLogger()
           
 void runBareInit()
          Perform client side initializations before each test, such as re-initializating the logger and printing some logging information.
 void runTest()
          Execute begin and end methods and calls the different ProtocolHandler lifecycle methods to execute the test on the server side.
 
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, failNotEquals, failNotSame, failSame
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TEST_METHOD_PREFIX

protected static final java.lang.String TEST_METHOD_PREFIX
The prefix of a test method.

See Also:
Constant Field Values

BEGIN_METHOD_PREFIX

protected static final java.lang.String BEGIN_METHOD_PREFIX
The prefix of a begin test method.

See Also:
Constant Field Values

END_METHOD_PREFIX

protected static final java.lang.String END_METHOD_PREFIX
The prefix of an end test method.

See Also:
Constant Field Values

CLIENT_GLOBAL_BEGIN_METHOD

protected static final java.lang.String CLIENT_GLOBAL_BEGIN_METHOD
The name of the method that is called before each test on the client side (if it exists).

See Also:
Constant Field Values

CLIENT_GLOBAL_END_METHOD

protected static final java.lang.String CLIENT_GLOBAL_END_METHOD
The name of the method that is called after each test on the client side (if it exists).

See Also:
Constant Field Values
Constructor Detail

ClientTestCaseCaller

public ClientTestCaseCaller(junit.framework.Test theDelegatedTest,
                            junit.framework.Test theWrappedTest,
                            ProtocolHandler theProtocolHandler)
Parameters:
theDelegatedTest - the test we are delegating for
theWrappedTest - the test being wrapped by this delegate (or null if none)
theProtocolHandler - the protocol handler to use to execute the tests on the server side
Method Detail

runTest

public void runTest()
             throws java.lang.Throwable
Execute begin and end methods and calls the different ProtocolHandler lifecycle methods to execute the test on the server side. Note that this method is overriden from the JUnit TestCase class in order to prevent JUnit from calling the TestCase.setUp() and TestCase.tearDown() methods on the client side. instead we are calling the server redirector proxy and the setup and teardown methods will be executed on the server side.

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

getLogger

public final org.apache.commons.logging.Log getLogger()
Returns:
The logger used by the TestCase class and subclasses to perform logging.

runBareInit

public void runBareInit()
Perform client side initializations before each test, such as re-initializating the logger and printing some logging information.


callBeginMethod

public void callBeginMethod(Request theRequest)
                     throws java.lang.Throwable
Call the test case begin method.

Parameters:
theRequest - the request object to pass to the begin method.
Throws:
java.lang.Throwable - any error that occurred when calling the begin method for the current test case.

callEndMethod

public java.lang.Object callEndMethod(Request theRequest,
                                      ResponseObjectFactory theResponseFactory)
                               throws java.lang.Throwable
Call the test case end method.

Parameters:
theRequest - the request data that were used to open the connection.
theResponseFactory - the factory to use to return response objects.
Returns:
the created Reponse object
Throws:
java.lang.Throwable - any error that occurred when calling the end method for the current test case.

callGlobalBeginMethod

public void callGlobalBeginMethod(Request theRequest)
                           throws java.lang.Throwable
Call the global begin method. This is the method that is called before each test if it exists. It is called on the client side only.

Parameters:
theRequest - the request object which will contain data that will be used to connect to the Cactus server side redirectors.
Throws:
java.lang.Throwable - any error that occurred when calling the method


Copyright © 2001-2009 The Apache Software Foundation. All Rights Reserved.