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
074771ec
Commit
074771ec
authored
Jun 22, 2015
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.2.x'
parents
d30dd1fa
cd62596e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
1 deletion
+17
-1
SpringBootServletInitializer.java
...mework/boot/context/web/SpringBootServletInitializer.java
+3
-1
SpringBootServletInitializerTests.java
...k/boot/context/web/SpringBootServletInitializerTests.java
+14
-0
No files found.
spring-boot/src/main/java/org/springframework/boot/context/web/SpringBootServletInitializer.java
View file @
074771ec
/*
/*
* Copyright 2012-201
4
the original author or authors.
* Copyright 2012-201
5
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -57,6 +57,7 @@ import org.springframework.web.context.WebApplicationContext;
...
@@ -57,6 +57,7 @@ import org.springframework.web.context.WebApplicationContext;
*
*
* @author Dave Syer
* @author Dave Syer
* @author Phillip Webb
* @author Phillip Webb
* @author Andy Wilkinson
* @see #configure(SpringApplicationBuilder)
* @see #configure(SpringApplicationBuilder)
*/
*/
public
abstract
class
SpringBootServletInitializer
implements
WebApplicationInitializer
{
public
abstract
class
SpringBootServletInitializer
implements
WebApplicationInitializer
{
...
@@ -84,6 +85,7 @@ public abstract class SpringBootServletInitializer implements WebApplicationInit
...
@@ -84,6 +85,7 @@ public abstract class SpringBootServletInitializer implements WebApplicationInit
protected
WebApplicationContext
createRootApplicationContext
(
protected
WebApplicationContext
createRootApplicationContext
(
ServletContext
servletContext
)
{
ServletContext
servletContext
)
{
SpringApplicationBuilder
builder
=
createSpringApplicationBuilder
();
SpringApplicationBuilder
builder
=
createSpringApplicationBuilder
();
builder
.
main
(
getClass
());
ApplicationContext
parent
=
getExistingRootWebApplicationContext
(
servletContext
);
ApplicationContext
parent
=
getExistingRootWebApplicationContext
(
servletContext
);
if
(
parent
!=
null
)
{
if
(
parent
!=
null
)
{
this
.
logger
.
info
(
"Root context already created (using as parent)."
);
this
.
logger
.
info
(
"Root context already created (using as parent)."
);
...
...
spring-boot/src/test/java/org/springframework/boot/context/web/SpringBootServletInitializerTests.java
View file @
074771ec
...
@@ -26,6 +26,7 @@ import org.hamcrest.Matcher;
...
@@ -26,6 +26,7 @@ import org.hamcrest.Matcher;
import
org.junit.Rule
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.rules.ExpectedException
;
import
org.junit.rules.ExpectedException
;
import
org.springframework.beans.DirectFieldAccessor
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.builder.SpringApplicationBuilder
;
import
org.springframework.boot.builder.SpringApplicationBuilder
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
...
@@ -33,12 +34,14 @@ import org.springframework.mock.web.MockServletContext;
...
@@ -33,12 +34,14 @@ import org.springframework.mock.web.MockServletContext;
import
org.springframework.web.context.WebApplicationContext
;
import
org.springframework.web.context.WebApplicationContext
;
import
static
org
.
hamcrest
.
Matchers
.
equalTo
;
import
static
org
.
hamcrest
.
Matchers
.
equalTo
;
import
static
org
.
hamcrest
.
Matchers
.
is
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
static
org
.
junit
.
Assert
.
assertThat
;
/**
/**
* Tests for {@link SpringBootServletInitializerTests}.
* Tests for {@link SpringBootServletInitializerTests}.
*
*
* @author Phillip Webb
* @author Phillip Webb
* @author Andy Wilkinson
*/
*/
public
class
SpringBootServletInitializerTests
{
public
class
SpringBootServletInitializerTests
{
...
@@ -79,6 +82,17 @@ public class SpringBootServletInitializerTests {
...
@@ -79,6 +82,17 @@ public class SpringBootServletInitializerTests {
assertThat
(
servletInitializer
.
applicationBuilder
.
built
,
equalTo
(
true
));
assertThat
(
servletInitializer
.
applicationBuilder
.
built
,
equalTo
(
true
));
}
}
@SuppressWarnings
(
"rawtypes"
)
@Test
public
void
mainClassHasSensibleDefault
()
throws
Exception
{
new
WithConfigurationAnnotation
()
.
createRootApplicationContext
(
this
.
servletContext
);
Class
mainApplicationClass
=
(
Class
<?>)
new
DirectFieldAccessor
(
this
.
application
)
.
getPropertyValue
(
"mainApplicationClass"
);
assertThat
(
mainApplicationClass
,
is
(
equalTo
((
Class
)
WithConfigurationAnnotation
.
class
)));
}
private
Matcher
<?
super
Set
<
Object
>>
equalToSet
(
Object
...
items
)
{
private
Matcher
<?
super
Set
<
Object
>>
equalToSet
(
Object
...
items
)
{
Set
<
Object
>
set
=
new
LinkedHashSet
<
Object
>();
Set
<
Object
>
set
=
new
LinkedHashSet
<
Object
>();
Collections
.
addAll
(
set
,
items
);
Collections
.
addAll
(
set
,
items
);
...
...
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