Search in sources :

Example 6 with Environment

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

the class CloudPlatformTests method getActiveWhenHasKubernetesServicePortAndNoKubernetesServiceHostShouldNotReturnKubernetes.

@Test
void getActiveWhenHasKubernetesServicePortAndNoKubernetesServiceHostShouldNotReturnKubernetes() {
    Environment environment = getEnvironmentWithEnvVariables(Collections.singletonMap("KUBERNETES_SERVICE_PORT", "8080"));
    CloudPlatform platform = CloudPlatform.getActive(environment);
    assertThat(platform).isNull();
}
Also used : 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 7 with Environment

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

the class CloudPlatformTests method getActiveWhenHasKubernetesServiceHostAndNoKubernetesServicePortShouldNotReturnKubernetes.

@Test
void getActiveWhenHasKubernetesServiceHostAndNoKubernetesServicePortShouldNotReturnKubernetes() {
    Environment environment = getEnvironmentWithEnvVariables(Collections.singletonMap("KUBERNETES_SERVICE_HOST", "---"));
    CloudPlatform platform = CloudPlatform.getActive(environment);
    assertThat(platform).isNull();
}
Also used : 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 8 with Environment

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

the class CloudPlatformTests method getActiveWhenHasAllAzureEnvVariablesShouldReturnAzureAppService.

@Test
void getActiveWhenHasAllAzureEnvVariablesShouldReturnAzureAppService() {
    Map<String, Object> envVars = new HashMap<>();
    envVars.put("WEBSITE_SITE_NAME", "---");
    envVars.put("WEBSITE_INSTANCE_ID", "1234");
    envVars.put("WEBSITE_RESOURCE_GROUP", "test");
    envVars.put("WEBSITE_SKU", "1234");
    Environment environment = getEnvironmentWithEnvVariables(envVars);
    CloudPlatform platform = CloudPlatform.getActive(environment);
    assertThat(platform).isEqualTo(CloudPlatform.AZURE_APP_SERVICE);
    assertThat(platform.isActive(environment)).isTrue();
}
Also used : HashMap(java.util.HashMap) 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 9 with Environment

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

the class CloudPlatformTests method getActiveWhenHasKubernetesServiceHostAndPortShouldReturnKubernetes.

@Test
void getActiveWhenHasKubernetesServiceHostAndPortShouldReturnKubernetes() {
    Map<String, Object> envVars = new HashMap<>();
    envVars.put("KUBERNETES_SERVICE_HOST", "---");
    envVars.put("KUBERNETES_SERVICE_PORT", "8080");
    Environment environment = getEnvironmentWithEnvVariables(envVars);
    CloudPlatform platform = CloudPlatform.getActive(environment);
    assertThat(platform).isEqualTo(CloudPlatform.KUBERNETES);
    assertThat(platform.isActive(environment)).isTrue();
}
Also used : HashMap(java.util.HashMap) 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 10 with Environment

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

the class CloudPlatformTests method getActiveWhenHasDynoShouldReturnHeroku.

@Test
void getActiveWhenHasDynoShouldReturnHeroku() {
    Environment environment = new MockEnvironment().withProperty("DYNO", "---");
    CloudPlatform platform = CloudPlatform.getActive(environment);
    assertThat(platform).isEqualTo(CloudPlatform.HEROKU);
    assertThat(platform.isActive(environment)).isTrue();
}
Also used : 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)

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