2016-07-06 57 views
0

我想拋出一個過濾器未被接受的異常在munit測試我的錯誤處理,但我收到此錯誤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()] 

回答

1

的我沒有看到throw-an CAL l在你粘貼的代碼片段中。

不管怎麼說,沒有找到org.mule.api.routing.filter.FilterUnacceptedException參數構造函數是不公開的,請嘗試使用#[new org.mule.api.routing.filter.FilterUnacceptedException('Some message')]

2

你可以使用常規組件引發的異常一樣,

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

希望它能幫助。

/T