Support commas in @ActiveProfiles

Update `SpringBootContextLoader` so that it correctly deals with an
`@ActiveProfiles` annotation that contains a comma.

Fixes gh-19537

Co-authored-by: Scott Frederick <sfrederick@pivotal.io>
Co-authored-by: Andy Wilkinson <awilkinson@pivotal.io>
This commit is contained in:
Phillip Webb
2020-04-17 18:44:17 -07:00
parent de8915432a
commit 7ab2bca376
2 changed files with 50 additions and 10 deletions

View File

@@ -153,8 +153,11 @@ public class SpringBootContextLoader extends AbstractContextLoader {
}
private void setActiveProfiles(ConfigurableEnvironment environment, String[] profiles) {
TestPropertyValues.of("spring.profiles.active=" + StringUtils.arrayToCommaDelimitedString(profiles))
.applyTo(environment);
String[] pairs = new String[profiles.length];
for (int i = 0; i < profiles.length; i++) {
pairs[i] = "spring.profiles.active[" + i + "]=" + profiles[i];
}
TestPropertyValues.of(pairs).applyTo(environment);
}
protected String[] getInlinedProperties(MergedContextConfiguration config) {