Search in sources :

Example 1 with ConfigurableEnvironment

use of cn.taketoday.core.env.ConfigurableEnvironment in project today-infrastructure by TAKETODAY.

the class ConfigDataEnvironmentPostProcessorIntegrationTests method runWhenHasProfileSpecificFileWithActiveOnProfileProperty.

@Test
// gh-24990
void runWhenHasProfileSpecificFileWithActiveOnProfileProperty() {
    ConfigurableApplicationContext context = this.application.run("--context.config.name=application-activate-on-profile-in-profile-specific-file");
    ConfigurableEnvironment environment = context.getEnvironment();
    assertThat(environment.getProperty("test1")).isEqualTo("test1");
    assertThat(environment.getProperty("test2")).isEqualTo("test2");
}
Also used : ConfigurableApplicationContext(cn.taketoday.context.ConfigurableApplicationContext) ConfigurableEnvironment(cn.taketoday.core.env.ConfigurableEnvironment) Test(org.junit.jupiter.api.Test)

Example 2 with ConfigurableEnvironment

use of cn.taketoday.core.env.ConfigurableEnvironment in project today-infrastructure by TAKETODAY.

the class ConfigDataEnvironmentPostProcessorIntegrationTests method runWhenCustomDefaultProfileSameAsActiveFromFileActivatesProfile.

@Test
void runWhenCustomDefaultProfileSameAsActiveFromFileActivatesProfile() {
    ConfigurableApplicationContext context = this.application.run("--context.config.location=classpath:configdata/profiles/", "--context.profiles.default=customdefault", "--context.config.name=customprofile");
    ConfigurableEnvironment environment = context.getEnvironment();
    assertThat(environment.containsProperty("customprofile")).isTrue();
    assertThat(environment.containsProperty("customprofile-customdefault")).isTrue();
    assertThat(environment.acceptsProfiles(Profiles.of("customdefault"))).isTrue();
}
Also used : ConfigurableApplicationContext(cn.taketoday.context.ConfigurableApplicationContext) ConfigurableEnvironment(cn.taketoday.core.env.ConfigurableEnvironment) Test(org.junit.jupiter.api.Test)

Example 3 with ConfigurableEnvironment

use of cn.taketoday.core.env.ConfigurableEnvironment in project today-infrastructure by TAKETODAY.

the class ConfigDataEnvironmentPostProcessorIntegrationTests method runWhenHasProfileSpecificImportWithCustomImportResolvesProfileSpecific.

@Test
// gh-26960
void runWhenHasProfileSpecificImportWithCustomImportResolvesProfileSpecific() {
    ConfigurableApplicationContext context = this.application.run("--context.config.name=application-profile-specific-import-with-custom-import");
    ConfigurableEnvironment environment = context.getEnvironment();
    assertThat(environment.containsProperty("test:boot")).isTrue();
    assertThat(environment.containsProperty("test:boot:ps")).isTrue();
}
Also used : ConfigurableApplicationContext(cn.taketoday.context.ConfigurableApplicationContext) ConfigurableEnvironment(cn.taketoday.core.env.ConfigurableEnvironment) Test(org.junit.jupiter.api.Test)

Example 4 with ConfigurableEnvironment

use of cn.taketoday.core.env.ConfigurableEnvironment in project today-infrastructure by TAKETODAY.

the class ConfigDataEnvironmentPostProcessorIntegrationTests method runWhenHasWildcardLocationLoadsFromAllMatchingLocations.

@Test
void runWhenHasWildcardLocationLoadsFromAllMatchingLocations() {
    ConfigurableApplicationContext context = this.application.run("--context.config.location=file:src/test/resources/config/*/", "--context.config.name=testproperties");
    ConfigurableEnvironment environment = context.getEnvironment();
    assertThat(environment.getProperty("first.property")).isEqualTo("apple");
    assertThat(environment.getProperty("second.property")).isEqualTo("ball");
}
Also used : ConfigurableApplicationContext(cn.taketoday.context.ConfigurableApplicationContext) ConfigurableEnvironment(cn.taketoday.core.env.ConfigurableEnvironment) Test(org.junit.jupiter.api.Test)

Example 5 with ConfigurableEnvironment

use of cn.taketoday.core.env.ConfigurableEnvironment in project today-infrastructure by TAKETODAY.

the class ConfigDataEnvironmentPostProcessorIntegrationTests method runWhenHasProfileSpecificImportWithImportImportsSecondProfileSpecificFile.

@Test
// gh-26960
void runWhenHasProfileSpecificImportWithImportImportsSecondProfileSpecificFile() {
    ConfigurableApplicationContext context = this.application.run("--context.config.name=application-profile-specific-import-with-import");
    ConfigurableEnvironment environment = context.getEnvironment();
    assertThat(environment.containsProperty("application-profile-specific-import-with-import")).isTrue();
    assertThat(environment.containsProperty("application-profile-specific-import-with-import-p1")).isTrue();
    assertThat(environment.containsProperty("application-profile-specific-import-with-import-p2")).isFalse();
    assertThat(environment.containsProperty("application-profile-specific-import-with-import-import")).isTrue();
    assertThat(environment.containsProperty("application-profile-specific-import-with-import-import-p1")).isTrue();
    assertThat(environment.containsProperty("application-profile-specific-import-with-import-import-p2")).isTrue();
}
Also used : ConfigurableApplicationContext(cn.taketoday.context.ConfigurableApplicationContext) ConfigurableEnvironment(cn.taketoday.core.env.ConfigurableEnvironment) Test(org.junit.jupiter.api.Test)

Aggregations

ConfigurableEnvironment (cn.taketoday.core.env.ConfigurableEnvironment)94 Test (org.junit.jupiter.api.Test)82 StandardEnvironment (cn.taketoday.core.env.StandardEnvironment)42 PropertySources (cn.taketoday.core.env.PropertySources)22 ConfigurableApplicationContext (cn.taketoday.context.ConfigurableApplicationContext)20 MapPropertySource (cn.taketoday.core.env.MapPropertySource)16 MockEnvironment (cn.taketoday.mock.env.MockEnvironment)8 AnnotationConfigApplicationContext (cn.taketoday.context.annotation.AnnotationConfigApplicationContext)6 AnnotatedBeanDefinition (cn.taketoday.beans.factory.annotation.AnnotatedBeanDefinition)4 StandardBeanFactory (cn.taketoday.beans.factory.support.StandardBeanFactory)4 ApplicationContext (cn.taketoday.context.ApplicationContext)4 ClassPathScanningCandidateComponentProvider (cn.taketoday.context.loader.ClassPathScanningCandidateComponentProvider)4 StandardApplicationContext (cn.taketoday.context.support.StandardApplicationContext)4 CommandLinePropertySource (cn.taketoday.core.env.CommandLinePropertySource)4 CompositePropertySource (cn.taketoday.core.env.CompositePropertySource)4 PropertiesPropertySource (cn.taketoday.core.env.PropertiesPropertySource)4 SystemEnvironmentPropertySource (cn.taketoday.core.env.SystemEnvironmentPropertySource)4 LinkedHashMap (java.util.LinkedHashMap)4 Map (java.util.Map)4 Properties (java.util.Properties)4