|
|
@ -1,5 +1,5 @@
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Copyright 2012-2020 the original author or authors.
|
|
|
|
* Copyright 2012-2021 the original author or authors.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
@ -19,6 +19,7 @@ package org.springframework.boot.cloud;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
|
|
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
|
|
|
|
|
|
|
@ -36,6 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
* Tests for {@link CloudPlatform}.
|
|
|
|
* Tests for {@link CloudPlatform}.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @author Phillip Webb
|
|
|
|
* @author Phillip Webb
|
|
|
|
|
|
|
|
* @author Nguyen Sach
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
class CloudPlatformTests {
|
|
|
|
class CloudPlatformTests {
|
|
|
|
|
|
|
|
|
|
|
@ -177,6 +179,16 @@ class CloudPlatformTests {
|
|
|
|
assertThat(CloudPlatform.KUBERNETES.isEnforced(binder)).isFalse();
|
|
|
|
assertThat(CloudPlatform.KUBERNETES.isEnforced(binder)).isFalse();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void isActiveWhenNoCloudPlatformIsEnforcedAndHasKubernetesServiceHostAndKubernetesServicePort() {
|
|
|
|
|
|
|
|
Map<String, Object> envVars = new HashMap<>();
|
|
|
|
|
|
|
|
envVars.put("EXAMPLE_SERVICE_HOST", "---");
|
|
|
|
|
|
|
|
envVars.put("EXAMPLE_SERVICE_PORT", "8080");
|
|
|
|
|
|
|
|
Environment environment = getEnvironmentWithEnvVariables(envVars);
|
|
|
|
|
|
|
|
((MockEnvironment) environment).setProperty("spring.main.cloud-platform", "none");
|
|
|
|
|
|
|
|
assertThat(Stream.of(CloudPlatform.values()).filter((platform) -> platform.isActive(environment)))
|
|
|
|
|
|
|
|
.containsExactly(CloudPlatform.NONE);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Environment getEnvironmentWithEnvVariables(Map<String, Object> environmentVariables) {
|
|
|
|
private Environment getEnvironmentWithEnvVariables(Map<String, Object> environmentVariables) {
|
|
|
|
MockEnvironment environment = new MockEnvironment();
|
|
|
|
MockEnvironment environment = new MockEnvironment();
|
|
|
|
PropertySource<?> propertySource = new SystemEnvironmentPropertySource(
|
|
|
|
PropertySource<?> propertySource = new SystemEnvironmentPropertySource(
|
|
|
|