Hi folks,
I'm doing the unit tests in my project, and I'm trying to use the Google
Guice. My repository classes have your EntityManagers, and, in my project,
to specify the persistence unit I have an annotation:
@javax.inject.Qualifier
@java.lang.annotation.Retention(RUNTIME)
@java.lang.annotation.Target({FIELD, TYPE, METHOD})
public @interface ConnectionDatabase {
}
In my repositories the entity managers are injected like this:
public class MyRepository implements IMyRepository {
@javax.inject.Inject
@ConnectionDatabase
private javax.persistence.EntityManager entityManager;
}
M ResourceProducer, like this:
public class ResourceProducer {
@javax.enterprise.inject.Produces
@Inject
@ConnectionDatabase
private javax.persistence.EntityManager entityManager;
}
My Module of Google Guice is like this:
public class ModuleTest extends AbstractModule {
@Override
public void configure() {
bind(new TypeLiteral<IMyRepository>() {}).to(MyRepository.class);
}
}
I have a persistence.xml with a persistence unit called "TestPU".
In my unit tests (or cintegration tests), using the Google Guice, the
EntityManager is not injected, and the following error is occurring:
No implementation for javax.persistence.EntityManager annotated with
@ConnectionDatabase() was bound.
while locating javax.persistence.EntityManager annotated with
@ConnectionDatabase()
for field at MyRepository.entityManager(<the line>)
at ModuloTest.configure(<the line of the bind "bind(new
TypeLiteral<IMyRepository>() {}).to(MyRepository.class)">)
Someone here can help me, please?
--
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-guice.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-guice/aa4d80df-40be-4e47-ba75-89833b20536f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.