Nav
You are viewing an older version of this topic. To go to a different version, use the version menu at the upper-right. +

Set Event Processor

The Set Event Processor allows you to define a Mule Event.
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 payload of a Mule Message:


         
      
1
2
3
<munit:set-event cloneOriginalEvent="false">
  <munit:payload value="#['payload_value']" mediaType="text/plain" encoding="UTF-8"/>
</munit:set-event>

The set-event has the cloneOriginalEvent property. If set to true, it clones the event produced by your code.
By default, the value of this property is false.

The payload element in the Set Event processor has the following attributes:

Attribute Name Description

value

Defines the value of the payload’s message.

encoding

Defines the encoding of the message. This attribute is optional.

mediaType

Defines the mime type of the message. This attribute is optional.

You can also use the Set Event processor to define message attributes and event variables:


         
      
1
2
3
4
5
6
7
8
9
<munit:set-event cloneOriginalEvent="false">
  <munit:payload value="#['payload_value']" mediaType="text/plain" encoding="UTF-8"/>

  <munit:attributes value="attribute_value" />

        <munit:variables>
          <munit:variable key="variable_key" value="variable_value" mediaType="text/plain" encoding="UTF-8"/>
        </munit:variables>
</munit:set-event>

All the properties have the same set of attributes:

Table 1. Property Message Processor’s Attributes
Attribute Name Description

key

The key of the property being set.

value

The content of the property.

encoding

Defines the encoding of the message. This attribute is optional.

mediaType

Defines the mime type of the message. This attribute 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 this topic: