use of org.springframework.boot.context.properties.source.MapConfigurationPropertySource in project spring-boot by spring-projects.
the class ConfigDataLocationBindHandlerTests method bindToValueObjectFromCommaStringPropertyIgnoresEmptyElements.
@Test
void bindToValueObjectFromCommaStringPropertyIgnoresEmptyElements() {
MapConfigurationPropertySource source = new MapConfigurationPropertySource();
source.put("test.locations", ",a,b,,c,");
Binder binder = new Binder(source);
ValueObject bound = binder.bind("test", VALUE_OBJECT, this.handler).get();
String expectedLocation = "\"test.locations\" from property source \"source\"";
assertThat(bound.getLocation(0)).hasToString("a");
assertThat(bound.getLocation(0).getOrigin()).hasToString(expectedLocation);
assertThat(bound.getLocation(1)).hasToString("b");
assertThat(bound.getLocation(1).getOrigin()).hasToString(expectedLocation);
assertThat(bound.getLocation(2)).hasToString("c");
assertThat(bound.getLocation(2).getOrigin()).hasToString(expectedLocation);
}
use of org.springframework.boot.context.properties.source.MapConfigurationPropertySource in project spring-boot by spring-projects.
the class ConfigDataLocationBindHandlerTests method bindToArrayFromCommaStringPropertyIgnoresEmptyElements.
@Test
void bindToArrayFromCommaStringPropertyIgnoresEmptyElements() {
MapConfigurationPropertySource source = new MapConfigurationPropertySource();
source.put("locations", ",a,,b,c,");
Binder binder = new Binder(source);
ConfigDataLocation[] bound = binder.bind("locations", ARRAY, this.handler).get();
String expectedLocation = "\"locations\" from property source \"source\"";
assertThat(bound[0]).hasToString("a");
assertThat(bound[0].getOrigin()).hasToString(expectedLocation);
assertThat(bound[1]).hasToString("b");
assertThat(bound[1].getOrigin()).hasToString(expectedLocation);
assertThat(bound[2]).hasToString("c");
assertThat(bound[2].getOrigin()).hasToString(expectedLocation);
}
use of org.springframework.boot.context.properties.source.MapConfigurationPropertySource in project spring-boot by spring-projects.
the class ConfigDataLocationBindHandlerTests method bindToValueObjectFromCommaStringPropertySetsOrigin.
@Test
void bindToValueObjectFromCommaStringPropertySetsOrigin() {
MapConfigurationPropertySource source = new MapConfigurationPropertySource();
source.put("test.locations", "a,b,c");
Binder binder = new Binder(source);
ValueObject bound = binder.bind("test", VALUE_OBJECT, this.handler).get();
String expectedLocation = "\"test.locations\" from property source \"source\"";
assertThat(bound.getLocation(0)).hasToString("a");
assertThat(bound.getLocation(0).getOrigin()).hasToString(expectedLocation);
assertThat(bound.getLocation(1)).hasToString("b");
assertThat(bound.getLocation(1).getOrigin()).hasToString(expectedLocation);
assertThat(bound.getLocation(2)).hasToString("c");
assertThat(bound.getLocation(2).getOrigin()).hasToString(expectedLocation);
}
use of org.springframework.boot.context.properties.source.MapConfigurationPropertySource in project spring-boot by spring-projects.
the class ConfigDataPropertiesTests method getImportOriginWhenBracketListReturnsOrigin.
@Test
void getImportOriginWhenBracketListReturnsOrigin() {
MapConfigurationPropertySource source = new MapConfigurationPropertySource();
source.put("spring.config.import[0]", "one");
source.put("spring.config.import[1]", "two");
source.put("spring.config.import[2]", "three");
Binder binder = new Binder(source);
ConfigDataProperties properties = ConfigDataProperties.get(binder);
assertThat(properties.getImports().get(1).getOrigin()).hasToString("\"spring.config.import[1]\" from property source \"source\"");
}
use of org.springframework.boot.context.properties.source.MapConfigurationPropertySource in project apollo by ctripcorp.
the class ApolloClientPropertiesFactoryTest method testCreateApolloClientProperties.
@Test
public void testCreateApolloClientProperties() throws IOException {
Map<String, String> map = new LinkedHashMap<>();
map.put("apollo.client.extension.enabled", "true");
map.put("apollo.client.extension.messaging-type", "long_polling");
MapConfigurationPropertySource propertySource = new MapConfigurationPropertySource(map);
Binder binder = new Binder(propertySource);
ApolloClientPropertiesFactory factory = new ApolloClientPropertiesFactory();
ApolloClientProperties apolloClientProperties = factory.createApolloClientProperties(binder, null);
Assert.assertEquals(apolloClientProperties.getExtension().getEnabled(), true);
Assert.assertEquals(apolloClientProperties.getExtension().getMessagingType(), ApolloClientMessagingType.LONG_POLLING);
}
Aggregations