Skip to content

Commit 26bbb6e

Browse files
committed
Polishing
1 parent b2a17ba commit 26bbb6e

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

spring-test/src/main/java/org/springframework/test/context/support/AbstractTestContextBootstrapper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131

3232
import org.springframework.beans.BeanInstantiationException;
3333
import org.springframework.beans.BeanUtils;
34-
import org.springframework.core.annotation.AnnotatedElementUtils;
3534
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
35+
import org.springframework.core.annotation.AnnotationUtils;
3636
import org.springframework.core.io.support.SpringFactoriesLoader;
3737
import org.springframework.test.context.BootstrapContext;
3838
import org.springframework.test.context.CacheAwareContextLoaderDelegate;
@@ -278,7 +278,7 @@ public final MergedContextConfiguration buildMergedContextConfiguration() {
278278
return buildDefaultMergedContextConfiguration(testClass, cacheAwareContextLoaderDelegate);
279279
}
280280

281-
if (AnnotatedElementUtils.findMergedAnnotation(testClass, ContextHierarchy.class) != null) {
281+
if (AnnotationUtils.findAnnotation(testClass, ContextHierarchy.class) != null) {
282282
Map<String, List<ContextConfigurationAttributes>> hierarchyMap = ContextLoaderUtils.buildContextHierarchyMap(testClass);
283283
MergedContextConfiguration parentConfig = null;
284284
MergedContextConfiguration mergedConfig = null;

spring-test/src/main/java/org/springframework/test/context/support/ContextLoaderUtils.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,12 @@ abstract class ContextLoaderUtils {
8181
* (must not be {@code null})
8282
* @return the list of lists of configuration attributes for the specified class;
8383
* never {@code null}
84-
* @throws IllegalArgumentException if the supplied class is {@code null}; if
84+
* @throws IllegalArgumentException if the supplied class is {@code null}; or if
8585
* neither {@code @ContextConfiguration} nor {@code @ContextHierarchy} is
86-
* <em>present</em> on the supplied class; or if a test class or composed annotation
86+
* <em>present</em> on the supplied class
87+
* @throws IllegalStateException if a test class or composed annotation
8788
* in the class hierarchy declares both {@code @ContextConfiguration} and
8889
* {@code @ContextHierarchy} as top-level annotations.
89-
* @throws IllegalStateException if no class in the class hierarchy declares
90-
* {@code @ContextHierarchy}.
9190
* @since 3.2.2
9291
* @see #buildContextHierarchyMap(Class)
9392
* @see #resolveContextConfigurationAttributes(Class)

spring-test/src/test/java/org/springframework/test/context/support/ContextLoaderUtilsContextHierarchyTests.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,7 +22,6 @@
2222
import java.util.List;
2323
import java.util.Map;
2424

25-
import org.junit.Ignore;
2625
import org.junit.Test;
2726

2827
import org.springframework.context.ApplicationContextInitializer;
@@ -60,10 +59,13 @@ public void resolveContextHierarchyAttributesForSingleTestClassWithContextConfig
6059
resolveContextHierarchyAttributes(SingleTestClassWithContextConfigurationAndContextHierarchyOnSingleMetaAnnotation.class);
6160
}
6261

63-
@Test(expected = IllegalStateException.class)
64-
@Ignore // an upfront findAnnotation check just for an assertion seems too expensive
62+
@Test
6563
public void resolveContextHierarchyAttributesForSingleTestClassWithImplicitSingleLevelContextHierarchy() {
66-
resolveContextHierarchyAttributes(BareAnnotations.class);
64+
List<List<ContextConfigurationAttributes>> hierarchyAttributes = resolveContextHierarchyAttributes(BareAnnotations.class);
65+
assertEquals(1, hierarchyAttributes.size());
66+
List<ContextConfigurationAttributes> configAttributesList = hierarchyAttributes.get(0);
67+
assertEquals(1, configAttributesList.size());
68+
debugConfigAttributes(configAttributesList);
6769
}
6870

6971
@Test

0 commit comments

Comments
 (0)