Search in sources :

Example 11 with MapConfigurationPropertySource

use of org.springframework.boot.context.properties.source.MapConfigurationPropertySource in project spring-boot by spring-projects.

the class MapBinderTests method bindToMapWhenMultipleInSameSourceCandidateShouldBindFirst.

@Test
void bindToMapWhenMultipleInSameSourceCandidateShouldBindFirst() {
    Map<String, Object> map = new HashMap<>();
    map.put("foo.bar", "1");
    map.put("foo.b-az", "2");
    map.put("foo.ba-z", "3");
    map.put("foo.bin", "4");
    MapConfigurationPropertySource propertySource = new MapConfigurationPropertySource(map);
    this.sources.add(propertySource);
    Map<String, Integer> result = this.binder.bind("foo", STRING_INTEGER_MAP).get();
    assertThat(result).hasSize(4);
    assertThat(result).containsEntry("bar", 1);
    assertThat(result).containsEntry("b-az", 2);
    assertThat(result).containsEntry("ba-z", 3);
    assertThat(result).containsEntry("bin", 4);
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) MapConfigurationPropertySource(org.springframework.boot.context.properties.source.MapConfigurationPropertySource) Test(org.junit.jupiter.api.Test)

Example 12 with MapConfigurationPropertySource

use of org.springframework.boot.context.properties.source.MapConfigurationPropertySource in project spring-boot by spring-projects.

the class SpringBootTestContextBootstrapper method getWebApplicationType.

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);
}
Also used : Binder(org.springframework.boot.context.properties.bind.Binder) ConfigurationPropertySource(org.springframework.boot.context.properties.source.ConfigurationPropertySource) MapConfigurationPropertySource(org.springframework.boot.context.properties.source.MapConfigurationPropertySource) MapConfigurationPropertySource(org.springframework.boot.context.properties.source.MapConfigurationPropertySource)

Example 13 with MapConfigurationPropertySource

use of org.springframework.boot.context.properties.source.MapConfigurationPropertySource in project spring-boot by spring-projects.

the class ServerPropertiesTests method bind.

private void bind(Map<String, String> map) {
    ConfigurationPropertySource source = new MapConfigurationPropertySource(map);
    new Binder(source).bind("server", Bindable.ofInstance(this.properties));
}
Also used : Binder(org.springframework.boot.context.properties.bind.Binder) ConfigurationPropertySource(org.springframework.boot.context.properties.source.ConfigurationPropertySource) MapConfigurationPropertySource(org.springframework.boot.context.properties.source.MapConfigurationPropertySource) MapConfigurationPropertySource(org.springframework.boot.context.properties.source.MapConfigurationPropertySource)

Example 14 with MapConfigurationPropertySource

use of org.springframework.boot.context.properties.source.MapConfigurationPropertySource in project spring-boot by spring-projects.

the class Saml2RelyingPartyPropertiesTests method bind.

private void bind(Map<String, String> map) {
    ConfigurationPropertySource source = new MapConfigurationPropertySource(map);
    new Binder(source).bind("spring.security.saml2.relyingparty", Bindable.ofInstance(this.properties));
}
Also used : Binder(org.springframework.boot.context.properties.bind.Binder) ConfigurationPropertySource(org.springframework.boot.context.properties.source.ConfigurationPropertySource) MapConfigurationPropertySource(org.springframework.boot.context.properties.source.MapConfigurationPropertySource) MapConfigurationPropertySource(org.springframework.boot.context.properties.source.MapConfigurationPropertySource)

Example 15 with MapConfigurationPropertySource

use of org.springframework.boot.context.properties.source.MapConfigurationPropertySource in project spring-boot by spring-projects.

the class ServletWebServerFactoryCustomizerTests method bindProperties.

private void bindProperties(Map<String, String> map) {
    ConfigurationPropertySource source = new MapConfigurationPropertySource(map);
    new Binder(source).bind("server", Bindable.ofInstance(this.properties));
}
Also used : Binder(org.springframework.boot.context.properties.bind.Binder) ConfigurationPropertySource(org.springframework.boot.context.properties.source.ConfigurationPropertySource) MapConfigurationPropertySource(org.springframework.boot.context.properties.source.MapConfigurationPropertySource) MapConfigurationPropertySource(org.springframework.boot.context.properties.source.MapConfigurationPropertySource)

Aggregations

MapConfigurationPropertySource (org.springframework.boot.context.properties.source.MapConfigurationPropertySource)35 Binder (org.springframework.boot.context.properties.bind.Binder)32 Test (org.junit.jupiter.api.Test)21 ConfigurationPropertySource (org.springframework.boot.context.properties.source.ConfigurationPropertySource)11 MockEnvironment (org.springframework.mock.env.MockEnvironment)7 HashMap (java.util.HashMap)4 Test (org.junit.Test)4 LinkedHashMap (java.util.LinkedHashMap)3 Environment (org.springframework.core.env.Environment)3 ArrayList (java.util.ArrayList)2 ApolloClientProperties (com.ctrip.framework.apollo.config.data.extension.properties.ApolloClientProperties)1 DataSourceBeanCreationException (org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.DataSourceBeanCreationException)1 ConfigurationPropertyNameAliases (org.springframework.boot.context.properties.source.ConfigurationPropertyNameAliases)1 Catalog (org.springframework.cloud.servicebroker.model.catalog.Catalog)1 Binder (org.springframework.cloud.stream.binder.Binder)1 ExtendedPropertiesBinder (org.springframework.cloud.stream.binder.ExtendedPropertiesBinder)1 BindingServiceProperties (org.springframework.cloud.stream.config.BindingServiceProperties)1 StandardEnvironment (org.springframework.core.env.StandardEnvironment)1 BeanPropertyBindingResult (org.springframework.validation.BeanPropertyBindingResult)1 BindException (org.springframework.validation.BindException)1