1 package org.wamblee.test.inject;
3 import javax.persistence.EntityManager;
4 import javax.persistence.PersistenceContext;
7 import org.wamblee.inject.InjectorBuilder;
9 import static org.mockito.Mockito.*;
10 import static junit.framework.TestCase.*;
12 public class JavaEETestInjectorFactoryTest {
15 private EntityManager entityManager;
17 private EntityManager entityManager2;
20 public EntityManager getEntityManager() {
21 return entityManager2;
24 public void setEntityManager(EntityManager aEm) {
29 public void testXyz() {
30 EntityManager em = mock(EntityManager.class);
31 InjectorBuilder.setInjectorFactory(new JavaEETestInjectorFactory(em));
33 assertNull(entityManager);
34 assertNull(entityManager2);
35 InjectorBuilder.getInjector().inject(this);
38 assertSame(em, entityManager);
39 assertSame(em, entityManager2);
42 public static class X {
47 @Test(expected = IllegalArgumentException.class)
48 public void testWrongType() {
49 EntityManager em = mock(EntityManager.class);
50 InjectorBuilder.setInjectorFactory(new JavaEETestInjectorFactory(em));
52 InjectorBuilder.getInjector().inject(x);