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

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


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.
Code:
 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("");
         servletContext.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM,
                 "classpath*:META-INF/spring-*.xml");
 
         ServletContextListener contextListener = new ContextLoaderListener();
         ServletContextEvent event = new ServletContextEvent(servletContext);
         contextListener.contextInitialized(event);
 
         ctx = WebApplicationContextUtils
                 .getRequiredWebApplicationContext(servletContext);
         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);
         facesListener.contextInitialized(event);
 
         LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder
                 .getFactory(FactoryFinder.LIFECYCLE_FACTORY);
         Lifecycle lifecycle = lifecycleFactory.getLifecycle(getLifecycleId());
         FacesContextFactory facesCtxFactory = (FacesContextFactory) FactoryFinder
                 .getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
         FacesContext ctx = facesCtxFactory.getFacesContext(servletContext,
                 new MockHttpServletRequest(), new MockHttpServletResponse(),
                 lifecycle);
 
         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