我正在嘗試設置MUnit測試以確認設置的有效內容方法正在將有效內容設置爲正確的值。我通過HTTP端點發送JSON文件。在MUnit測試期間將有效載荷設置爲http.query.params.variable_name
當運行流程通常有效載荷設置爲:
#[message.inboundproperties.'http.query.params'.json]
工作正常,但是當我跑我的測試斷言等於失敗。
我使用http.query.params = ParameterMap {[json = [[{「protocol」:「http」,「host」:「0.0.0.0」,「port」:「8085」, 「path」:「」,「operation」:「GET」},{「protocol」:「https」,「host」:「0.0.0.0」,「port」:「8086」,「path」:「」, 「操作」: 「後」}]]]}
我的主要流程如下:
<flow name="httpInboundFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
<set-payload value="#[message.inboundProperties.'http.query.params'.json]" doc:name="Set Payload To Query Params"/>
</flow>
我的測試XML是:
<munit:test name="tddmunitdemo-test-suiteTest" description="MUnit Test">
<munit:set payload="#[]" doc:name="Set Message">
<munit:inbound-properties>
<munit:inbound-property key="http.query.params" value="ParameterMap{[json=[[ { "protocol":"http", "host":"0.0.0.0", "port":"8085", "path":"", "operation":"GET" }, { "protocol":"https", "host":"0.0.0.0", "port":"8086", "path":"", "operation":"post" } ]]]}"/>
</munit:inbound-properties>
</munit:set>
<flow-ref name="httpInboundFlow" doc:name="httpInboundFlow"/>
<munit:assert-on-equals expectedValue="[ { "protocol":"http", "host":"0.0.0.0", "port":"8085", "path":"", "operation":"GET" }, { "protocol":"https", "host":"0.0.0.0", "port":"8086", "path":"", "operation":"post" } ]" actualValue="#[payload]" doc:name="Assert Equals"/>
</munit:test>
該測試失敗,並失敗消息卅一ng實際值爲空。
我可以通過嘲弄設置的有效載荷來修復它,但是我沒有檢查設置的有效載荷是否按預期工作。
發佈你的實際網址? – star
我在測試過程中沒有使用過?當我運行主流程時,我使用http:// localhost:8081 /?json = [\t「protocol」:「http」,\t「host」:「0.0.0.0」,\t「port」:「8085」 ,「\t」操作「:」GET「\t},\t {\t」protocol「:」https「,\t」host「:」0.0.0.0「,\t」port「:」8086「\t」 ,\t「path」:「」,\t「operation」:「post」\t}] –