How to integrate ICEFaces and Spring Mock web ?  XML
Forum Index -> General Help
Author Message

Joined: 13/Dec/2006 00:00:00
Messages: 1

I would like to make a test by using Spring's mock web environment with ICEFaces (with Sun's RI) loaded, therefore, FacesContext is avaliable for me to load the backing beans. There is an example of integrating MyFaces and Spring Mock web form Matt Raibles' AppFuse.
 public abstract class BasePageTestCase extends TestCase {
     protected final transient Log log = LogFactory.getLog(getClass());
     protected static final String MESSAGES = "ApplicationResources";
     protected static FacesContext facesContext;
     protected static MockServletConfig config;
     protected static MockServletContext servletContext;
     protected static WebApplicationContext ctx;
     // This static block ensures that Spring's BeanFactory and JSF's
     // FacesContext is only loaded once for all tests. If there's something
     // wrong with this approach - please let me know!
     static {
         servletContext = new MockServletContext("");
         ServletContextListener contextListener = new ContextLoaderListener();
         ServletContextEvent event = new ServletContextEvent(servletContext);
         ctx = WebApplicationContextUtils
         config = new MockServletConfig(servletContext);
         facesContext = performFacesContextConfig();
     protected void setUp() throws Exception {
     protected static FacesContext performFacesContextConfig() {
         // StartupServletContextListener is in MyFaces
         StartupServletContextListener facesListener = new StartupServletContextListener();
         ServletContextEvent event = new ServletContextEvent(servletContext);
         LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder
         Lifecycle lifecycle = lifecycleFactory.getLifecycle(getLifecycleId());
         FacesContextFactory facesCtxFactory = (FacesContextFactory) FactoryFinder
         FacesContext ctx = facesCtxFactory.getFacesContext(servletContext,
                 new MockHttpServletRequest(), new MockHttpServletResponse(),
         return ctx;

As I marked above, the class StartupServletContextListener is MyFaces class. How can I setup an environment like this with ICEFaces + Sun RI loaded as FacesContext?
Thanks a lot.
Forum Index -> General Help
Go to:   
Powered by JForum 2.1.7ice © JForum Team