Skip to content

Commit 5edd521

Browse files
committed
Merge branch '4.0.x'
Closes gh-48693
2 parents 86330d8 + a7122b0 commit 5edd521

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

core/spring-boot/src/test/java/org/springframework/boot/cloud/cloudfoundry/CloudFoundryVcapEnvironmentPostProcessorTests.java renamed to core/spring-boot/src/test/java/org/springframework/boot/cloud/CloudFoundryVcapEnvironmentPostProcessorTests.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.cloud.cloudfoundry;
17+
package org.springframework.boot.cloud;
1818

1919
import java.util.function.Supplier;
2020

21+
import org.jspecify.annotations.Nullable;
2122
import org.junit.jupiter.api.Test;
2223

23-
import org.springframework.boot.cloud.CloudFoundryVcapEnvironmentPostProcessor;
24+
import org.springframework.boot.SpringApplication;
2425
import org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor;
2526
import org.springframework.context.ConfigurableApplicationContext;
2627
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
@@ -42,6 +43,8 @@ class CloudFoundryVcapEnvironmentPostProcessorTests {
4243

4344
private final ConfigurableApplicationContext context = new AnnotationConfigApplicationContext();
4445

46+
private final SpringApplication application = new SpringApplication();
47+
4548
@Test
4649
void testApplicationProperties() {
4750
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context,
@@ -54,22 +57,22 @@ void testApplicationProperties() {
5457
+ "\"version\":\"3464e092-1c13-462e-a47c-807c30318a50\","
5558
+ "\"name\":\"dsyerenv\",\"uris\":[\"dsyerenv.cfapps.io\"],"
5659
+ "\"users\":[],\"start\":\"2013-05-29 02:37:59 +0000\",\"state_timestamp\":1369795079}");
57-
this.initializer.postProcessEnvironment(this.context.getEnvironment(), null);
60+
this.initializer.postProcessEnvironment(this.context.getEnvironment(), this.application);
5861
assertThat(getProperty("vcap.application.instance_id")).isEqualTo("bb7935245adf3e650dfb7c58a06e9ece");
5962
}
6063

6164
@Test
6265
void testApplicationUris() {
6366
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context,
6467
"VCAP_APPLICATION={\"instance_id\":\"bb7935245adf3e650dfb7c58a06e9ece\",\"instance_index\":0,\"uris\":[\"foo.cfapps.io\"]}");
65-
this.initializer.postProcessEnvironment(this.context.getEnvironment(), null);
68+
this.initializer.postProcessEnvironment(this.context.getEnvironment(), this.application);
6669
assertThat(getProperty("vcap.application.uris[0]")).isEqualTo("foo.cfapps.io");
6770
}
6871

6972
@Test
7073
void testUnparseableApplicationProperties() {
7174
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context, "VCAP_APPLICATION:");
72-
this.initializer.postProcessEnvironment(this.context.getEnvironment(), null);
75+
this.initializer.postProcessEnvironment(this.context.getEnvironment(), this.application);
7376
assertThat(getProperty("vcap")).isNull();
7477
}
7578

@@ -86,7 +89,7 @@ void testNullApplicationProperties() {
8689
+ "\"version\":\"3464e092-1c13-462e-a47c-807c30318a50\","
8790
+ "\"name\":\"dsyerenv\",\"uris\":[\"dsyerenv.cfapps.io\"],"
8891
+ "\"users\":[],\"start\":\"2013-05-29 02:37:59 +0000\",\"state_timestamp\":1369795079}");
89-
this.initializer.postProcessEnvironment(this.context.getEnvironment(), null);
92+
this.initializer.postProcessEnvironment(this.context.getEnvironment(), this.application);
9093
assertThat(getProperty("vcap")).isNull();
9194
}
9295

@@ -100,7 +103,7 @@ void testServiceProperties() {
100103
+ "\"host\":\"mysql-service-public.clqg2e2w3ecf.us-east-1.rds.amazonaws.com\","
101104
+ "\"port\":3306,\"user\":\"urpRuqTf8Cpe6\",\"username\":"
102105
+ "\"urpRuqTf8Cpe6\",\"password\":\"pxLsGVpsC9A5S\"}}]}");
103-
this.initializer.postProcessEnvironment(this.context.getEnvironment(), null);
106+
this.initializer.postProcessEnvironment(this.context.getEnvironment(), this.application);
104107
assertThat(getProperty("vcap.services.mysql.name")).isEqualTo("mysql");
105108
assertThat(getProperty("vcap.services.mysql.credentials.port")).isEqualTo("3306");
106109
assertThat(getProperty("vcap.services.mysql.credentials.ssl")).isEqualTo("true");
@@ -116,7 +119,7 @@ void testServicePropertiesWithoutNA() {
116119
+ "\"host\":\"mysql-service-public.clqg2e2w3ecf.us-east-1.rds.amazonaws.com\","
117120
+ "\"port\":3306,\"user\":\"urpRuqTf8Cpe6\",\"username\":\"urpRuqTf8Cpe6\","
118121
+ "\"password\":\"pxLsGVpsC9A5S\"}}]}");
119-
this.initializer.postProcessEnvironment(this.context.getEnvironment(), null);
122+
this.initializer.postProcessEnvironment(this.context.getEnvironment(), this.application);
120123
assertThat(getProperty("vcap.services.mysql.name")).isEqualTo("mysql");
121124
assertThat(getProperty("vcap.services.mysql.credentials.port")).isEqualTo("3306");
122125
}
@@ -127,7 +130,7 @@ void orderShouldBeBeforeConfigDataEnvironmentPostProcessorWithGap() {
127130
assertThat(this.initializer.getOrder()).isLessThan(ConfigDataEnvironmentPostProcessor.ORDER - 1);
128131
}
129132

130-
private String getProperty(String key) {
133+
private @Nullable String getProperty(String key) {
131134
return this.context.getEnvironment().getProperty(key);
132135
}
133136

0 commit comments

Comments
 (0)