context.getEnvironment().setActiveProfiles(mergedConfig.getActiveProfiles()); TestPropertySourceUtils.addPropertiesFilesToEnvironment(context, mergedConfig.getPropertySourceLocations()); TestPropertySourceUtils.addInlinedPropertiesToEnvironment(context, mergedConfig.getPropertySourceProperties());
void assertMergedConfig( MergedContextConfiguration mergedConfig, Class<?> expectedTestClass, String[] expectedLocations, Class<?>[] expectedClasses, Set<Class<? extends ApplicationContextInitializer<?>>> expectedInitializerClasses, Class<? extends ContextLoader> expectedContextLoaderClass) { assertNotNull(mergedConfig); assertEquals(expectedTestClass, mergedConfig.getTestClass()); assertNotNull(mergedConfig.getLocations()); assertArrayEquals(expectedLocations, mergedConfig.getLocations()); assertNotNull(mergedConfig.getClasses()); assertArrayEquals(expectedClasses, mergedConfig.getClasses()); assertNotNull(mergedConfig.getActiveProfiles()); if (expectedContextLoaderClass == null) { assertNull(mergedConfig.getContextLoader()); } else { assertEquals(expectedContextLoaderClass, mergedConfig.getContextLoader().getClass()); } assertNotNull(mergedConfig.getContextInitializerClasses()); assertEquals(expectedInitializerClasses, mergedConfig.getContextInitializerClasses()); }
public final ConfigurableApplicationContext loadContext(MergedContextConfiguration mergedConfig) throws Exception { if (log.isDebugEnabled()) { log.debug("Loading ApplicationContext for merged context configuration [" + mergedConfig + "]."); } ResourceLoadingXmlApplicationContext context = new ResourceLoadingXmlApplicationContext(mergedConfig.getLocations(), testResourceLoader, false); context.getEnvironment().setActiveProfiles(mergedConfig.getActiveProfiles()); prepareContext(context); context.refresh(); context.registerShutdownHook(); return context; }
public final ConfigurableApplicationContext loadContext(MergedContextConfiguration mergedConfig) throws Exception { if (log.isDebugEnabled()) { log.debug("Loading ApplicationContext for merged context configuration [" + mergedConfig + "]."); } ResourceLoadingXmlApplicationContext context = new ResourceLoadingXmlApplicationContext(mergedConfig.getLocations(), testResourceLoader, false); context.getEnvironment().setActiveProfiles(mergedConfig.getActiveProfiles()); prepareContext(context); context.refresh(); context.registerShutdownHook(); return context; }
public TinyMergedContextConfiguration(ContextLoader contextLoader, CacheAwareContextLoaderDelegate contextLoaderDelegate, MergedContextConfiguration mergedContextConfiguration, MergedContextConfiguration parentConfiguration) { super(mergedContextConfiguration.getTestClass(), mergedContextConfiguration.getLocations(), mergedContextConfiguration.getClasses(), mergedContextConfiguration.getActiveProfiles(), contextLoader); this.mergedContextConfiguration = mergedContextConfiguration; this.contextLoaderDelegate = contextLoaderDelegate; this.parentConfiguration = parentConfiguration; }
public ApplicationContext loadContext(MergedContextConfiguration mergedConfig) throws Exception { if (logger.isDebugEnabled()) { logger.debug("Loading ApplicationContext for merged context configuration [" + mergedConfig + "]."); } GenericWebApplicationContext context = new GenericWebApplicationContext(); ConfigurableEnvironment environment = context.getEnvironment(); environment.setActiveProfiles(mergedConfig.getActiveProfiles()); return loadContext(context, mergedConfig.getLocations()); }
application.getSources().addAll(Arrays.asList(configLocations)); ConfigurableEnvironment environment = getEnvironment(); if (!ObjectUtils.isEmpty(config.getActiveProfiles())) { setActiveProfiles(environment, config.getActiveProfiles());
/** * Create a new {@link MergedContextConfiguration} with different classes and * properties. * @param mergedConfig the source config * @param classes the replacement classes * @param propertySourceProperties the replacement properties * @return a new {@link MergedContextConfiguration} */ protected final MergedContextConfiguration createModifiedConfig( MergedContextConfiguration mergedConfig, Class<?>[] classes, String[] propertySourceProperties) { return new MergedContextConfiguration(mergedConfig.getTestClass(), mergedConfig.getLocations(), classes, mergedConfig.getContextInitializerClasses(), mergedConfig.getActiveProfiles(), mergedConfig.getPropertySourceLocations(), propertySourceProperties, mergedConfig.getContextCustomizers(), mergedConfig.getContextLoader(), getCacheAwareContextLoaderDelegate(), mergedConfig.getParent()); }
context.getEnvironment().setActiveProfiles(mergedConfig.getActiveProfiles()); TestPropertySourceUtils.addPropertiesFilesToEnvironment(context, mergedConfig.getPropertySourceLocations()); TestPropertySourceUtils.addInlinedPropertiesToEnvironment(context, mergedConfig.getPropertySourceProperties());
context.getEnvironment().setActiveProfiles(mergedConfig.getActiveProfiles()); TestPropertySourceUtils.addPropertiesFilesToEnvironment(context, mergedConfig.getPropertySourceLocations()); TestPropertySourceUtils.addInlinedPropertiesToEnvironment(context, mergedConfig.getPropertySourceProperties());