List of usage examples for javax.servlet ServletContextEvent ServletContextEvent
public ServletContextEvent(ServletContext source)
From source file:com.chilmers.configbootstrapper.ConfigServletContextListenerTest.java
@Test public void testDefault() { ServletContext contextMock = new MockServletContext(); ConfigServletContextListener testee = new ConfigServletContextListener(); testee.contextInitialized(new ServletContextEvent(contextMock)); Assert.assertEquals("classpath:application.properties", System.getProperty("application.config.location")); Assert.assertNotNull(LogManager.exists("com.chilmers.configbootstrapper.test")); }
From source file:edu.cornell.mannlib.vitro.webapp.startup.StartupManagerTest.java
@Before public void setup() { ctx = new ServletContextStub(); sce = new ServletContextEvent(ctx); sm = new StartupManager(); ss = StartupStatus.getBean(ctx);/*from w ww.j av a2 s.c om*/ // setLoggerLevel(this.getClass(), Level.DEBUG); setLoggerLevel(StartupStatus.class, Level.OFF); setLoggerLevel(StartupManager.class, Level.OFF); }
From source file:org.jasig.cas.web.init.SafeContextLoaderListenerTests.java
protected void setUp() throws Exception { this.listener = new SafeContextLoaderListener(); this.servletContext = new MockServletContext(); this.servletContextEvent = new ServletContextEvent(this.servletContext); }
From source file:ar.com.zauber.commons.spring.beans.factory.impl.ContextPathRegexCaseBlockTest.java
/** test */ public final void testCtxHome() { final MockServletContext servletCtx = new MockServletContext("/home"); servletCtx.addInitParameter("contextConfigLocation", "classpath:/spring-test-switch-regex.xml"); final TestFriendlyContextLoaderListener listener = new TestFriendlyContextLoaderListener(); listener.contextInitialized(new ServletContextEvent(servletCtx)); final WebApplicationContext ctx = ((TestFriendlyContextLoader) listener.getContextLoader()).getCtx(); assertEquals("home", ctx.getBean("test1")); }
From source file:com.cloudera.oryx.lambda.serving.ModelManagerListenerIT.java
@Test public void testListener() throws Exception { Map<String, Object> overlayConfig = new HashMap<>(); overlayConfig.put("oryx.serving.model-manager-class", MockServingModelManager.class.getName()); Config config = ConfigUtils.overlayOn(overlayConfig, getConfig()); String serializedConfig = ConfigUtils.serialize(config); MockServletContext mockContext = new MockServletContext(); mockContext.addInitParameter(ConfigUtils.class.getName() + ".serialized", serializedConfig); startMessaging();//from ww w . j a v a2 s. com ModelManagerListener<?, ?, ?> listener = new ModelManagerListener<>(); listener.init(mockContext); try { listener.contextInitialized(new ServletContextEvent(mockContext)); ServingModelManager<?> manager = (ServingModelManager<?>) mockContext .getAttribute(ModelManagerListener.MANAGER_KEY); assertNotNull(manager); assertFalse(manager.isReadOnly()); assertNotNull(manager.getConfig()); } finally { listener.contextDestroyed(new ServletContextEvent(mockContext)); } }
From source file:base.StripesWithoutMockTestFixture.java
private static void initServlet() { CTX.addInitParameter("contextConfigLocation", SPRING_APPLICATION_CONTEXT_XML); ContextLoaderListener springContextListener = new ContextLoaderListener(); springContextListener.contextInitialized(new ServletContextEvent(CTX)); CTX.setServlet(DispatcherServlet.class, "StripesDispatcher", null); }
From source file:org.openmrs.contrib.metadatarepository.webapp.listener.StartupListenerTest.java
protected void setUp() throws Exception { super.setUp(); sc = new MockServletContext(""); sc.addInitParameter(Constants.CSS_THEME, "simplicity"); // initialize Spring sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM, "classpath:/applicationContext-dao.xml, " + "classpath:/applicationContext-service.xml, " + "classpath:/applicationContext-resources.xml"); springListener = new ContextLoaderListener(); springListener.contextInitialized(new ServletContextEvent(sc)); listener = new StartupListener(); }
From source file:eu.openanalytics.rsb.config.BootstrapConfigurationServletContextListenerTestCase.java
@Before public void prepareTest() { bcscl = new BootstrapConfigurationServletContextListener(); mockServletContext = new MockServletContext() { @Override//from w w w. j av a 2 s . c om public String getRealPath(final String path) { return FileUtils.getTempDirectoryPath(); }; }; servletContextEvent = new ServletContextEvent(mockServletContext); }
From source file:ar.com.zauber.commons.spring.beans.factory.impl.ContextPathRegexCaseBlockTest.java
/** test */ public final void testCtxHouse() { final MockServletContext servletCtx = new MockServletContext("/house"); servletCtx.addInitParameter("contextConfigLocation", "classpath:/spring-test-switch-regex.xml"); final TestFriendlyContextLoaderListener listener = new TestFriendlyContextLoaderListener(); listener.contextInitialized(new ServletContextEvent(servletCtx)); final WebApplicationContext ctx = ((TestFriendlyContextLoader) listener.getContextLoader()).getCtx(); assertEquals("house", ctx.getBean("test1")); }
From source file:org.openmrs.contrib.metadatarepository.webapp.listener.StartupListenerTest.java
public void testContextInitialized() { listener.contextInitialized(new ServletContextEvent(sc)); assertTrue(sc.getAttribute(Constants.CONFIG) != null); Map config = (Map) sc.getAttribute(Constants.CONFIG); assertEquals(config.get(Constants.CSS_THEME), "simplicity"); assertTrue(sc.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE) != null); assertTrue(sc.getAttribute(Constants.AVAILABLE_ROLES) != null); }