Search in sources :

Example 1 with PropertySourceEntryDescriptor

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

the class EnvironmentEndpointTests method propertyEntryNotFound.

@Test
void propertyEntryNotFound() {
    ConfigurableEnvironment environment = emptyEnvironment();
    environment.getPropertySources().addFirst(singleKeyPropertySource("test", "foo", "bar"));
    EnvironmentEntryDescriptor descriptor = new EnvironmentEndpoint(environment).environmentEntry("does.not.exist");
    assertThat(descriptor).isNotNull();
    assertThat(descriptor.getProperty()).isNull();
    Map<String, PropertySourceEntryDescriptor> sources = propertySources(descriptor);
    assertThat(sources.keySet()).containsExactly("test");
    assertPropertySourceEntryDescriptor(sources.get("test"), null, null);
}
Also used : ConfigurableEnvironment(org.springframework.core.env.ConfigurableEnvironment) PropertySourceEntryDescriptor(org.springframework.boot.actuate.env.EnvironmentEndpoint.PropertySourceEntryDescriptor) EnvironmentEntryDescriptor(org.springframework.boot.actuate.env.EnvironmentEndpoint.EnvironmentEntryDescriptor) Test(org.junit.jupiter.api.Test)

Example 2 with PropertySourceEntryDescriptor

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

the class EnvironmentEndpointTests method propertyEntry.

@Test
void propertyEntry() {
    TestPropertyValues.of("my.foo=another").applyToSystemProperties(() -> {
        StandardEnvironment environment = new StandardEnvironment();
        TestPropertyValues.of("my.foo=bar", "my.foo2=bar2").applyTo(environment, TestPropertyValues.Type.MAP, "test");
        EnvironmentEntryDescriptor descriptor = new EnvironmentEndpoint(environment).environmentEntry("my.foo");
        assertThat(descriptor).isNotNull();
        assertThat(descriptor.getProperty()).isNotNull();
        assertThat(descriptor.getProperty().getSource()).isEqualTo("test");
        assertThat(descriptor.getProperty().getValue()).isEqualTo("bar");
        Map<String, PropertySourceEntryDescriptor> sources = propertySources(descriptor);
        assertThat(sources.keySet()).containsExactly("test", "systemProperties", "systemEnvironment");
        assertPropertySourceEntryDescriptor(sources.get("test"), "bar", null);
        assertPropertySourceEntryDescriptor(sources.get("systemProperties"), "another", null);
        assertPropertySourceEntryDescriptor(sources.get("systemEnvironment"), null, null);
        return null;
    });
}
Also used : PropertySourceEntryDescriptor(org.springframework.boot.actuate.env.EnvironmentEndpoint.PropertySourceEntryDescriptor) EnvironmentEntryDescriptor(org.springframework.boot.actuate.env.EnvironmentEndpoint.EnvironmentEntryDescriptor) StandardEnvironment(org.springframework.core.env.StandardEnvironment) Test(org.junit.jupiter.api.Test)

Example 3 with PropertySourceEntryDescriptor

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

the class EnvironmentEndpointTests method originAndOriginParents.

@Test
void originAndOriginParents() {
    StandardEnvironment environment = new StandardEnvironment();
    OriginParentMockPropertySource propertySource = new OriginParentMockPropertySource();
    propertySource.setProperty("name", "test");
    environment.getPropertySources().addFirst(propertySource);
    EnvironmentEntryDescriptor descriptor = new EnvironmentEndpoint(environment).environmentEntry("name");
    PropertySourceEntryDescriptor entryDescriptor = propertySources(descriptor).get("mockProperties");
    assertThat(entryDescriptor.getProperty().getOrigin()).isEqualTo("name");
    assertThat(entryDescriptor.getProperty().getOriginParents()).containsExactly("spring", "boot");
}
Also used : PropertySourceEntryDescriptor(org.springframework.boot.actuate.env.EnvironmentEndpoint.PropertySourceEntryDescriptor) EnvironmentEntryDescriptor(org.springframework.boot.actuate.env.EnvironmentEndpoint.EnvironmentEntryDescriptor) StandardEnvironment(org.springframework.core.env.StandardEnvironment) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)3 EnvironmentEntryDescriptor (org.springframework.boot.actuate.env.EnvironmentEndpoint.EnvironmentEntryDescriptor)3 PropertySourceEntryDescriptor (org.springframework.boot.actuate.env.EnvironmentEndpoint.PropertySourceEntryDescriptor)3 StandardEnvironment (org.springframework.core.env.StandardEnvironment)2 ConfigurableEnvironment (org.springframework.core.env.ConfigurableEnvironment)1