|
1 | 1 | /*
|
2 |
| - * Copyright 2012-2020 the original author or authors. |
| 2 | + * Copyright 2012-2021 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
19 | 19 | import java.util.Collections;
|
20 | 20 | import java.util.HashMap;
|
21 | 21 | import java.util.Map;
|
| 22 | +import java.util.stream.Stream; |
22 | 23 |
|
23 | 24 | import org.junit.jupiter.api.Test;
|
24 | 25 |
|
|
36 | 37 | * Tests for {@link CloudPlatform}.
|
37 | 38 | *
|
38 | 39 | * @author Phillip Webb
|
| 40 | + * @author Nguyen Sach |
39 | 41 | */
|
40 | 42 | class CloudPlatformTests {
|
41 | 43 |
|
@@ -177,6 +179,16 @@ void isEnforcedWhenBinderPropertyIsMissingReturnsFalse() {
|
177 | 179 | assertThat(CloudPlatform.KUBERNETES.isEnforced(binder)).isFalse();
|
178 | 180 | }
|
179 | 181 |
|
| 182 | + void isActiveWhenNoCloudPlatformIsEnforcedAndHasKubernetesServiceHostAndKubernetesServicePort() { |
| 183 | + Map<String, Object> envVars = new HashMap<>(); |
| 184 | + envVars.put("EXAMPLE_SERVICE_HOST", "---"); |
| 185 | + envVars.put("EXAMPLE_SERVICE_PORT", "8080"); |
| 186 | + Environment environment = getEnvironmentWithEnvVariables(envVars); |
| 187 | + ((MockEnvironment) environment).setProperty("spring.main.cloud-platform", "none"); |
| 188 | + assertThat(Stream.of(CloudPlatform.values()).filter((platform) -> platform.isActive(environment))) |
| 189 | + .containsExactly(CloudPlatform.NONE); |
| 190 | + } |
| 191 | + |
180 | 192 | private Environment getEnvironmentWithEnvVariables(Map<String, Object> environmentVariables) {
|
181 | 193 | MockEnvironment environment = new MockEnvironment();
|
182 | 194 | PropertySource<?> propertySource = new SystemEnvironmentPropertySource(
|
|
0 commit comments