StubInitialContextFactory.register();
InitialContext ctx = new InitialContext();
ctx.bind(BeanManagerLookup.BEAN_MANAGER_JNDI, setup.getBeanManager());
- MySingleton.reset();
+ MySingleton.reset();
}
@After
@Test
public void testGetSingleton() {
MyPojo pojo = new MyPojo();
- SimpleInjector injector = new SimpleInjector(new CdiInjectorFactory(BeanManagerLookup.lookup()));
+ SimpleInjector injector = new SimpleInjector(new CdiInjectorFactory(
+ BeanManagerLookup.lookup()));
injector.inject(pojo);
MySingleton obj = pojo.getSingleton();
@Override
public void inject(Object aComponent) {
MyPojo pojo2 = (MyPojo) aComponent;
- pojo2.setSingleton(singleton);
+ pojo2.setSingleton(singleton);
}
});
-
+
injector.inject(pojo);
- // verify the custom injector was called.
+ // verify the custom injector was called.
assertSame(singleton, pojo.getSingleton());
}
-
+
@RequestScoped
- public static class Y {
-
+ public static class Y {
+
}
- public static class X {
+
+ public static class X {
@Inject
- private Y y;
-
+ private Y y;
+
}
-
- @Test
- public void testInjectStorage() throws Exception {
- X x = new X();
+
+ @Test
+ public void testInjectStorage() throws Exception {
+ X x = new X();
InjectorBuilder.setInjectorFactory(null);
InjectorBuilder.getInjector().inject(x);
}
-
- @Test
- public void testInjectStorage2() {
- X x = new X();
+
+ @Test
+ public void testInjectStorage2() {
+ X x = new X();
InjectorBuilder.setInjectorFactory(null);
InjectorBuilder.getInjector().inject(x);
}
-
+
}