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
c5cfe54c
Commit
c5cfe54c
authored
Nov 01, 2013
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add spring-boot tests to test starter
parent
217ec5d5
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
63 additions
and
6 deletions
+63
-6
pom.xml
spring-boot-samples/spring-boot-sample-simple/pom.xml
+5
-0
SpringTestSampleSimpleApplicationTests.java
...sample/simple/SpringTestSampleSimpleApplicationTests.java
+38
-0
pom.xml
spring-boot-starters/spring-boot-starter-test/pom.xml
+6
-0
SpringApplicationContextLoader.java
...ngframework/boot/test/SpringApplicationContextLoader.java
+14
-6
No files found.
spring-boot-samples/spring-boot-sample-simple/pom.xml
View file @
c5cfe54c
...
@@ -18,6 +18,11 @@
...
@@ -18,6 +18,11 @@
<groupId>
${project.groupId}
</groupId>
<groupId>
${project.groupId}
</groupId>
<artifactId>
spring-boot-starter
</artifactId>
<artifactId>
spring-boot-starter
</artifactId>
</dependency>
</dependency>
<dependency>
<groupId>
${project.groupId}
</groupId>
<artifactId>
spring-boot-starter-test
</artifactId>
<scope>
test
</scope>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
<plugins>
<plugins>
...
...
spring-boot-samples/spring-boot-sample-simple/src/test/java/org/springframework/boot/sample/simple/SpringTestSampleSimpleApplicationTests.java
0 → 100644
View file @
c5cfe54c
/*
* Copyright 2012-2013 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
sample
.
simple
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.boot.test.SpringApplicationContextLoader
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
/**
* Tests for {@link SampleSimpleApplication}.
*
* @author Dave Syer
*/
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@ContextConfiguration
(
classes
=
SampleSimpleApplication
.
class
,
loader
=
SpringApplicationContextLoader
.
class
)
public
class
SpringTestSampleSimpleApplicationTests
{
@Test
public
void
testContextLoads
()
throws
Exception
{
}
}
spring-boot-starters/spring-boot-starter-test/pom.xml
View file @
c5cfe54c
...
@@ -18,6 +18,12 @@
...
@@ -18,6 +18,12 @@
<artifactId>
spring-boot-starter-logging
</artifactId>
<artifactId>
spring-boot-starter-logging
</artifactId>
<version>
${project.version}
</version>
<version>
${project.version}
</version>
</dependency>
</dependency>
<dependency>
<groupId>
${project.groupId}
</groupId>
<artifactId>
spring-boot
</artifactId>
<classifier>
tests
</classifier>
<version>
${project.version}
</version>
</dependency>
<dependency>
<dependency>
<groupId>
junit
</groupId>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
<artifactId>
junit
</artifactId>
...
...
spring-boot/src/test/java/org/springframework/boot/test/SpringApplicationContextLoader.java
View file @
c5cfe54c
...
@@ -80,12 +80,7 @@ public class SpringApplicationContextLoader extends AbstractContextLoader {
...
@@ -80,12 +80,7 @@ public class SpringApplicationContextLoader extends AbstractContextLoader {
initializers
.
add
(
BeanUtils
.
instantiate
(
type
));
initializers
.
add
(
BeanUtils
.
instantiate
(
type
));
}
}
if
(
mergedConfig
instanceof
WebMergedContextConfiguration
)
{
if
(
mergedConfig
instanceof
WebMergedContextConfiguration
)
{
WebMergedContextConfiguration
webConfig
=
(
WebMergedContextConfiguration
)
mergedConfig
;
new
WebConfigurer
().
setup
(
mergedConfig
,
application
,
initializers
);
MockServletContext
servletContext
=
new
MockServletContext
(
webConfig
.
getResourceBasePath
());
initializers
.
add
(
0
,
new
ServletContextApplicationContextInitializer
(
servletContext
));
application
.
setApplicationContextClass
(
GenericWebApplicationContext
.
class
);
}
}
else
{
else
{
application
.
setWebEnvironment
(
false
);
application
.
setWebEnvironment
(
false
);
...
@@ -105,4 +100,17 @@ public class SpringApplicationContextLoader extends AbstractContextLoader {
...
@@ -105,4 +100,17 @@ public class SpringApplicationContextLoader extends AbstractContextLoader {
return
"-context.xml"
;
return
"-context.xml"
;
}
}
private
static
class
WebConfigurer
{
void
setup
(
MergedContextConfiguration
mergedConfig
,
SpringApplication
application
,
List
<
ApplicationContextInitializer
<?>>
initializers
)
{
WebMergedContextConfiguration
webConfig
=
(
WebMergedContextConfiguration
)
mergedConfig
;
MockServletContext
servletContext
=
new
MockServletContext
(
webConfig
.
getResourceBasePath
());
initializers
.
add
(
0
,
new
ServletContextApplicationContextInitializer
(
servletContext
));
application
.
setApplicationContextClass
(
GenericWebApplicationContext
.
class
);
}
}
}
}
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