スケジューラ提供元を使用したフローのテスト
Scheduler コンポーネントによってトリガされる次のフローをテストし、フローが正しくトリガされていることを検証するには、次の手順を実行します。
<flow name="schedulerFlow">
<scheduler>
<scheduling-strategy >
<fixed-frequency frequency="10" timeUnit="SECONDS"/>
</scheduling-strategy>
</scheduler>
<set-payload value="#['test poll']"/>
</flow>
-
フロー提供元を有効にします。
MUnit ではフロー提供元 (トリガやリスナなど) が起動されないので、テスト用にどのフロー提供元を起動するかを設定する必要があります。次の例では、Scheduler を含むフローを有効にします。
<munit:test name="test-schedulerFlowTest"> <munit:enable-flow-sources> <munit:enable-flow-source value="schedulerFlow"/> </munit:enable-flow-sources> </munit:test>
-
Scheduler によってフロー実行がトリガされることを検証します。
フロー内のプロセッサがトリガされていることを検証するには、munit-tools:verify-call
プロセッサを使用します。テストしたいタイミングで Scheduler が動作しない場合は、
until-successful
内部に munit-tools:verify-call
をラップして、処理時間を短縮します。次の例では、テスト中にペイロードが 1 回以上実行されることを 3 回検証します。
<munit:execution> <until-successful maxRetries="3" millisBetweenRetries="100"> <munit-tools:verify-call processor="set-payload" atLeast="1"> <munit-tools:with-attributes > <munit-tools:with-attribute whereValue="#['test poll']" attributeName="value" /> </munit-tools:with-attributes> </munit-tools:verify-call> </until-successful> </munit:execution>