Mock an Interceptor

20 views
Skip to first unread message

Torsten Römer

unread,
Jan 17, 2019, 2:34:07 PM1/17/19
to CDI-Unit
I have an interceptor annotated only with @AroundInvoke, which is declared on a method of the @Stateless EJB under test with @Interceptors.

When I run the test the interceptor is called, to my surprise without it being included in @AdditionalClasses.

Now I would like to mock the interceptor like so:

    @Produces
    @ProducesAlternative
    @Mock
    private MyInterceptor interceptor;

but the real implementation is being called.

I tried to annotate the interceptor with @Interceptor and add it to @AdditionalClasses but that did not help.
The beans.xml is empty.
Injection of mocked beans works fine.

What could I be missing?

Torsten
Reply all
Reply to author
Forward
0 new messages