Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.cactus.spi.client.connector
Interface ProtocolHandler

All Known Implementing Classes:
  HttpProtocolHandler

public interface ProtocolHandler

Any communication protocol (e.g HTTP) used to connect between Cactus client side and Cactus server side must implement this lifecycle interface. This interface is part of the connector SPI. Here is the lifecycle followed by Cactus core:

- Call `createRequest()` to create a request object that will be passed to the `begin()` and `beginXXX()` methods. They will in turn enrich it with values set by the user.
- Call `begin()` and `beginXXX()` methods.
- Call `runTest(junit.framework.Test, junit.framework.Test, org.apache.cactus.Request)` to execute the tests.
- Call `createResponseObjectFactory(org.apache.cactus.spi.client.connector.ProtocolState)` to create a factory that is used to create a test response object that will be passed to the `endXXX()` and `end()` methods.
- Call `endXXX()` and `end()` methods.
- Call `afterTest(org.apache.cactus.spi.client.connector.ProtocolState)` to let the connector implementor clean up after the test. For example, the HTTP connector implementation closes the HTTP connection if the user has not closed it himself.

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

Method Summary
`void` | `afterTest(ProtocolState theState)` Let the connector implementor clean up after the test.
`Request` | `createRequest()` Create a request object that will be passed to the `begin()` and `beginXXX()` methods.
`ResponseObjectFactory` | `createResponseObjectFactory(ProtocolState theState)` Create a factory that is used by the core to create test response object that will be passed to the `endXXX()` and `end()` methods.
`ProtocolState` | `runTest(junit.framework.Test theDelegatedTest, junit.framework.Test theWrappedTest, Request theRequest)` Connect to the server side (to the redirector proxy), passing all information to execute the test there, trigger the test execution and gather the test results.

Method Detail

### createRequest

    public Request createRequest()

  Create a request object that will be passed to the `begin()` and `beginXXX()` methods. They will in turn enrich it with values set by the user.

  Returns:
    the request object

### runTest

    public ProtocolState runTest(junit.framework.Test theDelegatedTest,
                                 junit.framework.Test theWrappedTest,
                                 Request theRequest)
                          throws java.lang.Throwable

  Connect to the server side (to the redirector proxy), passing all information to execute the test there, trigger the test execution and gather the test results.

  Parameters:
    `theDelegatedTest` - the Cactus test to execute
    `theWrappedTest` - optionally specify a pure JUnit test case that is being wrapped and will be executed on the server side
    `theRequest` - the request containing data to connect to the redirector proxy
  Returns:
    an object holding state information that should be preserved and that will be passed to `createResponseObjectFactory(org.apache.cactus.spi.client.connector.ProtocolState)` and `afterTest(org.apache.cactus.spi.client.connector.ProtocolState)` later on
  Throws:
    `java.lang.Throwable` - any error that occurred when connecting to the server side, when executing the test or when gathering the test result.

### createResponseObjectFactory

    public ResponseObjectFactory createResponseObjectFactory(ProtocolState theState)

  Create a factory that is used by the core to create test response object that will be passed to the `endXXX()` and `end()` methods.

  Parameters:
    `theState` - any state information that has been preserved from the `runTest(junit.framework.Test, junit.framework.Test, org.apache.cactus.Request)` method (e.g. the HTTP connection object)
  Returns:
    the response object factory

### afterTest

    public void afterTest(ProtocolState theState)
                   throws java.lang.Exception

  Let the connector implementor clean up after the test. For example, the HTTP connector implementation closes the HTTP connection if the user has not closed it himself.

  Parameters:
    `theState` - any state information that has been preserved from the `runTest(junit.framework.Test, junit.framework.Test, org.apache.cactus.Request)` method (e.g. the HTTP connection object)
  Throws:
    `java.lang.Exception` - on error

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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