org.apache.cactus.internal.client
Class ClientTestCaseDelegate

java.lang.Object
  extended byjunit.framework.Assert
      extended byorg.apache.cactus.internal.client.ClientTestCaseDelegate
Direct Known Subclasses:
WebClientTestCaseDelegate

public class ClientTestCaseDelegate
extends junit.framework.Assert

Delegate class that provides useful methods for the Cactus XXXTestCase classes. All the methods provided are independent of any communication protocol between client side and server side (HTTP, JMS, etc). Subclasses will define additional behaviour that depends on the protocol. It provides the ability to run common code before each test on the client side (note that calling common tear down code is delegated to child classes as the method signature depends on the protocol used). In addition it provides the ability to execute some one time (per-JVM) initialisation code (a pity this is not provided in JUnit). It can be useful to start an embedded server for example. Note: In the future this should be refatored and provided using a custom JUnit TestSuite.

Version:
$Id: ClientTestCaseDelegate.java,v 1.2 2003/07/14 10:10:37 vmassol Exp $
Author:
Vincent Massol

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
ClientTestCaseDelegate(junit.framework.Test theDelegatedTest, junit.framework.Test theWrappedTest, Configuration theConfiguration)
           
 
Method Summary
 void callBeginMethod(Request theRequest)
          Call the test case begin method.
protected  void callClientGlobalBegin(Request theRequest)
          Call the global begin method.
protected  java.lang.String getBeginMethodName()
           
 Configuration getConfiguration()
           
protected  java.lang.String getCurrentTestMethod()
          Deprecated. Use getCurrentTestName() instead
protected  java.lang.String getCurrentTestName()
           
 junit.framework.Test getDelegatedTest()
           
protected  java.lang.String getEndMethodName()
           
 org.apache.commons.logging.Log getLogger()
           
 junit.framework.Test getWrappedTest()
           
 java.lang.String getWrappedTestName()
           
 boolean isWrappingATest()
           
 void runBareInit()
          Perform client side initializations before each test, such as re-initializating the logger and printing some logging information.
 void setConfiguration(Configuration theConfiguration)
          Sets the Cactus configuration * @param theConfiguration the Cactus configuration
 void setDelegatedTest(junit.framework.Test theDelegatedTest)
           
protected  void setLogger(org.apache.commons.logging.Log theLogger)
           
 void setWrappedTest(junit.framework.Test theWrappedTest)
           
 
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, 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

ClientTestCaseDelegate

public ClientTestCaseDelegate(junit.framework.Test theDelegatedTest,
                              junit.framework.Test theWrappedTest,
                              Configuration theConfiguration)
Parameters:
theDelegatedTest - the test we are delegating for
theWrappedTest - the test being wrapped by this delegate (or null if none)
theConfiguration - the configuration to use
Method Detail

setWrappedTest

public void setWrappedTest(junit.framework.Test theWrappedTest)
Parameters:
theWrappedTest - the pure JUnit test that we need to wrap

setDelegatedTest

public void setDelegatedTest(junit.framework.Test theDelegatedTest)
Parameters:
theDelegatedTest - the test we are delegating for

getWrappedTest

public junit.framework.Test getWrappedTest()
Returns:
the wrapped JUnit test

getDelegatedTest

public junit.framework.Test getDelegatedTest()
Returns:
the test we are delegating for

getLogger

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

setLogger

protected void setLogger(org.apache.commons.logging.Log theLogger)
Parameters:
theLogger - the logger to use

getConfiguration

public Configuration getConfiguration()
Returns:
the Cactus configuration

setConfiguration

public void setConfiguration(Configuration theConfiguration)
Sets the Cactus configuration * @param theConfiguration the Cactus configuration


getBeginMethodName

protected java.lang.String getBeginMethodName()
Returns:
the name of the test begin method to call that initialize the test by initializing the WebRequest object for the test case.

getEndMethodName

protected java.lang.String getEndMethodName()
Returns:
the name of the test end method to call when the test has been run on the server. It can be used to verify returned headers, cookies, ...

runBareInit

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


callClientGlobalBegin

protected void callClientGlobalBegin(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

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.

getCurrentTestMethod

protected java.lang.String getCurrentTestMethod()
Deprecated. Use getCurrentTestName() instead

See Also:
getCurrentTestName()

getCurrentTestName

protected java.lang.String getCurrentTestName()
Returns:
the name of the current test case being executed (it corresponds to the name of the test method with the "test" prefix removed. For example, for "testSomeTestOk" would return "someTestOk".

getWrappedTestName

public java.lang.String getWrappedTestName()
Returns:
The wrapped test name, if any (null otherwise).

isWrappingATest

public boolean isWrappingATest()
Returns:
whether this test case wraps another


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