### Question:
WeldContextListener implements ServletContextListener { @Override public void contextDestroyed(ServletContextEvent sce) { if (beanManager != null) { beanManager = null; } }  @Override void contextInitialized(ServletContextEvent servletContextEvent); @Override void contextDestroyed(ServletContextEvent sce);  }### Answer:
@Test public void testcontextDestroyed() throws Exception { EasyMockSupport mockSupport = new EasyMockSupport(); BeanManager beanManager = mockSupport.createMock( BeanManager.class ); mockSupport.replayAll(); WeldContextListener weldContextListener = getWeldContextListener(beanManager, null); Class<?> clazz = LocalWeldContextListener.class.getSuperclass(); Field beanManagerField = clazz.getDeclaredField("beanManager"); beanManagerField.setAccessible(true); assertNotNull( beanManagerField.get(weldContextListener) ); weldContextListener.contextDestroyed( null ); assertNull( beanManagerField.get(weldContextListener) ); mockSupport.verifyAll(); mockSupport.resetAll(); }