use of org.springframework.boot.context.properties.source.MapConfigurationPropertySource in project spring-boot by spring-projects.
the class ConfigDataPropertiesTests method getImportOriginWhenCommaListReturnsOrigin.
@Test
void getImportOriginWhenCommaListReturnsOrigin() {
MapConfigurationPropertySource source = new MapConfigurationPropertySource();
source.put("spring.config.import", "one,two,three");
Binder binder = new Binder(source);
ConfigDataProperties properties = ConfigDataProperties.get(binder);
assertThat(properties.getImports().get(1).getOrigin()).hasToString("\"spring.config.import\" from property source \"source\"");
}
use of org.springframework.boot.context.properties.source.MapConfigurationPropertySource in project spring-boot by spring-projects.
the class ConfigDataPropertiesTests method isActiveAgainstBoundDataWhenCloudPlatformDoesntMatch.
@Test
void isActiveAgainstBoundDataWhenCloudPlatformDoesntMatch() {
MapConfigurationPropertySource source = new MapConfigurationPropertySource();
source.put("spring.config.activate.on-cloud-platform", "cloud-foundry");
source.put("spring.config.activate.on-profile", "a | b");
Binder binder = new Binder(source);
ConfigDataProperties properties = ConfigDataProperties.get(binder);
ConfigDataActivationContext context = new ConfigDataActivationContext(CloudPlatform.KUBERNETES, createTestProfiles());
assertThat(properties.isActive(context)).isFalse();
}
use of org.springframework.boot.context.properties.source.MapConfigurationPropertySource in project spring-boot by spring-projects.
the class ProfilesTests method getDefaultWhenDefaultEnvironmentProfileAndBinderProperty.
@Test
void getDefaultWhenDefaultEnvironmentProfileAndBinderProperty() {
MockEnvironment environment = new MockEnvironment();
environment.setProperty("spring.profiles.default", "default");
List<ConfigurationPropertySource> sources = new ArrayList<>();
ConfigurationPropertySources.get(environment).forEach(sources::add);
sources.add(new MapConfigurationPropertySource(Collections.singletonMap("spring.profiles.default", "a,b,c")));
Binder binder = new Binder(sources);
Profiles profiles = new Profiles(environment, binder, null);
assertThat(profiles.getDefault()).containsExactly("default");
}
use of org.springframework.boot.context.properties.source.MapConfigurationPropertySource in project spring-boot by spring-projects.
the class ProfilesTests method getActiveWhenEnvironmentProfilesAndBinderProperty.
@Test
void getActiveWhenEnvironmentProfilesAndBinderProperty() {
MockEnvironment environment = new MockEnvironment();
environment.setActiveProfiles("a", "b", "c");
Binder binder = new Binder(new MapConfigurationPropertySource(Collections.singletonMap("spring.profiles.active", "d,e,f")));
Profiles profiles = new Profiles(environment, binder, null);
assertThat(profiles.getActive()).containsExactly("a", "b", "c", "d", "e", "f");
}
use of org.springframework.boot.context.properties.source.MapConfigurationPropertySource in project spring-boot by spring-projects.
the class ProfilesTests method getActiveWhenNoEnvironmentProfilesAndBinderProperty.
@Test
void getActiveWhenNoEnvironmentProfilesAndBinderProperty() {
Environment environment = new MockEnvironment();
Binder binder = new Binder(new MapConfigurationPropertySource(Collections.singletonMap("spring.profiles.active", "a,b,c")));
Profiles profiles = new Profiles(environment, binder, null);
assertThat(profiles.getActive()).containsExactly("a", "b", "c");
}
Aggregations