### Question:
WeldContextListener implements ServletContextListener { public void contextInitialized(ServletContextEvent servletContextEvent) { if (null != beanManager) { JspApplicationContext jspAppContext = getJspApplicationContext(servletContextEvent); jspAppContext.addELResolver(beanManager.getELResolver()); try { Class weldClass = Class.forName("org.jboss.weld.el.WeldELContextListener"); WeldELContextListener welcl = ( WeldELContextListener ) weldClass.newInstance(); jspAppContext.addELContextListener(welcl); } catch (Exception e) { logger.log(Level.WARNING, CDILoggerInfo.CDI_COULD_NOT_CREATE_WELDELCONTEXTlISTENER, new Object [] {e}); } ( ( JspApplicationContextImpl ) jspAppContext ).setExpressionFactory( beanManager.wrapExpressionFactory(jspAppContext.getExpressionFactory())); } }  void contextInitialized(ServletContextEvent servletContextEvent); void contextDestroyed(ServletContextEvent sce);  }### Answer:
@Test public void testcontextInitialized() throws Exception { EasyMockSupport mockSupport = new EasyMockSupport(); ELResolver elResolver = mockSupport.createMock(ELResolver.class); ExpressionFactory expressionFactory = mockSupport.createMock(ExpressionFactory.class); StandardContext servletContext = new StandardContext(); servletContext.getServletContext(); ServletContextEvent servletContextEvent = mockSupport.createMock( ServletContextEvent.class ); BeanManager beanManager = mockSupport.createMock( BeanManager.class ); JspApplicationContextImpl jspApplicationContext = new JspApplicationContextImpl(servletContext); expect(beanManager.getELResolver()).andReturn(elResolver); expect( beanManager.wrapExpressionFactory(isA(ExpressionFactory.class))).andReturn(expressionFactory); mockSupport.replayAll(); WeldContextListener weldContextListener = getWeldContextListener(beanManager, jspApplicationContext); weldContextListener.contextInitialized( servletContextEvent ); assertSame( expressionFactory, jspApplicationContext.getExpressionFactory() ); validateJspApplicationContext( jspApplicationContext, elResolver ); mockSupport.verifyAll(); mockSupport.resetAll(); }