| Namespace | http://www.mulesoft.org/schema/mule/mock |
|---|---|
| Schema Location | http://www.mulesoft.org/schema/mule/mock/1.0/mule-mock.xsd |
| Version | 1.0 |
| Minimum Mule Version | 3.2 |
Module for Mocking devkit Modules.
With this module you can mock using mockito framework all the modules that are written with Mule Devkit.
In order to be able to mock a module it has to be declare with a reference name. For example:
Otherwise the module/connector will not be accessible by a reference name and will not be able to be mocked.
| Configuration | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Configure an instance of this module
| |||||||||||
| Message Processors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Define what the mock must return on a message processor call. | |||||||||||
Expect to throw an exception when message processor is called. | |||||||||||
Throw an Exception when a connector tries to connect.
| |||||||||||
Reset mock behaviour
| |||||||||||
Check that the message processor was called with some specified parameters
| |||||||||||
To use the this module within a flow the namespace to the module must be included. The resulting flow will look similar to the following:
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mock="http://www.mulesoft.org/schema/mule/mock"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/core
http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/mock
http://www.mulesoft.org/schema/mule/mock/1.0/mule-mock.xsd">
<!-- here goes your flows and configuration elements -->
</mule>
This module is configured using the config element. This element must be placed outside of your flows and at the root of your Mule application. You can create as many configurations as you deem necesary as long as each carries its own name.
Each message processor, message source or transformer carries a config-ref attribute that allows the invoker to specify which configuration to use.
| Attributes | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Type | Name | Default Value | Description | Optional. Give a name to this configuration so it can be later referenced. | |||||||
Component that we want to mock. |
|||||||||||
Define what the mock must return on a message processor call.
If the message processor doesn't return any value then there is no need to define an expect.
You can define the message processor parameters in the same order they appear in the API documentation. In order to define the behaviour on that particular case.
INCLUDE_ERROR
| Name | Default Value | Description |
|---|---|---|
| Optional. Specify which configuration to use. | ||
| Message processor name. | ||
| Optional. Expected return value. | ||
| Optional. The flow name that creates the expected result |
Expect to throw an exception when message processor is called.
INCLUDE_ERROR
| Name | Default Value | Description |
|---|---|---|
| Optional. Specify which configuration to use. | ||
| Message processor name. | ||
| Java Exception full qualified name. |
Throw an Exception when a connector tries to connect.
INCLUDE_ERROR
| Name | Default Value | Description |
|---|---|---|
| Optional. Specify which configuration to use. |
Reset mock behaviour
INCLUDE_ERROR
| Name | Default Value | Description |
|---|---|---|
| Optional. Specify which configuration to use. |
Check that the message processor was called with some specified parameters
INCLUDE_ERROR
| Name | Default Value | Description |
|---|---|---|
| Optional. Specify which configuration to use. | ||
| Message processor Id | ||
| Optional. Number of times the message processor has to be called | ||
| Optional. Number of time the message processor has to be called at least. | ||
| Optional. Number of times the message processor has to be called at most. |