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.mule.tck.functional
Class FunctionalTestComponent

    java.lang.Object
      org.mule.tck.functional.FunctionalTestComponent

All Implemented Interfaces:
  MuleContextAware, Callable, Disposable, EventListener, Initialisable, Receiveable

Direct Known Subclasses:
  TestServiceComponent, TransactionalFunctionalTestComponent

    public class FunctionalTestComponent

extends Object
implements Callable, Initialisable, Disposable, MuleContextAware, Receiveable

`FunctionalTestComponent` is a service that can be used by functional tests. This service accepts an EventCallback that can be used to assert the state of the current event.

Also, this service fires `FunctionalTestNotification` via Mule for every message received. Tests can register with Mule to receive these events by implementing `FunctionalTestNotificationListener`.

See Also:
  `EventCallback`, `FunctionalTestNotification`, `FunctionalTestNotificationListener`

Field Summary
`protected Log` | `logger`
`static int` | `STREAM_BUFFER_SIZE`
`static int` | `STREAM_SAMPLE_SIZE`

Fields inherited from interface org.mule.api.lifecycle.Initialisable
`PHASE_NAME`

Fields inherited from interface org.mule.api.lifecycle.Disposable
`PHASE_NAME`

Constructor Summary
`FunctionalTestComponent()`

Method Summary
`protected String` | `append(String contents, MuleMessage message)` Will append the value of `getAppendString()` to the contents of the message.
`void` | `dispose()` A lifecycle method where implementor should free up any resources.
`String` | `getAppendString()`
`EventCallback` | `getEventCallback()` An event callback is called when a message is received by the service.
`Class<? extends Throwable>` | `getExceptionToThrow()`
`Object` | `getLastReceivedMessage()` If enableMessageHistory = true, returns the last message received by the service in chronological order.
`Object` | `getReceivedMessage(int number)` If enableMessageHistory = true, returns a message received by the service in chronological order.
`int` | `getReceivedMessagesCount()` If enableMessageHistory = true, returns the number of messages received by this service.
`Object` | `getReturnData()` Often you will may want to return a fixed message payload to simulate and external system call.
`long` | `getWaitTime()`
`void` | `initialise()` Method used to perform any initialisation work.
`boolean` | `isDoInboundTransform()`
`boolean` | `isEnableMessageHistory()`
`boolean` | `isEnableNotifications()`
`boolean` | `isLogMessageDetails()`
`boolean` | `isThrowException()` Sometimes you will want the service to always throw an exception, if this is the case you can set the 'throwException' property to true.
`Object` | `onCall(MuleEventContext context)` Passes the event to the listener
`Object` | `onReceive(Object data)` This method is used by some WebServices tests where you don' want to be introducing the `MuleEventContext` as a complex type.
`protected Object` | `process(Object data, MuleEventContext context)` The service method that implements the test component logic.
`void` | `setAppendString(String appendString)`
`void` | `setDoInboundTransform(boolean doInboundTransform)`
`void` | `setEnableMessageHistory(boolean enableMessageHistory)`
`void` | `setEnableNotifications(boolean enableNotifications)`
`void` | `setEventCallback(EventCallback eventCallback)` An event callback is called when a message is received by the service.
`void` | `setExceptionToThrow(Class<? extends Throwable> exceptionToThrow)`
`void` | `setLogMessageDetails(boolean logMessageDetails)`
`void` | `setMuleContext(MuleContext context)`
`void` | `setReturnData(Object returnData)` Often you will may want to return a fixed message payload to simulate and external system call.
`void` | `setThrowException(boolean throwException)` Sometimes you will want the service to always throw an exception, if this is the case you can set the 'throwException' property to true.
`void` | `setWaitTime(long waitTime)`
`protected void` | `throwException()` Always throws a `FunctionalTestException`.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### logger

    protected transient Log logger

### STREAM_SAMPLE_SIZE

    public static final int STREAM_SAMPLE_SIZE

See Also:
  Constant Field Values

### STREAM_BUFFER_SIZE

    public static final int STREAM_BUFFER_SIZE

See Also:
  Constant Field Values

Constructor Detail

### FunctionalTestComponent

    public FunctionalTestComponent()

Method Detail

### initialise

    public void initialise()

  Description copied from interface: `Initialisable`
  Method used to perform any initialisation work. If a fatal error occurs during initialisation an `InitialisationException` should be thrown, causing the Mule instance to shutdown. If the error is recoverable, say by retrying to connect, a `RecoverableException` should be thrown. There is no guarantee that by throwing a Recoverable exception that the Mule instance will not shut down.

  Specified by:
    `initialise` in interface `Initialisable`

### setMuleContext

    public void setMuleContext(MuleContext context)

  Specified by:
    `setMuleContext` in interface `MuleContextAware`

### dispose

    public void dispose()

  Description copied from interface: `Disposable`
  A lifecycle method where implementor should free up any resources. If an exception is thrown it should just be logged and processing should continue. This method should not throw Runtime exceptions.

  Specified by:
    `dispose` in interface `Disposable`

### onCall

    public Object onCall(MuleEventContext context)
                  throws Exception

  Passes the event to the listener

  Specified by:
    `onCall` in interface `Callable`
  Parameters:
    `context` - the context of the current event being process
  Returns:
    Object this object can be anything. When the `LifecycleAdapter` for the service receives this object it will first see if the Object is an `MuleMessage` if not and the Object is not null a new message will be created using the returned object as the payload. This new event will then get published via the configured outbound router if-
    1. One has been configured for the component.
    2. the `setStopFurtherProcessing(true)` wasn't called on the event context event.
  Throws:
    `Exception` - if the event fails to process properly. If exceptions aren't handled by the implementation they will be handled by the exceptionListener associated with the service

### onReceive

    public Object onReceive(Object data)
                     throws Exception

  This method is used by some WebServices tests where you don' want to be introducing the `MuleEventContext` as a complex type.

  Specified by:
    `onReceive` in interface `Receiveable`
  Parameters:
    `data` - the event data received
  Returns:
    the processed message
  Throws:
    `Exception`

### throwException

    protected void throwException()
                           throws Exception

  Always throws a `FunctionalTestException`. This methodis only called if `isThrowException()` is true.

  Throws:
    `FunctionalTestException` - or the exception specified in 'exceptionType
    `Exception`

### append

    protected String append(String contents,
                            MuleMessage message)

  Will append the value of `getAppendString()` to the contents of the message. This has a side affect that the inbound message will be converted to a string and the return payload will be a string. Note that the value of `getAppendString()` can contain expressions.

  Parameters:
    `contents` - the string vlaue of the current message payload
    `message` - the current message
  Returns:
    a concatenated string of the current payload and the appendString

### process

    protected Object process(Object data,
                             MuleEventContext context)
                      throws Exception

  The service method that implements the test component logic. This method can be called publically through either `onCall(org.mule.api.MuleEventContext)` or `onReceive(Object)`

  Parameters:
    `data` - The message payload
    `context` - the current `MuleEventContext`
  Returns:
    a new message payload according to the configuration of the component
  Throws:
    `Exception` - if there is a general failure or if `isThrowException()` is true.

### getEventCallback

    public EventCallback getEventCallback()

  An event callback is called when a message is received by the service. An MuleEvent callback isn't strictly required but it is usfal for performing assertions on the current message being received. Note that the FunctionalTestComponent should be made a singleton when using MuleEvent callbacks

  Another option is to register a `FunctionalTestNotificationListener` with Mule and this will deleiver a `FunctionalTestNotification` for every message received by this service

  Returns:
    the callback to call when a message is received
  See Also:
    `FunctionalTestNotification`, `FunctionalTestNotificationListener`

### setEventCallback

    public void setEventCallback(EventCallback eventCallback)

  An event callback is called when a message is received by the service. An MuleEvent callback isn't strictly required but it is usfal for performing assertions on the current message being received. Note that the FunctionalTestComponent should be made a singleton when using MuleEvent callbacks

  Another option is to register a `FunctionalTestNotificationListener` with Mule and this will deleiver a `FunctionalTestNotification` for every message received by this service

  Parameters:
    `eventCallback` - the callback to call when a message is received
  See Also:
    `FunctionalTestNotification`, `FunctionalTestNotificationListener`

### getReturnData

    public Object getReturnData()

  Often you will may want to return a fixed message payload to simulate and external system call. This can be done using the 'returnData' property. Note that you can return complex objects by using the element in the Xml configuration.

  Returns:
    the message payload to always return from this service instance

### setReturnData

    public void setReturnData(Object returnData)

  Often you will may want to return a fixed message payload to simulate and external system call. This can be done using the 'returnData' property. Note that you can return complex objects by using the element in the Xml configuration.

  Parameters:
    `returnData` - the message payload to always return from this service instance

### isThrowException

    public boolean isThrowException()

  Sometimes you will want the service to always throw an exception, if this is the case you can set the 'throwException' property to true.

  Returns:
    throwException true if an exception should always be thrown from this instance. If the `returnData` property is set and is of type java.lang.Exception, that exception will be thrown.

### setThrowException

    public void setThrowException(boolean throwException)

  Sometimes you will want the service to always throw an exception, if this is the case you can set the 'throwException' property to true.

  Parameters:
    `throwException` - true if an exception should always be thrown from this instance. If the `returnData` property is set and is of type java.lang.Exception, that exception will be thrown.

### isEnableMessageHistory

    public boolean isEnableMessageHistory()

### setEnableMessageHistory

    public void setEnableMessageHistory(boolean enableMessageHistory)

### getReceivedMessagesCount

    public int getReceivedMessagesCount()

  If enableMessageHistory = true, returns the number of messages received by this service.

  Returns:
    -1 if no message history, otherwise the history size

### getReceivedMessage

    public Object getReceivedMessage(int number)

  If enableMessageHistory = true, returns a message received by the service in chronological order. For example, getReceivedMessage(1) returns the first message received by the service, getReceivedMessage(2) returns the second message received by the service, etc.

### getLastReceivedMessage

    public Object getLastReceivedMessage()

  If enableMessageHistory = true, returns the last message received by the service in chronological order.

### getAppendString

    public String getAppendString()

### setAppendString

    public void setAppendString(String appendString)

### isEnableNotifications

    public boolean isEnableNotifications()

### setEnableNotifications

    public void setEnableNotifications(boolean enableNotifications)

### getExceptionToThrow

    public Class<? extends Throwable> getExceptionToThrow()

### setExceptionToThrow

    public void setExceptionToThrow(Class<? extends Throwable> exceptionToThrow)

### getWaitTime

    public long getWaitTime()

### setWaitTime

    public void setWaitTime(long waitTime)

### isDoInboundTransform

    public boolean isDoInboundTransform()

### setDoInboundTransform

    public void setDoInboundTransform(boolean doInboundTransform)

### isLogMessageDetails

    public boolean isLogMessageDetails()

### setLogMessageDetails

    public void setLogMessageDetails(boolean logMessageDetails)

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 © 2003-2010 MuleSoft, Inc.. All Rights Reserved.