Munit测试用例获取InterceptionException错误

时间:2019-11-22 13:49:50

标签: mule munit

在执行munit测试用例时,我收到InterceptionException。我正在使用的Munit版本是2.1.5。下面是我得到的错误堆栈跟踪。

org.mule.runtime.core.internal.processor.interceptor.InterceptionException: 
    at org.mule.runtime.core.internal.processor.interceptor.ReactiveInterceptionAction.failWithMessage(ReactiveInterceptionAction.java:100)
    at org.mule.runtime.core.internal.processor.interceptor.ReactiveInterceptionAction.fail(ReactiveInterceptionAction.java:113)
    at org.mule.munit.mock.interception.MunitProcessorInterceptor.failProcessor(MunitProcessorInterceptor.java:170)
    at org.mule.munit.mock.interception.MunitProcessorInterceptor.around(MunitProcessorInterceptor.java:108)
    at org.mule.runtime.core.internal.processor.interceptor.ReactiveAroundInterceptorAdapter.lambda$doAround$3(ReactiveAroundInterceptorAdapter.java:94)
    at org.mule.runtime.core.api.util.ExceptionUtils.tryExpecting(ExceptionUtils.java:227)
    at org.mule.runtime.core.api.util.ClassUtils.withContextClassLoader(ClassUtils.java:915)
    at org.mule.runtime.core.api.util.ClassUtils.withContextClassLoader(ClassUtils.java:879)
    at org.mule.runtime.core.internal.processor.interceptor.ReactiveAroundInterceptorAdapter.doAround(ReactiveAroundInterceptorAdapter.java:93)
    at org.mule.runtime.core.internal.processor.interceptor.ReactiveAroundInterceptorAdapter.lambda$null$1(ReactiveAroundInterceptorAdapter.java:60)
    at reactor.core.publisher.FluxFlatMap$FlatMapMain.onNext(FluxFlatMap.java:350)
    at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:121)
    at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:121)
    at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:121)
    at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:121)
    at reactor.core.publisher.FluxJust$WeakScalarSubscription.request(FluxJust.java:99)
    at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.request(FluxMapFuseable.java:162)
    at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.request(FluxMapFuseable.java:162)
    at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.request(FluxMapFuseable.java:162)
    at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.request(FluxMapFuseable.java:162)
    at reactor.core.publisher.FluxFlatMap$FlatMapMain.onSubscribe(FluxFlatMap.java:335)
    at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onSubscribe(FluxMapFuseable.java:90)
    at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onSubscribe(FluxMapFuseable.java:90)
    at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onSubscribe(FluxMapFuseable.java:90)
    at ...
    at org.mule.runtime.core.privileged.processor.chain.AbstractMessageProcessorChain$1.onNext(AbstractMessageProcessorChain.java:285)
    at reactor.core.publisher.FluxHide$SuppressFuseableSubscriber.onNext(FluxHide.java:127)
    at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.onNext(FluxPeekFuseable.java:204)
    at reactor.core.publisher.FluxSubscribeOnValue$ScheduledScalar.run(FluxSubscribeOnValue.java:178)
    at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:50)
    at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:27)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at org.mule.service.scheduler.internal.AbstractRunnableFutureDecorator.doRun(AbstractRunnableFutureDecorator.java:111)
    at org.mule.service.scheduler.internal.RunnableFutureDecorator.run(RunnableFutureDecorator.java:54)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

在这里,我在这里模拟错误类型为IBM-MQ:TIMEOUT的IBM MQ超时错误,并在转换消息中传递标头值并使用expression="#[payload]" is="#[MunitTools::notNullValue()]进行断言。任何帮助!我想知道为什么以及为什么会出现此错误,因为在调试测试用例时找不到任何特定的问题。

3 个答案:

答案 0 :(得分:1)

您需要在MUnit测试上设置ExpectedErrorType属性:

https://docs.mulesoft.com/munit/2.2/test-mock-errors-cookbook#on-error-propagate

答案 1 :(得分:0)

如果在模拟中设置错误类型,它将抛出该错误类型的异常。在这种情况下,异常是InterceptionException,与提供的错误类型关联

答案 2 :(得分:0)

对于IBM MQ,我至少建议至少使用IBM-MQ获得实时测试环境。导致它无法按预期运行。