Search in sources :

Example 1 with Environment

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

the class ConfigDataActivationContextTests method getCloudPlatformWhenCloudPropertyHasBeenContributedDuringInitialLoadDeducesCloudPlatform.

@Test
void getCloudPlatformWhenCloudPropertyHasBeenContributedDuringInitialLoadDeducesCloudPlatform() {
    Environment environment = createKubernetesEnvironment();
    Binder binder = new Binder(new MapConfigurationPropertySource(Collections.singletonMap("context.main.cloud-platform", "HEROKU")));
    ConfigDataActivationContext context = new ConfigDataActivationContext(environment, binder);
    assertThat(context.getCloudPlatform()).isEqualTo(CloudPlatform.HEROKU);
}
Also used : Binder(cn.taketoday.context.properties.bind.Binder) MockEnvironment(cn.taketoday.mock.env.MockEnvironment) Environment(cn.taketoday.core.env.Environment) StandardEnvironment(cn.taketoday.core.env.StandardEnvironment) MapConfigurationPropertySource(cn.taketoday.context.properties.source.MapConfigurationPropertySource) Test(org.junit.jupiter.api.Test)

Example 2 with Environment

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

the class ConfigDataActivationContextTests method getCloudPlatformWhenCloudPropertyNotPresentDeducesCloudPlatform.

@Test
void getCloudPlatformWhenCloudPropertyNotPresentDeducesCloudPlatform() {
    Environment environment = new MockEnvironment();
    Binder binder = Binder.get(environment);
    ConfigDataActivationContext context = new ConfigDataActivationContext(environment, binder);
    assertThat(context.getCloudPlatform()).isNull();
}
Also used : Binder(cn.taketoday.context.properties.bind.Binder) MockEnvironment(cn.taketoday.mock.env.MockEnvironment) MockEnvironment(cn.taketoday.mock.env.MockEnvironment) Environment(cn.taketoday.core.env.Environment) StandardEnvironment(cn.taketoday.core.env.StandardEnvironment) Test(org.junit.jupiter.api.Test)

Example 3 with Environment

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

the class ProfilesTests method getActiveWhenNoEnvironmentProfilesAndNoPropertyReturnsEmptyArray.

@Test
void getActiveWhenNoEnvironmentProfilesAndNoPropertyReturnsEmptyArray() {
    Environment environment = new MockEnvironment();
    Binder binder = Binder.get(environment);
    Profiles profiles = new Profiles(environment, binder, null);
    assertThat(profiles.getActive()).isEmpty();
}
Also used : Binder(cn.taketoday.context.properties.bind.Binder) MockEnvironment(cn.taketoday.mock.env.MockEnvironment) MockEnvironment(cn.taketoday.mock.env.MockEnvironment) Environment(cn.taketoday.core.env.Environment) Test(org.junit.jupiter.api.Test)

Example 4 with Environment

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

the class ProfilesTests method getDefaultWhenNoEnvironmentProfilesAndNoPropertyReturnsEmptyArray.

@Test
void getDefaultWhenNoEnvironmentProfilesAndNoPropertyReturnsEmptyArray() {
    Environment environment = new MockEnvironment();
    Binder binder = Binder.get(environment);
    Profiles profiles = new Profiles(environment, binder, null);
    assertThat(profiles.getDefault()).containsExactly("default");
}
Also used : Binder(cn.taketoday.context.properties.bind.Binder) MockEnvironment(cn.taketoday.mock.env.MockEnvironment) MockEnvironment(cn.taketoday.mock.env.MockEnvironment) Environment(cn.taketoday.core.env.Environment) Test(org.junit.jupiter.api.Test)

Example 5 with Environment

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

the class ProfilesTests method getActiveWhenNoEnvironmentProfilesAndBinderProperty.

@Test
void getActiveWhenNoEnvironmentProfilesAndBinderProperty() {
    Environment environment = new MockEnvironment();
    Binder binder = new Binder(new MapConfigurationPropertySource(Collections.singletonMap("context.profiles.active", "a,b,c")));
    Profiles profiles = new Profiles(environment, binder, null);
    assertThat(profiles.getActive()).containsExactly("a", "b", "c");
}
Also used : Binder(cn.taketoday.context.properties.bind.Binder) MockEnvironment(cn.taketoday.mock.env.MockEnvironment) MockEnvironment(cn.taketoday.mock.env.MockEnvironment) Environment(cn.taketoday.core.env.Environment) MapConfigurationPropertySource(cn.taketoday.context.properties.source.MapConfigurationPropertySource) Test(org.junit.jupiter.api.Test)

Aggregations

Environment (cn.taketoday.core.env.Environment)66 Test (org.junit.jupiter.api.Test)58 StandardEnvironment (cn.taketoday.core.env.StandardEnvironment)50 MockEnvironment (cn.taketoday.mock.env.MockEnvironment)48 HashMap (java.util.HashMap)16 Binder (cn.taketoday.context.properties.bind.Binder)14 ConfigurableEnvironment (cn.taketoday.core.env.ConfigurableEnvironment)10 MapConfigurationPropertySource (cn.taketoday.context.properties.source.MapConfigurationPropertySource)6 MapPropertySource (cn.taketoday.core.env.MapPropertySource)6 PropertySources (cn.taketoday.core.env.PropertySources)6 ApplicationPropertySourcesProcessor (cn.taketoday.context.support.ApplicationPropertySourcesProcessor)4 StandardApplicationContext (cn.taketoday.context.support.StandardApplicationContext)4 BeanInstantiationException (cn.taketoday.beans.BeanInstantiationException)3 ConfigurableBeanFactory (cn.taketoday.beans.factory.config.ConfigurableBeanFactory)3 BeanDefinitionRegistry (cn.taketoday.beans.factory.support.BeanDefinitionRegistry)3 PatternResourceLoader (cn.taketoday.core.io.PatternResourceLoader)3 BeanWrapper (cn.taketoday.beans.BeanWrapper)2 BeansException (cn.taketoday.beans.BeansException)2 PropertyValues (cn.taketoday.beans.PropertyValues)2 ApplicationContext (cn.taketoday.context.ApplicationContext)2