Dan
Dan

Reputation: 435

Munit test case getting InterceptionException error

I am getting InterceptionException while executing a munit test case. The Munit version I am using is 2.1.5. Below is the error stack trace I am getting.

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)

Here I am mocking timeout error for IBM MQ here with error type IBM-MQ:TIMEOUT and passing header values in a transform message and asserting with expression="#[payload]" is="#[MunitTools::notNullValue()]. Any help! I want to know why and how this error is coming, as I could not find any particular issue while debugging the test case.

Upvotes: 1

Views: 2571

Answers (3)

jpendle
jpendle

Reputation: 220

You need to set the expectedErrorType attribute on the MUnit test:

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

Upvotes: 3

Siva
Siva

Reputation: 98

With IBM MQ i will recommend at least to get a live test environment with IBM-MQ. cause it never runs as expected.

Upvotes: 0

Diego Strubolini
Diego Strubolini

Reputation: 66

If you set an error type in the mock, it will throw an exception with that error type. In this case, the exception is InterceptionException, associated with the provided error type

Upvotes: 0

Related Questions