Example usage for org.springframework.web.context ContextLoader CONTEXT_CLASS_PARAM

List of usage examples for org.springframework.web.context ContextLoader CONTEXT_CLASS_PARAM

Introduction

In this page you can find the example usage for org.springframework.web.context ContextLoader CONTEXT_CLASS_PARAM.

Prototype

String CONTEXT_CLASS_PARAM

To view the source code for org.springframework.web.context ContextLoader CONTEXT_CLASS_PARAM.

Click Source Link

Document

Config param for the root WebApplicationContext implementation class to use: .

Usage

From source file:org.jasig.springframework.web.portlet.context.PortletContextLoaderTests.java

@Test
public void testContextLoaderWithCustomContextAndParent() throws Exception {
    MockServletContext sc = new MockServletContext("");
    sc.addInitParameter(ContextLoader.CONTEXT_CLASS_PARAM, StaticWebApplicationContext.class.getName());
    sc.addInitParameter(PortletContextLoader.CONTEXT_CLASS_PARAM,
            SimplePortletApplicationContext.class.getName());
    ContextLoaderListener servletListener = new ContextLoaderListener();
    ServletContextListener listener = new PortletContextLoaderListener();
    ServletContextEvent event = new ServletContextEvent(sc);

    servletListener.contextInitialized(event);
    listener.contextInitialized(event);//from w  w  w .  ja  v  a2  s . c  om

    //initialize the portlet application context, needed because PortletContextLoaderListener.contextInitialized doesn't actually create
    //the portlet app context due to lack of PortletContext reference
    MockPortletContext pc = new MockPortletContext(sc);
    PortletApplicationContextUtils2.getPortletApplicationContext(pc);

    PortletApplicationContext wc = (PortletApplicationContext) pc
            .getAttribute(PortletApplicationContext.ROOT_PORTLET_APPLICATION_CONTEXT_ATTRIBUTE);
    assertTrue("Correct PortletApplicationContext exposed in PortletContext",
            wc instanceof SimplePortletApplicationContext);
}