Skip to content

Commit

Permalink
Make BootstrapUtils.resolveTestContextBootstrapper() public
Browse files Browse the repository at this point in the history
Closes gh-28891
  • Loading branch information
sbrannen committed Jul 30, 2022
1 parent ad99add commit 64c3ad3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -35,6 +35,8 @@
* {@code BootstrapUtils} is a collection of utility methods to assist with
* bootstrapping the <em>Spring TestContext Framework</em>.
*
* <p>Only intended for internal use.
*
* @author Sam Brannen
* @author Phillip Webb
* @since 4.1
Expand Down Expand Up @@ -114,6 +116,27 @@ private static CacheAwareContextLoaderDelegate createCacheAwareContextLoaderDele
}
}

/**
* Resolve the {@link TestContextBootstrapper} type for the supplied test class
* using the default {@link BootstrapContext}, instantiate the bootstrapper,
* and provide it a reference to the {@code BootstrapContext}.
* <p>If the {@link BootstrapWith @BootstrapWith} annotation is present on
* the test class, either directly or as a meta-annotation, then its
* {@link BootstrapWith#value value} will be used as the bootstrapper type.
* Otherwise, either the
* {@link org.springframework.test.context.support.DefaultTestContextBootstrapper
* DefaultTestContextBootstrapper} or the
* {@link org.springframework.test.context.web.WebTestContextBootstrapper
* WebTestContextBootstrapper} will be used, depending on the presence of
* {@link org.springframework.test.context.web.WebAppConfiguration @WebAppConfiguration}.
* @param testClass the test class for which the bootstrapper should be created
* @return a fully configured {@code TestContextBootstrapper}
* @since 6.0
*/
public static TestContextBootstrapper resolveTestContextBootstrapper(Class<?> testClass) {
return resolveTestContextBootstrapper(createBootstrapContext(testClass));
}

/**
* Resolve the {@link TestContextBootstrapper} type for the test class in the
* supplied {@link BootstrapContext}, instantiate it, and provide it a reference
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -119,7 +119,7 @@ public TestContext get() {
* @see #TestContextManager(TestContextBootstrapper)
*/
public TestContextManager(Class<?> testClass) {
this(BootstrapUtils.resolveTestContextBootstrapper(BootstrapUtils.createBootstrapContext(testClass)));
this(BootstrapUtils.resolveTestContextBootstrapper(testClass));
}

/**
Expand Down

0 comments on commit 64c3ad3

Please sign in to comment.