use of org.springframework.core.env.SystemEnvironmentPropertySource in project spring-boot by spring-projects.
the class PropertiesConfigurationFactoryTests method testBindWithDashPrefix.
@Test
public void testBindWithDashPrefix() throws Exception {
// gh-4045
this.targetName = "foo-bar";
MutablePropertySources propertySources = new MutablePropertySources();
propertySources.addLast(new SystemEnvironmentPropertySource("systemEnvironment", Collections.<String, Object>singletonMap("FOO_BAR_NAME", "blah")));
propertySources.addLast(new RandomValuePropertySource());
setupFactory();
this.factory.setPropertySources(propertySources);
this.factory.afterPropertiesSet();
Foo foo = this.factory.getObject();
assertThat(foo.name).isEqualTo("blah");
}
use of org.springframework.core.env.SystemEnvironmentPropertySource in project spring-boot by spring-projects.
the class PropertiesConfigurationFactoryTests method testBindWithDelimitedPrefixUsingDifferentDelimiter.
@Test
public void testBindWithDelimitedPrefixUsingDifferentDelimiter() throws Exception {
this.targetName = "env.foo";
MutablePropertySources propertySources = new MutablePropertySources();
propertySources.addLast(new SystemEnvironmentPropertySource("systemEnvironment", Collections.<String, Object>singletonMap("ENV_FOO_NAME", "blah")));
propertySources.addLast(new RandomValuePropertySource("random"));
this.ignoreUnknownFields = false;
setupFactory();
this.factory.setPropertySources(propertySources);
this.factory.afterPropertiesSet();
Foo foo = this.factory.getObject();
assertThat(foo.name).isEqualTo("blah");
}
use of org.springframework.core.env.SystemEnvironmentPropertySource in project spring-boot by spring-projects.
the class PropertiesConfigurationFactoryTests method testBindWithDelimitedPrefixUsingMatchingDelimiter.
@Test
public void testBindWithDelimitedPrefixUsingMatchingDelimiter() throws Exception {
this.targetName = "env_foo";
this.ignoreUnknownFields = false;
MutablePropertySources propertySources = new MutablePropertySources();
propertySources.addLast(new SystemEnvironmentPropertySource("systemEnvironment", Collections.<String, Object>singletonMap("ENV_FOO_NAME", "blah")));
propertySources.addLast(new RandomValuePropertySource("random"));
setupFactory();
this.factory.setPropertySources(propertySources);
this.factory.afterPropertiesSet();
Foo foo = this.factory.getObject();
assertThat(foo.name).isEqualTo("blah");
}
Aggregations