Getting started Community Training Tutorials Documentation APIs, AI & Tools
<set-payload
value="#[MunitTools::getResourceAsStream('util/files/example.txt')]"/>
MUnit resource matchers are utility functions that read test resource files and create Mule messages during a MUnit test. Use them to load file contents as streams, strings, or byte arrays, and to inspect queue sizes in your test validations.
Returns the resource from the path String as a stream.
<set-payload
value="#[MunitTools::getResourceAsStream('util/files/example.txt')]"/>
Returns the resource from the path String as a reusable stream.
<set-payload
value="#[MunitTools::getResourceAsReusableStream('util/files/example.txt')]"/>
Returns the resource from the path String as a String, where the second parameter (encoding) is optional.
<set-payload
value="#[MunitTools::getResourceAsString('util/files/example.txt')]"/>
You can also specify the encoding:
<set-payload
value="#[MunitTools::getResourceAsString('util/files/exampleISO.txt', 'ISO-8859-1')]"/>
Returns the resource from the path String as a byte array.
<set-payload
value="#[MunitTools::getResourceAsByteArray('util/files/example.txt')]"/>
Returns the size of the queue specified inside #[MunitTools::queueSize()].
For example, to assert the size of a queue named QUEUE_SIZE:
<munit:execution>
<munit-tools:queue queueName="QUEUE_SIZE">
<munit-tools:value>#['EXAMPLE']</munit-tools:value>
</munit-tools:queue>
</munit:execution>
<munit:validation>
<munit-tools:assert-that expression="#[MunitTools::queueSize('QUEUE_SIZE')]" is="#[MunitTools::equalTo(1)]"/>
</munit:validation>
Creates a Mule message with the specified attributes.
<munit:execution>
<set-payload value="#[MunitTools::createMessage( 'ITEM-1', 'text/plain', { property : 'ATTRIBUTE-1'}, null )]"/>
</munit:execution>