Studio Visual Editor
XML or Standalone Editor
<munit:set payload="#[]">
</munit:set>
The Set Message Processor provided by MUnit allows you to define Mule messages.
This message processor is normally used at the beginning of an MUnit test, to define the first message to send to the flow being tested.
The example below shows how to define a simple Mule message.
<munit:set payload="#[]">
</munit:set>
Attribute Name | Description |
---|---|
|
Defines the value of the payload’s message. It accepts MEL expressions. If left as a literal, it assumes a string value. |
|
Defines the encoding of the message. This attributes is optional. |
|
Defines the mime type of the message. This attributes is optional. |
If you wish to set the payload to be a Spring bean, you can make use of the MUnit MEL function getBeanFromMuleContext('bean_name') . See Assertion for details.
|
Using the MUnit Set
message processor, you can easily specify the message properties of any scope.
The example below shows how to define one of each property scopes:
<munit:set payload="#[]">
<munit:invocation-properties>
<munit:invocation-property key="key" value="#['value']"/>
</munit:invocation-properties>
<munit:inbound-properties>
<munit:inbound-property key="key" value="#['value']"/>
</munit:inbound-properties>
<munit:session-properties>
<munit:session-property key="key" value="#['value']"/>
</munit:session-properties>
<munit:outbound-properties>
<munit:outbound-property key="key" value="#['value']"/>
</munit:outbound-properties>
</munit:set>
All the properties have the same set of attributes:
Attribute Name | Description |
---|---|
|
The key of the property being set. |
|
The content of the property. It accepts MEL expressions. If left as a literal, it assumes a string value. |
|
Defines the encoding of the message. This attributes is optional. |
|
Defines the mime type of the message. This attributes is optional. |
You can define as many properties per each scope as you need for your test.
If you define two properties in the same scope with the same key, be aware that one would end up overwriting the other. |
In Mule a message payload never contains Null. Instead, Mule has a representation called NullPayload
.
In some scenarios, your test requires you to send such a payload. For these cases, MUnit provides the null-payload
message processor.
<munit:set-null-payload/>