Updates ConfigData to use updated api
See gh-1715
This commit is contained in:
@@ -54,8 +54,7 @@ public class NativeEnvironmentRepository implements EnvironmentRepository, Searc
|
||||
private static final String[] DEFAULT_LOCATIONS = new String[] { "classpath:/", "classpath:/config/", "file:./",
|
||||
"file:./config/" };
|
||||
|
||||
private static final Pattern RESOURCE_PATTERN = Pattern
|
||||
.compile("Resource config '(.*?)' imported via location \".*\"");
|
||||
static final Pattern RESOURCE_PATTERN = Pattern.compile("Config resource '(.*?)' via location.*");
|
||||
|
||||
private static Log logger = LogFactory.getLog(NativeEnvironmentRepository.class);
|
||||
|
||||
@@ -213,7 +212,7 @@ public class NativeEnvironmentRepository implements EnvironmentRepository, Searc
|
||||
map.put("spring.config.location",
|
||||
StringUtils.arrayToCommaDelimitedString(getLocations(application, profile, label).getLocations()));
|
||||
// globally ignore config files that are not found
|
||||
map.put("spring.config.on-location-not-found", "ignore");
|
||||
map.put("spring.config.on-not-found", "IGNORE");
|
||||
environment.getPropertySources().addFirst(new MapPropertySource("config-data-setup", map));
|
||||
return environment;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.cloud.config.server.environment;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
@@ -42,7 +44,8 @@ public class NativeEnvironmentRepositoryTests {
|
||||
@Before
|
||||
public void init() {
|
||||
ConfigurableApplicationContext context = new SpringApplicationBuilder(NativeEnvironmentRepositoryTests.class)
|
||||
.web(WebApplicationType.NONE).run();
|
||||
.properties("logging.level.org.springframework.boot.context.config=TRACE").web(WebApplicationType.NONE)
|
||||
.run();
|
||||
this.repository = new NativeEnvironmentRepository(context.getEnvironment(), new NativeEnvironmentProperties());
|
||||
this.repository.setVersion("myversion");
|
||||
this.repository.setDefaultLabel(null);
|
||||
@@ -215,4 +218,12 @@ public class NativeEnvironmentRepositoryTests {
|
||||
+ " ^\n");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resourcePatternWorks() {
|
||||
String name = "Config resource 'abc' via location '123'";
|
||||
Matcher matcher = NativeEnvironmentRepository.RESOURCE_PATTERN.matcher(name);
|
||||
assertThat(matcher.find()).isTrue();
|
||||
assertThat(matcher.group(1)).isEqualTo("abc");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user