Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
3fb1bdef
Commit
3fb1bdef
authored
Jul 13, 2017
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support to ContextLoader for configuring context's parent
Closes gh-9749
parent
192d9ee1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
0 deletions
+21
-0
AbstractContextLoader.java
...ingframework/boot/test/context/AbstractContextLoader.java
+11
-0
ContextLoader.java
.../org/springframework/boot/test/context/ContextLoader.java
+10
-0
No files found.
spring-boot-test/src/main/java/org/springframework/boot/test/context/AbstractContextLoader.java
View file @
3fb1bdef
...
...
@@ -62,6 +62,8 @@ class AbstractContextLoader<T extends ConfigurableApplicationContext, L extends
private
ClassLoader
classLoader
;
private
ApplicationContext
parent
;
protected
AbstractContextLoader
(
Supplier
<
T
>
contextSupplier
)
{
this
.
contextSupplier
=
contextSupplier
;
}
...
...
@@ -115,6 +117,12 @@ class AbstractContextLoader<T extends ConfigurableApplicationContext, L extends
return
self
();
}
@Override
public
L
parent
(
ApplicationContext
parent
)
{
this
.
parent
=
parent
;
return
self
();
}
/**
* Add the specified auto-configuration classes.
* @param autoConfigurations the auto-configuration classes to add
...
...
@@ -226,6 +234,9 @@ class AbstractContextLoader<T extends ConfigurableApplicationContext, L extends
private
T
configureApplicationContext
()
{
T
context
=
AbstractContextLoader
.
this
.
contextSupplier
.
get
();
if
(
this
.
parent
!=
null
)
{
context
.
setParent
(
this
.
parent
);
}
if
(
this
.
classLoader
!=
null
)
{
Assert
.
isInstanceOf
(
DefaultResourceLoader
.
class
,
context
);
((
DefaultResourceLoader
)
context
).
setClassLoader
(
this
.
classLoader
);
...
...
spring-boot-test/src/main/java/org/springframework/boot/test/context/ContextLoader.java
View file @
3fb1bdef
...
...
@@ -134,6 +134,16 @@ public interface ContextLoader {
*/
ContextLoader
classLoader
(
ClassLoader
classLoader
);
/**
* Configure the
* {@link org.springframework.context.ConfigurableApplicationContext#setParent(ApplicationContext)
* parent} of the {@link ApplicationContext}.
*
* @param parent the parent
* @return this instance
*/
ContextLoader
parent
(
ApplicationContext
parent
);
/**
* Create and refresh a new {@link ApplicationContext} based on the current state of
* this loader. The context is consumed by the specified {@code consumer} and closed
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment