|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.mule.tck.functional.FunctionalTestComponent
public class FunctionalTestComponent
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.
FunctionalTestNotification
via Mule for every message received.
Tests can register with Mule to receive these events by implementing
FunctionalTestNotificationListener
.
EventCallback
,
FunctionalTestNotification
,
FunctionalTestNotificationListener
Nested Class Summary | |
---|---|
static interface |
FunctionalTestComponent.LifecycleCallback
|
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 |
Fields inherited from interface org.mule.api.lifecycle.Startable |
---|
PHASE_NAME |
Fields inherited from interface org.mule.api.lifecycle.Stoppable |
---|
PHASE_NAME |
Constructor Summary | |
---|---|
FunctionalTestComponent()
|
Method Summary | |
---|---|
static void |
addLifecycleCallback(FunctionalTestComponent.LifecycleCallback callback)
|
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. |
String |
getExceptionText()
|
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. |
static void |
removeLifecycleCallback(FunctionalTestComponent.LifecycleCallback callback)
|
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 |
setExceptionText(String text)
|
void |
setExceptionToThrow(Class<? extends Throwable> exceptionToThrow)
|
void |
setId(String id)
|
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)
|
void |
start()
|
void |
stop()
|
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 |
---|
protected transient Log logger
public static final int STREAM_SAMPLE_SIZE
public static final int STREAM_BUFFER_SIZE
Constructor Detail |
---|
public FunctionalTestComponent()
Method Detail |
---|
public void initialise()
Initialisable
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.
initialise
in interface Initialisable
public void start() throws MuleException
start
in interface Startable
MuleException
public void setMuleContext(MuleContext context)
setMuleContext
in interface MuleContextAware
public void stop() throws MuleException
stop
in interface Stoppable
MuleException
public void dispose()
Disposable
dispose
in interface Disposable
public Object onCall(MuleEventContext context) throws Exception
onCall
in interface Callable
context
- the context of the current event being process
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-
setStopFurtherProcessing(true)
wasn't called
on the event context event.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 servicepublic Object onReceive(Object data) throws Exception
MuleEventContext
as
a complex type.
onReceive
in interface Receiveable
data
- the event data received
Exception
protected void throwException() throws Exception
FunctionalTestException
. This methodis only called if
isThrowException()
is true.
FunctionalTestException
- or the exception specified in 'exceptionType
Exception
protected String append(String contents, MuleMessage message)
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.
contents
- the string vlaue of the current message payloadmessage
- the current message
protected Object process(Object data, MuleEventContext context) throws Exception
onCall(org.mule.api.MuleEventContext)
or onReceive(Object)
data
- The message payloadcontext
- the current MuleEventContext
Exception
- if there is a general failure or if isThrowException()
is true.public EventCallback getEventCallback()
FunctionalTestNotificationListener
with Mule and this
will deleiver a FunctionalTestNotification
for every message received by this service
FunctionalTestNotification
,
FunctionalTestNotificationListener
public void setEventCallback(EventCallback eventCallback)
FunctionalTestNotificationListener
with Mule and this
will deleiver a FunctionalTestNotification
for every message received by this service
eventCallback
- the callback to call when a message is receivedFunctionalTestNotification
,
FunctionalTestNotificationListener
public Object getReturnData()
public void setReturnData(Object returnData)
returnData
- the message payload to always return from this service instancepublic boolean isThrowException()
returnData
property is set and is of type
java.lang.Exception, that exception will be thrown.public void setThrowException(boolean throwException)
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.public boolean isEnableMessageHistory()
public void setEnableMessageHistory(boolean enableMessageHistory)
public int getReceivedMessagesCount()
public Object getReceivedMessage(int number)
public Object getLastReceivedMessage()
public String getAppendString()
public void setAppendString(String appendString)
public boolean isEnableNotifications()
public void setEnableNotifications(boolean enableNotifications)
public Class<? extends Throwable> getExceptionToThrow()
public void setExceptionToThrow(Class<? extends Throwable> exceptionToThrow)
public long getWaitTime()
public void setWaitTime(long waitTime)
public boolean isDoInboundTransform()
public void setDoInboundTransform(boolean doInboundTransform)
public boolean isLogMessageDetails()
public void setLogMessageDetails(boolean logMessageDetails)
public String getExceptionText()
public void setExceptionText(String text)
public void setId(String id)
public static void addLifecycleCallback(FunctionalTestComponent.LifecycleCallback callback)
public static void removeLifecycleCallback(FunctionalTestComponent.LifecycleCallback callback)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |