@@ -90,21 +90,36 @@ public class TestContextManager {
90
90
91
91
92
92
/**
93
- * Construct a new {@code TestContextManager} for the specified {@linkplain Class test class}
94
- * and automatically {@linkplain #registerTestExecutionListeners register} the
95
- * {@link TestExecutionListener TestExecutionListeners} configured for the test class
96
- * via the {@link TestExecutionListeners @TestExecutionListeners} annotation.
93
+ * Construct a new {@code TestContextManager} for the specified {@linkplain Class test class},
94
+ * automatically {@linkplain #registerTestExecutionListeners registering} the necessary
95
+ * {@link TestExecutionListener TestExecutionListeners}.
96
+ * <p>Delegates to a {@link TestContextBootstrapper} for building the {@code TestContext}
97
+ * and retrieving the {@code TestExecutionListeners}.
97
98
* @param testClass the test class to be managed
99
+ * @see TestContextBootstrapper#buildTestContext
100
+ * @see TestContextBootstrapper#getTestExecutionListeners
98
101
* @see #registerTestExecutionListeners
99
102
*/
100
103
public TestContextManager (Class <?> testClass ) {
101
- CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate = new DefaultCacheAwareContextLoaderDelegate ();
102
- BootstrapContext bootstrapContext = new DefaultBootstrapContext (testClass , cacheAwareContextLoaderDelegate );
104
+ BootstrapContext bootstrapContext = createBootstrapContext (testClass );
103
105
TestContextBootstrapper testContextBootstrapper = BootstrapUtils .resolveTestContextBootstrapper (bootstrapContext );
104
106
this .testContext = testContextBootstrapper .buildTestContext ();
105
107
registerTestExecutionListeners (testContextBootstrapper .getTestExecutionListeners ());
106
108
}
107
109
110
+ /**
111
+ * Create the {@code BootstrapContext} for the specified {@linkplain Class test class}.
112
+ * <p>The default implementation creates a {@link DefaultBootstrapContext} that
113
+ * uses the {@link DefaultCacheAwareContextLoaderDelegate}.
114
+ * <p>Can be overridden by subclasses as necessary.
115
+ * @param testClass the test class for which the bootstrap context should be created
116
+ * @return a new {@code BootstrapContext}; never {@code null}
117
+ */
118
+ protected BootstrapContext createBootstrapContext (Class <?> testClass ) {
119
+ CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate = new DefaultCacheAwareContextLoaderDelegate ();
120
+ return new DefaultBootstrapContext (testClass , cacheAwareContextLoaderDelegate );
121
+ }
122
+
108
123
/**
109
124
* Get the {@link TestContext} managed by this {@code TestContextManager}.
110
125
*/
0 commit comments