|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2021 the original author or authors. |
| 2 | + * Copyright 2002-2022 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
35 | 35 | * {@code BootstrapUtils} is a collection of utility methods to assist with
|
36 | 36 | * bootstrapping the <em>Spring TestContext Framework</em>.
|
37 | 37 | *
|
| 38 | + * <p>Only intended for internal use. |
| 39 | + * |
38 | 40 | * @author Sam Brannen
|
39 | 41 | * @author Phillip Webb
|
40 | 42 | * @since 4.1
|
@@ -114,6 +116,27 @@ private static CacheAwareContextLoaderDelegate createCacheAwareContextLoaderDele
|
114 | 116 | }
|
115 | 117 | }
|
116 | 118 |
|
| 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 | + |
117 | 140 | /**
|
118 | 141 | * Resolve the {@link TestContextBootstrapper} type for the test class in the
|
119 | 142 | * supplied {@link BootstrapContext}, instantiate it, and provide it a reference
|
|
0 commit comments