use of org.springframework.boot.origin.OriginLookup in project spring-boot by spring-projects.
the class IntegrationPropertiesEnvironmentPostProcessorTests method registerIntegrationPropertiesPropertySourceWithResourceCanRetrieveOrigin.
@Test
@SuppressWarnings("unchecked")
void registerIntegrationPropertiesPropertySourceWithResourceCanRetrieveOrigin() {
ConfigurableEnvironment environment = new StandardEnvironment();
ClassPathResource resource = new ClassPathResource("spring.integration.properties", getClass());
new IntegrationPropertiesEnvironmentPostProcessor().registerIntegrationPropertiesPropertySource(environment, resource);
PropertySource<?> ps = environment.getPropertySources().get("META-INF/spring.integration.properties");
assertThat(ps).isNotNull().isInstanceOf(OriginLookup.class);
OriginLookup<String> originLookup = (OriginLookup<String>) ps;
assertThat(originLookup.getOrigin("spring.integration.channel.auto-create")).satisfies(textOrigin(resource, 0, 39));
assertThat(originLookup.getOrigin("spring.integration.channel.max-unicast-subscribers")).satisfies(textOrigin(resource, 1, 50));
assertThat(originLookup.getOrigin("spring.integration.channel.max-broadcast-subscribers")).satisfies(textOrigin(resource, 2, 52));
}
use of org.springframework.boot.origin.OriginLookup in project spring-boot by spring-projects.
the class EnvironmentEndpoint method describeValueOf.
@SuppressWarnings("unchecked")
private PropertyValueDescriptor describeValueOf(String name, PropertySource<?> source, PlaceholdersResolver resolver) {
Object resolved = resolver.resolvePlaceholders(source.getProperty(name));
Origin origin = ((source instanceof OriginLookup) ? ((OriginLookup<Object>) source).getOrigin(name) : null);
Object sanitizedValue = sanitize(source, name, resolved);
return new PropertyValueDescriptor(stringifyIfNecessary(sanitizedValue), origin);
}
Aggregations