Skip to content

Commit

Permalink
Use cached SearchStrategy
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrannen committed Oct 9, 2020
1 parent 136d185 commit 07027b8
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ private static Class<?> resolveExplicitTestContextBootstrapper(Class<?> testClas
}

private static Class<?> resolveDefaultTestContextBootstrapper(Class<?> testClass) throws Exception {
SearchStrategy searchStrategy = MetaAnnotationUtils.lookUpSearchStrategy(testClass);
SearchStrategy searchStrategy = MetaAnnotationUtils.getSearchStrategy(testClass);
boolean webApp = MergedAnnotations.from(testClass, searchStrategy, RepeatableContainers.none())
.isPresent(WEB_APP_CONFIGURATION_ANNOTATION_CLASS_NAME);
ClassLoader classLoader = BootstrapUtils.class.getClassLoader();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public abstract class TestPropertySourceUtils {


static MergedTestPropertySources buildMergedTestPropertySources(Class<?> testClass) {
SearchStrategy searchStrategy = MetaAnnotationUtils.lookUpSearchStrategy(testClass);
SearchStrategy searchStrategy = MetaAnnotationUtils.getSearchStrategy(testClass);
MergedAnnotations mergedAnnotations = MergedAnnotations.from(testClass, searchStrategy);
return (mergedAnnotations.isPresent(TestPropertySource.class) ?
mergeTestPropertySources(mergedAnnotations, searchStrategy) :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected MergedContextConfiguration processMergedContextConfiguration(MergedCon
}

private static MergedAnnotation<WebAppConfiguration> getWebAppConfiguration(Class<?> testClass) {
return MergedAnnotations.from(testClass, MetaAnnotationUtils.lookUpSearchStrategy(testClass),
return MergedAnnotations.from(testClass, MetaAnnotationUtils.getSearchStrategy(testClass),
RepeatableContainers.none()).get(WebAppConfiguration.class);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,11 @@ private static UntypedAnnotationDescriptor findAnnotationDescriptorForTypes(@Nul
* @return the resolved search strategy
* @since 5.3
*/
private static SearchStrategy getSearchStrategy(Class<?> clazz) {
public static SearchStrategy getSearchStrategy(Class<?> clazz) {
return cachedSearchStrategies.get(clazz);
}

public static SearchStrategy lookUpSearchStrategy(Class<?> clazz) {
private static SearchStrategy lookUpSearchStrategy(Class<?> clazz) {
EnclosingConfiguration enclosingConfiguration =
MergedAnnotations.from(clazz, SearchStrategy.TYPE_HIERARCHY_AND_ENCLOSING_CLASSES)
.stream(NestedTestConfiguration.class)
Expand Down Expand Up @@ -505,7 +505,7 @@ public AnnotationDescriptor<T> next() {
@SuppressWarnings("unchecked")
public Set<T> findAllLocalMergedAnnotations() {
Class<T> annotationType = (Class<T>) getAnnotationType();
SearchStrategy searchStrategy = lookUpSearchStrategy(getRootDeclaringClass());
SearchStrategy searchStrategy = getSearchStrategy(getRootDeclaringClass());
return MergedAnnotations.from(getRootDeclaringClass(), searchStrategy , RepeatableContainers.none())
.stream(annotationType)
.filter(MergedAnnotationPredicates.firstRunOf(MergedAnnotation::getAggregateIndex))
Expand Down

0 comments on commit 07027b8

Please sign in to comment.