List of usage examples for org.springframework.data.gemfire.support SpringContextBootstrappingInitializer CONTEXT_CONFIG_LOCATIONS_PARAMETER
String CONTEXT_CONFIG_LOCATIONS_PARAMETER
To view the source code for org.springframework.data.gemfire.support SpringContextBootstrappingInitializer CONTEXT_CONFIG_LOCATIONS_PARAMETER.
Click Source Link
From source file:org.spring.data.gemfire.app.main.InitializerPeerCacheApp.java
@Override protected ConfigurableApplicationContext initApplicationContext(final String... args) { new SpringContextBootstrappingInitializer().init(PropertyUtils.createProperties( Collections.singletonMap(SpringContextBootstrappingInitializer.CONTEXT_CONFIG_LOCATIONS_PARAMETER, StringUtils.arrayToCommaDelimitedString(getConfigurationFile(args))))); return SpringContextBootstrappingInitializer.getApplicationContext(); }
From source file:org.springframework.data.gemfire.support.SpringContextBootstrappingInitializerTest.java
@Test public void testInitWhenApplicationContextIsNull() { assertNull(SpringContextBootstrappingInitializer.applicationContext); final ConfigurableApplicationContext mockApplicationContext = mock(ConfigurableApplicationContext.class, "testInitWhenApplicationContextIsNull"); when(mockApplicationContext.getId()).thenReturn("testInitWhenApplicationContextIsNull"); when(mockApplicationContext.isRunning()).thenReturn(true); SpringContextBootstrappingInitializer initializer = new SpringContextBootstrappingInitializer() { @Override/*from www . ja va 2 s .co m*/ protected ConfigurableApplicationContext createApplicationContext(final String[] basePackages, final String[] configLocations) { return mockApplicationContext; } }; initializer.init(createParameters(SpringContextBootstrappingInitializer.CONTEXT_CONFIG_LOCATIONS_PARAMETER, "/path/to/spring/application/context.xml")); verify(mockApplicationContext, times(1)).addApplicationListener(same(initializer)); verify(mockApplicationContext, times(1)).registerShutdownHook(); verify(mockApplicationContext, times(1)).refresh(); assertSame(mockApplicationContext, SpringContextBootstrappingInitializer.getApplicationContext()); }
From source file:org.springframework.data.gemfire.support.SpringContextBootstrappingInitializerTest.java
@Test(expected = IllegalArgumentException.class) public void testInitWhenBasePackagesAndContextConfigLocationsParametersAreUnspecified() throws Throwable { assertNull(SpringContextBootstrappingInitializer.applicationContext); try {/*from w w w . j av a2 s . c o m*/ new SpringContextBootstrappingInitializer().init(createParameters( createParameters(SpringContextBootstrappingInitializer.CONTEXT_CONFIG_LOCATIONS_PARAMETER, ""), SpringContextBootstrappingInitializer.BASE_PACKAGES_PARAMETER, " ")); } catch (ApplicationContextException expected) { assertTrue(expected.getMessage().contains("Failed to bootstrap the Spring ApplicationContext!")); assertTrue(expected.getCause() instanceof IllegalArgumentException); assertEquals("'basePackages', 'configLocations' or 'AnnotatedClasses' must be specified" + " in order to construct and configure an instance of the ConfigurableApplicationContext", expected.getCause().getMessage()); throw expected.getCause(); } }
From source file:org.springframework.data.gemfire.support.SpringContextBootstrappingInitializerTest.java
@Test(expected = IllegalStateException.class) public void testInitLogsErrors() throws Throwable { final Log mockLog = mock(Log.class, "testInitLogsErrors.MockLog"); SpringContextBootstrappingInitializer initializer = new SpringContextBootstrappingInitializer() { @Override/*from w w w. j a v a2 s . c o m*/ protected Log initLogger() { return mockLog; } @Override protected ConfigurableApplicationContext createApplicationContext(final String[] basePackages, final String[] configLocations) { throw new IllegalStateException("TEST"); } }; try { initializer .init(createParameters(SpringContextBootstrappingInitializer.CONTEXT_CONFIG_LOCATIONS_PARAMETER, "classpath/to/spring/application/context.xml")); } catch (ApplicationContextException expected) { assertTrue(expected.getMessage().contains("Failed to bootstrap the Spring ApplicationContext!")); assertTrue(expected.getCause() instanceof IllegalStateException); assertEquals("TEST", expected.getCause().getMessage()); throw expected.getCause(); } finally { verify(mockLog, times(1)).error(eq("Failed to bootstrap the Spring ApplicationContext!"), any(RuntimeException.class)); } }