### Question:
SpringFacesBeanELResolver extends SpringBeanELResolver { @Override protected BeanFactory getBeanFactory(ELContext elContext) { if (SpringFacesContext.getCurrentInstance() == null) { return EMPTY_BEAN_FACTORY; } return SpringFacesContext.getCurrentInstance().getWebApplicationContext(); }    }### Answer:
@Test public void shouldHaveEmptyBeanFactoryWhenActive() throws Exception { BeanFactory factory = this.resolver.getBeanFactory(this.elContext); assertThat(((ListableBeanFactory) factory).getBeanDefinitionCount(), is(0)); }
@Test public void shouldGetBeanFactoryFromSpringFacesContext() throws Exception { SpringFacesContextSetter.setCurrentInstance(this.springFacesContext); try { ViewArtifact viewArtifact = new ViewArtifact("artifact"); ModelAndViewArtifact rendering = new ModelAndViewArtifact(viewArtifact, null); given(this.springFacesContext.getRendering()).willReturn(rendering); WebApplicationContext applicationContext = mock(WebApplicationContext.class); given(this.springFacesContext.getWebApplicationContext()).willReturn(applicationContext); assertThat(this.resolver.getBeanFactory(this.elContext), is(sameInstance((Object) applicationContext))); } finally { SpringFacesContextSetter.setCurrentInstance(null); } }