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
fc0d4e45
Commit
fc0d4e45
authored
Sep 21, 2016
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update CLI test auto-configuration to 1.4's new test infrastructure
Closes gh-6973
parent
be78dc4b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
17 deletions
+18
-17
SpringBootCompilerAutoConfiguration.java
...er/autoconfigure/SpringBootCompilerAutoConfiguration.java
+2
-1
SpringTestCompilerAutoConfiguration.java
...er/autoconfigure/SpringTestCompilerAutoConfiguration.java
+6
-5
integration.groovy
spring-boot-cli/test-samples/integration.groovy
+1
-2
integration_auto.groovy
spring-boot-cli/test-samples/integration_auto.groovy
+8
-7
integration_auto_test.groovy
spring-boot-cli/test-samples/integration_auto_test.groovy
+1
-2
No files found.
spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringBootCompilerAutoConfiguration.java
View file @
fc0d4e45
/*
* Copyright 2012-201
5
the original author or authors.
* Copyright 2012-201
6
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.
...
...
@@ -69,6 +69,7 @@ public class SpringBootCompilerAutoConfiguration extends CompilerAutoConfigurati
"org.springframework.boot.context.properties.ConfigurationProperties"
,
"org.springframework.boot.context.properties.EnableConfigurationProperties"
,
"org.springframework.boot.autoconfigure.EnableAutoConfiguration"
,
"org.springframework.boot.autoconfigure.SpringBootApplication"
,
"org.springframework.boot.context.properties.ConfigurationProperties"
,
"org.springframework.boot.context.properties.EnableConfigurationProperties"
);
imports
.
addStarImports
(
"org.springframework.stereotype"
,
...
...
spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringTestCompilerAutoConfiguration.java
View file @
fc0d4e45
...
...
@@ -41,8 +41,7 @@ public class SpringTestCompilerAutoConfiguration extends CompilerAutoConfigurati
@Override
public
boolean
matches
(
ClassNode
classNode
)
{
return
AstUtils
.
hasAtLeastOneAnnotation
(
classNode
,
"SpringApplicationConfiguration"
);
return
AstUtils
.
hasAtLeastOneAnnotation
(
classNode
,
"SpringBootTest"
);
}
@Override
...
...
@@ -66,8 +65,10 @@ public class SpringTestCompilerAutoConfiguration extends CompilerAutoConfigurati
@Override
public
void
applyImports
(
ImportCustomizer
imports
)
throws
CompilationFailedException
{
imports
.
addStarImports
(
"org.junit.runner"
,
"org.springframework.boot.test"
,
"org.springframework.http"
,
"org.springframework.test.context.junit4"
,
"org.springframework.test.annotation"
)
.
addImports
(
"org.springframework.test.context.web.WebAppConfiguration"
);
"org.springframework.boot.test.context"
,
"org.springframework.boot.test.web.client"
,
"org.springframework.http"
,
"org.springframework.test.context.junit4"
,
"org.springframework.test.annotation"
).
addImports
(
"org.springframework.boot.test.context.SpringBootTest.WebEnvironment"
);
}
}
spring-boot-cli/test-samples/integration.groovy
View file @
fc0d4e45
@SpringApplicationConfiguration
(
Application
)
@IntegrationTest
@SpringBootTest
(
classes
=
Application
)
class
BookTests
{
@Autowired
Book
book
...
...
spring-boot-cli/test-samples/integration_auto.groovy
View file @
fc0d4e45
@SpringApplicationConfiguration
(
Application
)
@IntegrationTest
(
'server.port:0'
)
@
WebAppConfigur
ation
@
DirtiesContext
package
com.example
@
SpringBootApplic
ation
@
SpringBootTest
(
classes
=
RestTests
,
webEnvironment
=
WebEnvironment
.
RANDOM_PORT
)
class
RestTests
{
@
Value
(
'${local.server.port}'
)
int
port
@
Autowired
TestRestTemplate
testRestTemplate
;
@Test
void
testHome
()
{
assertEquals
(
'Hello'
,
new
TestRestTemplate
().
getForObject
(
'http://localhost:'
+
port
,
String
))
assertEquals
(
'Hello'
,
testRestTemplate
.
getForObject
(
'/'
,
String
))
}
@RestController
...
...
@@ -17,4 +17,5 @@ class RestTests {
@RequestMapping
(
'/'
)
String
hello
()
{
'Hello'
}
}
}
spring-boot-cli/test-samples/integration_auto_test.groovy
View file @
fc0d4e45
@SpringApplicationConfiguration
(
ReactorApplication
)
@IntegrationTest
(
'server.port:0'
)
@SpringBootTest
(
classes
=
ReactorApplication
,
webEnvironment
=
WebEnvironment
.
RANDOM_PORT
)
class
RestTests
{
@Autowired
...
...
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