use of org.springframework.core.env.CompositePropertySource in project cas by apereo.
the class DefaultCasConfigurationPropertiesSourceLocatorTests method verifyGroovySlurper.
@Test
public void verifyGroovySlurper() {
val source = casCoreBootstrapPropertySourceLocator.locate(environment);
assertTrue(source instanceof CompositePropertySource);
val composite = (CompositePropertySource) source;
assertEquals("Static", composite.getProperty("cas.authn.accept.name"));
assertEquals("test::dev", composite.getProperty("cas.authn.accept.users"));
}
use of org.springframework.core.env.CompositePropertySource in project cas by apereo.
the class DefaultCasConfigurationPropertiesSourceLocatorTests method verifyLocator.
@Test
public void verifyLocator() {
val source = casCoreBootstrapPropertySourceLocator.locate(environment);
assertTrue(source instanceof CompositePropertySource);
assertNotNull(casConfigurationWatchService);
val composite = (CompositePropertySource) source;
assertEquals("https://cas.example.org:9999", composite.getProperty("cas.server.name"));
assertEquals("https://cas.example.org/something", composite.getProperty("cas.server.prefix"));
}
use of org.springframework.core.env.CompositePropertySource in project cas by apereo.
the class DefaultCasConfigurationPropertiesSourceLocatorTests method verifyPriority.
@Test
public void verifyPriority() {
val source = casCoreBootstrapPropertySourceLocator.locate(environment);
assertTrue(source instanceof CompositePropertySource);
val composite = (CompositePropertySource) source;
assertEquals("file", composite.getProperty("test.file"));
assertEquals("dirAppYml", composite.getProperty("test.dir.app"));
assertEquals("classpathAppYml", composite.getProperty("test.classpath"));
assertEquals("devProfileProp", composite.getProperty("test.dir.profile"));
assertEquals("standaloneProfileProp", composite.getProperty("profile.override.me"));
assertEquals("dirCasProp", composite.getProperty("test.dir.cas"));
}
use of org.springframework.core.env.CompositePropertySource in project cas by apereo.
the class WebjarValidationTests method verifyValidation.
@Test
public void verifyValidation() throws IOException {
val compositePropertySource = new CompositePropertySource("webjars");
compositePropertySource.addPropertySource(new PropertiesPropertySource("messages", PropertiesLoaderUtils.loadProperties(new ClassPathResource("cas_common_messages.properties"))));
compositePropertySource.addPropertySource(new PropertiesPropertySource("versions", PropertiesLoaderUtils.loadProperties(new FileSystemResource("../../gradle.properties"))));
Arrays.stream(compositePropertySource.getPropertyNames()).filter(key -> key.startsWith("webjars.")).map(key -> new ClassPathResource("META-INF/resources" + compositePropertySource.getProperty(key))).forEach(resource -> assertTrue(resource.exists(), () -> "Webjar path bad: " + resource.getPath()));
}
use of org.springframework.core.env.CompositePropertySource in project spring-boot by spring-projects.
the class SpringApplicationTests method commandLinePropertySourceEnhancesEnvironment.
@Test
void commandLinePropertySourceEnhancesEnvironment() {
SpringApplication application = new SpringApplication(ExampleConfig.class);
application.setWebApplicationType(WebApplicationType.NONE);
ConfigurableEnvironment environment = new StandardEnvironment();
environment.getPropertySources().addFirst(new MapPropertySource("commandLineArgs", Collections.singletonMap("foo", "original")));
application.setEnvironment(environment);
this.context = application.run("--foo=bar", "--bar=foo");
assertThat(environment).has(matchingPropertySource(CompositePropertySource.class, "commandLineArgs"));
assertThat(environment.getProperty("bar")).isEqualTo("foo");
// New command line properties take precedence
assertThat(environment.getProperty("foo")).isEqualTo("bar");
CompositePropertySource composite = (CompositePropertySource) environment.getPropertySources().get("commandLineArgs");
assertThat(composite.getPropertySources()).hasSize(2);
assertThat(composite.getPropertySources()).first().matches((source) -> source.getName().equals("springApplicationCommandLineArgs"), "is named springApplicationCommandLineArgs");
assertThat(composite.getPropertySources()).element(1).matches((source) -> source.getName().equals("commandLineArgs"), "is named commandLineArgs");
}
Aggregations