0

我试图在 munit 中抛出一个过滤器未接受的异常来测试我的错误处理,但我收到了这个错误

org.mule.api.MessagingException: Failed to invoke throw-an.
at get_data_filter_unaccepted_exception-test.mock:throw-an{doc:name=Throw unaccepted Exception, exception-ref=#[new org.mule.api.routing.filter.FilterUnacceptedException()], whenCalling=.*:.*}(get_data_from_qcfc-test-suite.xml:316)
at appleFlow.munit:test{initialState=started, description=Test, ignore=false, abstract=false, id=MunitTestFlow$$EnhancerByMUNIT$$904837f0{get_data_filter_unaccepted_exception-test}}(get_data_from_qcfc-test-suite.xml:315)
Caused by: org.mule.api.expression.ExpressionRuntimeException: Execution of the expression "new org.mule.api.routing.filter.FilterUnacceptedException()" failed.
    at org.mule.el.mvel.MVELExpressionLanguage.evaluateInternal(MVELExpressionLanguage.java:232)

这是我的抛出异常

<mock:when messageProcessor=".*:.*" doc:name="Mock API Token Web Service Call">
        <mock:with-attributes>
            <mock:with-attribute name="doc:name" whereValue="#['Get API Token']"/>
        </mock:with-attributes>
        <mock:then-return payload="#[getResource('api_token_success.xml').asString()]" mimeType="application/xml"/>

    </mock:when>

我认为这是因为我的 MEL 声明

#[new org.mule.api.routing.filter.FilterUnacceptedException()]
4

2 回答 2

2

你可以使用一个 groovy 组件来抛出你的异常

<scripting:component doc:name="Throw Exception">
        <scripting:script engine="Groovy"><![CDATA[throw new org.mule.api.routing.filter.FilterUnacceptedException(); ]]></scripting:script>
    </scripting:component>

希望能帮助到你。

/T

于 2016-07-07T16:32:29.093 回答
1

throw-an在您粘贴的代码段中看不到 call 。

无论如何,没有参数构造函数org.mule.api.routing.filter.FilterUnacceptedException是不公开的,尝试使用#[new org.mule.api.routing.filter.FilterUnacceptedException('Some message')]

于 2016-07-06T19:02:33.333 回答