MyContainerInjectionProvider extends DiscoverableInjectionProvider { public void inject(Object instance) throws InjectionProviderException { try { InjectionUtil.inject(instance, ctx); } catch (NamingException e) { throw new InjectionProviderException(e); } } MyContainerInjectionProvider(); void inject(Object instance); void invokePostConstruct(Object instance); void invokePreDestroy(Object instance);  }
@Test public void testInject() throws Exception { MockServiceBean bean = new MockServiceBean(); InitialContext ctx = new InitialContext(); ctx.bind(new CompositeName(MyNameParser.parseClassName("resource", MockService.class)), bean); ManagedBean mb = new ManagedBean(); provider.inject(mb); assertNotNull(mb.mockService); assertEquals(IDO_IT, mb.callDoIt()); assertEquals(IDO_IT, mb.callDoItMapped()); assertEquals(IDO_IT, mb.callDoItResoucedAndMapped()); assertEquals(IDO_IT, mb.callDoItResourced()); assertEquals(IDO_IT, mb.callDoItInterface()); assertEquals(IDO_IT, mb.callDoItResourcedByType()); }