ApplicationFactory applicationFactory = (ApplicationFactory)FactoryFinder.getFactory("javax.faces.application.ApplicationFactory");
application = (MockApplication)applicationFactory.getApplication();
facesContext.setApplication(application);
RenderKitFactory renderKitFactory = (RenderKitFactory)FactoryFinder.getFactory("javax.faces.render.RenderKitFactory");
//Wrap renderers with proper exval wrapper
renderKit = new DefaultRenderKitWrapperFactory().create(new MockRenderKit());
renderKitFactory.addRenderKit("HTML_BASIC", renderKit);
// additional setup not provided automatically by the shale mock stuff
facesContext.getExternalContext().getApplicationMap().put(MyfacesConfig.class.getName(), new MyfacesConfig());
writer = new MockResponseWriter(new StringWriter(), null, null);