Allow environment overrides to be escaped for placeholders

E.g. spring.cloud.config.server.overrides.foo=$\{bar} will evaluate
to foo=${bar} in the client's Environment (allowing local replacement
of the placeholder instead of on the configserver).
This commit is contained in:
Dave Syer
2015-04-03 10:32:41 +01:00
parent 91d12e7c56
commit 280a7a2c09
2 changed files with 24 additions and 7 deletions

View File

@@ -234,4 +234,15 @@ public class EnvironmentControllerTests {
.get(0).getSource().toString());
}
@Test
public void overrideWithEscapedPlaceholders() throws Exception {
controller.setOverrides(Collections.singletonMap("foo", "$\\{bar}"));
Map<String, Object> map = new HashMap<String, Object>();
map.put("bar", "foo");
environment.add(new PropertySource("one", map));
Mockito.when(repository.findOne("foo", "bar", "master")).thenReturn(environment);
assertEquals("{foo=${bar}}", controller.defaultLabel("foo", "bar").getPropertySources()
.get(0).getSource().toString());
}
}