Search in sources :

Example 46 with MapPropertySource

use of org.springframework.core.env.MapPropertySource in project spring-boot by spring-projects.

the class EnvironmentTestUtils method getOrAdd.

@SuppressWarnings("unchecked")
private static Map<String, Object> getOrAdd(MutablePropertySources sources, String name) {
    if (sources.contains(name)) {
        return (Map<String, Object>) sources.get(name).getSource();
    }
    Map<String, Object> map = new HashMap<>();
    sources.addFirst(new MapPropertySource(name, map));
    return map;
}
Also used : HashMap(java.util.HashMap) MapPropertySource(org.springframework.core.env.MapPropertySource) Map(java.util.Map) HashMap(java.util.HashMap)

Example 47 with MapPropertySource

use of org.springframework.core.env.MapPropertySource in project spring-boot by spring-projects.

the class SpringBootTestContextBootstrapper method convertToPropertySources.

private PropertySources convertToPropertySources(String[] properties) {
    Map<String, Object> source = TestPropertySourceUtils.convertInlinedPropertiesToMap(properties);
    MutablePropertySources sources = new MutablePropertySources();
    sources.addFirst(new MapPropertySource("inline", source));
    return sources;
}
Also used : MapPropertySource(org.springframework.core.env.MapPropertySource) MutablePropertySources(org.springframework.core.env.MutablePropertySources)

Example 48 with MapPropertySource

use of org.springframework.core.env.MapPropertySource in project spring-boot by spring-projects.

the class ResourceBanner method getTitleResolver.

private PropertyResolver getTitleResolver(Class<?> sourceClass) {
    MutablePropertySources sources = new MutablePropertySources();
    String applicationTitle = getApplicationTitle(sourceClass);
    Map<String, Object> titleMap = Collections.<String, Object>singletonMap("application.title", (applicationTitle == null ? "" : applicationTitle));
    sources.addFirst(new MapPropertySource("title", titleMap));
    return new PropertySourcesPropertyResolver(sources);
}
Also used : PropertySourcesPropertyResolver(org.springframework.core.env.PropertySourcesPropertyResolver) MapPropertySource(org.springframework.core.env.MapPropertySource) MutablePropertySources(org.springframework.core.env.MutablePropertySources)

Example 49 with MapPropertySource

use of org.springframework.core.env.MapPropertySource in project spring-boot by spring-projects.

the class ResourceBanner method getVersionResolver.

private PropertyResolver getVersionResolver(Class<?> sourceClass) {
    MutablePropertySources propertySources = new MutablePropertySources();
    propertySources.addLast(new MapPropertySource("version", getVersionsMap(sourceClass)));
    return new PropertySourcesPropertyResolver(propertySources);
}
Also used : PropertySourcesPropertyResolver(org.springframework.core.env.PropertySourcesPropertyResolver) MapPropertySource(org.springframework.core.env.MapPropertySource) MutablePropertySources(org.springframework.core.env.MutablePropertySources)

Example 50 with MapPropertySource

use of org.springframework.core.env.MapPropertySource in project spring-boot by spring-projects.

the class LogFileTests method getPropertyResolver.

private PropertyResolver getPropertyResolver(String file, String path) {
    Map<String, Object> properties = new LinkedHashMap<>();
    properties.put("logging.file", file);
    properties.put("logging.path", path);
    PropertySource<?> propertySource = new MapPropertySource("properties", properties);
    MutablePropertySources propertySources = new MutablePropertySources();
    propertySources.addFirst(propertySource);
    return new PropertySourcesPropertyResolver(propertySources);
}
Also used : PropertySourcesPropertyResolver(org.springframework.core.env.PropertySourcesPropertyResolver) MapPropertySource(org.springframework.core.env.MapPropertySource) MutablePropertySources(org.springframework.core.env.MutablePropertySources) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

MapPropertySource (org.springframework.core.env.MapPropertySource)74 Test (org.junit.Test)53 HashMap (java.util.HashMap)36 StandardEnvironment (org.springframework.core.env.StandardEnvironment)27 URI (java.net.URI)24 AnnotationConfigWebApplicationContext (org.springframework.web.context.support.AnnotationConfigWebApplicationContext)23 MessageSerDe (com.kixeye.chassis.transport.serde.MessageSerDe)21 ProtobufMessageSerDe (com.kixeye.chassis.transport.serde.converter.ProtobufMessageSerDe)15 RestTemplate (org.springframework.web.client.RestTemplate)15 ServiceError (com.kixeye.chassis.transport.dto.ServiceError)14 JsonJacksonMessageSerDe (com.kixeye.chassis.transport.serde.converter.JsonJacksonMessageSerDe)14 XmlMessageSerDe (com.kixeye.chassis.transport.serde.converter.XmlMessageSerDe)14 YamlJacksonMessageSerDe (com.kixeye.chassis.transport.serde.converter.YamlJacksonMessageSerDe)14 SerDeHttpMessageConverter (com.kixeye.chassis.transport.http.SerDeHttpMessageConverter)13 HttpMessageConverter (org.springframework.http.converter.HttpMessageConverter)13 MutablePropertySources (org.springframework.core.env.MutablePropertySources)11 QueuingWebSocketListener (com.kixeye.chassis.transport.websocket.QueuingWebSocketListener)9 WebSocketMessageRegistry (com.kixeye.chassis.transport.websocket.WebSocketMessageRegistry)9 ArrayList (java.util.ArrayList)9 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)9