Polish MergedTestPropertySources

This commit is contained in:
Sam Brannen
2019-07-28 15:38:14 +02:00
parent a37eaf75c4
commit bfbe8f8780
2 changed files with 6 additions and 5 deletions

View File

@@ -30,7 +30,7 @@ import org.springframework.util.Assert;
*/ */
class MergedTestPropertySources { class MergedTestPropertySources {
private static final String[] EMPTY_STRING_ARRAY = new String[0]; private static final MergedTestPropertySources empty = new MergedTestPropertySources(new String[0], new String[0]);
private final String[] locations; private final String[] locations;
@@ -38,12 +38,13 @@ class MergedTestPropertySources {
/** /**
* Create an <em>empty</em> {@code MergedTestPropertySources} instance. * Factory for an <em>empty</em> {@code MergedTestPropertySources} instance.
*/ */
MergedTestPropertySources() { static MergedTestPropertySources empty() {
this(EMPTY_STRING_ARRAY, EMPTY_STRING_ARRAY); return empty;
} }
/** /**
* Create a {@code MergedTestPropertySources} instance with the supplied * Create a {@code MergedTestPropertySources} instance with the supplied
* {@code locations} and {@code properties}. * {@code locations} and {@code properties}.

View File

@@ -92,7 +92,7 @@ public abstract class TestPropertySourceUtils {
static MergedTestPropertySources buildMergedTestPropertySources(Class<?> testClass) { static MergedTestPropertySources buildMergedTestPropertySources(Class<?> testClass) {
MergedAnnotations mergedAnnotations = MergedAnnotations.from(testClass, SearchStrategy.EXHAUSTIVE); MergedAnnotations mergedAnnotations = MergedAnnotations.from(testClass, SearchStrategy.EXHAUSTIVE);
return (mergedAnnotations.isPresent(TestPropertySource.class) ? mergeTestPropertySources(mergedAnnotations) : return (mergedAnnotations.isPresent(TestPropertySource.class) ? mergeTestPropertySources(mergedAnnotations) :
new MergedTestPropertySources()); MergedTestPropertySources.empty());
} }
private static MergedTestPropertySources mergeTestPropertySources(MergedAnnotations mergedAnnotations) { private static MergedTestPropertySources mergeTestPropertySources(MergedAnnotations mergedAnnotations) {