Resource Matchers

getResourceAsStream(String)

Returns the resource from the path String as a stream.

Example
<set-payload
  value="#[MunitTools::getResourceAsStream('util/files/example.txt')]"/>

getResourceAsReusableStream(String)

Returns the resource from the path String as a reusable stream.

Example
 <set-payload
   value="#[MunitTools::getResourceAsReusableStream('util/files/example.txt')]"/>

getResourceAsString(String)

Returns the resource from the path String as a String.

Example
<set-payload
  value="#[MunitTools::getResourceAsString('util/files/example.txt')]"/>

You can also specify the encoding:

Example
<set-payload
  value="#[MunitTools::getResourceAsString('util/files/exampleISO.txt', 'ISO-8859-1')]"/>

getResourceAsByteArray(String)

Returns the resource from the path String as a byte array.

Example
 <set-payload
   value="#[MunitTools::getResourceAsByteArray('util/files/example.txt')]"/>

queueSize(String)

Returns the size of the queue specified inside #[MunitTools::queueSize()].

For example, to assert the size of a queue named QUEUE_SIZE:

Example
<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>

createMessage(payload: Any, mimeType: String|Null , attributes: Any, attributeMimeType: String|Null)

Creates a Mule message with the specified attributes.

Example
<munit:execution>
     <set-payload value="#[MunitTools::createMessage( 'ITEM-1',  'text/plain', { property : 'ATTRIBUTE-1'}, null )]"/>
 </munit:execution>

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub
Give us your feedback!
We want to build the best documentation experience for you!
Help us improve with your feedback.
Take the survey!