quarkus: Mocked bean created via method is not injected in another bean
Describe the bug
Beans which are created via @Produces api are not injected in others beans fields. It works fine if I annotate bean with @ApplicationScope instead of using @Produces.
Expected behavior
Mocked bean in passed to other beans.
Actual behavior
Real bean in passed to other beans.
How to Reproduce?
example repo: https://github.com/vadim-hleif/test-quarkus-mocking
Output of uname -a or ver
Darwin Vadims-MacBook-Pro.local 20.6.0 Darwin Kernel Version 20.6.0: Tue Oct 12 18:33:42 PDT 2021; root:xnu-7195.141.8~1/RELEASE_X86_64 x86_64
Output of java -version
openjdk 17.0.3 2022-04-19 LTS OpenJDK Runtime Environment Zulu17.34+19-CA (build 17.0.3+7-LTS) OpenJDK 64-Bit Server VM Zulu17.34+19-CA (build 17.0.3+7-LTS, mixed mode, sharing)
GraalVM version (if different from Java)
No response
Quarkus version or git rev
2.10.2
Build tool (ie. output of mvnw --version or gradlew --version)
7.4.2
Additional information
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 24 (13 by maintainers)
Commits related to this issue
- Ensure that Quarkus can mock final methods of beans created from producers Fixes: #26733 — committed to geoand/quarkus by geoand 2 years ago
- Ensure that Quarkus can mock final methods of beans created from producers Fixes: #26733 — committed to geoand/quarkus by geoand 2 years ago
- Ensure that Quarkus can mock final methods of beans created from producers Fixes: #26733 — committed to geoand/quarkus by geoand 2 years ago
- Ensure that Quarkus can mock final methods of beans created from producers Fixes: #26733 — committed to geoand/quarkus by geoand 2 years ago
- Ensure that Quarkus can mock final methods of beans created from producers Fixes: #26733 — committed to geoand/quarkus by geoand 2 years ago
- Merge pull request #27179 from geoand/#26733 Ensure that Quarkus can mock final methods of beans created by producers — committed to quarkusio/quarkus by geoand 2 years ago
- Ensure that Quarkus can mock final methods of beans created from producers Fixes: #26733 (cherry picked from commit 3390d0362a81b95f034a5ed8a18b856d729fc63a) — committed to gsmet/quarkus by geoand 2 years ago
- Ensure that Quarkus can mock final methods of beans created from producers Fixes: #26733 — committed to miador/quarkus by geoand 2 years ago
https://github.com/quarkusio/quarkus/pull/27179 should take care of the problem
I reopened the issue since this an actual problem, but so far I haven’t been able to pinpoint the root cause.
Oh, fixed the extension, thank you for this!
https://github.com/vadim-hleif/test-quarkus-mocking/runs/7722415736?check_suite_focus=true
I just figured out why we are seeing different results. This file has the wrong casing, which a Mac doesn’t matter, but in Linux does…
But making all classes as open resolves this issue, sorry, you are right.