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