File tree 2 files changed +34
-4
lines changed
cucumber/runtime/java/spring
org/springframework/test/context
2 files changed +34
-4
lines changed Original file line number Diff line number Diff line change 1
1
package cucumber .runtime .java .spring ;
2
2
3
- import cucumber .runtime .CucumberException ;
3
+ import static org .springframework .test .context .FixBootstrapUtils .createBootstrapContext ;
4
+ import static org .springframework .test .context .FixBootstrapUtils .resolveTestContextBootstrapper ;
5
+
4
6
import cucumber .api .java .ObjectFactory ;
7
+ import cucumber .runtime .CucumberException ;
5
8
import org .springframework .beans .BeansException ;
6
9
import org .springframework .beans .factory .config .BeanDefinition ;
7
10
import org .springframework .beans .factory .config .ConfigurableListableBeanFactory ;
@@ -202,12 +205,14 @@ private boolean annotatedWithSupportedSpringRootTestAnnotations(Class<?> type) {
202
205
203
206
class CucumberTestContextManager extends TestContextManager {
204
207
205
- public CucumberTestContextManager (Class <?> testClass ) {
206
- super (testClass );
208
+ CucumberTestContextManager (Class <?> testClass ) {
209
+ // Does the same as TestContextManager(Class<?>) but creates a
210
+ // DefaultCacheAwareContextLoaderDelegate that uses a thread local contextCache.
211
+ super (resolveTestContextBootstrapper (createBootstrapContext (testClass )));
207
212
registerGlueCodeScope (getContext ());
208
213
}
209
214
210
- public ConfigurableListableBeanFactory getBeanFactory () {
215
+ ConfigurableListableBeanFactory getBeanFactory () {
211
216
return getContext ().getBeanFactory ();
212
217
}
213
218
Original file line number Diff line number Diff line change
1
+ package org .springframework .test .context ;
2
+
3
+ import org .springframework .test .context .cache .ContextCache ;
4
+ import org .springframework .test .context .cache .DefaultCacheAwareContextLoaderDelegate ;
5
+ import org .springframework .test .context .cache .DefaultContextCache ;
6
+ import org .springframework .test .context .support .DefaultBootstrapContext ;
7
+
8
+ public class FixBootstrapUtils extends BootstrapUtils {
9
+
10
+ private static ThreadLocal <ContextCache > contextCache = new ThreadLocal <ContextCache >(){
11
+ @ Override
12
+ protected ContextCache initialValue () {
13
+ return new DefaultContextCache ();
14
+ }
15
+ };
16
+
17
+ public static BootstrapContext createBootstrapContext (Class <?> testClass ) {
18
+ CacheAwareContextLoaderDelegate contextLoader = new DefaultCacheAwareContextLoaderDelegate (contextCache .get ());
19
+ return new DefaultBootstrapContext (testClass , contextLoader );
20
+ }
21
+
22
+ public static TestContextBootstrapper resolveTestContextBootstrapper (BootstrapContext bootstrapContext ) {
23
+ return BootstrapUtils .resolveTestContextBootstrapper (bootstrapContext );
24
+ }
25
+ }
You can’t perform that action at this time.
0 commit comments