use of org.springframework.boot.context.properties.source.ConfigurationPropertySource in project spring-cloud-open-service-broker by spring-cloud.
the class ServiceBrokerPropertiesTest method emptyCatalog.
@Test
public void emptyCatalog() {
Map<String, String> map = new HashMap<>();
ConfigurationPropertySource source = new MapConfigurationPropertySource(map);
Binder binder = new Binder(source);
ServiceBrokerProperties properties = new ServiceBrokerProperties();
binder.bind("spring.cloud.openservicebroker", Bindable.ofInstance(properties));
assertThat(properties.getCatalog()).isNull();
}
use of org.springframework.boot.context.properties.source.ConfigurationPropertySource in project spring-boot by spring-projects.
the class InactiveConfigDataAccessExceptionTests method throwIfPropertyFoundWhenPropertyNotFoundDoesNothing.
@Test
void throwIfPropertyFoundWhenPropertyNotFoundDoesNothing() {
ConfigDataEnvironmentContributor contributor = mock(ConfigDataEnvironmentContributor.class);
ConfigurationPropertySource configurationPropertySource = ConfigurationPropertySource.from(this.propertySource);
given(contributor.getConfigurationPropertySource()).willReturn(configurationPropertySource);
InactiveConfigDataAccessException.throwIfPropertyFound(contributor, ConfigurationPropertyName.of("spring"));
}
use of org.springframework.boot.context.properties.source.ConfigurationPropertySource in project spring-boot by spring-projects.
the class ProfilesTests method getActiveWhenEnvironmentProfilesAndBinderPropertyShouldReturnEnvironmentProperty.
@Test
void getActiveWhenEnvironmentProfilesAndBinderPropertyShouldReturnEnvironmentProperty() {
MockEnvironment environment = new MockEnvironment();
environment.setProperty("spring.profiles.active", "a,b,c");
List<ConfigurationPropertySource> sources = new ArrayList<>();
ConfigurationPropertySources.get(environment).forEach(sources::add);
sources.add(new MapConfigurationPropertySource(Collections.singletonMap("spring.profiles.active", "d,e,f")));
Binder binder = new Binder(sources);
Profiles profiles = new Profiles(environment, binder, null);
assertThat(profiles.getActive()).containsExactly("a", "b", "c");
}
use of org.springframework.boot.context.properties.source.ConfigurationPropertySource in project spring-boot by spring-projects.
the class WebFluxPropertiesTests method bind.
private void bind(Map<String, String> map) {
ConfigurationPropertySource source = new MapConfigurationPropertySource(map);
new Binder(source).bind("spring.webflux", Bindable.ofInstance(this.properties));
}
use of org.springframework.boot.context.properties.source.ConfigurationPropertySource in project spring-boot by spring-projects.
the class NoUnboundElementsBindHandlerTests method bindWhenUsingNoUnboundElementsHandlerShouldBindIfUnboundSystemProperties.
@Test
void bindWhenUsingNoUnboundElementsHandlerShouldBindIfUnboundSystemProperties() {
MockConfigurationPropertySource source = new MockConfigurationPropertySource();
source.put("example.foo", "bar");
source.put("example.other", "baz");
this.sources.add(source);
this.binder = new Binder(this.sources);
NoUnboundElementsBindHandler handler = new NoUnboundElementsBindHandler(BindHandler.DEFAULT, ((configurationPropertySource) -> false));
Example bound = this.binder.bind("example", Bindable.of(Example.class), handler).get();
assertThat(bound.getFoo()).isEqualTo("bar");
}
Aggregations