[SPR-7960] No longer tracking empty activated profiles.
This commit is contained in:
parent
c7473f9124
commit
6981ee566c
|
|
@ -254,6 +254,12 @@ abstract class ContextLoaderUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ObjectUtils.isEmpty(profiles)) {
|
if (!ObjectUtils.isEmpty(profiles)) {
|
||||||
|
|
||||||
|
// Preserve the order in which the profiles were declared by
|
||||||
|
// reversing the array. This is necessary since we prepend each
|
||||||
|
// non-empty element to the aggregated list as we traverse the
|
||||||
|
// class hierarchy. Note that the following works because
|
||||||
|
// Arrays.asList() "writes through" to the underlying array.
|
||||||
Collections.reverse(Arrays.<String> asList(profiles));
|
Collections.reverse(Arrays.<String> asList(profiles));
|
||||||
|
|
||||||
for (String profile : profiles) {
|
for (String profile : profiles) {
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,20 @@ public class ContextLoaderUtilsTests {
|
||||||
assertEquals(0, profiles.length);
|
assertEquals(0, profiles.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void resolveActivatedProfilesWithNoProfilesDeclared() {
|
||||||
|
String[] profiles = ContextLoaderUtils.resolveActivatedProfiles(NoProfilesDeclared.class);
|
||||||
|
assertNotNull(profiles);
|
||||||
|
assertEquals(0, profiles.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void resolveActivatedProfilesWithEmptyProfiles() {
|
||||||
|
String[] profiles = ContextLoaderUtils.resolveActivatedProfiles(EmptyProfiles.class);
|
||||||
|
assertNotNull(profiles);
|
||||||
|
assertEquals(0, profiles.length);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void resolveActivatedProfilesWithLocalAnnotation() {
|
public void resolveActivatedProfilesWithLocalAnnotation() {
|
||||||
String[] profiles = ContextLoaderUtils.resolveActivatedProfiles(Foo.class);
|
String[] profiles = ContextLoaderUtils.resolveActivatedProfiles(Foo.class);
|
||||||
|
|
@ -74,6 +88,14 @@ public class ContextLoaderUtilsTests {
|
||||||
private static class Enigma {
|
private static class Enigma {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ActivateProfiles
|
||||||
|
private static class NoProfilesDeclared {
|
||||||
|
}
|
||||||
|
|
||||||
|
@ActivateProfiles({ " ", "\t" })
|
||||||
|
private static class EmptyProfiles {
|
||||||
|
}
|
||||||
|
|
||||||
@ActivateProfiles(profiles = "foo")
|
@ActivateProfiles(profiles = "foo")
|
||||||
private static class Foo {
|
private static class Foo {
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue