public class FunctionalTestProcessor extends org.mule.runtime.api.component.AbstractComponent implements Processor, org.mule.runtime.api.lifecycle.Lifecycle
FunctionalTestProcessor 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.| Modifier and Type | Class and Description |
|---|---|
static interface |
FunctionalTestProcessor.LifecycleCallback |
ReactiveProcessor.ProcessingType| Constructor and Description |
|---|
FunctionalTestProcessor() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addLifecycleCallback(FunctionalTestProcessor.LifecycleCallback callback) |
protected String |
append(String contents,
CoreEvent event)
Will append the value of
getAppendString() to the contents of the message. |
protected FunctionalTestNotification |
buildEventReceivedNotification(org.mule.runtime.api.message.Message message,
CoreEvent replyMessage) |
void |
dispose() |
protected CoreEvent |
doProcess(CoreEvent event)
The service method that implements the test component logic.
|
String |
getAppendString() |
EventCallback |
getEventCallback()
An event callback is called when a message is received by the service.
|
String |
getExceptionText() |
Class<? extends Throwable> |
getExceptionToThrow() |
static FunctionalTestProcessor |
getFromFlow(org.mule.runtime.api.component.location.ConfigurationComponentLocator locator,
String flowName) |
CoreEvent |
getLastReceivedMessage()
If enableMessageHistory = true, returns the last message received by the service in chronological order.
|
ReactiveProcessor.ProcessingType |
getProcessingType() |
CoreEvent |
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() |
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.
|
CoreEvent |
process(CoreEvent event) |
static void |
removeLifecycleCallback(FunctionalTestProcessor.LifecycleCallback callback) |
void |
setAppendString(String appendString) |
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 |
setProcessingType(ReactiveProcessor.ProcessingType processingType) |
void |
setProcessorClass(String processorClass) |
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. |
getAnnotation, getAnnotations, getLocation, getRootContainerLocation, initRootContainerName, setAnnotationspublic void initialise()
throws org.mule.runtime.api.lifecycle.InitialisationException
initialise in interface org.mule.runtime.api.lifecycle.Initialisableorg.mule.runtime.api.lifecycle.InitialisationExceptionpublic void start()
throws org.mule.runtime.api.exception.MuleException
start in interface org.mule.runtime.api.lifecycle.Startableorg.mule.runtime.api.exception.MuleExceptionpublic void stop()
throws org.mule.runtime.api.exception.MuleException
stop in interface org.mule.runtime.api.lifecycle.Stoppableorg.mule.runtime.api.exception.MuleExceptionpublic void dispose()
dispose in interface org.mule.runtime.api.lifecycle.Disposablepublic CoreEvent process(CoreEvent event) throws org.mule.runtime.api.exception.MuleException
protected void throwException()
throws Exception
FunctionalTestException. This methodis only called if isThrowException() is true.FunctionalTestException - or the exception specified in 'exceptionTypeExceptionprotected String append(String contents, CoreEvent event)
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 payloadevent - the current eventprotected CoreEvent doProcess(CoreEvent event) throws Exception
event - the current CoreEventException - if there is a general failure or if isThrowException() is true.protected FunctionalTestNotification buildEventReceivedNotification(org.mule.runtime.api.message.Message message, CoreEvent replyMessage) throws TransformerException
TransformerExceptionpublic EventCallback getEventCallback()
FunctionalTestNotificationListener with Mule and this will deleiver a
FunctionalTestNotification for every message received by this serviceFunctionalTestNotification,
FunctionalTestNotificationListenerpublic void setEventCallback(EventCallback eventCallback)
FunctionalTestNotificationListener with Mule and this will deleiver a
FunctionalTestNotification for every message received by this serviceeventCallback - the callback to call when a message is receivedFunctionalTestNotification,
FunctionalTestNotificationListenerpublic Object getReturnData()
public void setReturnData(Object returnData)
returnData - the message payload to always return from this service instancepublic boolean isThrowException()
getReturnData()
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 getReturnData()
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 CoreEvent getReceivedMessage(int number)
public CoreEvent getLastReceivedMessage()
public String getAppendString()
public void setAppendString(String appendString)
public boolean isEnableNotifications()
public void setEnableNotifications(boolean enableNotifications)
public long getWaitTime()
public void setWaitTime(long waitTime)
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(FunctionalTestProcessor.LifecycleCallback callback)
public static void removeLifecycleCallback(FunctionalTestProcessor.LifecycleCallback callback)
public static FunctionalTestProcessor getFromFlow(org.mule.runtime.api.component.location.ConfigurationComponentLocator locator, String flowName) throws Exception
test:processor from a flow with the provided name.Exceptionpublic void setProcessorClass(String processorClass)
public ReactiveProcessor.ProcessingType getProcessingType()
getProcessingType in interface ReactiveProcessorpublic void setProcessingType(ReactiveProcessor.ProcessingType processingType)
Copyright © 2003–2019 MuleSoft, Inc.. All rights reserved.