use of org.springframework.core.env.Environment in project spring-boot by spring-projects.
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();
}
use of org.springframework.core.env.Environment in project spring-boot by spring-projects.
the class CloudPlatformTests method getActiveWhenHasVcapApplicationShouldReturnCloudFoundry.
@Test
void getActiveWhenHasVcapApplicationShouldReturnCloudFoundry() {
Environment environment = new MockEnvironment().withProperty("VCAP_APPLICATION", "---");
CloudPlatform platform = CloudPlatform.getActive(environment);
assertThat(platform).isEqualTo(CloudPlatform.CLOUD_FOUNDRY);
assertThat(platform.isActive(environment)).isTrue();
}
use of org.springframework.core.env.Environment in project spring-boot by spring-projects.
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();
}
use of org.springframework.core.env.Environment in project spring-boot by spring-projects.
the class CloudPlatformTests method getActiveWhenHasServiceHostAndNoServicePortShouldNotReturnKubernetes.
@Test
void getActiveWhenHasServiceHostAndNoServicePortShouldNotReturnKubernetes() {
Environment environment = getEnvironmentWithEnvVariables(Collections.singletonMap("EXAMPLE_SERVICE_HOST", "---"));
CloudPlatform platform = CloudPlatform.getActive(environment);
assertThat(platform).isNull();
}
use of org.springframework.core.env.Environment in project spring-boot by spring-projects.
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();
}
Aggregations