context.getEnvironment().setActiveProfiles(mergedConfig.getActiveProfiles()); TestPropertySourceUtils.addPropertiesFilesToEnvironment(context, mergedConfig.getPropertySourceLocations()); TestPropertySourceUtils.addInlinedPropertiesToEnvironment(context, mergedConfig.getPropertySourceProperties()); invokeApplicationContextInitializers(context, mergedConfig);
/** * Create a new {@link MergedContextConfiguration} with different classes. * @param mergedConfig the source config * @param classes the replacement classes * @return a new {@link MergedContextConfiguration} */ protected final MergedContextConfiguration createModifiedConfig( MergedContextConfiguration mergedConfig, Class<?>[] classes) { return createModifiedConfig(mergedConfig, classes, mergedConfig.getPropertySourceProperties()); }
private List<String> getAndProcessPropertySourceProperties( MergedContextConfiguration mergedConfig) { List<String> propertySourceProperties = new ArrayList<>( Arrays.asList(mergedConfig.getPropertySourceProperties())); String differentiator = getDifferentiatorPropertySourceProperty(); if (differentiator != null) { propertySourceProperties.add(differentiator); } processPropertySourceProperties(mergedConfig, propertySourceProperties); return propertySourceProperties; }
private void addPropertySourcePropertiesUsingReflection(TestContext testContext, String[] properties) { MergedContextConfiguration configuration = (MergedContextConfiguration) ReflectionTestUtils.getField(testContext, "mergedContextConfiguration"); Set<String> merged = new LinkedHashSet<String>(Arrays.asList(configuration.getPropertySourceProperties())); merged.addAll(Arrays.asList(properties)); addIntegrationTestProperty(merged); ReflectionTestUtils.setField(configuration, "propertySourceProperties", merged.toArray(new String[merged.size()])); }
protected String[] getInlinedProperties(MergedContextConfiguration config) { ArrayList<String> properties = new ArrayList<>(); // JMX bean names will clash if the same bean is used in multiple contexts disableJmx(properties); properties.addAll(Arrays.asList(config.getPropertySourceProperties())); if (!isEmbeddedWebEnvironment(config) && !hasCustomServerPort(properties)) { properties.add("server.port=-1"); } return StringUtils.toStringArray(properties); }
private WebApplicationType getWebApplicationType( MergedContextConfiguration configuration) { ConfigurationPropertySource source = new MapConfigurationPropertySource( TestPropertySourceUtils.convertInlinedPropertiesToMap( configuration.getPropertySourceProperties())); Binder binder = new Binder(source); return binder .bind("spring.main.web-application-type", Bindable.of(WebApplicationType.class)) .orElseGet(this::deduceWebApplicationType); }
context.getEnvironment().setActiveProfiles(mergedConfig.getActiveProfiles()); TestPropertySourceUtils.addPropertiesFilesToEnvironment(context, mergedConfig.getPropertySourceLocations()); TestPropertySourceUtils.addInlinedPropertiesToEnvironment(context, mergedConfig.getPropertySourceProperties()); invokeApplicationContextInitializers(context, mergedConfig);
context.getEnvironment().setActiveProfiles(mergedConfig.getActiveProfiles()); TestPropertySourceUtils.addPropertiesFilesToEnvironment(context, mergedConfig.getPropertySourceLocations()); TestPropertySourceUtils.addInlinedPropertiesToEnvironment(context, mergedConfig.getPropertySourceProperties()); invokeApplicationContextInitializers(context, mergedConfig);