|
30 | 30 | *
|
31 | 31 | * @author Dave Syer
|
32 | 32 | * @author Andy Wilkinson
|
| 33 | + * @author Hans Schulz |
| 34 | + * @author Madhura Bhave |
33 | 35 | */
|
34 | 36 | class CloudFoundryVcapEnvironmentPostProcessorTests {
|
35 | 37 |
|
@@ -116,6 +118,26 @@ void testServicePropertiesWithoutNA() {
|
116 | 118 | assertThat(getProperty("vcap.services.mysql.credentials.port")).isEqualTo("3306");
|
117 | 119 | }
|
118 | 120 |
|
| 121 | + @Test |
| 122 | + void testServicePropertiesContainingKeysWithDot() { |
| 123 | + TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context, |
| 124 | + "VCAP_SERVICES={\"user-provided\":[{\"name\":\"test\",\"label\":\"test-label\"," |
| 125 | + + "\"credentials\":{\"key.with.dots\":\"some-value\"}}]}"); |
| 126 | + this.initializer.postProcessEnvironment(this.context.getEnvironment(), null); |
| 127 | + assertThat(getProperty("vcap.services.test.name")).isEqualTo("test"); |
| 128 | + assertThat(getProperty("vcap.services.test.credentials[key.with.dots]")).isEqualTo("some-value"); |
| 129 | + } |
| 130 | + |
| 131 | + @Test |
| 132 | + void testServicePropertiesContainingKeysWithUpperCaseAndNonAlphaNumericCharacters() { |
| 133 | + TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context, |
| 134 | + "VCAP_SERVICES={\"user-provided\":[{\"name\":\"test\",\"label\":\"test-label\"," |
| 135 | + + "\"credentials\":{\"My-Key\":\"some-value\", \"foo@\":\"bar\"}}]}"); |
| 136 | + this.initializer.postProcessEnvironment(this.context.getEnvironment(), null); |
| 137 | + assertThat(getProperty("vcap.services.test.credentials[My-Key]")).isEqualTo("some-value"); |
| 138 | + assertThat(getProperty("vcap.services.test.credentials[foo@]")).isEqualTo("bar"); |
| 139 | + } |
| 140 | + |
119 | 141 | private String getProperty(String key) {
|
120 | 142 | return this.context.getEnvironment().getProperty(key);
|
121 | 143 | }
|
|
0 commit comments