I'm just writing unit tests for a small project and they should work in a standards-compliant way (of course).
For testing purposes I'd need to enable an Interceptor on certain beans, however this should only be done when executing the tests. I don't want to touch the production code part of my (maven) project.
My current approach:
However using the latest versions of weld this approach doesn't work since the interceptor has to be activated in the beans.xml of the production code.
To demonstrate the problem (?) I attached a little demo project running a unit test checking if the interceptor was called on a test method.
The project can be built and tested with weld 2.1.x or 2.2.x. In the attached version the interceptor-activation in the "main" beans.xml is commented out.
The results are as follows:
|test results||interceptor activated in main beans.xml||interceptor not activated in main beans.xml|
So two questions:
I'll answer the question myself, at least partly. @Priority has to enable the interceptor. This is perfectly OK in my case.
However I was surprised because of the change in behavior. Perhaps this should be mentioned in the change log. Or maybe I just missed it.
PS: Posting this as a reply wasn't possible due to technical problems, sorry. I'll try to correct this later.