### Question:
Resources { @Produces @RequestScoped @Named("facesContext") public FacesContext produceFacesContext() { FacesContext ctx = FacesContext.getCurrentInstance(); if (ctx == null) { throw new ContextNotActiveException("FacesContext is not active"); } return ctx; }  @Produces Logger produceLog(InjectionPoint injectionPoint); @Produces @RequestScoped @Named("facesContext") FacesContext produceFacesContext(); static String readStringFromClasspathFile(String filePath);  }### Answer:
@Test public void produceFacesContext() { Resources tested = new Resources(); try { tested.produceFacesContext(); Assert.fail("ContextNotActiveException expected"); } catch (ContextNotActiveException e) { } try { FacesContext fcMock = Mockito.mock(FacesContext.class); FacesContextMock.setCurrentInstanceImpl(fcMock); Assert.assertEquals(fcMock, tested.produceFacesContext()); } finally { FacesContextMock.setCurrentInstanceImpl(null); } }