### Question:
DefaultSpringFacesContext extends SpringFacesContext { @Override public void render(View view, Map<String, Object> model) { FacesContext context = getFacesContext(); try { if (view instanceof FacesView) { render(context, ((FacesView) view).getViewArtifact(), model); } else { try { render(context, view, model); } catch (Exception e) { ReflectionUtils.rethrowRuntimeException(e); } } } finally { context.release(); } } DefaultSpringFacesContext(LifecycleAccessor lifecycleAccessor, WebApplicationContext webApplicationContext,
			HttpServletRequest request, HttpServletResponse response, Object handler); void release(); @Override Object getHandler(); @Override Object getController(); @Override FacesContext getFacesContext(); @Override WebApplicationContext getWebApplicationContext(); @Override void render(View view, Map<String, Object> model); @Override ModelAndViewArtifact getRendering();  }### Answer:
@Test public void shouldRenderNonFacesView() throws Exception { View view = mock(View.class); Map<String, Object> model = new HashMap<String, Object>(); this.springFacesContext.render(view, model); verify(view).render(model, this.request, this.response); }
@Test public void shouldRenderFacesRenderedView() throws Exception { FacesRenderedView view = mock(FacesRenderedView.class); Map<String, Object> model = new HashMap<String, Object>(); this.springFacesContext.render(view, model); verify(view).render(eq(model), this.facesContextCaptor.capture()); assertIsWrappedFacesContext(this.facesContextCaptor.getValue()); }
@Test public void shouldRenderFacesView() throws Exception { FacesView view = mock(FacesView.class); given(view.getViewArtifact()).willReturn(new ViewArtifact("artifact")); Map<String, Object> model = new HashMap<String, Object>(); Lifecycle lifecycle = mock(Lifecycle.class); given(this.lifecycleAccessor.getLifecycle()).willReturn(lifecycle); this.springFacesContext.render(view, model); verify(lifecycle).execute(this.facesContextCaptor.capture()); assertIsWrappedFacesContext(this.facesContextCaptor.getValue()); verify(lifecycle).render(this.facesContextCaptor.capture()); assertIsWrappedFacesContext(this.facesContextCaptor.getValue()); }
@Test public void shouldNotRenderMVCViewIfPartialRequest() throws Exception { View view = mock(View.class); Map<String, Object> model = new HashMap<String, Object>(); given(this.partialViewContext.isPartialRequest()).willReturn(true); given(this.partialViewContext.isAjaxRequest()).willReturn(true); this.thrown.expect(IllegalStateException.class); this.thrown.expectMessage("Unable to render MVC response to Faces AJAX request"); this.springFacesContext.render(view, model); }
@Test public void shouldSetViewRootIfDoubleRendering() throws Exception { FacesView view = mock(FacesView.class); given(view.getViewArtifact()).willReturn(new ViewArtifact("theartifact")); final Map<String, Object> model = new HashMap<String, Object>(); Application application = mock(Application.class); ViewHandler viewHandler = mock(ViewHandler.class); final UIViewRoot newViewRoot = mock(UIViewRoot.class); given(this.facesContext.getApplication()).willReturn(application); given(application.getViewHandler()).willReturn(viewHandler); given(viewHandler.createView(any(FacesContext.class), eq("newartifact"))).willReturn(newViewRoot); Lifecycle lifecycle = mock(Lifecycle.class); given(this.lifecycleAccessor.getLifecycle()).willReturn(lifecycle); willAnswer(new Answer<Object>() { public Object answer(InvocationOnMock invocation) throws Throwable { FacesView view2 = mock(FacesView.class); given(view2.getViewArtifact()).willReturn(new ViewArtifact("newartifact")); DefaultSpringFacesContextTest.this.springFacesContext.render(view2, model); verify(DefaultSpringFacesContextTest.this.facesContext).setViewRoot(newViewRoot); return null; } }).given(lifecycle).render((FacesContext) any()); this.springFacesContext.render(view, model); }