Polishing

This commit is contained in:
Sam Brannen 2016-03-28 16:17:47 +02:00
parent b2a17ba537
commit 26bbb6e767
3 changed files with 12 additions and 11 deletions

View File

@ -31,8 +31,8 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeanInstantiationException; import org.springframework.beans.BeanInstantiationException;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.core.annotation.AnnotatedElementUtils;
import org.springframework.core.annotation.AnnotationAwareOrderComparator; import org.springframework.core.annotation.AnnotationAwareOrderComparator;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.core.io.support.SpringFactoriesLoader; import org.springframework.core.io.support.SpringFactoriesLoader;
import org.springframework.test.context.BootstrapContext; import org.springframework.test.context.BootstrapContext;
import org.springframework.test.context.CacheAwareContextLoaderDelegate; import org.springframework.test.context.CacheAwareContextLoaderDelegate;
@ -278,7 +278,7 @@ public abstract class AbstractTestContextBootstrapper implements TestContextBoot
return buildDefaultMergedContextConfiguration(testClass, cacheAwareContextLoaderDelegate); return buildDefaultMergedContextConfiguration(testClass, cacheAwareContextLoaderDelegate);
} }
if (AnnotatedElementUtils.findMergedAnnotation(testClass, ContextHierarchy.class) != null) { if (AnnotationUtils.findAnnotation(testClass, ContextHierarchy.class) != null) {
Map<String, List<ContextConfigurationAttributes>> hierarchyMap = ContextLoaderUtils.buildContextHierarchyMap(testClass); Map<String, List<ContextConfigurationAttributes>> hierarchyMap = ContextLoaderUtils.buildContextHierarchyMap(testClass);
MergedContextConfiguration parentConfig = null; MergedContextConfiguration parentConfig = null;
MergedContextConfiguration mergedConfig = null; MergedContextConfiguration mergedConfig = null;

View File

@ -81,13 +81,12 @@ abstract class ContextLoaderUtils {
* (must not be {@code null}) * (must not be {@code null})
* @return the list of lists of configuration attributes for the specified class; * @return the list of lists of configuration attributes for the specified class;
* never {@code null} * never {@code null}
* @throws IllegalArgumentException if the supplied class is {@code null}; if * @throws IllegalArgumentException if the supplied class is {@code null}; or if
* neither {@code @ContextConfiguration} nor {@code @ContextHierarchy} is * neither {@code @ContextConfiguration} nor {@code @ContextHierarchy} is
* <em>present</em> on the supplied class; or if a test class or composed annotation * <em>present</em> on the supplied class
* @throws IllegalStateException if a test class or composed annotation
* in the class hierarchy declares both {@code @ContextConfiguration} and * in the class hierarchy declares both {@code @ContextConfiguration} and
* {@code @ContextHierarchy} as top-level annotations. * {@code @ContextHierarchy} as top-level annotations.
* @throws IllegalStateException if no class in the class hierarchy declares
* {@code @ContextHierarchy}.
* @since 3.2.2 * @since 3.2.2
* @see #buildContextHierarchyMap(Class) * @see #buildContextHierarchyMap(Class)
* @see #resolveContextConfigurationAttributes(Class) * @see #resolveContextConfigurationAttributes(Class)

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2014 the original author or authors. * Copyright 2002-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -22,7 +22,6 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.springframework.context.ApplicationContextInitializer; import org.springframework.context.ApplicationContextInitializer;
@ -60,10 +59,13 @@ public class ContextLoaderUtilsContextHierarchyTests extends AbstractContextConf
resolveContextHierarchyAttributes(SingleTestClassWithContextConfigurationAndContextHierarchyOnSingleMetaAnnotation.class); resolveContextHierarchyAttributes(SingleTestClassWithContextConfigurationAndContextHierarchyOnSingleMetaAnnotation.class);
} }
@Test(expected = IllegalStateException.class) @Test
@Ignore // an upfront findAnnotation check just for an assertion seems too expensive
public void resolveContextHierarchyAttributesForSingleTestClassWithImplicitSingleLevelContextHierarchy() { public void resolveContextHierarchyAttributesForSingleTestClassWithImplicitSingleLevelContextHierarchy() {
resolveContextHierarchyAttributes(BareAnnotations.class); List<List<ContextConfigurationAttributes>> hierarchyAttributes = resolveContextHierarchyAttributes(BareAnnotations.class);
assertEquals(1, hierarchyAttributes.size());
List<ContextConfigurationAttributes> configAttributesList = hierarchyAttributes.get(0);
assertEquals(1, configAttributesList.size());
debugConfigAttributes(configAttributesList);
} }
@Test @Test