Skip to content

Commit 64c3ad3

Browse files
committed
Make BootstrapUtils.resolveTestContextBootstrapper() public
Closes gh-28891
1 parent ad99add commit 64c3ad3

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

spring-test/src/main/java/org/springframework/test/context/BootstrapUtils.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2022 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.
@@ -35,6 +35,8 @@
3535
* {@code BootstrapUtils} is a collection of utility methods to assist with
3636
* bootstrapping the <em>Spring TestContext Framework</em>.
3737
*
38+
* <p>Only intended for internal use.
39+
*
3840
* @author Sam Brannen
3941
* @author Phillip Webb
4042
* @since 4.1
@@ -114,6 +116,27 @@ private static CacheAwareContextLoaderDelegate createCacheAwareContextLoaderDele
114116
}
115117
}
116118

119+
/**
120+
* Resolve the {@link TestContextBootstrapper} type for the supplied test class
121+
* using the default {@link BootstrapContext}, instantiate the bootstrapper,
122+
* and provide it a reference to the {@code BootstrapContext}.
123+
* <p>If the {@link BootstrapWith @BootstrapWith} annotation is present on
124+
* the test class, either directly or as a meta-annotation, then its
125+
* {@link BootstrapWith#value value} will be used as the bootstrapper type.
126+
* Otherwise, either the
127+
* {@link org.springframework.test.context.support.DefaultTestContextBootstrapper
128+
* DefaultTestContextBootstrapper} or the
129+
* {@link org.springframework.test.context.web.WebTestContextBootstrapper
130+
* WebTestContextBootstrapper} will be used, depending on the presence of
131+
* {@link org.springframework.test.context.web.WebAppConfiguration @WebAppConfiguration}.
132+
* @param testClass the test class for which the bootstrapper should be created
133+
* @return a fully configured {@code TestContextBootstrapper}
134+
* @since 6.0
135+
*/
136+
public static TestContextBootstrapper resolveTestContextBootstrapper(Class<?> testClass) {
137+
return resolveTestContextBootstrapper(createBootstrapContext(testClass));
138+
}
139+
117140
/**
118141
* Resolve the {@link TestContextBootstrapper} type for the test class in the
119142
* supplied {@link BootstrapContext}, instantiate it, and provide it a reference

spring-test/src/main/java/org/springframework/test/context/TestContextManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2022 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.
@@ -119,7 +119,7 @@ public TestContext get() {
119119
* @see #TestContextManager(TestContextBootstrapper)
120120
*/
121121
public TestContextManager(Class<?> testClass) {
122-
this(BootstrapUtils.resolveTestContextBootstrapper(BootstrapUtils.createBootstrapContext(testClass)));
122+
this(BootstrapUtils.resolveTestContextBootstrapper(testClass));
123123
}
124124

125125
/**

0 commit comments

Comments
 (0)