### Question:
CdiObjectFactory extends ObjectFactory { protected BeanManager findBeanManager() { BeanManager bm = null; try { Context initialContext = new InitialContext(); if (jndiKey != null && jndiKey.trim().length() > 0) { bm = lookup(initialContext, jndiKey); } if (bm == null) { bm = lookup(initialContext, CDI_JNDIKEY_BEANMANAGER_COMP); } if (bm == null) { bm = lookup(initialContext, CDI_JNDIKEY_BEANMANAGER_APP); } if (bm == null) { bm = lookup(initialContext, CDI_JNDIKEY_BEANMANAGER_COMP_ENV); } if (bm == null) { LOG.error("[findBeanManager]: Could not find BeanManager instance for any given JNDI key, giving up"); } } catch ( NamingException e ) { LOG.error("[findBeanManager]: Unable to get InitialContext for BeanManager lookup", e); } return bm; } 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 testFindBeanManager() throws Exception { assertNotNull(new CdiObjectFactory().findBeanManager()); }