dadrus / jpa-unit

JUnit extension to test javax.persistence entities
Apache License 2.0
29 stars 9 forks source link

Let cdi extension inject `EntityManager` and `EntityManagerFactory` not only into CDI Producer #38

Open dadrus opened 6 years ago

dadrus commented 6 years ago

As of today the jpa-unit cdi-extension handles CDI Producer only. That is, the jpa-unit cdi-extension cannot cope with situations, where the code under test injects EntityManaget or EntityManagetFactory directly (by using e.g. @PersistenceContext annotation). In such situation the developer has to inject the EntityManaget or EntityManagetFactory created by the jpa-unit by hand (e.g. by using a corresponding setter or reflection) in the test setup method. The jpa-unit cdi-extension is even not needed in such cases. It would be however helpful, if the cdi-extension would support such cases as well, thus eliminating the need of manual setup.

trauchhaupt commented 5 years ago

Is there any suggestion on how to get around that problem?