public String getRenderResult3() { try { FacesContext currentContext = FacesContext.getCurrentInstance(); ExternalContextImpl externalContext = new ExternalContextImpl( (ServletContext) currentContext.getExternalContext().getContext(), (HttpServletRequest) currentContext.getExternalContext().getRequest(), (HttpServletResponse) currentContext.getExternalContext().getResponse()); LifecycleImpl lifecycle = new LifecycleImpl(); FacesContextImpl context = new FacesContextImpl(externalContext, lifecycle); /* * Actual test. */ Application application = context.getApplication(); UIViewRoot root = (UIViewRoot) application.createComponent(UIViewRoot.COMPONENT_TYPE); // if no UIViewRoot then null should be returned assertTrue(context.getRenderKit() == null); // if UIViewRoot is present but has no RenderKitID, null // should be rendered context.setViewRoot(root); assertTrue(context.getRenderKit() == null); // UIViewRoot is present, and has an ID for a non existent // RenderKit - null should be returned root.setRenderKitId("nosuchkit"); assertTrue(context.getRenderKit() == null); // UIViewRoot with valid RenderKit id should return a RenderKit root.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT); assertTrue(context.getRenderKit() != null); } catch (Exception exception) { exception.printStackTrace(); fail(); } return "PASSED"; }