### Question:
CdiObjectFactory extends ObjectFactory { @Override @SuppressWarnings({ "rawtypes", "unchecked" }) public Object buildBean(String className, Map<String, Object> extraContext, boolean injectInternal) throws Exception { Class<?> clazz = getClassInstance(className); InjectionTarget injectionTarget = getInjectionTarget(clazz); final CreationalContext ctx = buildNonContextualCreationalContext(beanManager); Object o = injectionTarget.produce(ctx); injectionTarget.inject(o, ctx); injectionTarget.postConstruct(o); if (injectInternal) { injectInternalBeans(o); } return o; } CdiObjectFactory(); @Inject(value = "struts.objectFactory.cdi.jndiKey", required = false) void setJndiKey( String jndiKey ); @Override @SuppressWarnings({ "rawtypes", "unchecked" }) Object buildBean(String className, Map<String, Object> extraContext, boolean injectInternal); @Override boolean isNoArgConstructorRequired(); static final String CDI_JNDIKEY_BEANMANAGER_COMP; static final String CDI_JNDIKEY_BEANMANAGER_APP; static final String CDI_JNDIKEY_BEANMANAGER_COMP_ENV; }### Answer:
@Test public void testGetBean() throws Exception { final CdiObjectFactory cdiObjectFactory = new CdiObjectFactory(); FooConsumer fooConsumer = (FooConsumer) cdiObjectFactory.buildBean(FooConsumer.class.getCanonicalName(), null, false); assertNotNull(fooConsumer); assertNotNull(fooConsumer.fooService); }