Search in sources :

Example 1 with PropertySourceDescriptor

use of org.springframework.boot.actuate.env.EnvironmentEndpoint.PropertySourceDescriptor in project spring-boot by spring-projects.

the class EnvironmentEndpointTests method basicResponse.

@Test
void basicResponse() {
    ConfigurableEnvironment environment = emptyEnvironment();
    environment.getPropertySources().addLast(singleKeyPropertySource("one", "my.key", "first"));
    environment.getPropertySources().addLast(singleKeyPropertySource("two", "my.key", "second"));
    EnvironmentDescriptor descriptor = new EnvironmentEndpoint(environment).environment(null);
    assertThat(descriptor.getActiveProfiles()).isEmpty();
    Map<String, PropertySourceDescriptor> sources = propertySources(descriptor);
    assertThat(sources.keySet()).containsExactly("one", "two");
    assertThat(sources.get("one").getProperties()).containsOnlyKeys("my.key");
    assertThat(sources.get("two").getProperties()).containsOnlyKeys("my.key");
}
Also used : PropertySourceDescriptor(org.springframework.boot.actuate.env.EnvironmentEndpoint.PropertySourceDescriptor) ConfigurableEnvironment(org.springframework.core.env.ConfigurableEnvironment) EnvironmentDescriptor(org.springframework.boot.actuate.env.EnvironmentEndpoint.EnvironmentDescriptor) Test(org.junit.jupiter.api.Test)

Example 2 with PropertySourceDescriptor

use of org.springframework.boot.actuate.env.EnvironmentEndpoint.PropertySourceDescriptor in project spring-boot by spring-projects.

the class EnvironmentEndpointTests method multipleSourcesWithSameProperty.

@Test
void multipleSourcesWithSameProperty() {
    ConfigurableEnvironment environment = emptyEnvironment();
    environment.getPropertySources().addFirst(singleKeyPropertySource("one", "a", "alpha"));
    environment.getPropertySources().addFirst(singleKeyPropertySource("two", "a", "apple"));
    EnvironmentDescriptor descriptor = new EnvironmentEndpoint(environment).environment(null);
    Map<String, PropertySourceDescriptor> sources = propertySources(descriptor);
    assertThat(sources.keySet()).containsExactly("two", "one");
    assertThat(sources.get("one").getProperties().get("a").getValue()).isEqualTo("alpha");
    assertThat(sources.get("two").getProperties().get("a").getValue()).isEqualTo("apple");
}
Also used : PropertySourceDescriptor(org.springframework.boot.actuate.env.EnvironmentEndpoint.PropertySourceDescriptor) ConfigurableEnvironment(org.springframework.core.env.ConfigurableEnvironment) EnvironmentDescriptor(org.springframework.boot.actuate.env.EnvironmentEndpoint.EnvironmentDescriptor) Test(org.junit.jupiter.api.Test)

Example 3 with PropertySourceDescriptor

use of org.springframework.boot.actuate.env.EnvironmentEndpoint.PropertySourceDescriptor in project spring-boot by spring-projects.

the class EnvironmentEndpointTests method compositeSourceIsHandledCorrectly.

@Test
void compositeSourceIsHandledCorrectly() {
    ConfigurableEnvironment environment = emptyEnvironment();
    CompositePropertySource source = new CompositePropertySource("composite");
    source.addPropertySource(new MapPropertySource("one", Collections.singletonMap("foo", "bar")));
    source.addPropertySource(new MapPropertySource("two", Collections.singletonMap("foo", "spam")));
    environment.getPropertySources().addFirst(source);
    EnvironmentDescriptor descriptor = new EnvironmentEndpoint(environment).environment(null);
    Map<String, PropertySourceDescriptor> sources = propertySources(descriptor);
    assertThat(sources.keySet()).containsExactly("composite:one", "composite:two");
    assertThat(sources.get("composite:one").getProperties().get("foo").getValue()).isEqualTo("bar");
    assertThat(sources.get("composite:two").getProperties().get("foo").getValue()).isEqualTo("spam");
}
Also used : PropertySourceDescriptor(org.springframework.boot.actuate.env.EnvironmentEndpoint.PropertySourceDescriptor) ConfigurableEnvironment(org.springframework.core.env.ConfigurableEnvironment) CompositePropertySource(org.springframework.core.env.CompositePropertySource) MapPropertySource(org.springframework.core.env.MapPropertySource) EnvironmentDescriptor(org.springframework.boot.actuate.env.EnvironmentEndpoint.EnvironmentDescriptor) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)3 EnvironmentDescriptor (org.springframework.boot.actuate.env.EnvironmentEndpoint.EnvironmentDescriptor)3 PropertySourceDescriptor (org.springframework.boot.actuate.env.EnvironmentEndpoint.PropertySourceDescriptor)3 ConfigurableEnvironment (org.springframework.core.env.ConfigurableEnvironment)3 CompositePropertySource (org.springframework.core.env.CompositePropertySource)1 MapPropertySource (org.springframework.core.env.MapPropertySource)1