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
fad5ce45
Commit
fad5ce45
authored
Apr 23, 2014
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
316cb875
Changes
46
Hide whitespace changes
Inline
Side-by-side
Showing
46 changed files
with
274 additions
and
251 deletions
+274
-251
EndpointWebMvcAutoConfiguration.java
...ctuate/autoconfigure/EndpointWebMvcAutoConfiguration.java
+4
-4
ManagementServerPropertiesAutoConfiguration.java
...onfigure/ManagementServerPropertiesAutoConfiguration.java
+1
-1
ThymeleafAutoConfiguration.java
...t/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java
+3
-5
WebMvcAutoConfiguration.java
...ework/boot/autoconfigure/web/WebMvcAutoConfiguration.java
+1
-1
SecurityPropertiesTests.java
.../boot/autoconfigure/security/SecurityPropertiesTests.java
+1
-0
WebMvcAutoConfigurationTests.java
.../boot/autoconfigure/web/WebMvcAutoConfigurationTests.java
+4
-7
appendix-application-properties.adoc
...cs/src/main/asciidoc/appendix-application-properties.adoc
+1
-1
howto.adoc
spring-boot-docs/src/main/asciidoc/howto.adoc
+14
-9
production-ready-features.adoc
...oot-docs/src/main/asciidoc/production-ready-features.adoc
+12
-14
spring-boot-features.adoc
spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
+33
-30
SampleActuatorUiApplicationPortTests.java
...ple/actuator/ui/SampleActuatorUiApplicationPortTests.java
+3
-3
SampleActuatorUiApplicationTests.java
.../sample/actuator/ui/SampleActuatorUiApplicationTests.java
+7
-7
EndpointsPropertiesSampleActuatorApplicationTests.java
...or/EndpointsPropertiesSampleActuatorApplicationTests.java
+2
-2
ManagementAddressActuatorApplicationTests.java
...e/actuator/ManagementAddressActuatorApplicationTests.java
+4
-3
ManagementPortSampleActuatorApplicationTests.java
...ctuator/ManagementPortSampleActuatorApplicationTests.java
+3
-3
NoManagementSampleActuatorApplicationTests.java
.../actuator/NoManagementSampleActuatorApplicationTests.java
+6
-6
SampleActuatorApplicationTests.java
.../java/sample/actuator/SampleActuatorApplicationTests.java
+20
-19
ShutdownSampleActuatorApplicationTests.java
...mple/actuator/ShutdownSampleActuatorApplicationTests.java
+4
-3
UnsecureManagementSampleActuatorApplicationTests.java
...tor/UnsecureManagementSampleActuatorApplicationTests.java
+4
-4
UnsecureSampleActuatorApplicationTests.java
...mple/actuator/UnsecureSampleActuatorApplicationTests.java
+5
-5
SampleJettyApplicationTests.java
...c/test/java/sample/jetty/SampleJettyApplicationTests.java
+2
-2
SampleServletApplicationTests.java
...st/java/sample/servlet/SampleServletApplicationTests.java
+4
-4
NonAutoConfigurationSampleTomcatApplicationTests.java
...cat/NonAutoConfigurationSampleTomcatApplicationTests.java
+3
-2
SampleTomcatApplicationTests.java
...test/java/sample/tomcat/SampleTomcatApplicationTests.java
+2
-2
SampleTraditionalApplicationTests.java
...sample/traditional/SampleTraditionalApplicationTests.java
+3
-3
SampleWebJspApplicationTests.java
...rc/test/java/sample/jsp/SampleWebJspApplicationTests.java
+2
-2
SampleMethodSecurityApplicationTests.java
...ample/ui/method/SampleMethodSecurityApplicationTests.java
+14
-14
SampleSecureApplicationTests.java
...t/java/sample/ui/secure/SampleSecureApplicationTests.java
+4
-4
SampleWebStaticApplicationTests.java
.../test/java/sample/ui/SampleWebStaticApplicationTests.java
+7
-7
SampleWebUiApplicationTests.java
.../src/test/java/sample/ui/SampleWebUiApplicationTests.java
+6
-6
CustomContainerWebSocketsApplicationTests.java
...ocket/echo/CustomContainerWebSocketsApplicationTests.java
+3
-3
SampleWebSocketsApplicationTests.java
...ples/websocket/echo/SampleWebSocketsApplicationTests.java
+4
-4
ProjectLibraries.java
...rg/springframework/boot/gradle/task/ProjectLibraries.java
+3
-5
RunMojo.java
...src/main/java/org/springframework/boot/maven/RunMojo.java
+3
-1
EmbeddedWebApplicationContext.java
.../boot/context/embedded/EmbeddedWebApplicationContext.java
+3
-7
RegistrationBean.java
...ringframework/boot/context/embedded/RegistrationBean.java
+0
-1
ServletListenerRegistrationBean.java
...oot/context/embedded/ServletListenerRegistrationBean.java
+1
-1
EmbeddedServletContainerTestExecutionListener.java
...t/test/EmbeddedServletContainerTestExecutionListener.java
+16
-14
EnvironmentTestUtils.java
...a/org/springframework/boot/test/EnvironmentTestUtils.java
+0
-3
IntegrationTest.java
...n/java/org/springframework/boot/test/IntegrationTest.java
+9
-2
SpringApplicationContextLoader.java
...ngframework/boot/test/SpringApplicationContextLoader.java
+35
-26
RelaxedDataBinderTests.java
...org/springframework/boot/bind/RelaxedDataBinderTests.java
+2
-3
RandomValuePropertySourceTests.java
...k/boot/context/config/RandomValuePropertySourceTests.java
+3
-1
PropertySourcesLoaderTests.java
.../springframework/boot/env/PropertySourcesLoaderTests.java
+4
-2
YamlPropertySourceLoaderTests.java
...ringframework/boot/env/YamlPropertySourceLoaderTests.java
+6
-4
TestRestTemplateTests.java
.../org/springframework/boot/test/TestRestTemplateTests.java
+3
-1
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfiguration.java
View file @
fad5ce45
...
@@ -200,15 +200,15 @@ public class EndpointWebMvcAutoConfiguration implements ApplicationContextAware,
...
@@ -200,15 +200,15 @@ public class EndpointWebMvcAutoConfiguration implements ApplicationContextAware,
registerContainer
(
this
.
applicationContext
,
registerContainer
(
this
.
applicationContext
,
childContext
.
getEmbeddedServletContainer
());
childContext
.
getEmbeddedServletContainer
());
}
}
catch
(
RuntimeException
e
)
{
catch
(
RuntimeException
e
x
)
{
// No support currently for deploying a war with management.port=<different>,
// No support currently for deploying a war with management.port=<different>,
// and this is the signature of that happening
// and this is the signature of that happening
if
(
e
instanceof
EmbeddedServletContainerException
if
(
e
x
instanceof
EmbeddedServletContainerException
||
e
.
getCause
()
instanceof
EmbeddedServletContainerException
)
{
||
e
x
.
getCause
()
instanceof
EmbeddedServletContainerException
)
{
logger
.
warn
(
"Could not start embedded container (management endpoints are still available through JMX)"
);
logger
.
warn
(
"Could not start embedded container (management endpoints are still available through JMX)"
);
}
}
else
{
else
{
throw
e
;
throw
e
x
;
}
}
}
}
};
};
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/ManagementServerPropertiesAutoConfiguration.java
View file @
fad5ce45
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
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.
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java
View file @
fad5ce45
...
@@ -178,7 +178,7 @@ public class ThymeleafAutoConfiguration {
...
@@ -178,7 +178,7 @@ public class ThymeleafAutoConfiguration {
resolver
.
setTemplateEngine
(
this
.
templateEngine
);
resolver
.
setTemplateEngine
(
this
.
templateEngine
);
resolver
.
setCharacterEncoding
(
this
.
environment
.
getProperty
(
"encoding"
,
resolver
.
setCharacterEncoding
(
this
.
environment
.
getProperty
(
"encoding"
,
"UTF-8"
));
"UTF-8"
));
resolver
.
setContentType
(
a
ddEncoding
(
resolver
.
setContentType
(
a
ppendCharset
(
this
.
environment
.
getProperty
(
"contentType"
,
"text/html"
),
this
.
environment
.
getProperty
(
"contentType"
,
"text/html"
),
resolver
.
getCharacterEncoding
()));
resolver
.
getCharacterEncoding
()));
resolver
.
setExcludedViewNames
(
this
.
environment
.
getProperty
(
resolver
.
setExcludedViewNames
(
this
.
environment
.
getProperty
(
...
@@ -191,13 +191,11 @@ public class ThymeleafAutoConfiguration {
...
@@ -191,13 +191,11 @@ public class ThymeleafAutoConfiguration {
return
resolver
;
return
resolver
;
}
}
private
String
a
ddEncoding
(
String
type
,
String
charset
)
{
private
String
a
ppendCharset
(
String
type
,
String
charset
)
{
if
(
type
.
contains
(
"charset="
))
{
if
(
type
.
contains
(
"charset="
))
{
return
type
;
return
type
;
}
}
else
{
return
type
+
";charset="
+
charset
;
return
type
+
";charset="
+
charset
;
}
}
}
}
}
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration.java
View file @
fad5ce45
...
@@ -143,7 +143,7 @@ public class WebMvcAutoConfiguration {
...
@@ -143,7 +143,7 @@ public class WebMvcAutoConfiguration {
@Value
(
"${spring.resources.cachePeriod:}"
)
@Value
(
"${spring.resources.cachePeriod:}"
)
private
Integer
cachePeriod
;
private
Integer
cachePeriod
;
@Value
(
"${spring.mvc.locale:}"
)
@Value
(
"${spring.mvc.locale:}"
)
private
String
locale
=
""
;
private
String
locale
=
""
;
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/SecurityPropertiesTests.java
View file @
fad5ce45
...
@@ -38,6 +38,7 @@ import static org.junit.Assert.assertTrue;
...
@@ -38,6 +38,7 @@ import static org.junit.Assert.assertTrue;
public
class
SecurityPropertiesTests
{
public
class
SecurityPropertiesTests
{
private
SecurityProperties
security
=
new
SecurityProperties
();
private
SecurityProperties
security
=
new
SecurityProperties
();
private
RelaxedDataBinder
binder
=
new
RelaxedDataBinder
(
this
.
security
,
"security"
);
private
RelaxedDataBinder
binder
=
new
RelaxedDataBinder
(
this
.
security
,
"security"
);
@Before
@Before
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfigurationTests.java
View file @
fad5ce45
...
@@ -149,7 +149,6 @@ public class WebMvcAutoConfigurationTests {
...
@@ -149,7 +149,6 @@ public class WebMvcAutoConfigurationTests {
equalTo
((
Resource
)
new
ClassPathResource
(
"/foo/"
)));
equalTo
((
Resource
)
new
ClassPathResource
(
"/foo/"
)));
}
}
@Test
(
expected
=
NoSuchBeanDefinitionException
.
class
)
public
void
noLocaleResolver
()
throws
Exception
{
public
void
noLocaleResolver
()
throws
Exception
{
this
.
context
=
new
AnnotationConfigEmbeddedWebApplicationContext
();
this
.
context
=
new
AnnotationConfigEmbeddedWebApplicationContext
();
this
.
context
.
register
(
AllResources
.
class
,
Config
.
class
,
this
.
context
.
register
(
AllResources
.
class
,
Config
.
class
,
...
@@ -157,6 +156,7 @@ public class WebMvcAutoConfigurationTests {
...
@@ -157,6 +156,7 @@ public class WebMvcAutoConfigurationTests {
HttpMessageConvertersAutoConfiguration
.
class
,
HttpMessageConvertersAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
);
PropertyPlaceholderAutoConfiguration
.
class
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
this
.
thrown
.
expect
(
NoSuchBeanDefinitionException
.
class
);
this
.
context
.
getBean
(
LocaleResolver
.
class
);
this
.
context
.
getBean
(
LocaleResolver
.
class
);
}
}
...
@@ -164,8 +164,7 @@ public class WebMvcAutoConfigurationTests {
...
@@ -164,8 +164,7 @@ public class WebMvcAutoConfigurationTests {
public
void
overrideLocale
()
throws
Exception
{
public
void
overrideLocale
()
throws
Exception
{
this
.
context
=
new
AnnotationConfigEmbeddedWebApplicationContext
();
this
.
context
=
new
AnnotationConfigEmbeddedWebApplicationContext
();
// set fixed locale
// set fixed locale
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.mvc.locale:en_UK"
);
"spring.mvc.locale:en_UK"
);
this
.
context
.
register
(
AllResources
.
class
,
Config
.
class
,
this
.
context
.
register
(
AllResources
.
class
,
Config
.
class
,
WebMvcAutoConfiguration
.
class
,
WebMvcAutoConfiguration
.
class
,
HttpMessageConvertersAutoConfiguration
.
class
,
HttpMessageConvertersAutoConfiguration
.
class
,
...
@@ -176,11 +175,9 @@ public class WebMvcAutoConfigurationTests {
...
@@ -176,11 +175,9 @@ public class WebMvcAutoConfigurationTests {
request
.
addPreferredLocale
(
StringUtils
.
parseLocaleString
(
"nl_NL"
));
request
.
addPreferredLocale
(
StringUtils
.
parseLocaleString
(
"nl_NL"
));
LocaleResolver
localeResolver
=
this
.
context
.
getBean
(
LocaleResolver
.
class
);
LocaleResolver
localeResolver
=
this
.
context
.
getBean
(
LocaleResolver
.
class
);
Locale
locale
=
localeResolver
.
resolveLocale
(
request
);
Locale
locale
=
localeResolver
.
resolveLocale
(
request
);
assertThat
(
localeResolver
,
assertThat
(
localeResolver
,
instanceOf
(
FixedLocaleResolver
.
class
));
instanceOf
(
FixedLocaleResolver
.
class
));
// test locale resolver uses fixed locale and not user preferred locale
// test locale resolver uses fixed locale and not user preferred locale
assertThat
(
locale
.
toString
(),
assertThat
(
locale
.
toString
(),
equalTo
(
"en_UK"
));
equalTo
(
"en_UK"
));
}
}
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
...
...
spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc
View file @
fad5ce45
...
@@ -77,7 +77,7 @@ content into your application; rather pick only the properties that you need.
...
@@ -77,7 +77,7 @@ content into your application; rather pick only the properties that you need.
spring.thymeleaf.suffix=.html
spring.thymeleaf.suffix=.html
spring.thymeleaf.mode=HTML5
spring.thymeleaf.mode=HTML5
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.content
T
ype=text/html # ;charset=<encoding> is added
spring.thymeleaf.content
-t
ype=text/html # ;charset=<encoding> is added
spring.thymeleaf.cache=true # set to false for hot refresh
spring.thymeleaf.cache=true # set to false for hot refresh
# INTERNATIONALIZATION ({sc-spring-boot-autoconfigure}/MessageSourceAutoConfiguration.{sc-ext}[MessageSourceAutoConfiguration])
# INTERNATIONALIZATION ({sc-spring-boot-autoconfigure}/MessageSourceAutoConfiguration.{sc-ext}[MessageSourceAutoConfiguration])
...
...
spring-boot-docs/src/main/asciidoc/howto.adoc
View file @
fad5ce45
...
@@ -365,7 +365,7 @@ that and be sure that it has initialized is to add a `@Bean` of type
...
@@ -365,7 +365,7 @@ that and be sure that it has initialized is to add a `@Bean` of type
out of the event when it is published.
out of the event when it is published.
A really useful thing to do in is to use `@IntegrationTest` to set `server.port=0`
A really useful thing to do in is to use `@IntegrationTest` to set `server.port=0`
and then inject the actual (
"local") port as a `@Value`. E
xample:
and then inject the actual (
``local'') port as a `@Value`. For e
xample:
[source,java,indent=0,subs="verbatim,quotes,attributes"]
[source,java,indent=0,subs="verbatim,quotes,attributes"]
----
----
...
@@ -377,8 +377,8 @@ and then inject the actual ("local") port as a `@Value`. Example:
...
@@ -377,8 +377,8 @@ and then inject the actual ("local") port as a `@Value`. Example:
@Autowired
@Autowired
EmbeddedWebApplicationContext server;
EmbeddedWebApplicationContext server;
@Value("${local.server.port}")
@Value("${local.server.port}")
int port;
int port;
// ...
// ...
...
@@ -386,6 +386,8 @@ and then inject the actual ("local") port as a `@Value`. Example:
...
@@ -386,6 +386,8 @@ and then inject the actual ("local") port as a `@Value`. Example:
}
}
----
----
[[howto-configure-tomcat]]
[[howto-configure-tomcat]]
=== Configure Tomcat
=== Configure Tomcat
Generally you can follow the advice from
Generally you can follow the advice from
...
@@ -630,6 +632,8 @@ then `http://localhost:8080/thing` will serve a JSON representation of it by def
...
@@ -630,6 +632,8 @@ then `http://localhost:8080/thing` will serve a JSON representation of it by def
Sometimes in a browser you might see XML responses (but by default only if `MyThing` was
Sometimes in a browser you might see XML responses (but by default only if `MyThing` was
a JAXB object) because browsers tend to send accept headers that prefer XML.
a JAXB object) because browsers tend to send accept headers that prefer XML.
[[howto-write-an-xml-rest-service]]
[[howto-write-an-xml-rest-service]]
=== Write an XML REST service
=== Write an XML REST service
Since JAXB is in the JDK the same example as we used for JSON would work, as long as the
Since JAXB is in the JDK the same example as we used for JSON would work, as long as the
...
@@ -637,15 +641,16 @@ Since JAXB is in the JDK the same example as we used for JSON would work, as lon
...
@@ -637,15 +641,16 @@ Since JAXB is in the JDK the same example as we used for JSON would work, as lon
[source,java,indent=0,subs="verbatim,quotes,attributes"]
[source,java,indent=0,subs="verbatim,quotes,attributes"]
----
----
@XmlRootElement
@XmlRootElement
public class MyThing {
public class MyThing {
private String name;
private String name;
// .. getters and setters
// .. getters and setters
}
}
----
----
To get the server to render XML instead of JSON you might have to send
To get the server to render XML instead of JSON you might have to send an
an `Accept: text/xml` header (or use a browser).
`Accept: text/xml` header (or use a browser).
[[howto-customize-the-jackson-objectmapper]]
[[howto-customize-the-jackson-objectmapper]]
...
@@ -1009,7 +1014,7 @@ not something you want to be on the classpath in production. It is a Hibernate f
...
@@ -1009,7 +1014,7 @@ not something you want to be on the classpath in production. It is a Hibernate f
Spring JDBC has a `DataSource` initializer feature. Spring Boot enables it by default and
Spring JDBC has a `DataSource` initializer feature. Spring Boot enables it by default and
loads SQL from the standard locations `schema.sql` and `data.sql` (in the root of the
loads SQL from the standard locations `schema.sql` and `data.sql` (in the root of the
classpath). In addition Spring Boot will load a file `schema-${platform}.sql` where
classpath). In addition Spring Boot will load a file `schema-${platform}.sql` where
`platform` is the value of `spring.datasource.platform`, e.g. you might choose to set
`platform` is the value of `spring.datasource.platform`, e.g. you might choose to set
it to the vendor name of the database (`hsqldb`, `h2`, `oracle`, `mysql`,
it to the vendor name of the database (`hsqldb`, `h2`, `oracle`, `mysql`,
`postgresql` etc.). Spring Boot enables the failfast feature of the Spring JDBC
`postgresql` etc.). Spring Boot enables the failfast feature of the Spring JDBC
initializer by default, so if the scripts cause exceptions the application will fail
initializer by default, so if the scripts cause exceptions the application will fail
...
...
spring-boot-docs/src/main/asciidoc/production-ready-features.adoc
View file @
fad5ce45
...
@@ -740,18 +740,15 @@ if needed.
...
@@ -740,18 +740,15 @@ if needed.
[[
production
-
ready
-
error
-
handling
]]
[[
production
-
ready
-
error
-
handling
]]
==
Error
Handling
==
Error
Handling
Spring
Boot
Actuator
provides
an
`/
error
`
mapping
by
default
that
handles
all
errors
in
a
sensible
way
,
and
it
is
registered
as
a
``
global
''
error
page
in
the
servlet
container
.
For
machine
clients
it
will
produce
a
JSON
response
with
details
of
the
error
,
the
HTTP
status
and
the
exception
message
.
For
browser
clients
there
is
a
``
whitelabel
''
error
view
that
renders
the
same
data
in
HTML
format
(
to
customize
it
just
add
a
`
View
`
that
resolves
to
``
error
''
).
Spring
Boot
Actuator
provides
an
`/
error
`
mapping
by
default
that
If
you
want
more
specific
error
pages
for
some
conditions
,
the
embedded
servlet
containers
handles
all
errors
in
a
sensible
way
,
and
it
is
registered
as
a
support
a
uniform
Java
DSL
for
customizing
the
error
handling
.
For
example
:
"global"
error
page
in
the
servlet
container
.
For
machine
clients
it
will
produce
a
JSON
response
with
details
of
the
error
,
the
HTTP
status
and
the
exception
message
.
For
browser
clients
there
is
a
"whitelabel"
error
view
that
renders
the
same
data
in
HTML
format
(
to
customize
it
just
add
a
`
View
`
that
resolves
to
``
error
''
).
If
you
want
more
specific
error
pages
for
some
conditions
,
the
embedded
servlet
containers
support
a
uniform
Java
DSL
for
customizing
the
error
handling
.
For
example
:
[
source
,
java
,
indent
=
0
,
subs
=
"verbatim,quotes,attributes"
]
[
source
,
java
,
indent
=
0
,
subs
=
"verbatim,quotes,attributes"
]
----
----
...
@@ -772,11 +769,11 @@ uniform Java DSL for customizing the error handling. For example:
...
@@ -772,11 +769,11 @@ uniform Java DSL for customizing the error handling. For example:
}
}
----
----
You
can
also
use
regular
Spring
MVC
features
like
http
://
docs
.
spring
.
io
/
spring
/
docs
/
current
/
spring
-
framework
-
reference
/
htmlsingle
/#
mvc
-
exception
-
handlers
[`@
ExceptionHandler
`
You
can
also
use
regular
Spring
MVC
features
like
http
://
docs
.
spring
.
io
/
spring
/
docs
/
current
/
spring
-
framework
-
reference
/
htmlsingle
/#
mvc
-
exception
-
handlers
[`@
ExceptionHandler
`
methods
]
and
http
://
docs
.
spring
.
io
/
spring
/
docs
/
current
/
spring
-
framework
-
reference
/
htmlsingle
/#
mvc
-
ann
-
controller
-
advice
[`@
ControllerAdvice
`].
methods
]
and
http
://
docs
.
spring
.
io
/
spring
/
docs
/
current
/
spring
-
framework
-
reference
/
htmlsingle
/#
mvc
-
ann
-
controller
-
advice
[`@
ControllerAdvice
`].
[[
production
-
ready
-
process
-
monitoring
]]
[[
production
-
ready
-
process
-
monitoring
]]
==
Process
monitoring
==
Process
monitoring
In
Spring
Boot
Actuator
you
can
find
`
ApplicationPidListener
`
which
creates
file
In
Spring
Boot
Actuator
you
can
find
`
ApplicationPidListener
`
which
creates
file
...
@@ -789,10 +786,11 @@ ways described below.
...
@@ -789,10 +786,11 @@ ways described below.
[[production-ready-process-monitoring-configuration]]
[[production-ready-process-monitoring-configuration]]
=== Extend configuration
=== Extend configuration
In `META-INF/spring.factories` file you have to activate the listener:
In `META-INF/spring.factories` file you have to activate the listener:
[indent=0]
[indent=0]
----
----
org.springframework.context.ApplicationListener=\
org.springframework.context.ApplicationListener=\
org.springframework.boot.actuate.system.ApplicationPidListener
org.springframework.boot.actuate.system.ApplicationPidListener
----
----
...
...
spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
View file @
fad5ce45
...
@@ -231,24 +231,23 @@ default `name`. When running in production, an `application.properties` can be p
...
@@ -231,24 +231,23 @@ default `name`. When running in production, an `application.properties` can be p
outside of your jar that overrides `name`; and for one-off testing, you can launch with
outside of your jar that overrides `name`; and for one-off testing, you can launch with
a specific command line switch (e.g. `java -jar app.jar --name="Spring"`).
a specific command line switch (e.g. `java -jar app.jar --name="Spring"`).
The `RandomValuePropertySource` is useful for injecting random values
The `RandomValuePropertySource` is useful for injecting random values (e.g. into secrets
(e.g. into secrets or test cases). It can produce integers, longs or
or test cases). It can produce integers, longs or strings, e.g.
strings, e.g.
[source,properties,indent=0]
[source,properties,indent=0]
----
----
my.secret=${random.value}
my.secret=${random.value}
my.number=${random.int}
my.number=${random.int}
my.bignumber=${random.long}
my.bignumber=${random.long}
my.number.less.than.ten=${random.int(10)}
my.number.less.than.ten=${random.int(10)}
my.number.in.range=${random.int[1024,65536]}
my.number.in.range=${random.int[1024,65536]}
----
----
The `random.int*` syntax is `OPEN value (,max) CLOSE` where the
The `random.int*` syntax is `OPEN value (,max) CLOSE` where the `OPEN,CLOSE` are any
`OPEN,CLOSE` are any character and `value,max` are integers. If
character and `value,max` are integers. If `max` is provided then `value` is the minimum
`max` is provided then `value` is the minimum value and `max` is the
value and `max` is the maximum (exclusive).
maximum (exclusive).
[[boot-features-external-config-command-line-args]]
[[boot-features-external-config-command-line-args]]
=== Accessing command line properties
=== Accessing command line properties
...
@@ -372,15 +371,15 @@ Would be transformed into these properties:
...
@@ -372,15 +371,15 @@ Would be transformed into these properties:
environments.prod.name=My Cool App
environments.prod.name=My Cool App
----
----
YAML lists are represented as property keys with `[index]` dereferencers,
YAML lists are represented as property keys with `[index]` dereferencers,
for example this YAML:
for example this YAML:
[source,yaml,indent=0]
[source,yaml,indent=0]
----
----
my:
my:
servers:
servers:
- dev.bar.com
- dev.bar.com
- foo.bar.com
- foo.bar.com
----
----
Would be transformed into these properties:
Would be transformed into these properties:
...
@@ -391,22 +390,25 @@ Would be transformed into these properties:
...
@@ -391,22 +390,25 @@ Would be transformed into these properties:
my.servers[1]=foo.bar.com
my.servers[1]=foo.bar.com
----
----
To bind to properties like that using the Spring `DataBinder`
To bind to properties like that using the Spring `DataBinder` utilities (which is what
utilities (which is what `@ConfigurationProperties` does) you need to
`@ConfigurationProperties` does) you need to have a property in the target bean of type
have a property in the target bean of type `java.util.List` (or `Set`)
`java.util.List` (or `Set`) and you either need to provide a setter, or initialize it
and you either need to provide a setter, or initialize it with a
with a mutable value, e.g. this will bind to the properties above
mutable value, e.g. this will bind to the properties above
[source,java,indent=0]
[source,java,indent=0]
----
----
@ConfigurationProperties(prefix="my")
@ConfigurationProperties(prefix="my")
public class Config {
public class Config {
private List<String> servers = new ArrayList<String>();
private List<String> servers = new ArrayList<String>();
public List<String> getServers() { return this.servers; }
}
public List<String> getServers() {
return this.servers;
}
}
----
----
[[boot-features-external-config-exposing-yaml-to-spring]]
[[boot-features-external-config-exposing-yaml-to-spring]]
==== Exposing YAML as properties in the Spring Environment
==== Exposing YAML as properties in the Spring Environment
The `YamlPropertySourceLoader` class can be used to expose YAML as a `PropertySource`
The `YamlPropertySourceLoader` class can be used to expose YAML as a `PropertySource`
...
@@ -1570,9 +1572,10 @@ interaction. For Example:
...
@@ -1570,9 +1572,10 @@ interaction. For Example:
}
}
----
----
To change the port you can add environment properties to
To change the port you can add environment properties to `@IntegrationTest` as colon- or
`@IntegrationTest` as colon- or equals-separated name-value pairs,
equals-separated name-value pairs, e.g. `@IntegrationTest("server.port:9000")`.
e.g. `@IntegrationTest("server.port:9000")`.
[[boot-features-test-utilities]]
[[boot-features-test-utilities]]
=== Test utilities
=== Test utilities
...
...
spring-boot-samples/spring-boot-sample-actuator-ui/src/test/java/sample/actuator/ui/SampleActuatorUiApplicationPortTests.java
View file @
fad5ce45
...
@@ -16,8 +16,6 @@
...
@@ -16,8 +16,6 @@
package
sample
.
actuator
.
ui
;
package
sample
.
actuator
.
ui
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
java.util.Map
;
import
java.util.Map
;
import
org.junit.Test
;
import
org.junit.Test
;
...
@@ -34,6 +32,8 @@ import org.springframework.test.annotation.DirtiesContext;
...
@@ -34,6 +32,8 @@ import org.springframework.test.annotation.DirtiesContext;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
/**
/**
* Integration tests for separate management and main service ports.
* Integration tests for separate management and main service ports.
*
*
...
@@ -42,7 +42,7 @@ import org.springframework.test.context.web.WebAppConfiguration;
...
@@ -42,7 +42,7 @@ import org.springframework.test.context.web.WebAppConfiguration;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringApplicationConfiguration
(
classes
=
SampleActuatorUiApplication
.
class
)
@SpringApplicationConfiguration
(
classes
=
SampleActuatorUiApplication
.
class
)
@WebAppConfiguration
@WebAppConfiguration
@IntegrationTest
({
"server.port=0"
,
"management.port:0"
})
@IntegrationTest
({
"server.port=0"
,
"management.port:0"
})
@DirtiesContext
@DirtiesContext
public
class
SampleActuatorUiApplicationPortTests
{
public
class
SampleActuatorUiApplicationPortTests
{
...
...
spring-boot-samples/spring-boot-sample-actuator-ui/src/test/java/sample/actuator/ui/SampleActuatorUiApplicationTests.java
View file @
fad5ce45
...
@@ -23,8 +23,8 @@ import org.junit.Test;
...
@@ -23,8 +23,8 @@ import org.junit.Test;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.TestRestTemplate
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.TestRestTemplate
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpMethod
;
import
org.springframework.http.HttpMethod
;
...
@@ -58,8 +58,8 @@ public class SampleActuatorUiApplicationTests {
...
@@ -58,8 +58,8 @@ public class SampleActuatorUiApplicationTests {
HttpHeaders
headers
=
new
HttpHeaders
();
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setAccept
(
Arrays
.
asList
(
MediaType
.
TEXT_HTML
));
headers
.
setAccept
(
Arrays
.
asList
(
MediaType
.
TEXT_HTML
));
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
exchange
(
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
exchange
(
"http://localhost:"
+
port
,
HttpMethod
.
GET
,
new
HttpEntity
<
Void
>(
headers
),
"http://localhost:"
+
this
.
port
,
HttpMethod
.
GET
,
new
HttpEntity
<
Void
>(
String
.
class
);
headers
),
String
.
class
);
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertTrue
(
"Wrong body (title doesn't match):\n"
+
entity
.
getBody
(),
entity
assertTrue
(
"Wrong body (title doesn't match):\n"
+
entity
.
getBody
(),
entity
.
getBody
().
contains
(
"<title>Hello"
));
.
getBody
().
contains
(
"<title>Hello"
));
...
@@ -68,7 +68,7 @@ public class SampleActuatorUiApplicationTests {
...
@@ -68,7 +68,7 @@ public class SampleActuatorUiApplicationTests {
@Test
@Test
public
void
testCss
()
throws
Exception
{
public
void
testCss
()
throws
Exception
{
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
getForEntity
(
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
getForEntity
(
"http://localhost:"
+
port
+
"/css/bootstrap.min.css"
,
String
.
class
);
"http://localhost:"
+
this
.
port
+
"/css/bootstrap.min.css"
,
String
.
class
);
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertTrue
(
"Wrong body:\n"
+
entity
.
getBody
(),
entity
.
getBody
().
contains
(
"body"
));
assertTrue
(
"Wrong body:\n"
+
entity
.
getBody
(),
entity
.
getBody
().
contains
(
"body"
));
}
}
...
@@ -77,7 +77,7 @@ public class SampleActuatorUiApplicationTests {
...
@@ -77,7 +77,7 @@ public class SampleActuatorUiApplicationTests {
public
void
testMetrics
()
throws
Exception
{
public
void
testMetrics
()
throws
Exception
{
@SuppressWarnings
(
"rawtypes"
)
@SuppressWarnings
(
"rawtypes"
)
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
().
getForEntity
(
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
().
getForEntity
(
"http://localhost:"
+
port
+
"/metrics"
,
Map
.
class
);
"http://localhost:"
+
this
.
port
+
"/metrics"
,
Map
.
class
);
assertEquals
(
HttpStatus
.
UNAUTHORIZED
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
UNAUTHORIZED
,
entity
.
getStatusCode
());
}
}
...
@@ -86,8 +86,8 @@ public class SampleActuatorUiApplicationTests {
...
@@ -86,8 +86,8 @@ public class SampleActuatorUiApplicationTests {
HttpHeaders
headers
=
new
HttpHeaders
();
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setAccept
(
Arrays
.
asList
(
MediaType
.
TEXT_HTML
));
headers
.
setAccept
(
Arrays
.
asList
(
MediaType
.
TEXT_HTML
));
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
exchange
(
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
exchange
(
"http://localhost:"
+
port
+
"/error"
,
HttpMethod
.
GET
,
new
HttpEntity
<
Void
>(
"http://localhost:"
+
this
.
port
+
"/error"
,
HttpMethod
.
GET
,
headers
),
String
.
class
);
new
HttpEntity
<
Void
>(
headers
),
String
.
class
);
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertTrue
(
"Wrong body:\n"
+
entity
.
getBody
(),
entity
.
getBody
()
assertTrue
(
"Wrong body:\n"
+
entity
.
getBody
(),
entity
.
getBody
()
.
contains
(
"<html>"
));
.
contains
(
"<html>"
));
...
...
spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/EndpointsPropertiesSampleActuatorApplicationTests.java
View file @
fad5ce45
...
@@ -53,7 +53,7 @@ public class EndpointsPropertiesSampleActuatorApplicationTests {
...
@@ -53,7 +53,7 @@ public class EndpointsPropertiesSampleActuatorApplicationTests {
public
void
testCustomErrorPath
()
throws
Exception
{
public
void
testCustomErrorPath
()
throws
Exception
{
@SuppressWarnings
(
"rawtypes"
)
@SuppressWarnings
(
"rawtypes"
)
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
(
"user"
,
"password"
)
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
(
"user"
,
"password"
)
.
getForEntity
(
"http://localhost:"
+
port
+
"/oops"
,
Map
.
class
);
.
getForEntity
(
"http://localhost:"
+
this
.
port
+
"/oops"
,
Map
.
class
);
assertEquals
(
HttpStatus
.
INTERNAL_SERVER_ERROR
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
INTERNAL_SERVER_ERROR
,
entity
.
getStatusCode
());
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
Map
<
String
,
Object
>
body
=
entity
.
getBody
();
Map
<
String
,
Object
>
body
=
entity
.
getBody
();
...
@@ -64,7 +64,7 @@ public class EndpointsPropertiesSampleActuatorApplicationTests {
...
@@ -64,7 +64,7 @@ public class EndpointsPropertiesSampleActuatorApplicationTests {
@Test
@Test
public
void
testCustomContextPath
()
throws
Exception
{
public
void
testCustomContextPath
()
throws
Exception
{
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
getForEntity
(
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
getForEntity
(
"http://localhost:"
+
port
+
"/admin/health"
,
String
.
class
);
"http://localhost:"
+
this
.
port
+
"/admin/health"
,
String
.
class
);
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
String
body
=
entity
.
getBody
();
String
body
=
entity
.
getBody
();
assertEquals
(
"ok"
,
body
);
assertEquals
(
"ok"
,
body
);
...
...
spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ManagementAddressActuatorApplicationTests.java
View file @
fad5ce45
...
@@ -16,8 +16,6 @@
...
@@ -16,8 +16,6 @@
package
sample
.
actuator
;
package
sample
.
actuator
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
java.util.Map
;
import
java.util.Map
;
import
org.junit.Test
;
import
org.junit.Test
;
...
@@ -34,6 +32,8 @@ import org.springframework.test.annotation.DirtiesContext;
...
@@ -34,6 +32,8 @@ import org.springframework.test.annotation.DirtiesContext;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
/**
/**
* Integration tests for separate management and main service ports.
* Integration tests for separate management and main service ports.
*
*
...
@@ -42,7 +42,8 @@ import org.springframework.test.context.web.WebAppConfiguration;
...
@@ -42,7 +42,8 @@ import org.springframework.test.context.web.WebAppConfiguration;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringApplicationConfiguration
(
classes
=
SampleActuatorApplication
.
class
)
@SpringApplicationConfiguration
(
classes
=
SampleActuatorApplication
.
class
)
@WebAppConfiguration
@WebAppConfiguration
@IntegrationTest
({
"server.port=0"
,
"management.port=0"
,
"management.address=127.0.0.1"
,
"management.contextPath:/admin"
})
@IntegrationTest
({
"server.port=0"
,
"management.port=0"
,
"management.address=127.0.0.1"
,
"management.contextPath:/admin"
})
@DirtiesContext
@DirtiesContext
public
class
ManagementAddressActuatorApplicationTests
{
public
class
ManagementAddressActuatorApplicationTests
{
...
...
spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ManagementPortSampleActuatorApplicationTests.java
View file @
fad5ce45
...
@@ -16,8 +16,6 @@
...
@@ -16,8 +16,6 @@
package
sample
.
actuator
;
package
sample
.
actuator
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
java.util.Map
;
import
java.util.Map
;
import
org.junit.Test
;
import
org.junit.Test
;
...
@@ -34,6 +32,8 @@ import org.springframework.test.annotation.DirtiesContext;
...
@@ -34,6 +32,8 @@ import org.springframework.test.annotation.DirtiesContext;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
/**
/**
* Integration tests for separate management and main service ports.
* Integration tests for separate management and main service ports.
*
*
...
@@ -42,7 +42,7 @@ import org.springframework.test.context.web.WebAppConfiguration;
...
@@ -42,7 +42,7 @@ import org.springframework.test.context.web.WebAppConfiguration;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringApplicationConfiguration
(
classes
=
SampleActuatorApplication
.
class
)
@SpringApplicationConfiguration
(
classes
=
SampleActuatorApplication
.
class
)
@WebAppConfiguration
@WebAppConfiguration
@IntegrationTest
({
"server.port=0"
,
"management.port=0"
})
@IntegrationTest
({
"server.port=0"
,
"management.port=0"
})
@DirtiesContext
@DirtiesContext
public
class
ManagementPortSampleActuatorApplicationTests
{
public
class
ManagementPortSampleActuatorApplicationTests
{
...
...
spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/NoManagementSampleActuatorApplicationTests.java
View file @
fad5ce45
...
@@ -16,8 +16,6 @@
...
@@ -16,8 +16,6 @@
package
sample
.
actuator
;
package
sample
.
actuator
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
java.util.Map
;
import
java.util.Map
;
import
org.junit.Test
;
import
org.junit.Test
;
...
@@ -34,6 +32,8 @@ import org.springframework.test.annotation.DirtiesContext;
...
@@ -34,6 +32,8 @@ import org.springframework.test.annotation.DirtiesContext;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
/**
/**
* Integration tests for switching off management endpoints.
* Integration tests for switching off management endpoints.
*
*
...
@@ -42,13 +42,13 @@ import org.springframework.test.context.web.WebAppConfiguration;
...
@@ -42,13 +42,13 @@ import org.springframework.test.context.web.WebAppConfiguration;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringApplicationConfiguration
(
classes
=
SampleActuatorApplication
.
class
)
@SpringApplicationConfiguration
(
classes
=
SampleActuatorApplication
.
class
)
@WebAppConfiguration
@WebAppConfiguration
@IntegrationTest
({
"server.port=0"
,
"management.port=-1"
})
@IntegrationTest
({
"server.port=0"
,
"management.port=-1"
})
@DirtiesContext
@DirtiesContext
public
class
NoManagementSampleActuatorApplicationTests
{
public
class
NoManagementSampleActuatorApplicationTests
{
@Autowired
@Autowired
private
SecurityProperties
security
;
private
SecurityProperties
security
;
@Value
(
"${local.server.port}"
)
@Value
(
"${local.server.port}"
)
private
int
port
=
0
;
private
int
port
=
0
;
...
@@ -56,7 +56,7 @@ public class NoManagementSampleActuatorApplicationTests {
...
@@ -56,7 +56,7 @@ public class NoManagementSampleActuatorApplicationTests {
public
void
testHome
()
throws
Exception
{
public
void
testHome
()
throws
Exception
{
@SuppressWarnings
(
"rawtypes"
)
@SuppressWarnings
(
"rawtypes"
)
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
(
"user"
,
getPassword
())
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
(
"user"
,
getPassword
())
.
getForEntity
(
"http://localhost:"
+
port
,
Map
.
class
);
.
getForEntity
(
"http://localhost:"
+
this
.
port
,
Map
.
class
);
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
Map
<
String
,
Object
>
body
=
entity
.
getBody
();
Map
<
String
,
Object
>
body
=
entity
.
getBody
();
...
@@ -68,7 +68,7 @@ public class NoManagementSampleActuatorApplicationTests {
...
@@ -68,7 +68,7 @@ public class NoManagementSampleActuatorApplicationTests {
testHome
();
// makes sure some requests have been made
testHome
();
// makes sure some requests have been made
@SuppressWarnings
(
"rawtypes"
)
@SuppressWarnings
(
"rawtypes"
)
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
(
"user"
,
getPassword
())
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
(
"user"
,
getPassword
())
.
getForEntity
(
"http://localhost:"
+
port
+
"/metrics"
,
Map
.
class
);
.
getForEntity
(
"http://localhost:"
+
this
.
port
+
"/metrics"
,
Map
.
class
);
assertEquals
(
HttpStatus
.
NOT_FOUND
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
NOT_FOUND
,
entity
.
getStatusCode
());
}
}
...
...
spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/SampleActuatorApplicationTests.java
View file @
fad5ce45
...
@@ -65,7 +65,7 @@ public class SampleActuatorApplicationTests {
...
@@ -65,7 +65,7 @@ public class SampleActuatorApplicationTests {
public
void
testHomeIsSecure
()
throws
Exception
{
public
void
testHomeIsSecure
()
throws
Exception
{
@SuppressWarnings
(
"rawtypes"
)
@SuppressWarnings
(
"rawtypes"
)
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
().
getForEntity
(
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
().
getForEntity
(
"http://localhost:"
+
port
,
Map
.
class
);
"http://localhost:"
+
this
.
port
,
Map
.
class
);
assertEquals
(
HttpStatus
.
UNAUTHORIZED
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
UNAUTHORIZED
,
entity
.
getStatusCode
());
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
Map
<
String
,
Object
>
body
=
entity
.
getBody
();
Map
<
String
,
Object
>
body
=
entity
.
getBody
();
...
@@ -78,16 +78,16 @@ public class SampleActuatorApplicationTests {
...
@@ -78,16 +78,16 @@ public class SampleActuatorApplicationTests {
public
void
testMetricsIsSecure
()
throws
Exception
{
public
void
testMetricsIsSecure
()
throws
Exception
{
@SuppressWarnings
(
"rawtypes"
)
@SuppressWarnings
(
"rawtypes"
)
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
().
getForEntity
(
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
().
getForEntity
(
"http://localhost:"
+
port
+
"/metrics"
,
Map
.
class
);
"http://localhost:"
+
this
.
port
+
"/metrics"
,
Map
.
class
);
assertEquals
(
HttpStatus
.
UNAUTHORIZED
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
UNAUTHORIZED
,
entity
.
getStatusCode
());
entity
=
new
TestRestTemplate
().
getForEntity
(
"http://localhost:"
+
port
+
"/metrics/"
,
entity
=
new
TestRestTemplate
().
getForEntity
(
"http://localhost:"
+
this
.
port
Map
.
class
);
+
"/metrics/"
,
Map
.
class
);
assertEquals
(
HttpStatus
.
UNAUTHORIZED
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
UNAUTHORIZED
,
entity
.
getStatusCode
());
entity
=
new
TestRestTemplate
().
getForEntity
(
"http://localhost:"
+
port
+
"/metrics/foo"
,
entity
=
new
TestRestTemplate
().
getForEntity
(
"http://localhost:"
+
this
.
port
Map
.
class
);
+
"/metrics/foo"
,
Map
.
class
);
assertEquals
(
HttpStatus
.
UNAUTHORIZED
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
UNAUTHORIZED
,
entity
.
getStatusCode
());
entity
=
new
TestRestTemplate
().
getForEntity
(
entity
=
new
TestRestTemplate
().
getForEntity
(
"http://localhost:"
+
this
.
port
"http://localhost:"
+
port
+
"/metrics.json"
,
Map
.
class
);
+
"/metrics.json"
,
Map
.
class
);
assertEquals
(
HttpStatus
.
UNAUTHORIZED
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
UNAUTHORIZED
,
entity
.
getStatusCode
());
}
}
...
@@ -95,7 +95,7 @@ public class SampleActuatorApplicationTests {
...
@@ -95,7 +95,7 @@ public class SampleActuatorApplicationTests {
public
void
testHome
()
throws
Exception
{
public
void
testHome
()
throws
Exception
{
@SuppressWarnings
(
"rawtypes"
)
@SuppressWarnings
(
"rawtypes"
)
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
(
"user"
,
getPassword
())
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
(
"user"
,
getPassword
())
.
getForEntity
(
"http://localhost:"
+
port
,
Map
.
class
);
.
getForEntity
(
"http://localhost:"
+
this
.
port
,
Map
.
class
);
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
Map
<
String
,
Object
>
body
=
entity
.
getBody
();
Map
<
String
,
Object
>
body
=
entity
.
getBody
();
...
@@ -107,7 +107,7 @@ public class SampleActuatorApplicationTests {
...
@@ -107,7 +107,7 @@ public class SampleActuatorApplicationTests {
testHome
();
// makes sure some requests have been made
testHome
();
// makes sure some requests have been made
@SuppressWarnings
(
"rawtypes"
)
@SuppressWarnings
(
"rawtypes"
)
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
(
"user"
,
getPassword
())
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
(
"user"
,
getPassword
())
.
getForEntity
(
"http://localhost:"
+
port
+
"/metrics"
,
Map
.
class
);
.
getForEntity
(
"http://localhost:"
+
this
.
port
+
"/metrics"
,
Map
.
class
);
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
Map
<
String
,
Object
>
body
=
entity
.
getBody
();
Map
<
String
,
Object
>
body
=
entity
.
getBody
();
...
@@ -118,7 +118,7 @@ public class SampleActuatorApplicationTests {
...
@@ -118,7 +118,7 @@ public class SampleActuatorApplicationTests {
public
void
testEnv
()
throws
Exception
{
public
void
testEnv
()
throws
Exception
{
@SuppressWarnings
(
"rawtypes"
)
@SuppressWarnings
(
"rawtypes"
)
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
(
"user"
,
getPassword
())
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
(
"user"
,
getPassword
())
.
getForEntity
(
"http://localhost:"
+
port
+
"/env"
,
Map
.
class
);
.
getForEntity
(
"http://localhost:"
+
this
.
port
+
"/env"
,
Map
.
class
);
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
Map
<
String
,
Object
>
body
=
entity
.
getBody
();
Map
<
String
,
Object
>
body
=
entity
.
getBody
();
...
@@ -128,7 +128,7 @@ public class SampleActuatorApplicationTests {
...
@@ -128,7 +128,7 @@ public class SampleActuatorApplicationTests {
@Test
@Test
public
void
testHealth
()
throws
Exception
{
public
void
testHealth
()
throws
Exception
{
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
getForEntity
(
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
getForEntity
(
"http://localhost:"
+
port
+
"/health"
,
String
.
class
);
"http://localhost:"
+
this
.
port
+
"/health"
,
String
.
class
);
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertEquals
(
"ok"
,
entity
.
getBody
());
assertEquals
(
"ok"
,
entity
.
getBody
());
}
}
...
@@ -136,7 +136,7 @@ public class SampleActuatorApplicationTests {
...
@@ -136,7 +136,7 @@ public class SampleActuatorApplicationTests {
@Test
@Test
public
void
testErrorPage
()
throws
Exception
{
public
void
testErrorPage
()
throws
Exception
{
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
(
"user"
,
getPassword
())
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
(
"user"
,
getPassword
())
.
getForEntity
(
"http://localhost:"
+
port
+
"/foo"
,
String
.
class
);
.
getForEntity
(
"http://localhost:"
+
this
.
port
+
"/foo"
,
String
.
class
);
assertEquals
(
HttpStatus
.
INTERNAL_SERVER_ERROR
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
INTERNAL_SERVER_ERROR
,
entity
.
getStatusCode
());
String
body
=
entity
.
getBody
();
String
body
=
entity
.
getBody
();
assertNotNull
(
body
);
assertNotNull
(
body
);
...
@@ -149,8 +149,8 @@ public class SampleActuatorApplicationTests {
...
@@ -149,8 +149,8 @@ public class SampleActuatorApplicationTests {
headers
.
setAccept
(
Arrays
.
asList
(
MediaType
.
TEXT_HTML
));
headers
.
setAccept
(
Arrays
.
asList
(
MediaType
.
TEXT_HTML
));
HttpEntity
<?>
request
=
new
HttpEntity
<
Void
>(
headers
);
HttpEntity
<?>
request
=
new
HttpEntity
<
Void
>(
headers
);
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
(
"user"
,
getPassword
())
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
(
"user"
,
getPassword
())
.
exchange
(
"http://localhost:"
+
port
+
"/foo"
,
HttpMethod
.
GET
,
request
,
.
exchange
(
"http://localhost:"
+
this
.
port
+
"/foo"
,
HttpMethod
.
GET
,
String
.
class
);
request
,
String
.
class
);
assertEquals
(
HttpStatus
.
INTERNAL_SERVER_ERROR
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
INTERNAL_SERVER_ERROR
,
entity
.
getStatusCode
());
String
body
=
entity
.
getBody
();
String
body
=
entity
.
getBody
();
assertNotNull
(
"Body was null"
,
body
);
assertNotNull
(
"Body was null"
,
body
);
...
@@ -160,10 +160,11 @@ public class SampleActuatorApplicationTests {
...
@@ -160,10 +160,11 @@ public class SampleActuatorApplicationTests {
@Test
@Test
public
void
testTrace
()
throws
Exception
{
public
void
testTrace
()
throws
Exception
{
new
TestRestTemplate
().
getForEntity
(
"http://localhost:"
+
port
+
"/health"
,
String
.
class
);
new
TestRestTemplate
().
getForEntity
(
"http://localhost:"
+
this
.
port
+
"/health"
,
String
.
class
);
@SuppressWarnings
(
"rawtypes"
)
@SuppressWarnings
(
"rawtypes"
)
ResponseEntity
<
List
>
entity
=
new
TestRestTemplate
(
"user"
,
getPassword
())
ResponseEntity
<
List
>
entity
=
new
TestRestTemplate
(
"user"
,
getPassword
())
.
getForEntity
(
"http://localhost:"
+
port
+
"/trace"
,
List
.
class
);
.
getForEntity
(
"http://localhost:"
+
this
.
port
+
"/trace"
,
List
.
class
);
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
List
<
Map
<
String
,
Object
>>
list
=
entity
.
getBody
();
List
<
Map
<
String
,
Object
>>
list
=
entity
.
getBody
();
...
@@ -178,7 +179,7 @@ public class SampleActuatorApplicationTests {
...
@@ -178,7 +179,7 @@ public class SampleActuatorApplicationTests {
public
void
testErrorPageDirectAccess
()
throws
Exception
{
public
void
testErrorPageDirectAccess
()
throws
Exception
{
@SuppressWarnings
(
"rawtypes"
)
@SuppressWarnings
(
"rawtypes"
)
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
().
getForEntity
(
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
().
getForEntity
(
"http://localhost:"
+
port
+
"/error"
,
Map
.
class
);
"http://localhost:"
+
this
.
port
+
"/error"
,
Map
.
class
);
assertEquals
(
HttpStatus
.
INTERNAL_SERVER_ERROR
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
INTERNAL_SERVER_ERROR
,
entity
.
getStatusCode
());
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
Map
<
String
,
Object
>
body
=
entity
.
getBody
();
Map
<
String
,
Object
>
body
=
entity
.
getBody
();
...
@@ -190,7 +191,7 @@ public class SampleActuatorApplicationTests {
...
@@ -190,7 +191,7 @@ public class SampleActuatorApplicationTests {
public
void
testBeans
()
throws
Exception
{
public
void
testBeans
()
throws
Exception
{
@SuppressWarnings
(
"rawtypes"
)
@SuppressWarnings
(
"rawtypes"
)
ResponseEntity
<
List
>
entity
=
new
TestRestTemplate
(
"user"
,
getPassword
())
ResponseEntity
<
List
>
entity
=
new
TestRestTemplate
(
"user"
,
getPassword
())
.
getForEntity
(
"http://localhost:"
+
port
+
"/beans"
,
List
.
class
);
.
getForEntity
(
"http://localhost:"
+
this
.
port
+
"/beans"
,
List
.
class
);
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertEquals
(
1
,
entity
.
getBody
().
size
());
assertEquals
(
1
,
entity
.
getBody
().
size
());
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
...
...
spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ShutdownSampleActuatorApplicationTests.java
View file @
fad5ce45
...
@@ -24,8 +24,8 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -24,8 +24,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.autoconfigure.security.SecurityProperties
;
import
org.springframework.boot.autoconfigure.security.SecurityProperties
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.TestRestTemplate
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.TestRestTemplate
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.test.annotation.DirtiesContext
;
import
org.springframework.test.annotation.DirtiesContext
;
...
@@ -57,7 +57,7 @@ public class ShutdownSampleActuatorApplicationTests {
...
@@ -57,7 +57,7 @@ public class ShutdownSampleActuatorApplicationTests {
public
void
testHome
()
throws
Exception
{
public
void
testHome
()
throws
Exception
{
@SuppressWarnings
(
"rawtypes"
)
@SuppressWarnings
(
"rawtypes"
)
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
(
"user"
,
getPassword
())
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
(
"user"
,
getPassword
())
.
getForEntity
(
"http://localhost:"
+
port
,
Map
.
class
);
.
getForEntity
(
"http://localhost:"
+
this
.
port
,
Map
.
class
);
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
Map
<
String
,
Object
>
body
=
entity
.
getBody
();
Map
<
String
,
Object
>
body
=
entity
.
getBody
();
...
@@ -68,7 +68,8 @@ public class ShutdownSampleActuatorApplicationTests {
...
@@ -68,7 +68,8 @@ public class ShutdownSampleActuatorApplicationTests {
public
void
testShutdown
()
throws
Exception
{
public
void
testShutdown
()
throws
Exception
{
@SuppressWarnings
(
"rawtypes"
)
@SuppressWarnings
(
"rawtypes"
)
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
(
"user"
,
getPassword
())
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
(
"user"
,
getPassword
())
.
postForEntity
(
"http://localhost:"
+
port
+
"/shutdown"
,
null
,
Map
.
class
);
.
postForEntity
(
"http://localhost:"
+
this
.
port
+
"/shutdown"
,
null
,
Map
.
class
);
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
Map
<
String
,
Object
>
body
=
entity
.
getBody
();
Map
<
String
,
Object
>
body
=
entity
.
getBody
();
...
...
spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/UnsecureManagementSampleActuatorApplicationTests.java
View file @
fad5ce45
...
@@ -22,8 +22,8 @@ import org.junit.Test;
...
@@ -22,8 +22,8 @@ import org.junit.Test;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.TestRestTemplate
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.TestRestTemplate
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.test.annotation.DirtiesContext
;
import
org.springframework.test.annotation.DirtiesContext
;
...
@@ -44,7 +44,7 @@ import static org.junit.Assert.assertTrue;
...
@@ -44,7 +44,7 @@ import static org.junit.Assert.assertTrue;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringApplicationConfiguration
(
classes
=
SampleActuatorApplication
.
class
)
@SpringApplicationConfiguration
(
classes
=
SampleActuatorApplication
.
class
)
@WebAppConfiguration
@WebAppConfiguration
@IntegrationTest
({
"server.port:0"
,
"management.security.enabled:false"
})
@IntegrationTest
({
"server.port:0"
,
"management.security.enabled:false"
})
@DirtiesContext
@DirtiesContext
@ActiveProfiles
(
"unsecure-management"
)
@ActiveProfiles
(
"unsecure-management"
)
public
class
UnsecureManagementSampleActuatorApplicationTests
{
public
class
UnsecureManagementSampleActuatorApplicationTests
{
...
@@ -56,7 +56,7 @@ public class UnsecureManagementSampleActuatorApplicationTests {
...
@@ -56,7 +56,7 @@ public class UnsecureManagementSampleActuatorApplicationTests {
public
void
testHomeIsSecure
()
throws
Exception
{
public
void
testHomeIsSecure
()
throws
Exception
{
@SuppressWarnings
(
"rawtypes"
)
@SuppressWarnings
(
"rawtypes"
)
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
().
getForEntity
(
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
().
getForEntity
(
"http://localhost:"
+
port
,
Map
.
class
);
"http://localhost:"
+
this
.
port
,
Map
.
class
);
assertEquals
(
HttpStatus
.
UNAUTHORIZED
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
UNAUTHORIZED
,
entity
.
getStatusCode
());
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
Map
<
String
,
Object
>
body
=
entity
.
getBody
();
Map
<
String
,
Object
>
body
=
entity
.
getBody
();
...
@@ -75,7 +75,7 @@ public class UnsecureManagementSampleActuatorApplicationTests {
...
@@ -75,7 +75,7 @@ public class UnsecureManagementSampleActuatorApplicationTests {
}
}
@SuppressWarnings
(
"rawtypes"
)
@SuppressWarnings
(
"rawtypes"
)
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
().
getForEntity
(
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
().
getForEntity
(
"http://localhost:"
+
port
+
"/metrics"
,
Map
.
class
);
"http://localhost:"
+
this
.
port
+
"/metrics"
,
Map
.
class
);
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
Map
<
String
,
Object
>
body
=
entity
.
getBody
();
Map
<
String
,
Object
>
body
=
entity
.
getBody
();
...
...
spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/UnsecureSampleActuatorApplicationTests.java
View file @
fad5ce45
...
@@ -16,9 +16,6 @@
...
@@ -16,9 +16,6 @@
package
sample
.
actuator
;
package
sample
.
actuator
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
java.util.Map
;
import
java.util.Map
;
import
org.junit.Test
;
import
org.junit.Test
;
...
@@ -33,6 +30,9 @@ import org.springframework.test.annotation.DirtiesContext;
...
@@ -33,6 +30,9 @@ import org.springframework.test.annotation.DirtiesContext;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
/**
/**
* Integration tests for unsecured service endpoints (even with Spring Security on
* Integration tests for unsecured service endpoints (even with Spring Security on
* classpath).
* classpath).
...
@@ -42,7 +42,7 @@ import org.springframework.test.context.web.WebAppConfiguration;
...
@@ -42,7 +42,7 @@ import org.springframework.test.context.web.WebAppConfiguration;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringApplicationConfiguration
(
classes
=
SampleActuatorApplication
.
class
)
@SpringApplicationConfiguration
(
classes
=
SampleActuatorApplication
.
class
)
@WebAppConfiguration
@WebAppConfiguration
@IntegrationTest
({
"server.port:0"
,
"security.basic.enabled:false"
})
@IntegrationTest
({
"server.port:0"
,
"security.basic.enabled:false"
})
@DirtiesContext
@DirtiesContext
public
class
UnsecureSampleActuatorApplicationTests
{
public
class
UnsecureSampleActuatorApplicationTests
{
...
@@ -53,7 +53,7 @@ public class UnsecureSampleActuatorApplicationTests {
...
@@ -53,7 +53,7 @@ public class UnsecureSampleActuatorApplicationTests {
public
void
testHome
()
throws
Exception
{
public
void
testHome
()
throws
Exception
{
@SuppressWarnings
(
"rawtypes"
)
@SuppressWarnings
(
"rawtypes"
)
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
().
getForEntity
(
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
().
getForEntity
(
"http://localhost:"
+
port
,
Map
.
class
);
"http://localhost:"
+
this
.
port
,
Map
.
class
);
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
Map
<
String
,
Object
>
body
=
entity
.
getBody
();
Map
<
String
,
Object
>
body
=
entity
.
getBody
();
...
...
spring-boot-samples/spring-boot-sample-jetty/src/test/java/sample/jetty/SampleJettyApplicationTests.java
View file @
fad5ce45
...
@@ -20,8 +20,8 @@ import org.junit.Test;
...
@@ -20,8 +20,8 @@ import org.junit.Test;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.TestRestTemplate
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.TestRestTemplate
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.test.annotation.DirtiesContext
;
import
org.springframework.test.annotation.DirtiesContext
;
...
@@ -48,7 +48,7 @@ public class SampleJettyApplicationTests {
...
@@ -48,7 +48,7 @@ public class SampleJettyApplicationTests {
@Test
@Test
public
void
testHome
()
throws
Exception
{
public
void
testHome
()
throws
Exception
{
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
getForEntity
(
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
getForEntity
(
"http://localhost:"
+
port
,
String
.
class
);
"http://localhost:"
+
this
.
port
,
String
.
class
);
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertEquals
(
"Hello World"
,
entity
.
getBody
());
assertEquals
(
"Hello World"
,
entity
.
getBody
());
}
}
...
...
spring-boot-samples/spring-boot-sample-servlet/src/test/java/sample/servlet/SampleServletApplicationTests.java
View file @
fad5ce45
...
@@ -16,8 +16,6 @@
...
@@ -16,8 +16,6 @@
package
sample
.
servlet
;
package
sample
.
servlet
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -32,6 +30,8 @@ import org.springframework.test.annotation.DirtiesContext;
...
@@ -32,6 +30,8 @@ import org.springframework.test.annotation.DirtiesContext;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
/**
/**
* Basic integration tests for demo application.
* Basic integration tests for demo application.
*
*
...
@@ -53,14 +53,14 @@ public class SampleServletApplicationTests {
...
@@ -53,14 +53,14 @@ public class SampleServletApplicationTests {
@Test
@Test
public
void
testHomeIsSecure
()
throws
Exception
{
public
void
testHomeIsSecure
()
throws
Exception
{
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
getForEntity
(
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
getForEntity
(
"http://localhost:"
+
port
,
String
.
class
);
"http://localhost:"
+
this
.
port
,
String
.
class
);
assertEquals
(
HttpStatus
.
UNAUTHORIZED
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
UNAUTHORIZED
,
entity
.
getStatusCode
());
}
}
@Test
@Test
public
void
testHome
()
throws
Exception
{
public
void
testHome
()
throws
Exception
{
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
(
"user"
,
getPassword
())
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
(
"user"
,
getPassword
())
.
getForEntity
(
"http://localhost:"
+
port
,
String
.
class
);
.
getForEntity
(
"http://localhost:"
+
this
.
port
,
String
.
class
);
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertEquals
(
"Hello World"
,
entity
.
getBody
());
assertEquals
(
"Hello World"
,
entity
.
getBody
());
}
}
...
...
spring-boot-samples/spring-boot-sample-tomcat/src/test/java/sample/tomcat/NonAutoConfigurationSampleTomcatApplicationTests.java
View file @
fad5ce45
...
@@ -27,8 +27,8 @@ import org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfi
...
@@ -27,8 +27,8 @@ import org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfi
import
org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.TestRestTemplate
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.TestRestTemplate
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Import
;
import
org.springframework.context.annotation.Import
;
...
@@ -41,6 +41,7 @@ import org.springframework.test.context.web.WebAppConfiguration;
...
@@ -41,6 +41,7 @@ import org.springframework.test.context.web.WebAppConfiguration;
import
sample.tomcat.NonAutoConfigurationSampleTomcatApplicationTests.NonAutoConfigurationSampleTomcatApplication
;
import
sample.tomcat.NonAutoConfigurationSampleTomcatApplicationTests.NonAutoConfigurationSampleTomcatApplication
;
import
sample.tomcat.service.HelloWorldService
;
import
sample.tomcat.service.HelloWorldService
;
import
sample.tomcat.web.SampleController
;
import
sample.tomcat.web.SampleController
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
/**
/**
...
@@ -76,7 +77,7 @@ public class NonAutoConfigurationSampleTomcatApplicationTests {
...
@@ -76,7 +77,7 @@ public class NonAutoConfigurationSampleTomcatApplicationTests {
@Test
@Test
public
void
testHome
()
throws
Exception
{
public
void
testHome
()
throws
Exception
{
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
getForEntity
(
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
getForEntity
(
"http://localhost:"
+
port
,
String
.
class
);
"http://localhost:"
+
this
.
port
,
String
.
class
);
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertEquals
(
"Hello World"
,
entity
.
getBody
());
assertEquals
(
"Hello World"
,
entity
.
getBody
());
}
}
...
...
spring-boot-samples/spring-boot-sample-tomcat/src/test/java/sample/tomcat/SampleTomcatApplicationTests.java
View file @
fad5ce45
...
@@ -20,8 +20,8 @@ import org.junit.Test;
...
@@ -20,8 +20,8 @@ import org.junit.Test;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.TestRestTemplate
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.TestRestTemplate
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.test.annotation.DirtiesContext
;
import
org.springframework.test.annotation.DirtiesContext
;
...
@@ -48,7 +48,7 @@ public class SampleTomcatApplicationTests {
...
@@ -48,7 +48,7 @@ public class SampleTomcatApplicationTests {
@Test
@Test
public
void
testHome
()
throws
Exception
{
public
void
testHome
()
throws
Exception
{
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
getForEntity
(
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
getForEntity
(
"http://localhost:"
+
port
,
String
.
class
);
"http://localhost:"
+
this
.
port
,
String
.
class
);
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertEquals
(
"Hello World"
,
entity
.
getBody
());
assertEquals
(
"Hello World"
,
entity
.
getBody
());
}
}
...
...
spring-boot-samples/spring-boot-sample-traditional/src/test/java/sample/traditional/SampleTraditionalApplicationTests.java
View file @
fad5ce45
...
@@ -20,8 +20,8 @@ import org.junit.Test;
...
@@ -20,8 +20,8 @@ import org.junit.Test;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.TestRestTemplate
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.TestRestTemplate
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.test.annotation.DirtiesContext
;
import
org.springframework.test.annotation.DirtiesContext
;
...
@@ -49,7 +49,7 @@ public class SampleTraditionalApplicationTests {
...
@@ -49,7 +49,7 @@ public class SampleTraditionalApplicationTests {
@Test
@Test
public
void
testHomeJsp
()
throws
Exception
{
public
void
testHomeJsp
()
throws
Exception
{
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
getForEntity
(
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
getForEntity
(
"http://localhost:"
+
port
,
String
.
class
);
"http://localhost:"
+
this
.
port
,
String
.
class
);
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
String
body
=
entity
.
getBody
();
String
body
=
entity
.
getBody
();
assertTrue
(
"Wrong body:\n"
+
body
,
body
.
contains
(
"<html>"
));
assertTrue
(
"Wrong body:\n"
+
body
,
body
.
contains
(
"<html>"
));
...
@@ -59,7 +59,7 @@ public class SampleTraditionalApplicationTests {
...
@@ -59,7 +59,7 @@ public class SampleTraditionalApplicationTests {
@Test
@Test
public
void
testStaticPage
()
throws
Exception
{
public
void
testStaticPage
()
throws
Exception
{
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
getForEntity
(
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
getForEntity
(
"http://localhost:"
+
port
+
"/index.html"
,
String
.
class
);
"http://localhost:"
+
this
.
port
+
"/index.html"
,
String
.
class
);
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
String
body
=
entity
.
getBody
();
String
body
=
entity
.
getBody
();
assertTrue
(
"Wrong body:\n"
+
body
,
body
.
contains
(
"<html>"
));
assertTrue
(
"Wrong body:\n"
+
body
,
body
.
contains
(
"<html>"
));
...
...
spring-boot-samples/spring-boot-sample-web-jsp/src/test/java/sample/jsp/SampleWebJspApplicationTests.java
View file @
fad5ce45
...
@@ -20,8 +20,8 @@ import org.junit.Test;
...
@@ -20,8 +20,8 @@ import org.junit.Test;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.TestRestTemplate
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.TestRestTemplate
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.test.annotation.DirtiesContext
;
import
org.springframework.test.annotation.DirtiesContext
;
...
@@ -49,7 +49,7 @@ public class SampleWebJspApplicationTests {
...
@@ -49,7 +49,7 @@ public class SampleWebJspApplicationTests {
@Test
@Test
public
void
testJspWithEl
()
throws
Exception
{
public
void
testJspWithEl
()
throws
Exception
{
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
getForEntity
(
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
getForEntity
(
"http://localhost:"
+
port
,
String
.
class
);
"http://localhost:"
+
this
.
port
,
String
.
class
);
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertTrue
(
"Wrong body:\n"
+
entity
.
getBody
(),
assertTrue
(
"Wrong body:\n"
+
entity
.
getBody
(),
entity
.
getBody
().
contains
(
"/resources/text.txt"
));
entity
.
getBody
().
contains
(
"/resources/text.txt"
));
...
...
spring-boot-samples/spring-boot-sample-web-method-security/src/test/java/sample/ui/method/SampleMethodSecurityApplicationTests.java
View file @
fad5ce45
...
@@ -16,9 +16,6 @@
...
@@ -16,9 +16,6 @@
package
sample
.
ui
.
method
;
package
sample
.
ui
.
method
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.regex.Matcher
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
java.util.regex.Pattern
;
...
@@ -41,6 +38,9 @@ import org.springframework.test.context.web.WebAppConfiguration;
...
@@ -41,6 +38,9 @@ import org.springframework.test.context.web.WebAppConfiguration;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.MultiValueMap
;
import
org.springframework.util.MultiValueMap
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
/**
/**
* Basic integration tests for demo application.
* Basic integration tests for demo application.
*
*
...
@@ -61,8 +61,8 @@ public class SampleMethodSecurityApplicationTests {
...
@@ -61,8 +61,8 @@ public class SampleMethodSecurityApplicationTests {
HttpHeaders
headers
=
new
HttpHeaders
();
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setAccept
(
Arrays
.
asList
(
MediaType
.
TEXT_HTML
));
headers
.
setAccept
(
Arrays
.
asList
(
MediaType
.
TEXT_HTML
));
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
exchange
(
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
exchange
(
"http://localhost:"
+
port
,
HttpMethod
.
GET
,
new
HttpEntity
<
Void
>(
headers
),
"http://localhost:"
+
this
.
port
,
HttpMethod
.
GET
,
new
HttpEntity
<
Void
>(
String
.
class
);
headers
),
String
.
class
);
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertTrue
(
"Wrong body (title doesn't match):\n"
+
entity
.
getBody
(),
entity
assertTrue
(
"Wrong body (title doesn't match):\n"
+
entity
.
getBody
(),
entity
.
getBody
().
contains
(
"<title>Login"
));
.
getBody
().
contains
(
"<title>Login"
));
...
@@ -77,12 +77,12 @@ public class SampleMethodSecurityApplicationTests {
...
@@ -77,12 +77,12 @@ public class SampleMethodSecurityApplicationTests {
form
.
set
(
"password"
,
"admin"
);
form
.
set
(
"password"
,
"admin"
);
getCsrf
(
form
,
headers
);
getCsrf
(
form
,
headers
);
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
exchange
(
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
exchange
(
"http://localhost:"
+
port
+
"/login"
,
HttpMethod
.
POST
,
"http://localhost:"
+
this
.
port
+
"/login"
,
HttpMethod
.
POST
,
new
HttpEntity
<
MultiValueMap
<
String
,
String
>>(
form
,
headers
),
new
HttpEntity
<
MultiValueMap
<
String
,
String
>>(
form
,
headers
),
String
.
class
);
String
.
class
);
assertEquals
(
HttpStatus
.
FOUND
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
FOUND
,
entity
.
getStatusCode
());
assertEquals
(
"http://localhost:"
+
port
+
"/"
,
entity
.
getHeaders
().
getLocation
()
assertEquals
(
"http://localhost:"
+
this
.
port
+
"/"
,
entity
.
getHeaders
()
.
toString
());
.
getLocation
().
toString
());
}
}
@Test
@Test
...
@@ -94,7 +94,7 @@ public class SampleMethodSecurityApplicationTests {
...
@@ -94,7 +94,7 @@ public class SampleMethodSecurityApplicationTests {
form
.
set
(
"password"
,
"user"
);
form
.
set
(
"password"
,
"user"
);
getCsrf
(
form
,
headers
);
getCsrf
(
form
,
headers
);
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
exchange
(
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
exchange
(
"http://localhost:"
+
port
+
"/login"
,
HttpMethod
.
POST
,
"http://localhost:"
+
this
.
port
+
"/login"
,
HttpMethod
.
POST
,
new
HttpEntity
<
MultiValueMap
<
String
,
String
>>(
form
,
headers
),
new
HttpEntity
<
MultiValueMap
<
String
,
String
>>(
form
,
headers
),
String
.
class
);
String
.
class
);
assertEquals
(
HttpStatus
.
FOUND
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
FOUND
,
entity
.
getStatusCode
());
...
@@ -110,28 +110,28 @@ public class SampleMethodSecurityApplicationTests {
...
@@ -110,28 +110,28 @@ public class SampleMethodSecurityApplicationTests {
@Test
@Test
public
void
testManagementProtected
()
throws
Exception
{
public
void
testManagementProtected
()
throws
Exception
{
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
()
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
()
.
getForEntity
(
.
getForEntity
(
"http://localhost:"
+
port
+
"/beans"
,
String
.
class
);
"http://localhost:"
+
this
.
port
+
"/beans"
,
String
.
class
);
assertEquals
(
HttpStatus
.
UNAUTHORIZED
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
UNAUTHORIZED
,
entity
.
getStatusCode
());
}
}
@Test
@Test
public
void
testManagementAuthorizedAccess
()
throws
Exception
{
public
void
testManagementAuthorizedAccess
()
throws
Exception
{
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
(
"admin"
,
"admin"
)
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
(
"admin"
,
"admin"
)
.
getForEntity
(
"http://localhost:"
+
port
+
"/beans"
,
String
.
class
);
.
getForEntity
(
"http://localhost:"
+
this
.
port
+
"/beans"
,
String
.
class
);
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
}
}
@Test
@Test
public
void
testManagementUnauthorizedAccess
()
throws
Exception
{
public
void
testManagementUnauthorizedAccess
()
throws
Exception
{
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
(
"user"
,
"user"
)
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
(
"user"
,
"user"
)
.
getForEntity
(
"http://localhost:"
+
port
+
"/beans"
,
String
.
class
);
.
getForEntity
(
"http://localhost:"
+
this
.
port
+
"/beans"
,
String
.
class
);
assertEquals
(
HttpStatus
.
FORBIDDEN
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
FORBIDDEN
,
entity
.
getStatusCode
());
}
}
private
void
getCsrf
(
MultiValueMap
<
String
,
String
>
form
,
HttpHeaders
headers
)
{
private
void
getCsrf
(
MultiValueMap
<
String
,
String
>
form
,
HttpHeaders
headers
)
{
ResponseEntity
<
String
>
page
=
new
TestRestTemplate
().
getForEntity
(
ResponseEntity
<
String
>
page
=
new
TestRestTemplate
().
getForEntity
(
"http://localhost:"
+
port
+
"/login"
,
String
.
class
);
"http://localhost:"
+
this
.
port
+
"/login"
,
String
.
class
);
String
cookie
=
page
.
getHeaders
().
getFirst
(
"Set-Cookie"
);
String
cookie
=
page
.
getHeaders
().
getFirst
(
"Set-Cookie"
);
headers
.
set
(
"Cookie"
,
cookie
);
headers
.
set
(
"Cookie"
,
cookie
);
String
body
=
page
.
getBody
();
String
body
=
page
.
getBody
();
...
...
spring-boot-samples/spring-boot-sample-web-secure/src/test/java/sample/ui/secure/SampleSecureApplicationTests.java
View file @
fad5ce45
...
@@ -22,8 +22,8 @@ import org.junit.Test;
...
@@ -22,8 +22,8 @@ import org.junit.Test;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.TestRestTemplate
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.TestRestTemplate
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpMethod
;
import
org.springframework.http.HttpMethod
;
...
@@ -57,8 +57,8 @@ public class SampleSecureApplicationTests {
...
@@ -57,8 +57,8 @@ public class SampleSecureApplicationTests {
HttpHeaders
headers
=
new
HttpHeaders
();
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setAccept
(
Arrays
.
asList
(
MediaType
.
TEXT_HTML
));
headers
.
setAccept
(
Arrays
.
asList
(
MediaType
.
TEXT_HTML
));
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
exchange
(
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
exchange
(
"http://localhost:"
+
port
,
HttpMethod
.
GET
,
new
HttpEntity
<
Void
>(
headers
),
"http://localhost:"
+
this
.
port
,
HttpMethod
.
GET
,
new
HttpEntity
<
Void
>(
String
.
class
);
headers
),
String
.
class
);
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertTrue
(
"Wrong body (title doesn't match):\n"
+
entity
.
getBody
(),
entity
assertTrue
(
"Wrong body (title doesn't match):\n"
+
entity
.
getBody
(),
entity
.
getBody
().
contains
(
"<title>Login"
));
.
getBody
().
contains
(
"<title>Login"
));
...
@@ -67,7 +67,7 @@ public class SampleSecureApplicationTests {
...
@@ -67,7 +67,7 @@ public class SampleSecureApplicationTests {
@Test
@Test
public
void
testCss
()
throws
Exception
{
public
void
testCss
()
throws
Exception
{
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
getForEntity
(
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
getForEntity
(
"http://localhost:"
+
port
+
"/css/bootstrap.min.css"
,
String
.
class
);
"http://localhost:"
+
this
.
port
+
"/css/bootstrap.min.css"
,
String
.
class
);
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertTrue
(
"Wrong body:\n"
+
entity
.
getBody
(),
entity
.
getBody
().
contains
(
"body"
));
assertTrue
(
"Wrong body:\n"
+
entity
.
getBody
(),
entity
.
getBody
().
contains
(
"body"
));
}
}
...
...
spring-boot-samples/spring-boot-sample-web-static/src/test/java/sample/ui/SampleWebStaticApplicationTests.java
View file @
fad5ce45
...
@@ -16,9 +16,6 @@
...
@@ -16,9 +16,6 @@
package
sample
.
ui
;
package
sample
.
ui
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
...
@@ -32,6 +29,9 @@ import org.springframework.test.annotation.DirtiesContext;
...
@@ -32,6 +29,9 @@ import org.springframework.test.annotation.DirtiesContext;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
/**
/**
* Basic integration tests for demo application.
* Basic integration tests for demo application.
*
*
...
@@ -43,14 +43,14 @@ import org.springframework.test.context.web.WebAppConfiguration;
...
@@ -43,14 +43,14 @@ import org.springframework.test.context.web.WebAppConfiguration;
@IntegrationTest
(
"server.port=0"
)
@IntegrationTest
(
"server.port=0"
)
@DirtiesContext
@DirtiesContext
public
class
SampleWebStaticApplicationTests
{
public
class
SampleWebStaticApplicationTests
{
@Value
(
"${local.server.port}"
)
@Value
(
"${local.server.port}"
)
private
int
port
=
0
;
private
int
port
=
0
;
@Test
@Test
public
void
testHome
()
throws
Exception
{
public
void
testHome
()
throws
Exception
{
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
getForEntity
(
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
getForEntity
(
"http://localhost:"
+
port
,
String
.
class
);
"http://localhost:"
+
this
.
port
,
String
.
class
);
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertTrue
(
"Wrong body (title doesn't match):\n"
+
entity
.
getBody
(),
entity
assertTrue
(
"Wrong body (title doesn't match):\n"
+
entity
.
getBody
(),
entity
.
getBody
().
contains
(
"<title>Static"
));
.
getBody
().
contains
(
"<title>Static"
));
...
@@ -59,8 +59,8 @@ public class SampleWebStaticApplicationTests {
...
@@ -59,8 +59,8 @@ public class SampleWebStaticApplicationTests {
@Test
@Test
public
void
testCss
()
throws
Exception
{
public
void
testCss
()
throws
Exception
{
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
getForEntity
(
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
getForEntity
(
"http://localhost:"
+
port
+
"/webjars/bootstrap/3.0.3/css/bootstrap.min.css"
,
"http://localhost:"
+
this
.
port
String
.
class
);
+
"/webjars/bootstrap/3.0.3/css/bootstrap.min.css"
,
String
.
class
);
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertTrue
(
"Wrong body:\n"
+
entity
.
getBody
(),
entity
.
getBody
().
contains
(
"body"
));
assertTrue
(
"Wrong body:\n"
+
entity
.
getBody
(),
entity
.
getBody
().
contains
(
"body"
));
assertEquals
(
"Wrong content type:\n"
+
entity
.
getHeaders
().
getContentType
(),
assertEquals
(
"Wrong content type:\n"
+
entity
.
getHeaders
().
getContentType
(),
...
...
spring-boot-samples/spring-boot-sample-web-ui/src/test/java/sample/ui/SampleWebUiApplicationTests.java
View file @
fad5ce45
...
@@ -22,8 +22,8 @@ import org.junit.Test;
...
@@ -22,8 +22,8 @@ import org.junit.Test;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.IntegrationTest
;
import
org.springframework.boot.test.TestRestTemplate
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.TestRestTemplate
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.test.annotation.DirtiesContext
;
import
org.springframework.test.annotation.DirtiesContext
;
...
@@ -54,7 +54,7 @@ public class SampleWebUiApplicationTests {
...
@@ -54,7 +54,7 @@ public class SampleWebUiApplicationTests {
@Test
@Test
public
void
testHome
()
throws
Exception
{
public
void
testHome
()
throws
Exception
{
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
getForEntity
(
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
getForEntity
(
"http://localhost:"
+
port
,
String
.
class
);
"http://localhost:"
+
this
.
port
,
String
.
class
);
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertTrue
(
"Wrong body (title doesn't match):\n"
+
entity
.
getBody
(),
entity
assertTrue
(
"Wrong body (title doesn't match):\n"
+
entity
.
getBody
(),
entity
.
getBody
().
contains
(
"<title>Messages"
));
.
getBody
().
contains
(
"<title>Messages"
));
...
@@ -67,16 +67,16 @@ public class SampleWebUiApplicationTests {
...
@@ -67,16 +67,16 @@ public class SampleWebUiApplicationTests {
MultiValueMap
<
String
,
String
>
map
=
new
LinkedMultiValueMap
<
String
,
String
>();
MultiValueMap
<
String
,
String
>
map
=
new
LinkedMultiValueMap
<
String
,
String
>();
map
.
set
(
"text"
,
"FOO text"
);
map
.
set
(
"text"
,
"FOO text"
);
map
.
set
(
"summary"
,
"FOO"
);
map
.
set
(
"summary"
,
"FOO"
);
URI
location
=
new
TestRestTemplate
().
postForLocation
(
"http://localhost:"
+
port
,
URI
location
=
new
TestRestTemplate
().
postForLocation
(
"http://localhost:"
map
);
+
this
.
port
,
map
);
assertTrue
(
"Wrong location:\n"
+
location
,
assertTrue
(
"Wrong location:\n"
+
location
,
location
.
toString
().
contains
(
"localhost:"
+
port
));
location
.
toString
().
contains
(
"localhost:"
+
this
.
port
));
}
}
@Test
@Test
public
void
testCss
()
throws
Exception
{
public
void
testCss
()
throws
Exception
{
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
getForEntity
(
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
getForEntity
(
"http://localhost:"
+
port
+
"/css/bootstrap.min.css"
,
String
.
class
);
"http://localhost:"
+
this
.
port
+
"/css/bootstrap.min.css"
,
String
.
class
);
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertTrue
(
"Wrong body:\n"
+
entity
.
getBody
(),
entity
.
getBody
().
contains
(
"body"
));
assertTrue
(
"Wrong body:\n"
+
entity
.
getBody
(),
entity
.
getBody
().
contains
(
"body"
));
}
}
...
...
spring-boot-samples/spring-boot-sample-websocket/src/test/java/samples/websocket/echo/CustomContainerWebSocketsApplicationTests.java
View file @
fad5ce45
...
@@ -16,8 +16,6 @@
...
@@ -16,8 +16,6 @@
package
samples
.
websocket
.
echo
;
package
samples
.
websocket
.
echo
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
java.util.concurrent.CountDownLatch
;
import
java.util.concurrent.CountDownLatch
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
...
@@ -47,6 +45,8 @@ import samples.websocket.client.SimpleGreetingService;
...
@@ -47,6 +45,8 @@ import samples.websocket.client.SimpleGreetingService;
import
samples.websocket.config.SampleWebSocketsApplication
;
import
samples.websocket.config.SampleWebSocketsApplication
;
import
samples.websocket.echo.CustomContainerWebSocketsApplicationTests.CustomContainerConfiguration
;
import
samples.websocket.echo.CustomContainerWebSocketsApplicationTests.CustomContainerConfiguration
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringApplicationConfiguration
(
classes
=
{
SampleWebSocketsApplication
.
class
,
@SpringApplicationConfiguration
(
classes
=
{
SampleWebSocketsApplication
.
class
,
CustomContainerConfiguration
.
class
})
CustomContainerConfiguration
.
class
})
...
@@ -57,7 +57,7 @@ public class CustomContainerWebSocketsApplicationTests {
...
@@ -57,7 +57,7 @@ public class CustomContainerWebSocketsApplicationTests {
private
static
Log
logger
=
LogFactory
private
static
Log
logger
=
LogFactory
.
getLog
(
CustomContainerWebSocketsApplicationTests
.
class
);
.
getLog
(
CustomContainerWebSocketsApplicationTests
.
class
);
private
static
int
PORT
=
SocketUtils
.
findAvailableTcpPort
();
private
static
int
PORT
=
SocketUtils
.
findAvailableTcpPort
();
private
static
final
String
WS_URI
=
"ws://localhost:"
+
PORT
+
"/ws/echo/websocket"
;
private
static
final
String
WS_URI
=
"ws://localhost:"
+
PORT
+
"/ws/echo/websocket"
;
...
...
spring-boot-samples/spring-boot-sample-websocket/src/test/java/samples/websocket/echo/SampleWebSocketsApplicationTests.java
View file @
fad5ce45
...
@@ -16,8 +16,6 @@
...
@@ -16,8 +16,6 @@
package
samples
.
websocket
.
echo
;
package
samples
.
websocket
.
echo
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
java.util.concurrent.CountDownLatch
;
import
java.util.concurrent.CountDownLatch
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
...
@@ -45,6 +43,8 @@ import samples.websocket.client.SimpleClientWebSocketHandler;
...
@@ -45,6 +43,8 @@ import samples.websocket.client.SimpleClientWebSocketHandler;
import
samples.websocket.client.SimpleGreetingService
;
import
samples.websocket.client.SimpleGreetingService
;
import
samples.websocket.config.SampleWebSocketsApplication
;
import
samples.websocket.config.SampleWebSocketsApplication
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringApplicationConfiguration
(
classes
=
SampleWebSocketsApplication
.
class
)
@SpringApplicationConfiguration
(
classes
=
SampleWebSocketsApplication
.
class
)
@WebAppConfiguration
@WebAppConfiguration
...
@@ -58,10 +58,10 @@ public class SampleWebSocketsApplicationTests {
...
@@ -58,10 +58,10 @@ public class SampleWebSocketsApplicationTests {
@Value
(
"${local.server.port}"
)
@Value
(
"${local.server.port}"
)
private
int
port
;
private
int
port
;
@Before
@Before
public
void
init
()
{
public
void
init
()
{
WS_URI
=
"ws://localhost:"
+
port
+
"/echo/websocket"
;
WS_URI
=
"ws://localhost:"
+
this
.
port
+
"/echo/websocket"
;
}
}
@Test
@Test
...
...
spring-boot-tools/spring-boot-gradle-plugin/src/main/groovy/org/springframework/boot/gradle/task/ProjectLibraries.java
View file @
fad5ce45
...
@@ -18,8 +18,6 @@ package org.springframework.boot.gradle.task;
...
@@ -18,8 +18,6 @@ package org.springframework.boot.gradle.task;
import
java.io.File
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.Collections
;
import
java.util.Set
;
import
org.gradle.api.Project
;
import
org.gradle.api.Project
;
import
org.gradle.api.artifacts.Configuration
;
import
org.gradle.api.artifacts.Configuration
;
...
@@ -30,7 +28,7 @@ import org.springframework.boot.loader.tools.LibraryScope;
...
@@ -30,7 +28,7 @@ import org.springframework.boot.loader.tools.LibraryScope;
/**
/**
* Expose Gradle {@link Configuration}s as {@link Libraries}.
* Expose Gradle {@link Configuration}s as {@link Libraries}.
*
*
* @author Phillip Webb
* @author Phillip Webb
* @author Andy Wilkinson
* @author Andy Wilkinson
*/
*/
...
@@ -44,7 +42,7 @@ class ProjectLibraries implements Libraries {
...
@@ -44,7 +42,7 @@ class ProjectLibraries implements Libraries {
/**
/**
* Create a new {@link ProjectLibraries} instance of the specified {@link Project}.
* Create a new {@link ProjectLibraries} instance of the specified {@link Project}.
*
*
* @param project the gradle project
* @param project the gradle project
*/
*/
public
ProjectLibraries
(
Project
project
)
{
public
ProjectLibraries
(
Project
project
)
{
...
@@ -53,7 +51,7 @@ class ProjectLibraries implements Libraries {
...
@@ -53,7 +51,7 @@ class ProjectLibraries implements Libraries {
/**
/**
* Set the name of the provided configuration. Defaults to 'providedRuntime'.
* Set the name of the provided configuration. Defaults to 'providedRuntime'.
*
*
* @param providedConfigurationName the providedConfigurationName to set
* @param providedConfigurationName the providedConfigurationName to set
*/
*/
public
void
setProvidedConfigurationName
(
String
providedConfigurationName
)
{
public
void
setProvidedConfigurationName
(
String
providedConfigurationName
)
{
...
...
spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RunMojo.java
View file @
fad5ce45
...
@@ -111,7 +111,9 @@ public class RunMojo extends AbstractMojo {
...
@@ -111,7 +111,9 @@ public class RunMojo extends AbstractMojo {
getLog
().
info
(
"Attaching agent: "
+
this
.
agent
);
getLog
().
info
(
"Attaching agent: "
+
this
.
agent
);
if
(
this
.
noverify
!=
null
&&
this
.
noverify
&&
!
AgentAttacher
.
hasNoVerify
())
{
if
(
this
.
noverify
!=
null
&&
this
.
noverify
&&
!
AgentAttacher
.
hasNoVerify
())
{
throw
new
MojoExecutionException
(
throw
new
MojoExecutionException
(
"The JVM must be started with -noverify for this agent to work. You can use MAVEN_OPTS=-noverify to add that flag."
);
"The JVM must be started with -noverify for "
+
"this agent to work. You can use MAVEN_OPTS=-noverify "
+
"to add that flag."
);
}
}
AgentAttacher
.
attach
(
this
.
agent
);
AgentAttacher
.
attach
(
this
.
agent
);
}
}
...
...
spring-boot/src/main/java/org/springframework/boot/context/embedded/EmbeddedWebApplicationContext.java
View file @
fad5ce45
...
@@ -89,10 +89,7 @@ import org.springframework.web.context.support.WebApplicationContextUtils;
...
@@ -89,10 +89,7 @@ import org.springframework.web.context.support.WebApplicationContextUtils;
*/
*/
public
class
EmbeddedWebApplicationContext
extends
GenericWebApplicationContext
{
public
class
EmbeddedWebApplicationContext
extends
GenericWebApplicationContext
{
/**
private
static
final
String
DEFAULT_SERVER_NAME
=
"server"
;
*
*/
private
static
final
String
SERVER
=
"server"
;
/**
/**
* Constant value for the DispatcherServlet bean name. A Servlet bean with this name
* Constant value for the DispatcherServlet bean name. A Servlet bean with this name
...
@@ -166,7 +163,7 @@ public class EmbeddedWebApplicationContext extends GenericWebApplicationContext
...
@@ -166,7 +163,7 @@ public class EmbeddedWebApplicationContext extends GenericWebApplicationContext
EmbeddedServletContainerFactory
containerFactory
=
getEmbeddedServletContainerFactory
();
EmbeddedServletContainerFactory
containerFactory
=
getEmbeddedServletContainerFactory
();
this
.
embeddedServletContainer
=
containerFactory
this
.
embeddedServletContainer
=
containerFactory
.
getEmbeddedServletContainer
(
getSelfInitializer
());
.
getEmbeddedServletContainer
(
getSelfInitializer
());
this
.
containers
.
put
(
SERVER
,
this
.
embeddedServletContainer
);
this
.
containers
.
put
(
DEFAULT_SERVER_NAME
,
this
.
embeddedServletContainer
);
}
}
else
if
(
getServletContext
()
!=
null
)
{
else
if
(
getServletContext
()
!=
null
)
{
try
{
try
{
...
@@ -391,7 +388,7 @@ public class EmbeddedWebApplicationContext extends GenericWebApplicationContext
...
@@ -391,7 +388,7 @@ public class EmbeddedWebApplicationContext extends GenericWebApplicationContext
try
{
try
{
this
.
embeddedServletContainer
.
stop
();
this
.
embeddedServletContainer
.
stop
();
this
.
embeddedServletContainer
=
null
;
this
.
embeddedServletContainer
=
null
;
this
.
containers
.
remove
(
SERVER
);
this
.
containers
.
remove
(
DEFAULT_SERVER_NAME
);
}
}
catch
(
Exception
ex
)
{
catch
(
Exception
ex
)
{
throw
new
IllegalStateException
(
ex
);
throw
new
IllegalStateException
(
ex
);
...
@@ -439,7 +436,6 @@ public class EmbeddedWebApplicationContext extends GenericWebApplicationContext
...
@@ -439,7 +436,6 @@ public class EmbeddedWebApplicationContext extends GenericWebApplicationContext
* A registry of embedded containers by name. The
* A registry of embedded containers by name. The
* {@link #getEmbeddedServletContainer() canonical container} is called "server".
* {@link #getEmbeddedServletContainer() canonical container} is called "server".
* Anyone else who creates one can register it with whatever name they please.
* Anyone else who creates one can register it with whatever name they please.
*
* @return the containers
* @return the containers
*/
*/
public
Map
<
String
,
EmbeddedServletContainer
>
getEmbeddedServletContainers
()
{
public
Map
<
String
,
EmbeddedServletContainer
>
getEmbeddedServletContainers
()
{
...
...
spring-boot/src/main/java/org/springframework/boot/context/embedded/RegistrationBean.java
View file @
fad5ce45
...
@@ -70,7 +70,6 @@ public abstract class RegistrationBean implements ServletContextInitializer, Ord
...
@@ -70,7 +70,6 @@ public abstract class RegistrationBean implements ServletContextInitializer, Ord
/**
/**
* Flag to indicate that the registration is enabled.
* Flag to indicate that the registration is enabled.
*
* @param enabled the enabled to set
* @param enabled the enabled to set
*/
*/
public
void
setEnabled
(
boolean
enabled
)
{
public
void
setEnabled
(
boolean
enabled
)
{
...
...
spring-boot/src/main/java/org/springframework/boot/context/embedded/ServletListenerRegistrationBean.java
View file @
fad5ce45
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
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.
...
...
spring-boot/src/main/java/org/springframework/boot/test/EmbeddedServletContainerListener.java
→
spring-boot/src/main/java/org/springframework/boot/test/EmbeddedServletContainer
TestExecution
Listener.java
View file @
fad5ce45
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
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.
...
@@ -18,34 +18,36 @@ package org.springframework.boot.test;
...
@@ -18,34 +18,36 @@ package org.springframework.boot.test;
import
java.util.Map
;
import
java.util.Map
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.context.embedded.EmbeddedServletContainer
;
import
org.springframework.boot.context.embedded.EmbeddedServletContainer
;
import
org.springframework.boot.context.embedded.EmbeddedWebApplicationContext
;
import
org.springframework.boot.context.embedded.EmbeddedWebApplicationContext
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.core.env.Environment
;
import
org.springframework.test.context.TestContext
;
import
org.springframework.test.context.TestContext
;
import
org.springframework.test.context.support.AbstractTestExecutionListener
;
import
org.springframework.test.context.support.AbstractTestExecutionListener
;
/**
/**
* Listener that injects the server port (if one is discoverable from the application
* Listener that injects the server port into an {@link Environment} property named
* context)into a field annotated with {@link Value @Value("dynamic.port")}.
* {@literal local.<server>.port}. Useful when the server is running on a dynamic
* port.
*
*
* @author Dave Syer
* @author Dave Syer
*/
*/
public
class
EmbeddedServletContainerListener
extends
AbstractTestExecutionListener
{
public
class
EmbeddedServletContainerTestExecutionListener
extends
AbstractTestExecutionListener
{
@Override
@Override
public
void
prepareTestInstance
(
TestContext
testContext
)
throws
Exception
{
public
void
prepareTestInstance
(
TestContext
testContext
)
throws
Exception
{
ApplicationContext
context
=
testContext
.
getApplicationContext
();
ApplicationContext
context
=
testContext
.
getApplicationContext
();
if
(
!(
context
instanceof
EmbeddedWebApplicationContext
)
)
{
if
(
context
instanceof
EmbeddedWebApplicationContext
)
{
return
;
prepareTestInstance
((
EmbeddedWebApplicationContext
)
context
)
;
}
}
EmbeddedWebApplicationContext
embedded
=
(
EmbeddedWebApplicationContext
)
context
;
}
Map
<
String
,
EmbeddedServletContainer
>
containers
=
embedded
.
getEmbeddedServletContainers
();
private
void
prepareTestInstance
(
EmbeddedWebApplicationContext
context
)
{
for
(
String
name
:
containers
.
keySet
())
{
for
(
Map
.
Entry
<
String
,
EmbeddedServletContainer
>
entry
:
context
int
port
=
containers
.
get
(
name
).
getPort
();
.
getEmbeddedServletContainers
().
entrySet
())
{
EnvironmentTestUtils
.
addEnvironment
(
embedded
,
"local."
+
name
+
".port:"
EnvironmentTestUtils
.
addEnvironment
(
context
,
"local."
+
entry
.
getKey
()
+
port
);
+
".port:"
+
entry
.
getValue
().
getPort
()
);
}
}
}
}
}
}
spring-boot/src/main/java/org/springframework/boot/test/EnvironmentTestUtils.java
View file @
fad5ce45
...
@@ -37,7 +37,6 @@ public abstract class EnvironmentTestUtils {
...
@@ -37,7 +37,6 @@ public abstract class EnvironmentTestUtils {
* Add additional (high priority) values to an {@link Environment} owned by an
* Add additional (high priority) values to an {@link Environment} owned by an
* {@link ApplicationContext}. Name-value pairs can be specified with colon (":") or
* {@link ApplicationContext}. Name-value pairs can be specified with colon (":") or
* equals ("=") separators.
* equals ("=") separators.
*
* @param context the context with an environment to modify
* @param context the context with an environment to modify
* @param pairs the name:value pairs
* @param pairs the name:value pairs
*/
*/
...
@@ -49,7 +48,6 @@ public abstract class EnvironmentTestUtils {
...
@@ -49,7 +48,6 @@ public abstract class EnvironmentTestUtils {
/**
/**
* Add additional (high priority) values to an {@link Environment}. Name-value pairs
* Add additional (high priority) values to an {@link Environment}. Name-value pairs
* can be specified with colon (":") or equals ("=") separators.
* can be specified with colon (":") or equals ("=") separators.
*
* @param environment the environment to modify
* @param environment the environment to modify
* @param pairs the name:value pairs
* @param pairs the name:value pairs
*/
*/
...
@@ -61,7 +59,6 @@ public abstract class EnvironmentTestUtils {
...
@@ -61,7 +59,6 @@ public abstract class EnvironmentTestUtils {
/**
/**
* Add additional (high priority) values to an {@link Environment}. Name-value pairs
* Add additional (high priority) values to an {@link Environment}. Name-value pairs
* can be specified with colon (":") or equals ("=") separators.
* can be specified with colon (":") or equals ("=") separators.
*
* @param environment the environment to modify
* @param environment the environment to modify
* @param name the property source name
* @param name the property source name
* @param pairs the name:value pairs
* @param pairs the name:value pairs
...
...
spring-boot/src/main/java/org/springframework/boot/test/IntegrationTest.java
View file @
fad5ce45
...
@@ -23,6 +23,7 @@ import java.lang.annotation.Retention;
...
@@ -23,6 +23,7 @@ import java.lang.annotation.Retention;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
import
java.lang.annotation.Target
;
import
org.springframework.core.env.Environment
;
import
org.springframework.test.context.TestExecutionListeners
;
import
org.springframework.test.context.TestExecutionListeners
;
import
org.springframework.test.context.support.DependencyInjectionTestExecutionListener
;
import
org.springframework.test.context.support.DependencyInjectionTestExecutionListener
;
import
org.springframework.test.context.support.DirtiesContextTestExecutionListener
;
import
org.springframework.test.context.support.DirtiesContextTestExecutionListener
;
...
@@ -40,11 +41,17 @@ import org.springframework.test.context.transaction.TransactionalTestExecutionLi
...
@@ -40,11 +41,17 @@ import org.springframework.test.context.transaction.TransactionalTestExecutionLi
@Target
(
ElementType
.
TYPE
)
@Target
(
ElementType
.
TYPE
)
// Leave out the ServletTestExecutionListener because it only deals with Mock* servlet
// Leave out the ServletTestExecutionListener because it only deals with Mock* servlet
// stuff. A real embedded application will not need the mocks.
// stuff. A real embedded application will not need the mocks.
@TestExecutionListeners
(
listeners
=
{
EmbeddedServletContainerListener
.
class
,
@TestExecutionListeners
(
listeners
=
{
EmbeddedServletContainerTestExecutionListener
.
class
,
DependencyInjectionTestExecutionListener
.
class
,
DependencyInjectionTestExecutionListener
.
class
,
DirtiesContextTestExecutionListener
.
class
,
DirtiesContextTestExecutionListener
.
class
,
TransactionalTestExecutionListener
.
class
})
TransactionalTestExecutionListener
.
class
})
public
@interface
IntegrationTest
{
public
@interface
IntegrationTest
{
String
[]
value
()
default
""
;
/**
* Properties in form {@literal key=value} that should be added to the Spring
* {@link Environment} before the test runs.
*/
String
[]
value
()
default
{};
}
}
spring-boot/src/main/java/org/springframework/boot/test/SpringApplicationContextLoader.java
View file @
fad5ce45
...
@@ -18,6 +18,7 @@ package org.springframework.boot.test;
...
@@ -18,6 +18,7 @@ package org.springframework.boot.test;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.LinkedHashMap
;
import
java.util.LinkedHashMap
;
import
java.util.LinkedHashSet
;
import
java.util.LinkedHashSet
;
...
@@ -66,19 +67,18 @@ import org.springframework.web.context.support.GenericWebApplicationContext;
...
@@ -66,19 +67,18 @@ import org.springframework.web.context.support.GenericWebApplicationContext;
public
class
SpringApplicationContextLoader
extends
AbstractContextLoader
{
public
class
SpringApplicationContextLoader
extends
AbstractContextLoader
{
@Override
@Override
public
ApplicationContext
loadContext
(
MergedContextConfiguration
mergedC
onfig
)
public
ApplicationContext
loadContext
(
MergedContextConfiguration
c
onfig
)
throws
Exception
{
throws
Exception
{
SpringApplication
application
=
getSpringApplication
();
SpringApplication
application
=
getSpringApplication
();
application
.
setSources
(
getSources
(
mergedC
onfig
));
application
.
setSources
(
getSources
(
c
onfig
));
if
(!
ObjectUtils
.
isEmpty
(
mergedC
onfig
.
getActiveProfiles
()))
{
if
(!
ObjectUtils
.
isEmpty
(
c
onfig
.
getActiveProfiles
()))
{
application
.
setAdditionalProfiles
(
mergedC
onfig
.
getActiveProfiles
());
application
.
setAdditionalProfiles
(
c
onfig
.
getActiveProfiles
());
}
}
application
.
setDefaultProperties
(
get
Args
(
mergedC
onfig
));
application
.
setDefaultProperties
(
get
EnvironmentProperties
(
c
onfig
));
List
<
ApplicationContextInitializer
<?>>
initializers
=
getInitializers
(
List
<
ApplicationContextInitializer
<?>>
initializers
=
getInitializers
(
config
,
mergedConfig
,
application
);
application
);
if
(
mergedC
onfig
instanceof
WebMergedContextConfiguration
)
{
if
(
c
onfig
instanceof
WebMergedContextConfiguration
)
{
new
WebConfigurer
().
configure
(
mergedC
onfig
,
application
,
initializers
);
new
WebConfigurer
().
configure
(
c
onfig
,
application
,
initializers
);
}
}
else
{
else
{
application
.
setWebEnvironment
(
false
);
application
.
setWebEnvironment
(
false
);
...
@@ -134,32 +134,41 @@ public class SpringApplicationContextLoader extends AbstractContextLoader {
...
@@ -134,32 +134,41 @@ public class SpringApplicationContextLoader extends AbstractContextLoader {
.
detectDefaultConfigurationClasses
(
declaringClass
);
.
detectDefaultConfigurationClasses
(
declaringClass
);
}
}
private
Map
<
String
,
Object
>
get
Args
(
MergedContextConfiguration
mergedC
onfig
)
{
private
Map
<
String
,
Object
>
get
EnvironmentProperties
(
MergedContextConfiguration
c
onfig
)
{
Map
<
String
,
Object
>
arg
s
=
new
LinkedHashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
propertie
s
=
new
LinkedHashMap
<
String
,
Object
>();
// JMX bean names will clash if the same bean is used in multiple contexts
// JMX bean names will clash if the same bean is used in multiple contexts
args
.
put
(
"spring.jmx.enabled"
,
"false"
);
disableJmx
(
properties
);
IntegrationTest
annotation
=
AnnotationUtils
.
findAnnotation
(
IntegrationTest
annotation
=
AnnotationUtils
.
findAnnotation
(
mergedConfig
.
getTestClass
(),
IntegrationTest
.
class
);
config
.
getTestClass
(),
IntegrationTest
.
class
);
properties
.
putAll
(
getEnvironmentProperties
(
annotation
));
return
properties
;
}
private
void
disableJmx
(
Map
<
String
,
Object
>
properties
)
{
properties
.
put
(
"spring.jmx.enabled"
,
"false"
);
}
private
Map
<
String
,
String
>
getEnvironmentProperties
(
IntegrationTest
annotation
)
{
if
(
annotation
==
null
)
{
if
(
annotation
==
null
)
{
// Not running an embedded server, just setting up web context
return
getDefaultEnvironmentProperties
();
args
.
put
(
"server.port"
,
"-1"
);
}
}
else
{
return
extractEnvironmentProperties
(
annotation
.
value
());
args
.
putAll
(
extractProperties
(
annotation
.
value
()));
}
}
return
args
;
private
Map
<
String
,
String
>
getDefaultEnvironmentProperties
()
{
return
Collections
.
singletonMap
(
"server.port"
,
"-1"
);
}
}
private
Map
<
String
,
String
>
extractProperties
(
String
[]
values
)
{
private
Map
<
String
,
String
>
extract
Environment
Properties
(
String
[]
values
)
{
Map
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
properties
=
new
HashMap
<
String
,
String
>();
for
(
String
pair
:
values
)
{
for
(
String
pair
:
values
)
{
int
index
=
pair
.
indexOf
(
":"
);
int
index
=
pair
.
indexOf
(
":"
);
index
=
index
<
0
?
index
=
pair
.
indexOf
(
"="
)
:
index
;
index
=
(
index
<
0
?
index
=
pair
.
indexOf
(
"="
)
:
index
)
;
String
key
=
pair
.
substring
(
0
,
index
>
0
?
index
:
pair
.
length
());
String
key
=
pair
.
substring
(
0
,
index
>
0
?
index
:
pair
.
length
());
String
value
=
index
>
0
?
pair
.
substring
(
index
+
1
)
:
""
;
String
value
=
(
index
>
0
?
pair
.
substring
(
index
+
1
)
:
""
)
;
map
.
put
(
key
.
trim
(),
value
.
trim
());
properties
.
put
(
key
.
trim
(),
value
.
trim
());
}
}
return
map
;
return
properties
;
}
}
private
List
<
ApplicationContextInitializer
<?>>
getInitializers
(
private
List
<
ApplicationContextInitializer
<?>>
getInitializers
(
...
...
spring-boot/src/test/java/org/springframework/boot/bind/RelaxedDataBinderTests.java
View file @
fad5ce45
...
@@ -264,7 +264,7 @@ public class RelaxedDataBinderTests {
...
@@ -264,7 +264,7 @@ public class RelaxedDataBinderTests {
bind
(
target
,
"nested.foo: bar\n"
+
"nested.value: 123"
);
bind
(
target
,
"nested.foo: bar\n"
+
"nested.value: 123"
);
assertEquals
(
"123"
,
target
.
getNested
().
get
(
"value"
));
assertEquals
(
"123"
,
target
.
getNested
().
get
(
"value"
));
}
}
@Test
@Test
public
void
testBindNestedMapOfString
()
throws
Exception
{
public
void
testBindNestedMapOfString
()
throws
Exception
{
TargetWithNestedMapOfString
target
=
new
TargetWithNestedMapOfString
();
TargetWithNestedMapOfString
target
=
new
TargetWithNestedMapOfString
();
...
@@ -510,7 +510,7 @@ public class RelaxedDataBinderTests {
...
@@ -510,7 +510,7 @@ public class RelaxedDataBinderTests {
}
}
}
}
@SuppressWarnings
(
"rawtypes"
)
@SuppressWarnings
(
"rawtypes"
)
public
static
class
TargetWithNestedUntypedMap
{
public
static
class
TargetWithNestedUntypedMap
{
...
@@ -526,7 +526,6 @@ public class RelaxedDataBinderTests {
...
@@ -526,7 +526,6 @@ public class RelaxedDataBinderTests {
}
}
public
static
class
TargetWithNestedMapOfString
{
public
static
class
TargetWithNestedMapOfString
{
private
Map
<
String
,
String
>
nested
;
private
Map
<
String
,
String
>
nested
;
...
...
spring-boot/src/test/java/org/springframework/boot/context/config/RandomValuePropertySourceTests.java
View file @
fad5ce45
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
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.
...
@@ -23,6 +23,8 @@ import static org.junit.Assert.assertNull;
...
@@ -23,6 +23,8 @@ import static org.junit.Assert.assertNull;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
/**
/**
* Tests for {@link RandomValuePropertySource}.
*
* @author Dave Syer
* @author Dave Syer
*/
*/
public
class
RandomValuePropertySourceTests
{
public
class
RandomValuePropertySourceTests
{
...
...
spring-boot/src/test/java/org/springframework/boot/env/PropertySourcesLoaderTests.java
View file @
fad5ce45
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
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.
...
@@ -21,6 +21,8 @@ import org.junit.Test;
...
@@ -21,6 +21,8 @@ import org.junit.Test;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
/**
/**
* Tests for {@link PropertySourcesLoader}.
*
* @author Dave Syer
* @author Dave Syer
*/
*/
public
class
PropertySourcesLoaderTests
{
public
class
PropertySourcesLoaderTests
{
...
@@ -28,7 +30,7 @@ public class PropertySourcesLoaderTests {
...
@@ -28,7 +30,7 @@ public class PropertySourcesLoaderTests {
private
PropertySourcesLoader
loader
=
new
PropertySourcesLoader
();
private
PropertySourcesLoader
loader
=
new
PropertySourcesLoader
();
@Test
@Test
public
void
test
()
{
public
void
fileExtensions
()
{
assertTrue
(
this
.
loader
.
getAllFileExtensions
().
contains
(
"yml"
));
assertTrue
(
this
.
loader
.
getAllFileExtensions
().
contains
(
"yml"
));
assertTrue
(
this
.
loader
.
getAllFileExtensions
().
contains
(
"yaml"
));
assertTrue
(
this
.
loader
.
getAllFileExtensions
().
contains
(
"yaml"
));
assertTrue
(
this
.
loader
.
getAllFileExtensions
().
contains
(
"properties"
));
assertTrue
(
this
.
loader
.
getAllFileExtensions
().
contains
(
"properties"
));
...
...
spring-boot/src/test/java/org/springframework/boot/env/YamlPropertySourceLoaderTests.java
View file @
fad5ce45
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
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.
...
@@ -24,6 +24,8 @@ import static org.junit.Assert.assertEquals;
...
@@ -24,6 +24,8 @@ import static org.junit.Assert.assertEquals;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
/**
/**
* Tests for {@link YamlPropertySourceLoader}.
*
* @author Dave Syer
* @author Dave Syer
*/
*/
public
class
YamlPropertySourceLoaderTests
{
public
class
YamlPropertySourceLoaderTests
{
...
@@ -31,9 +33,9 @@ public class YamlPropertySourceLoaderTests {
...
@@ -31,9 +33,9 @@ public class YamlPropertySourceLoaderTests {
private
YamlPropertySourceLoader
loader
=
new
YamlPropertySourceLoader
();
private
YamlPropertySourceLoader
loader
=
new
YamlPropertySourceLoader
();
@Test
@Test
public
void
test
()
throws
Exception
{
public
void
load
()
throws
Exception
{
PropertySource
<?>
source
=
this
.
loader
.
load
(
"resource"
,
new
ByteArrayResource
(
ByteArrayResource
resource
=
new
ByteArrayResource
(
"foo:\n bar: spam"
.
getBytes
());
"foo:\n bar: spam"
.
getBytes
())
,
null
);
PropertySource
<?>
source
=
this
.
loader
.
load
(
"resource"
,
resource
,
null
);
assertNotNull
(
source
);
assertNotNull
(
source
);
assertEquals
(
"spam"
,
source
.
getProperty
(
"foo.bar"
));
assertEquals
(
"spam"
,
source
.
getProperty
(
"foo.bar"
));
}
}
...
...
spring-boot/src/test/java/org/springframework/boot/test/TestRestTemplateTests.java
View file @
fad5ce45
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
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.
...
@@ -23,6 +23,8 @@ import org.springframework.http.client.InterceptingClientHttpRequestFactory;
...
@@ -23,6 +23,8 @@ import org.springframework.http.client.InterceptingClientHttpRequestFactory;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
/**
/**
* Tests for {@link TestRestTemplate}.
*
* @author Dave Syer
* @author Dave Syer
*/
*/
public
class
TestRestTemplateTests
{
public
class
TestRestTemplateTests
{
...
...
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