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
c8152bfc
Commit
c8152bfc
authored
Jan 09, 2014
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SpringBootTestUtils->EnvironmentTestUtils
parent
478e6557
Changes
28
Show whitespace changes
Inline
Side-by-side
Showing
28 changed files
with
124 additions
and
119 deletions
+124
-119
EndpointAutoConfigurationTests.java
...actuate/autoconfigure/EndpointAutoConfigurationTests.java
+3
-3
EndpointWebMvcAutoConfigurationTests.java
...e/autoconfigure/EndpointWebMvcAutoConfigurationTests.java
+3
-3
JolokiaAutoConfigurationTests.java
.../actuate/autoconfigure/JolokiaAutoConfigurationTests.java
+2
-2
ManagementSecurityAutoConfigurationTests.java
...toconfigure/ManagementSecurityAutoConfigurationTests.java
+4
-4
AbstractEndpointTests.java
...ramework/boot/actuate/endpoint/AbstractEndpointTests.java
+2
-2
EnvironmentMvcEndpointTests.java
...oot/actuate/endpoint/mvc/EnvironmentMvcEndpointTests.java
+2
-2
JolokiaEndpointTests.java
...ework/boot/actuate/endpoint/mvc/JolokiaEndpointTests.java
+2
-2
PropertyPlaceholderAutoConfigurationTests.java
...oconfigure/PropertyPlaceholderAutoConfigurationTests.java
+3
-3
RabbitAutoconfigurationTests.java
...boot/autoconfigure/amqp/RabbitAutoconfigurationTests.java
+6
-6
AopAutoConfigurationTests.java
...ork/boot/autoconfigure/aop/AopAutoConfigurationTests.java
+4
-4
BatchAutoConfigurationTests.java
...boot/autoconfigure/batch/BatchAutoConfigurationTests.java
+3
-3
DataSourceAutoConfigurationTests.java
.../autoconfigure/jdbc/DataSourceAutoConfigurationTests.java
+3
-3
TomcatDataSourceConfigurationTests.java
...utoconfigure/jdbc/TomcatDataSourceConfigurationTests.java
+2
-2
JmsTemplateAutoConfigurationTests.java
.../autoconfigure/jms/JmsTemplateAutoConfigurationTests.java
+7
-7
AbstractJpaAutoConfigurationTests.java
...oconfigure/orm/jpa/AbstractJpaAutoConfigurationTests.java
+3
-3
HibernateJpaAutoConfigurationTests.java
...configure/orm/jpa/HibernateJpaAutoConfigurationTests.java
+2
-2
RedisAutoConfigurationTests.java
...boot/autoconfigure/redis/RedisAutoConfigurationTests.java
+2
-2
SecurityAutoConfigurationTests.java
...utoconfigure/security/SecurityAutoConfigurationTests.java
+4
-4
ServerPropertiesAutoConfigurationTests.java
...configure/web/ServerPropertiesAutoConfigurationTests.java
+3
-3
ContextIdApplicationContextInitializerTests.java
...tializer/ContextIdApplicationContextInitializerTests.java
+5
-5
EnvironmentDelegateApplicationContextInitializerTests.java
...nvironmentDelegateApplicationContextInitializerTests.java
+6
-6
ConfigFileApplicationListenerTests.java
.../context/listener/ConfigFileApplicationListenerTests.java
+11
-6
EnvironmentDelegateApplicationListenerTests.java
...listener/EnvironmentDelegateApplicationListenerTests.java
+3
-3
FileEncodingApplicationListenerTests.java
...ontext/listener/FileEncodingApplicationListenerTests.java
+3
-3
LoggingApplicationListenerTests.java
...oot/context/listener/LoggingApplicationListenerTests.java
+8
-8
VcapApplicationListenerTests.java
...k/boot/context/listener/VcapApplicationListenerTests.java
+5
-5
EnableConfigurationPropertiesTests.java
...ontext/properties/EnableConfigurationPropertiesTests.java
+19
-19
EnvironmentTestUtils.java
...a/org/springframework/boot/test/EnvironmentTestUtils.java
+4
-4
No files found.
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointAutoConfigurationTests.java
View file @
c8152bfc
...
@@ -32,7 +32,7 @@ import org.springframework.boot.actuate.endpoint.ShutdownEndpoint;
...
@@ -32,7 +32,7 @@ import org.springframework.boot.actuate.endpoint.ShutdownEndpoint;
import
org.springframework.boot.actuate.endpoint.TraceEndpoint
;
import
org.springframework.boot.actuate.endpoint.TraceEndpoint
;
import
org.springframework.boot.autoconfigure.AutoConfigurationReport
;
import
org.springframework.boot.autoconfigure.AutoConfigurationReport
;
import
org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration
;
import
org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration
;
import
org.springframework.boot.test.
SpringBoo
tTestUtils
;
import
org.springframework.boot.test.
Environmen
tTestUtils
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
...
@@ -104,7 +104,7 @@ public class EndpointAutoConfigurationTests {
...
@@ -104,7 +104,7 @@ public class EndpointAutoConfigurationTests {
@Test
@Test
public
void
testInfoEndpointConfiguration
()
throws
Exception
{
public
void
testInfoEndpointConfiguration
()
throws
Exception
{
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
=
new
AnnotationConfigApplicationContext
();
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"info.foo:bar"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"info.foo:bar"
);
this
.
context
.
register
(
EndpointAutoConfiguration
.
class
);
this
.
context
.
register
(
EndpointAutoConfiguration
.
class
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
InfoEndpoint
endpoint
=
this
.
context
.
getBean
(
InfoEndpoint
.
class
);
InfoEndpoint
endpoint
=
this
.
context
.
getBean
(
InfoEndpoint
.
class
);
...
@@ -116,7 +116,7 @@ public class EndpointAutoConfigurationTests {
...
@@ -116,7 +116,7 @@ public class EndpointAutoConfigurationTests {
@Test
@Test
public
void
testNoGitProperties
()
throws
Exception
{
public
void
testNoGitProperties
()
throws
Exception
{
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
=
new
AnnotationConfigApplicationContext
();
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"spring.git.properties:classpath:nonexistent"
);
"spring.git.properties:classpath:nonexistent"
);
this
.
context
.
register
(
EndpointAutoConfiguration
.
class
);
this
.
context
.
register
(
EndpointAutoConfiguration
.
class
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfigurationTests.java
View file @
c8152bfc
...
@@ -33,7 +33,7 @@ import org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfi
...
@@ -33,7 +33,7 @@ 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.context.embedded.AnnotationConfigEmbeddedWebApplicationContext
;
import
org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext
;
import
org.springframework.boot.test.
SpringBoo
tTestUtils
;
import
org.springframework.boot.test.
Environmen
tTestUtils
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.http.HttpMethod
;
import
org.springframework.http.HttpMethod
;
...
@@ -121,7 +121,7 @@ public class EndpointWebMvcAutoConfigurationTests {
...
@@ -121,7 +121,7 @@ public class EndpointWebMvcAutoConfigurationTests {
@Test
@Test
public
void
specificPortsViaProperties
()
throws
Exception
{
public
void
specificPortsViaProperties
()
throws
Exception
{
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
applicationContext
,
"server.port:7070"
,
Environmen
tTestUtils
.
addEnvironment
(
this
.
applicationContext
,
"server.port:7070"
,
"management.port:7071"
);
"management.port:7071"
);
this
.
applicationContext
.
register
(
RootConfig
.
class
,
this
.
applicationContext
.
register
(
RootConfig
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
,
...
@@ -142,7 +142,7 @@ public class EndpointWebMvcAutoConfigurationTests {
...
@@ -142,7 +142,7 @@ public class EndpointWebMvcAutoConfigurationTests {
@Test
@Test
public
void
contextPath
()
throws
Exception
{
public
void
contextPath
()
throws
Exception
{
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
applicationContext
,
"management.contextPath:/test"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
applicationContext
,
"management.contextPath:/test"
);
this
.
applicationContext
.
register
(
RootConfig
.
class
,
this
.
applicationContext
.
register
(
RootConfig
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
,
ManagementServerPropertiesAutoConfiguration
.
class
,
ManagementServerPropertiesAutoConfiguration
.
class
,
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/JolokiaAutoConfigurationTests.java
View file @
c8152bfc
...
@@ -26,7 +26,7 @@ import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomi
...
@@ -26,7 +26,7 @@ import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomi
import
org.springframework.boot.context.embedded.EmbeddedServletContainerFactory
;
import
org.springframework.boot.context.embedded.EmbeddedServletContainerFactory
;
import
org.springframework.boot.context.embedded.MockEmbeddedServletContainerFactory
;
import
org.springframework.boot.context.embedded.MockEmbeddedServletContainerFactory
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.boot.test.
SpringBoo
tTestUtils
;
import
org.springframework.boot.test.
Environmen
tTestUtils
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
...
@@ -65,7 +65,7 @@ public class JolokiaAutoConfigurationTests {
...
@@ -65,7 +65,7 @@ public class JolokiaAutoConfigurationTests {
@Test
@Test
public
void
agentDisabled
()
throws
Exception
{
public
void
agentDisabled
()
throws
Exception
{
this
.
context
=
new
AnnotationConfigEmbeddedWebApplicationContext
();
this
.
context
=
new
AnnotationConfigEmbeddedWebApplicationContext
();
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"endpoints.jolokia.enabled:false"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"endpoints.jolokia.enabled:false"
);
this
.
context
.
register
(
Config
.
class
,
WebMvcAutoConfiguration
.
class
,
this
.
context
.
register
(
Config
.
class
,
WebMvcAutoConfiguration
.
class
,
ManagementServerPropertiesAutoConfiguration
.
class
,
ManagementServerPropertiesAutoConfiguration
.
class
,
HttpMessageConvertersAutoConfiguration
.
class
,
HttpMessageConvertersAutoConfiguration
.
class
,
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/ManagementSecurityAutoConfigurationTests.java
View file @
c8152bfc
...
@@ -25,7 +25,7 @@ import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfigurati
...
@@ -25,7 +25,7 @@ import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfigurati
import
org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration
;
import
org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration
;
import
org.springframework.boot.context.listener.LoggingApplicationListener
;
import
org.springframework.boot.context.listener.LoggingApplicationListener
;
import
org.springframework.boot.test.
SpringBoo
tTestUtils
;
import
org.springframework.boot.test.
Environmen
tTestUtils
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.event.ContextRefreshedEvent
;
import
org.springframework.context.event.ContextRefreshedEvent
;
...
@@ -117,7 +117,7 @@ public class ManagementSecurityAutoConfigurationTests {
...
@@ -117,7 +117,7 @@ public class ManagementSecurityAutoConfigurationTests {
EndpointAutoConfiguration
.
class
,
EndpointAutoConfiguration
.
class
,
ManagementServerPropertiesAutoConfiguration
.
class
,
ManagementServerPropertiesAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
);
PropertyPlaceholderAutoConfiguration
.
class
);
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"security.ignored:none"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"security.ignored:none"
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
// Just the application and management endpoints now
// Just the application and management endpoints now
assertEquals
(
2
,
this
.
context
.
getBean
(
FilterChainProxy
.
class
).
getFilterChains
()
assertEquals
(
2
,
this
.
context
.
getBean
(
FilterChainProxy
.
class
).
getFilterChains
()
...
@@ -134,7 +134,7 @@ public class ManagementSecurityAutoConfigurationTests {
...
@@ -134,7 +134,7 @@ public class ManagementSecurityAutoConfigurationTests {
EndpointAutoConfiguration
.
class
,
EndpointWebMvcAutoConfiguration
.
class
,
EndpointAutoConfiguration
.
class
,
EndpointWebMvcAutoConfiguration
.
class
,
ManagementServerPropertiesAutoConfiguration
.
class
,
ManagementServerPropertiesAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
);
PropertyPlaceholderAutoConfiguration
.
class
);
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"security.basic.enabled:false"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"security.basic.enabled:false"
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
// Just the management endpoints (one filter) and ignores now
// Just the management endpoints (one filter) and ignores now
assertEquals
(
7
,
this
.
context
.
getBean
(
FilterChainProxy
.
class
).
getFilterChains
()
assertEquals
(
7
,
this
.
context
.
getBean
(
FilterChainProxy
.
class
).
getFilterChains
()
...
@@ -171,7 +171,7 @@ public class ManagementSecurityAutoConfigurationTests {
...
@@ -171,7 +171,7 @@ public class ManagementSecurityAutoConfigurationTests {
private
static
AnnotationConfigWebApplicationContext
debugRefresh
(
private
static
AnnotationConfigWebApplicationContext
debugRefresh
(
AnnotationConfigWebApplicationContext
context
)
{
AnnotationConfigWebApplicationContext
context
)
{
SpringBoo
tTestUtils
.
addEnvironment
(
context
,
"debug:true"
);
Environmen
tTestUtils
.
addEnvironment
(
context
,
"debug:true"
);
LoggingApplicationListener
logging
=
new
LoggingApplicationListener
();
LoggingApplicationListener
logging
=
new
LoggingApplicationListener
();
logging
.
onApplicationEvent
(
new
SpringApplicationBeforeRefreshEvent
(
logging
.
onApplicationEvent
(
new
SpringApplicationBeforeRefreshEvent
(
new
SpringApplication
(),
context
,
new
String
[
0
]));
new
SpringApplication
(),
context
,
new
String
[
0
]));
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/AbstractEndpointTests.java
View file @
c8152bfc
...
@@ -21,7 +21,7 @@ import java.util.Collections;
...
@@ -21,7 +21,7 @@ import java.util.Collections;
import
org.junit.After
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.springframework.boot.test.
SpringBoo
tTestUtils
;
import
org.springframework.boot.test.
Environmen
tTestUtils
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.core.env.MapPropertySource
;
import
org.springframework.core.env.MapPropertySource
;
import
org.springframework.core.env.PropertySource
;
import
org.springframework.core.env.PropertySource
;
...
@@ -84,7 +84,7 @@ public abstract class AbstractEndpointTests<T extends Endpoint<?>> {
...
@@ -84,7 +84,7 @@ public abstract class AbstractEndpointTests<T extends Endpoint<?>> {
@Test
@Test
public
void
idOverride
()
throws
Exception
{
public
void
idOverride
()
throws
Exception
{
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
=
new
AnnotationConfigApplicationContext
();
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
this
.
property
+
".id:myid"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
this
.
property
+
".id:myid"
);
this
.
context
.
register
(
this
.
configClass
);
this
.
context
.
register
(
this
.
configClass
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
assertThat
(
getEndpointBean
().
getId
(),
equalTo
(
"myid"
));
assertThat
(
getEndpointBean
().
getId
(),
equalTo
(
"myid"
));
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/EnvironmentMvcEndpointTests.java
View file @
c8152bfc
...
@@ -25,7 +25,7 @@ import org.springframework.boot.actuate.autoconfigure.ManagementServerProperties
...
@@ -25,7 +25,7 @@ import org.springframework.boot.actuate.autoconfigure.ManagementServerProperties
import
org.springframework.boot.actuate.endpoint.EnvironmentEndpoint
;
import
org.springframework.boot.actuate.endpoint.EnvironmentEndpoint
;
import
org.springframework.boot.actuate.endpoint.mvc.EnvironmentMvcEndpointTests.TestConfiguration
;
import
org.springframework.boot.actuate.endpoint.mvc.EnvironmentMvcEndpointTests.TestConfiguration
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.
SpringBoo
tTestUtils
;
import
org.springframework.boot.test.
Environmen
tTestUtils
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
...
@@ -59,7 +59,7 @@ public class EnvironmentMvcEndpointTests {
...
@@ -59,7 +59,7 @@ public class EnvironmentMvcEndpointTests {
@Before
@Before
public
void
setUp
()
{
public
void
setUp
()
{
this
.
mvc
=
MockMvcBuilders
.
webAppContextSetup
(
this
.
context
).
build
();
this
.
mvc
=
MockMvcBuilders
.
webAppContextSetup
(
this
.
context
).
build
();
SpringBoo
tTestUtils
.
addEnvironment
((
ConfigurableApplicationContext
)
this
.
context
,
"foo:bar"
);
Environmen
tTestUtils
.
addEnvironment
((
ConfigurableApplicationContext
)
this
.
context
,
"foo:bar"
);
}
}
@Test
@Test
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/JolokiaEndpointTests.java
View file @
c8152bfc
...
@@ -28,7 +28,7 @@ import org.springframework.boot.actuate.autoconfigure.ManagementServerProperties
...
@@ -28,7 +28,7 @@ import org.springframework.boot.actuate.autoconfigure.ManagementServerProperties
import
org.springframework.boot.actuate.endpoint.mvc.JolokiaEndpointTests.Config
;
import
org.springframework.boot.actuate.endpoint.mvc.JolokiaEndpointTests.Config
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.
SpringBoo
tTestUtils
;
import
org.springframework.boot.test.
Environmen
tTestUtils
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Import
;
import
org.springframework.context.annotation.Import
;
...
@@ -66,7 +66,7 @@ public class JolokiaEndpointTests {
...
@@ -66,7 +66,7 @@ public class JolokiaEndpointTests {
@Before
@Before
public
void
setUp
()
{
public
void
setUp
()
{
this
.
mvc
=
MockMvcBuilders
.
webAppContextSetup
(
this
.
context
).
build
();
this
.
mvc
=
MockMvcBuilders
.
webAppContextSetup
(
this
.
context
).
build
();
SpringBoo
tTestUtils
.
addEnvironment
((
ConfigurableApplicationContext
)
this
.
context
,
"foo:bar"
);
Environmen
tTestUtils
.
addEnvironment
((
ConfigurableApplicationContext
)
this
.
context
,
"foo:bar"
);
}
}
@Test
@Test
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/PropertyPlaceholderAutoConfigurationTests.java
View file @
c8152bfc
...
@@ -19,7 +19,7 @@ package org.springframework.boot.autoconfigure;
...
@@ -19,7 +19,7 @@ package org.springframework.boot.autoconfigure;
import
org.junit.After
;
import
org.junit.After
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.test.
SpringBoo
tTestUtils
;
import
org.springframework.boot.test.
Environmen
tTestUtils
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
...
@@ -48,7 +48,7 @@ public class PropertyPlaceholderAutoConfigurationTests {
...
@@ -48,7 +48,7 @@ public class PropertyPlaceholderAutoConfigurationTests {
public
void
propertyPlaceholderse
()
throws
Exception
{
public
void
propertyPlaceholderse
()
throws
Exception
{
this
.
context
.
register
(
PropertyPlaceholderAutoConfiguration
.
class
,
this
.
context
.
register
(
PropertyPlaceholderAutoConfiguration
.
class
,
PlaceholderConfig
.
class
);
PlaceholderConfig
.
class
);
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"foo:two"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"foo:two"
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
assertEquals
(
"two"
,
this
.
context
.
getBean
(
PlaceholderConfig
.
class
).
getFoo
());
assertEquals
(
"two"
,
this
.
context
.
getBean
(
PlaceholderConfig
.
class
).
getFoo
());
}
}
...
@@ -57,7 +57,7 @@ public class PropertyPlaceholderAutoConfigurationTests {
...
@@ -57,7 +57,7 @@ public class PropertyPlaceholderAutoConfigurationTests {
public
void
propertyPlaceholdersOverride
()
throws
Exception
{
public
void
propertyPlaceholdersOverride
()
throws
Exception
{
this
.
context
.
register
(
PropertyPlaceholderAutoConfiguration
.
class
,
this
.
context
.
register
(
PropertyPlaceholderAutoConfiguration
.
class
,
PlaceholderConfig
.
class
,
PlaceholdersOverride
.
class
);
PlaceholderConfig
.
class
,
PlaceholdersOverride
.
class
);
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"foo:two"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"foo:two"
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
assertEquals
(
"spam"
,
this
.
context
.
getBean
(
PlaceholderConfig
.
class
).
getFoo
());
assertEquals
(
"spam"
,
this
.
context
.
getBean
(
PlaceholderConfig
.
class
).
getFoo
());
}
}
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoconfigurationTests.java
View file @
c8152bfc
...
@@ -25,7 +25,7 @@ import org.springframework.amqp.rabbit.connection.ConnectionFactory;
...
@@ -25,7 +25,7 @@ import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import
org.springframework.amqp.rabbit.core.RabbitAdmin
;
import
org.springframework.amqp.rabbit.core.RabbitAdmin
;
import
org.springframework.amqp.rabbit.core.RabbitTemplate
;
import
org.springframework.amqp.rabbit.core.RabbitTemplate
;
import
org.springframework.beans.factory.NoSuchBeanDefinitionException
;
import
org.springframework.beans.factory.NoSuchBeanDefinitionException
;
import
org.springframework.boot.test.
SpringBoo
tTestUtils
;
import
org.springframework.boot.test.
Environmen
tTestUtils
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
...
@@ -65,7 +65,7 @@ public class RabbitAutoconfigurationTests {
...
@@ -65,7 +65,7 @@ public class RabbitAutoconfigurationTests {
public
void
testRabbitTemplateWithOverrides
()
{
public
void
testRabbitTemplateWithOverrides
()
{
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
.
register
(
TestConfiguration
.
class
,
RabbitAutoConfiguration
.
class
);
this
.
context
.
register
(
TestConfiguration
.
class
,
RabbitAutoConfiguration
.
class
);
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"spring.rabbitmq.host:remote-server"
,
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"spring.rabbitmq.host:remote-server"
,
"spring.rabbitmq.port:9000"
,
"spring.rabbitmq.username:alice"
,
"spring.rabbitmq.port:9000"
,
"spring.rabbitmq.username:alice"
,
"spring.rabbitmq.password:secret"
,
"spring.rabbitmq.virtual_host:/vhost"
);
"spring.rabbitmq.password:secret"
,
"spring.rabbitmq.virtual_host:/vhost"
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
...
@@ -80,7 +80,7 @@ public class RabbitAutoconfigurationTests {
...
@@ -80,7 +80,7 @@ public class RabbitAutoconfigurationTests {
public
void
testRabbitTemplateEmptyVirtualHost
()
{
public
void
testRabbitTemplateEmptyVirtualHost
()
{
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
.
register
(
TestConfiguration
.
class
,
RabbitAutoConfiguration
.
class
);
this
.
context
.
register
(
TestConfiguration
.
class
,
RabbitAutoConfiguration
.
class
);
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"spring.rabbitmq.virtual_host:"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"spring.rabbitmq.virtual_host:"
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
CachingConnectionFactory
connectionFactory
=
this
.
context
CachingConnectionFactory
connectionFactory
=
this
.
context
.
getBean
(
CachingConnectionFactory
.
class
);
.
getBean
(
CachingConnectionFactory
.
class
);
...
@@ -91,7 +91,7 @@ public class RabbitAutoconfigurationTests {
...
@@ -91,7 +91,7 @@ public class RabbitAutoconfigurationTests {
public
void
testRabbitTemplateVirtualHostMissingSlash
()
{
public
void
testRabbitTemplateVirtualHostMissingSlash
()
{
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
.
register
(
TestConfiguration
.
class
,
RabbitAutoConfiguration
.
class
);
this
.
context
.
register
(
TestConfiguration
.
class
,
RabbitAutoConfiguration
.
class
);
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"spring.rabbitmq.virtual_host:foo"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"spring.rabbitmq.virtual_host:foo"
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
CachingConnectionFactory
connectionFactory
=
this
.
context
CachingConnectionFactory
connectionFactory
=
this
.
context
.
getBean
(
CachingConnectionFactory
.
class
);
.
getBean
(
CachingConnectionFactory
.
class
);
...
@@ -102,7 +102,7 @@ public class RabbitAutoconfigurationTests {
...
@@ -102,7 +102,7 @@ public class RabbitAutoconfigurationTests {
public
void
testRabbitTemplateDefaultVirtualHost
()
{
public
void
testRabbitTemplateDefaultVirtualHost
()
{
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
.
register
(
TestConfiguration
.
class
,
RabbitAutoConfiguration
.
class
);
this
.
context
.
register
(
TestConfiguration
.
class
,
RabbitAutoConfiguration
.
class
);
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"spring.rabbitmq.virtual_host:/"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"spring.rabbitmq.virtual_host:/"
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
CachingConnectionFactory
connectionFactory
=
this
.
context
CachingConnectionFactory
connectionFactory
=
this
.
context
.
getBean
(
CachingConnectionFactory
.
class
);
.
getBean
(
CachingConnectionFactory
.
class
);
...
@@ -126,7 +126,7 @@ public class RabbitAutoconfigurationTests {
...
@@ -126,7 +126,7 @@ public class RabbitAutoconfigurationTests {
public
void
testStaticQueues
()
{
public
void
testStaticQueues
()
{
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
.
register
(
TestConfiguration
.
class
,
RabbitAutoConfiguration
.
class
);
this
.
context
.
register
(
TestConfiguration
.
class
,
RabbitAutoConfiguration
.
class
);
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"spring.rabbitmq.dynamic:false"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"spring.rabbitmq.dynamic:false"
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
// There should NOT be an AmqpAdmin bean when dynamic is switch to false
// There should NOT be an AmqpAdmin bean when dynamic is switch to false
this
.
thrown
.
expect
(
NoSuchBeanDefinitionException
.
class
);
this
.
thrown
.
expect
(
NoSuchBeanDefinitionException
.
class
);
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/aop/AopAutoConfigurationTests.java
View file @
c8152bfc
...
@@ -20,7 +20,7 @@ import org.aspectj.lang.annotation.Aspect;
...
@@ -20,7 +20,7 @@ import org.aspectj.lang.annotation.Aspect;
import
org.aspectj.lang.annotation.Before
;
import
org.aspectj.lang.annotation.Before
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
;
import
org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
;
import
org.springframework.boot.test.
SpringBoo
tTestUtils
;
import
org.springframework.boot.test.
Environmen
tTestUtils
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
...
@@ -42,7 +42,7 @@ public class AopAutoConfigurationTests {
...
@@ -42,7 +42,7 @@ public class AopAutoConfigurationTests {
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
.
register
(
TestConfiguration
.
class
,
AopAutoConfiguration
.
class
,
this
.
context
.
register
(
TestConfiguration
.
class
,
AopAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
);
PropertyPlaceholderAutoConfiguration
.
class
);
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"spring.aop.auto:false"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"spring.aop.auto:false"
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
TestAspect
aspect
=
this
.
context
.
getBean
(
TestAspect
.
class
);
TestAspect
aspect
=
this
.
context
.
getBean
(
TestAspect
.
class
);
assertFalse
(
aspect
.
isCalled
());
assertFalse
(
aspect
.
isCalled
());
...
@@ -56,7 +56,7 @@ public class AopAutoConfigurationTests {
...
@@ -56,7 +56,7 @@ public class AopAutoConfigurationTests {
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
.
register
(
TestConfiguration
.
class
,
AopAutoConfiguration
.
class
,
this
.
context
.
register
(
TestConfiguration
.
class
,
AopAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
);
PropertyPlaceholderAutoConfiguration
.
class
);
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"spring.aop.proxyTargetClass:true"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"spring.aop.proxyTargetClass:true"
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
TestAspect
aspect
=
this
.
context
.
getBean
(
TestAspect
.
class
);
TestAspect
aspect
=
this
.
context
.
getBean
(
TestAspect
.
class
);
assertFalse
(
aspect
.
isCalled
());
assertFalse
(
aspect
.
isCalled
());
...
@@ -70,7 +70,7 @@ public class AopAutoConfigurationTests {
...
@@ -70,7 +70,7 @@ public class AopAutoConfigurationTests {
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
.
register
(
TestConfiguration
.
class
,
AopAutoConfiguration
.
class
,
this
.
context
.
register
(
TestConfiguration
.
class
,
AopAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
);
PropertyPlaceholderAutoConfiguration
.
class
);
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"spring.aop.proxyTargetClass:false"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"spring.aop.proxyTargetClass:false"
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
TestAspect
aspect
=
this
.
context
.
getBean
(
TestAspect
.
class
);
TestAspect
aspect
=
this
.
context
.
getBean
(
TestAspect
.
class
);
assertFalse
(
aspect
.
isCalled
());
assertFalse
(
aspect
.
isCalled
());
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationTests.java
View file @
c8152bfc
...
@@ -44,7 +44,7 @@ import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfigurati
...
@@ -44,7 +44,7 @@ import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfigurati
import
org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration
;
import
org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration
;
import
org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration
;
import
org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration
;
import
org.springframework.boot.autoconfigure.orm.jpa.test.City
;
import
org.springframework.boot.autoconfigure.orm.jpa.test.City
;
import
org.springframework.boot.test.
SpringBoo
tTestUtils
;
import
org.springframework.boot.test.
Environmen
tTestUtils
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.context.annotation.ComponentScan
;
...
@@ -105,7 +105,7 @@ public class BatchAutoConfigurationTests {
...
@@ -105,7 +105,7 @@ public class BatchAutoConfigurationTests {
@Test
@Test
public
void
testDisableLaunchesJob
()
throws
Exception
{
public
void
testDisableLaunchesJob
()
throws
Exception
{
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
=
new
AnnotationConfigApplicationContext
();
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"spring.batch.job.enabled:false"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"spring.batch.job.enabled:false"
);
this
.
context
.
register
(
JobConfiguration
.
class
,
BatchAutoConfiguration
.
class
,
this
.
context
.
register
(
JobConfiguration
.
class
,
BatchAutoConfiguration
.
class
,
EmbeddedDataSourceConfiguration
.
class
,
EmbeddedDataSourceConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
);
PropertyPlaceholderAutoConfiguration
.
class
);
...
@@ -117,7 +117,7 @@ public class BatchAutoConfigurationTests {
...
@@ -117,7 +117,7 @@ public class BatchAutoConfigurationTests {
@Test
@Test
public
void
testDisableSchemaLoader
()
throws
Exception
{
public
void
testDisableSchemaLoader
()
throws
Exception
{
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
=
new
AnnotationConfigApplicationContext
();
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"spring.datasource.name:batchtest"
,
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"spring.datasource.name:batchtest"
,
"spring.batch.initializer.enabled:false"
);
"spring.batch.initializer.enabled:false"
);
this
.
context
.
register
(
TestConfiguration
.
class
,
BatchAutoConfiguration
.
class
,
this
.
context
.
register
(
TestConfiguration
.
class
,
BatchAutoConfiguration
.
class
,
EmbeddedDataSourceConfiguration
.
class
,
EmbeddedDataSourceConfiguration
.
class
,
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfigurationTests.java
View file @
c8152bfc
...
@@ -32,7 +32,7 @@ import org.apache.commons.dbcp.BasicDataSource;
...
@@ -32,7 +32,7 @@ import org.apache.commons.dbcp.BasicDataSource;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.mockito.Mockito
;
import
org.mockito.Mockito
;
import
org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
;
import
org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
;
import
org.springframework.boot.test.
SpringBoo
tTestUtils
;
import
org.springframework.boot.test.
Environmen
tTestUtils
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
...
@@ -66,7 +66,7 @@ public class DataSourceAutoConfigurationTests {
...
@@ -66,7 +66,7 @@ public class DataSourceAutoConfigurationTests {
@Test
@Test
public
void
testEmbeddedTypeDefaultsUsername
()
throws
Exception
{
public
void
testEmbeddedTypeDefaultsUsername
()
throws
Exception
{
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"spring.datasource.driverClassName:org.hsqldb.jdbcDriver"
,
"spring.datasource.driverClassName:org.hsqldb.jdbcDriver"
,
"spring.datasource.url:jdbc:hsqldb:mem:testdb"
);
"spring.datasource.url:jdbc:hsqldb:mem:testdb"
);
this
.
context
.
register
(
DataSourceAutoConfiguration
.
class
,
this
.
context
.
register
(
DataSourceAutoConfiguration
.
class
,
...
@@ -81,7 +81,7 @@ public class DataSourceAutoConfigurationTests {
...
@@ -81,7 +81,7 @@ public class DataSourceAutoConfigurationTests {
@Test
@Test
public
void
testExplicitDriverClassClearsUserName
()
throws
Exception
{
public
void
testExplicitDriverClassClearsUserName
()
throws
Exception
{
SpringBoo
tTestUtils
Environmen
tTestUtils
.
addEnvironment
(
.
addEnvironment
(
this
.
context
,
this
.
context
,
"spring.datasource.driverClassName:org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfigurationTests$DatabaseDriver"
,
"spring.datasource.driverClassName:org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfigurationTests$DatabaseDriver"
,
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/TomcatDataSourceConfigurationTests.java
View file @
c8152bfc
...
@@ -24,7 +24,7 @@ import org.junit.After;
...
@@ -24,7 +24,7 @@ import org.junit.After;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.springframework.beans.factory.BeanCreationException
;
import
org.springframework.beans.factory.BeanCreationException
;
import
org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
;
import
org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
;
import
org.springframework.boot.test.
SpringBoo
tTestUtils
;
import
org.springframework.boot.test.
Environmen
tTestUtils
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.util.ReflectionUtils
;
import
org.springframework.util.ReflectionUtils
;
...
@@ -56,7 +56,7 @@ public class TomcatDataSourceConfigurationTests {
...
@@ -56,7 +56,7 @@ public class TomcatDataSourceConfigurationTests {
@Test
@Test
public
void
testDataSourcePropertiesOverridden
()
throws
Exception
{
public
void
testDataSourcePropertiesOverridden
()
throws
Exception
{
this
.
context
.
register
(
TomcatDataSourceConfiguration
.
class
);
this
.
context
.
register
(
TomcatDataSourceConfiguration
.
class
);
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"spring.datasource.url:jdbc:foo//bar/spam"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"spring.datasource.url:jdbc:foo//bar/spam"
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
assertEquals
(
"jdbc:foo//bar/spam"
,
assertEquals
(
"jdbc:foo//bar/spam"
,
this
.
context
.
getBean
(
org
.
apache
.
tomcat
.
jdbc
.
pool
.
DataSource
.
class
)
this
.
context
.
getBean
(
org
.
apache
.
tomcat
.
jdbc
.
pool
.
DataSource
.
class
)
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/JmsTemplateAutoConfigurationTests.java
View file @
c8152bfc
...
@@ -23,7 +23,7 @@ import org.apache.activemq.pool.PooledConnectionFactory;
...
@@ -23,7 +23,7 @@ import org.apache.activemq.pool.PooledConnectionFactory;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.springframework.beans.BeansException
;
import
org.springframework.beans.BeansException
;
import
org.springframework.beans.factory.config.BeanPostProcessor
;
import
org.springframework.beans.factory.config.BeanPostProcessor
;
import
org.springframework.boot.test.
SpringBoo
tTestUtils
;
import
org.springframework.boot.test.
Environmen
tTestUtils
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
...
@@ -118,7 +118,7 @@ public class JmsTemplateAutoConfigurationTests {
...
@@ -118,7 +118,7 @@ public class JmsTemplateAutoConfigurationTests {
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
this
.
context
.
register
(
TestConfiguration
.
class
,
JmsTemplateAutoConfiguration
.
class
);
.
register
(
TestConfiguration
.
class
,
JmsTemplateAutoConfiguration
.
class
);
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"spring.jms.pubSubDomain:false"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"spring.jms.pubSubDomain:false"
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
JmsTemplate
jmsTemplate
=
this
.
context
.
getBean
(
JmsTemplate
.
class
);
JmsTemplate
jmsTemplate
=
this
.
context
.
getBean
(
JmsTemplate
.
class
);
ActiveMQConnectionFactory
connectionFactory
=
this
.
context
ActiveMQConnectionFactory
connectionFactory
=
this
.
context
...
@@ -134,7 +134,7 @@ public class JmsTemplateAutoConfigurationTests {
...
@@ -134,7 +134,7 @@ public class JmsTemplateAutoConfigurationTests {
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
this
.
context
.
register
(
TestConfiguration
.
class
,
JmsTemplateAutoConfiguration
.
class
);
.
register
(
TestConfiguration
.
class
,
JmsTemplateAutoConfiguration
.
class
);
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"spring.activemq.inMemory:false"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"spring.activemq.inMemory:false"
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
JmsTemplate
jmsTemplate
=
this
.
context
.
getBean
(
JmsTemplate
.
class
);
JmsTemplate
jmsTemplate
=
this
.
context
.
getBean
(
JmsTemplate
.
class
);
ActiveMQConnectionFactory
connectionFactory
=
this
.
context
ActiveMQConnectionFactory
connectionFactory
=
this
.
context
...
@@ -153,7 +153,7 @@ public class JmsTemplateAutoConfigurationTests {
...
@@ -153,7 +153,7 @@ public class JmsTemplateAutoConfigurationTests {
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
this
.
context
.
register
(
TestConfiguration
.
class
,
JmsTemplateAutoConfiguration
.
class
);
.
register
(
TestConfiguration
.
class
,
JmsTemplateAutoConfiguration
.
class
);
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"spring.activemq.inMemory:false"
,
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"spring.activemq.inMemory:false"
,
"spring.activemq.brokerURL:tcp://remote-host:10000"
);
"spring.activemq.brokerURL:tcp://remote-host:10000"
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
JmsTemplate
jmsTemplate
=
this
.
context
.
getBean
(
JmsTemplate
.
class
);
JmsTemplate
jmsTemplate
=
this
.
context
.
getBean
(
JmsTemplate
.
class
);
...
@@ -173,7 +173,7 @@ public class JmsTemplateAutoConfigurationTests {
...
@@ -173,7 +173,7 @@ public class JmsTemplateAutoConfigurationTests {
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
this
.
context
.
register
(
TestConfiguration
.
class
,
JmsTemplateAutoConfiguration
.
class
);
.
register
(
TestConfiguration
.
class
,
JmsTemplateAutoConfiguration
.
class
);
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"spring.activemq.pooled:true"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"spring.activemq.pooled:true"
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
JmsTemplate
jmsTemplate
=
this
.
context
.
getBean
(
JmsTemplate
.
class
);
JmsTemplate
jmsTemplate
=
this
.
context
.
getBean
(
JmsTemplate
.
class
);
PooledConnectionFactory
pool
=
this
.
context
PooledConnectionFactory
pool
=
this
.
context
...
@@ -191,7 +191,7 @@ public class JmsTemplateAutoConfigurationTests {
...
@@ -191,7 +191,7 @@ public class JmsTemplateAutoConfigurationTests {
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
this
.
context
.
register
(
TestConfiguration
.
class
,
JmsTemplateAutoConfiguration
.
class
);
.
register
(
TestConfiguration
.
class
,
JmsTemplateAutoConfiguration
.
class
);
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"spring.activemq.pooled:true"
,
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"spring.activemq.pooled:true"
,
"spring.activemq.inMemory:false"
);
"spring.activemq.inMemory:false"
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
JmsTemplate
jmsTemplate
=
this
.
context
.
getBean
(
JmsTemplate
.
class
);
JmsTemplate
jmsTemplate
=
this
.
context
.
getBean
(
JmsTemplate
.
class
);
...
@@ -210,7 +210,7 @@ public class JmsTemplateAutoConfigurationTests {
...
@@ -210,7 +210,7 @@ public class JmsTemplateAutoConfigurationTests {
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
this
.
context
.
register
(
TestConfiguration
.
class
,
JmsTemplateAutoConfiguration
.
class
);
.
register
(
TestConfiguration
.
class
,
JmsTemplateAutoConfiguration
.
class
);
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"spring.activemq.pooled:true"
,
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"spring.activemq.pooled:true"
,
"spring.activemq.inMemory:false"
,
"spring.activemq.inMemory:false"
,
"spring.activemq.brokerURL:tcp://remote-host:10000"
);
"spring.activemq.brokerURL:tcp://remote-host:10000"
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/AbstractJpaAutoConfigurationTests.java
View file @
c8152bfc
...
@@ -28,7 +28,7 @@ import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfigurati
...
@@ -28,7 +28,7 @@ import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfigurati
import
org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration
;
import
org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration
;
import
org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration
;
import
org.springframework.boot.autoconfigure.orm.jpa.test.City
;
import
org.springframework.boot.autoconfigure.orm.jpa.test.City
;
import
org.springframework.boot.test.
SpringBoo
tTestUtils
;
import
org.springframework.boot.test.
Environmen
tTestUtils
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
...
@@ -112,7 +112,7 @@ public abstract class AbstractJpaAutoConfigurationTests {
...
@@ -112,7 +112,7 @@ public abstract class AbstractJpaAutoConfigurationTests {
public
void
testOpenEntityManagerInViewInterceptorNotRegisteredWhenExplicitlyOff
()
public
void
testOpenEntityManagerInViewInterceptorNotRegisteredWhenExplicitlyOff
()
throws
Exception
{
throws
Exception
{
AnnotationConfigWebApplicationContext
context
=
new
AnnotationConfigWebApplicationContext
();
AnnotationConfigWebApplicationContext
context
=
new
AnnotationConfigWebApplicationContext
();
SpringBoo
tTestUtils
.
addEnvironment
(
context
,
"spring.jpa.open_in_view:false"
);
Environmen
tTestUtils
.
addEnvironment
(
context
,
"spring.jpa.open_in_view:false"
);
context
.
register
(
TestConfiguration
.
class
,
context
.
register
(
TestConfiguration
.
class
,
ComponentScanDetectorConfiguration
.
class
,
ComponentScanDetectorConfiguration
.
class
,
EmbeddedDataSourceConfiguration
.
class
,
EmbeddedDataSourceConfiguration
.
class
,
...
@@ -124,7 +124,7 @@ public abstract class AbstractJpaAutoConfigurationTests {
...
@@ -124,7 +124,7 @@ public abstract class AbstractJpaAutoConfigurationTests {
@Test
@Test
public
void
customJpaProperties
()
throws
Exception
{
public
void
customJpaProperties
()
throws
Exception
{
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"spring.jpa.properties.a:b"
,
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"spring.jpa.properties.a:b"
,
"spring.jpa.properties.c:d"
);
"spring.jpa.properties.c:d"
);
setupTestConfiguration
();
setupTestConfiguration
();
this
.
context
.
refresh
();
this
.
context
.
refresh
();
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfigurationTests.java
View file @
c8152bfc
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
orm
.
jpa
;
package
org
.
springframework
.
boot
.
autoconfigure
.
orm
.
jpa
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.springframework.boot.test.
SpringBoo
tTestUtils
;
import
org.springframework.boot.test.
Environmen
tTestUtils
;
import
org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean
;
import
org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean
;
import
static
org
.
hamcrest
.
Matchers
.
equalTo
;
import
static
org
.
hamcrest
.
Matchers
.
equalTo
;
...
@@ -38,7 +38,7 @@ public class HibernateJpaAutoConfigurationTests extends AbstractJpaAutoConfigura
...
@@ -38,7 +38,7 @@ public class HibernateJpaAutoConfigurationTests extends AbstractJpaAutoConfigura
@Test
@Test
public
void
testCustomNamingStrategy
()
throws
Exception
{
public
void
testCustomNamingStrategy
()
throws
Exception
{
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"spring.jpa.hibernate.namingstrategy:"
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"spring.jpa.hibernate.namingstrategy:"
+
"org.hibernate.cfg.EJB3NamingStrategy"
);
+
"org.hibernate.cfg.EJB3NamingStrategy"
);
setupTestConfiguration
();
setupTestConfiguration
();
this
.
context
.
refresh
();
this
.
context
.
refresh
();
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/redis/RedisAutoConfigurationTests.java
View file @
c8152bfc
...
@@ -18,7 +18,7 @@ package org.springframework.boot.autoconfigure.redis;
...
@@ -18,7 +18,7 @@ package org.springframework.boot.autoconfigure.redis;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
;
import
org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
;
import
org.springframework.boot.test.
SpringBoo
tTestUtils
;
import
org.springframework.boot.test.
Environmen
tTestUtils
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory
;
import
org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory
;
import
org.springframework.data.redis.core.RedisOperations
;
import
org.springframework.data.redis.core.RedisOperations
;
...
@@ -47,7 +47,7 @@ public class RedisAutoConfigurationTests {
...
@@ -47,7 +47,7 @@ public class RedisAutoConfigurationTests {
@Test
@Test
public
void
testOverrideRedisConfiguration
()
throws
Exception
{
public
void
testOverrideRedisConfiguration
()
throws
Exception
{
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
=
new
AnnotationConfigApplicationContext
();
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"spring.redis.host:foo"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"spring.redis.host:foo"
);
this
.
context
.
register
(
RedisAutoConfiguration
.
class
,
this
.
context
.
register
(
RedisAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
);
PropertyPlaceholderAutoConfiguration
.
class
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/SecurityAutoConfigurationTests.java
View file @
c8152bfc
...
@@ -26,7 +26,7 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
...
@@ -26,7 +26,7 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import
org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration
;
import
org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration
;
import
org.springframework.boot.autoconfigure.orm.jpa.test.City
;
import
org.springframework.boot.autoconfigure.orm.jpa.test.City
;
import
org.springframework.boot.context.listener.LoggingApplicationListener
;
import
org.springframework.boot.context.listener.LoggingApplicationListener
;
import
org.springframework.boot.test.
SpringBoo
tTestUtils
;
import
org.springframework.boot.test.
Environmen
tTestUtils
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
...
@@ -72,7 +72,7 @@ public class SecurityAutoConfigurationTests {
...
@@ -72,7 +72,7 @@ public class SecurityAutoConfigurationTests {
this
.
context
.
setServletContext
(
new
MockServletContext
());
this
.
context
.
setServletContext
(
new
MockServletContext
());
this
.
context
.
register
(
SecurityAutoConfiguration
.
class
,
this
.
context
.
register
(
SecurityAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
);
PropertyPlaceholderAutoConfiguration
.
class
);
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"security.ignored:none"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"security.ignored:none"
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
// Just the application endpoints now
// Just the application endpoints now
assertEquals
(
1
,
this
.
context
.
getBean
(
FilterChainProxy
.
class
).
getFilterChains
()
assertEquals
(
1
,
this
.
context
.
getBean
(
FilterChainProxy
.
class
).
getFilterChains
()
...
@@ -85,7 +85,7 @@ public class SecurityAutoConfigurationTests {
...
@@ -85,7 +85,7 @@ public class SecurityAutoConfigurationTests {
this
.
context
.
setServletContext
(
new
MockServletContext
());
this
.
context
.
setServletContext
(
new
MockServletContext
());
this
.
context
.
register
(
SecurityAutoConfiguration
.
class
,
this
.
context
.
register
(
SecurityAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
);
PropertyPlaceholderAutoConfiguration
.
class
);
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"security.basic.enabled:false"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"security.basic.enabled:false"
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
// No security at all not even ignores
// No security at all not even ignores
assertEquals
(
0
,
this
.
context
.
getBeanNamesForType
(
FilterChainProxy
.
class
).
length
);
assertEquals
(
0
,
this
.
context
.
getBeanNamesForType
(
FilterChainProxy
.
class
).
length
);
...
@@ -118,7 +118,7 @@ public class SecurityAutoConfigurationTests {
...
@@ -118,7 +118,7 @@ public class SecurityAutoConfigurationTests {
private
static
AnnotationConfigWebApplicationContext
debugRefresh
(
private
static
AnnotationConfigWebApplicationContext
debugRefresh
(
AnnotationConfigWebApplicationContext
context
)
{
AnnotationConfigWebApplicationContext
context
)
{
SpringBoo
tTestUtils
.
addEnvironment
(
context
,
"debug:true"
);
Environmen
tTestUtils
.
addEnvironment
(
context
,
"debug:true"
);
LoggingApplicationListener
logging
=
new
LoggingApplicationListener
();
LoggingApplicationListener
logging
=
new
LoggingApplicationListener
();
logging
.
onApplicationEvent
(
new
SpringApplicationBeforeRefreshEvent
(
logging
.
onApplicationEvent
(
new
SpringApplicationBeforeRefreshEvent
(
new
SpringApplication
(),
context
,
new
String
[
0
]));
new
SpringApplication
(),
context
,
new
String
[
0
]));
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesAutoConfigurationTests.java
View file @
c8152bfc
...
@@ -32,7 +32,7 @@ import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomi
...
@@ -32,7 +32,7 @@ import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomi
import
org.springframework.boot.context.embedded.EmbeddedServletContainerFactory
;
import
org.springframework.boot.context.embedded.EmbeddedServletContainerFactory
;
import
org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory
;
import
org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory
;
import
org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory
;
import
org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory
;
import
org.springframework.boot.test.
SpringBoo
tTestUtils
;
import
org.springframework.boot.test.
Environmen
tTestUtils
;
import
org.springframework.context.ApplicationContextException
;
import
org.springframework.context.ApplicationContextException
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
...
@@ -72,7 +72,7 @@ public class ServerPropertiesAutoConfigurationTests {
...
@@ -72,7 +72,7 @@ public class ServerPropertiesAutoConfigurationTests {
this
.
context
=
new
AnnotationConfigEmbeddedWebApplicationContext
();
this
.
context
=
new
AnnotationConfigEmbeddedWebApplicationContext
();
this
.
context
.
register
(
Config
.
class
,
ServerPropertiesAutoConfiguration
.
class
,
this
.
context
.
register
(
Config
.
class
,
ServerPropertiesAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
);
PropertyPlaceholderAutoConfiguration
.
class
);
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"server.port:9000"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"server.port:9000"
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
ServerProperties
server
=
this
.
context
.
getBean
(
ServerProperties
.
class
);
ServerProperties
server
=
this
.
context
.
getBean
(
ServerProperties
.
class
);
assertNotNull
(
server
);
assertNotNull
(
server
);
...
@@ -86,7 +86,7 @@ public class ServerPropertiesAutoConfigurationTests {
...
@@ -86,7 +86,7 @@ public class ServerPropertiesAutoConfigurationTests {
this
.
context
=
new
AnnotationConfigEmbeddedWebApplicationContext
();
this
.
context
=
new
AnnotationConfigEmbeddedWebApplicationContext
();
this
.
context
.
register
(
Config
.
class
,
ServerPropertiesAutoConfiguration
.
class
,
this
.
context
.
register
(
Config
.
class
,
ServerPropertiesAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
);
PropertyPlaceholderAutoConfiguration
.
class
);
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"server.tomcat.basedir:target/foo"
,
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"server.tomcat.basedir:target/foo"
,
"server.port:9000"
);
"server.port:9000"
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
ServerProperties
server
=
this
.
context
.
getBean
(
ServerProperties
.
class
);
ServerProperties
server
=
this
.
context
.
getBean
(
ServerProperties
.
class
);
...
...
spring-boot/src/test/java/org/springframework/boot/context/initializer/ContextIdApplicationContextInitializerTests.java
View file @
c8152bfc
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
package
org
.
springframework
.
boot
.
context
.
initializer
;
package
org
.
springframework
.
boot
.
context
.
initializer
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.springframework.boot.test.
SpringBoo
tTestUtils
;
import
org.springframework.boot.test.
Environmen
tTestUtils
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
...
@@ -42,7 +42,7 @@ public class ContextIdApplicationContextInitializerTests {
...
@@ -42,7 +42,7 @@ public class ContextIdApplicationContextInitializerTests {
@Test
@Test
public
void
testNameAndPort
()
{
public
void
testNameAndPort
()
{
ConfigurableApplicationContext
context
=
new
AnnotationConfigApplicationContext
();
ConfigurableApplicationContext
context
=
new
AnnotationConfigApplicationContext
();
SpringBoo
tTestUtils
.
addEnvironment
(
context
,
"spring.application.name:foo"
,
"PORT:8080"
);
Environmen
tTestUtils
.
addEnvironment
(
context
,
"spring.application.name:foo"
,
"PORT:8080"
);
this
.
initializer
.
initialize
(
context
);
this
.
initializer
.
initialize
(
context
);
assertEquals
(
"foo:8080"
,
context
.
getId
());
assertEquals
(
"foo:8080"
,
context
.
getId
());
}
}
...
@@ -50,7 +50,7 @@ public class ContextIdApplicationContextInitializerTests {
...
@@ -50,7 +50,7 @@ public class ContextIdApplicationContextInitializerTests {
@Test
@Test
public
void
testNameAndProfiles
()
{
public
void
testNameAndProfiles
()
{
ConfigurableApplicationContext
context
=
new
AnnotationConfigApplicationContext
();
ConfigurableApplicationContext
context
=
new
AnnotationConfigApplicationContext
();
SpringBoo
tTestUtils
.
addEnvironment
(
context
,
"spring.application.name:foo"
,
Environmen
tTestUtils
.
addEnvironment
(
context
,
"spring.application.name:foo"
,
"spring.profiles.active: spam,bar"
,
"spring.application.index:12"
);
"spring.profiles.active: spam,bar"
,
"spring.application.index:12"
);
this
.
initializer
.
initialize
(
context
);
this
.
initializer
.
initialize
(
context
);
assertEquals
(
"foo:spam,bar:12"
,
context
.
getId
());
assertEquals
(
"foo:spam,bar:12"
,
context
.
getId
());
...
@@ -59,7 +59,7 @@ public class ContextIdApplicationContextInitializerTests {
...
@@ -59,7 +59,7 @@ public class ContextIdApplicationContextInitializerTests {
@Test
@Test
public
void
testCloudFoundry
()
{
public
void
testCloudFoundry
()
{
ConfigurableApplicationContext
context
=
new
AnnotationConfigApplicationContext
();
ConfigurableApplicationContext
context
=
new
AnnotationConfigApplicationContext
();
SpringBoo
tTestUtils
.
addEnvironment
(
context
,
"spring.config.name:foo"
,
"PORT:8080"
,
Environmen
tTestUtils
.
addEnvironment
(
context
,
"spring.config.name:foo"
,
"PORT:8080"
,
"vcap.application.name:bar"
,
"vcap.application.instance_index:2"
);
"vcap.application.name:bar"
,
"vcap.application.instance_index:2"
);
this
.
initializer
.
initialize
(
context
);
this
.
initializer
.
initialize
(
context
);
assertEquals
(
"bar:2"
,
context
.
getId
());
assertEquals
(
"bar:2"
,
context
.
getId
());
...
@@ -68,7 +68,7 @@ public class ContextIdApplicationContextInitializerTests {
...
@@ -68,7 +68,7 @@ public class ContextIdApplicationContextInitializerTests {
@Test
@Test
public
void
testExplicitName
()
{
public
void
testExplicitName
()
{
ConfigurableApplicationContext
context
=
new
AnnotationConfigApplicationContext
();
ConfigurableApplicationContext
context
=
new
AnnotationConfigApplicationContext
();
SpringBoo
tTestUtils
.
addEnvironment
(
context
,
"spring.application.name:spam"
,
Environmen
tTestUtils
.
addEnvironment
(
context
,
"spring.application.name:spam"
,
"spring.config.name:foo"
,
"PORT:8080"
,
"vcap.application.name:bar"
,
"spring.config.name:foo"
,
"PORT:8080"
,
"vcap.application.name:bar"
,
"vcap.application.instance_index:2"
);
"vcap.application.instance_index:2"
);
this
.
initializer
.
initialize
(
context
);
this
.
initializer
.
initialize
(
context
);
...
...
spring-boot/src/test/java/org/springframework/boot/context/initializer/EnvironmentDelegateApplicationContextInitializerTests.java
View file @
c8152bfc
...
@@ -19,7 +19,7 @@ package org.springframework.boot.context.initializer;
...
@@ -19,7 +19,7 @@ package org.springframework.boot.context.initializer;
import
org.junit.Rule
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.rules.ExpectedException
;
import
org.junit.rules.ExpectedException
;
import
org.springframework.boot.test.
SpringBoo
tTestUtils
;
import
org.springframework.boot.test.
Environmen
tTestUtils
;
import
org.springframework.context.ApplicationContextException
;
import
org.springframework.context.ApplicationContextException
;
import
org.springframework.context.ApplicationContextInitializer
;
import
org.springframework.context.ApplicationContextInitializer
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.ConfigurableApplicationContext
;
...
@@ -46,7 +46,7 @@ public class EnvironmentDelegateApplicationContextInitializerTests {
...
@@ -46,7 +46,7 @@ public class EnvironmentDelegateApplicationContextInitializerTests {
@Test
@Test
public
void
orderedInitialize
()
throws
Exception
{
public
void
orderedInitialize
()
throws
Exception
{
StaticApplicationContext
context
=
new
StaticApplicationContext
();
StaticApplicationContext
context
=
new
StaticApplicationContext
();
SpringBoo
tTestUtils
.
addEnvironment
(
context
,
Environmen
tTestUtils
.
addEnvironment
(
context
,
"context.initializer.classes:"
+
MockInitB
.
class
.
getName
()
+
","
"context.initializer.classes:"
+
MockInitB
.
class
.
getName
()
+
","
+
MockInitA
.
class
.
getName
());
+
MockInitA
.
class
.
getName
());
this
.
initializer
.
initialize
(
context
);
this
.
initializer
.
initialize
(
context
);
...
@@ -63,14 +63,14 @@ public class EnvironmentDelegateApplicationContextInitializerTests {
...
@@ -63,14 +63,14 @@ public class EnvironmentDelegateApplicationContextInitializerTests {
@Test
@Test
public
void
emptyInitializers
()
throws
Exception
{
public
void
emptyInitializers
()
throws
Exception
{
StaticApplicationContext
context
=
new
StaticApplicationContext
();
StaticApplicationContext
context
=
new
StaticApplicationContext
();
SpringBoo
tTestUtils
.
addEnvironment
(
context
,
"context.initializer.classes:"
);
Environmen
tTestUtils
.
addEnvironment
(
context
,
"context.initializer.classes:"
);
this
.
initializer
.
initialize
(
context
);
this
.
initializer
.
initialize
(
context
);
}
}
@Test
@Test
public
void
noSuchInitializerClass
()
throws
Exception
{
public
void
noSuchInitializerClass
()
throws
Exception
{
StaticApplicationContext
context
=
new
StaticApplicationContext
();
StaticApplicationContext
context
=
new
StaticApplicationContext
();
SpringBoo
tTestUtils
.
addEnvironment
(
context
,
Environmen
tTestUtils
.
addEnvironment
(
context
,
"context.initializer.classes:missing.madeup.class"
);
"context.initializer.classes:missing.madeup.class"
);
this
.
thrown
.
expect
(
ApplicationContextException
.
class
);
this
.
thrown
.
expect
(
ApplicationContextException
.
class
);
this
.
initializer
.
initialize
(
context
);
this
.
initializer
.
initialize
(
context
);
...
@@ -79,7 +79,7 @@ public class EnvironmentDelegateApplicationContextInitializerTests {
...
@@ -79,7 +79,7 @@ public class EnvironmentDelegateApplicationContextInitializerTests {
@Test
@Test
public
void
notAnInitializerClass
()
throws
Exception
{
public
void
notAnInitializerClass
()
throws
Exception
{
StaticApplicationContext
context
=
new
StaticApplicationContext
();
StaticApplicationContext
context
=
new
StaticApplicationContext
();
SpringBoo
tTestUtils
.
addEnvironment
(
context
,
Environmen
tTestUtils
.
addEnvironment
(
context
,
"context.initializer.classes:"
+
Object
.
class
.
getName
());
"context.initializer.classes:"
+
Object
.
class
.
getName
());
this
.
thrown
.
expect
(
IllegalArgumentException
.
class
);
this
.
thrown
.
expect
(
IllegalArgumentException
.
class
);
this
.
initializer
.
initialize
(
context
);
this
.
initializer
.
initialize
(
context
);
...
@@ -88,7 +88,7 @@ public class EnvironmentDelegateApplicationContextInitializerTests {
...
@@ -88,7 +88,7 @@ public class EnvironmentDelegateApplicationContextInitializerTests {
@Test
@Test
public
void
genericNotSuitable
()
throws
Exception
{
public
void
genericNotSuitable
()
throws
Exception
{
StaticApplicationContext
context
=
new
StaticApplicationContext
();
StaticApplicationContext
context
=
new
StaticApplicationContext
();
SpringBoo
tTestUtils
.
addEnvironment
(
context
,
"context.initializer.classes:"
Environmen
tTestUtils
.
addEnvironment
(
context
,
"context.initializer.classes:"
+
NotSuitableInit
.
class
.
getName
());
+
NotSuitableInit
.
class
.
getName
());
this
.
thrown
.
expect
(
IllegalArgumentException
.
class
);
this
.
thrown
.
expect
(
IllegalArgumentException
.
class
);
this
.
thrown
.
expectMessage
(
"generic parameter"
);
this
.
thrown
.
expectMessage
(
"generic parameter"
);
...
...
spring-boot/src/test/java/org/springframework/boot/context/listener/ConfigFileApplicationListenerTests.java
View file @
c8152bfc
...
@@ -24,7 +24,7 @@ import org.junit.After;
...
@@ -24,7 +24,7 @@ import org.junit.After;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringApplicationEnvironmentAvailableEvent
;
import
org.springframework.boot.SpringApplicationEnvironmentAvailableEvent
;
import
org.springframework.boot.test.
SpringBoo
tTestUtils
;
import
org.springframework.boot.test.
Environmen
tTestUtils
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Profile
;
import
org.springframework.context.annotation.Profile
;
...
@@ -35,6 +35,7 @@ import org.springframework.core.env.StandardEnvironment;
...
@@ -35,6 +35,7 @@ import org.springframework.core.env.StandardEnvironment;
import
static
org
.
hamcrest
.
Matchers
.
contains
;
import
static
org
.
hamcrest
.
Matchers
.
contains
;
import
static
org
.
hamcrest
.
Matchers
.
equalTo
;
import
static
org
.
hamcrest
.
Matchers
.
equalTo
;
import
static
org
.
hamcrest
.
Matchers
.
is
;
import
static
org
.
hamcrest
.
Matchers
.
notNullValue
;
import
static
org
.
hamcrest
.
Matchers
.
notNullValue
;
import
static
org
.
hamcrest
.
Matchers
.
nullValue
;
import
static
org
.
hamcrest
.
Matchers
.
nullValue
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
...
@@ -59,6 +60,7 @@ public class ConfigFileApplicationListenerTests {
...
@@ -59,6 +60,7 @@ public class ConfigFileApplicationListenerTests {
@After
@After
public
void
cleanup
()
{
public
void
cleanup
()
{
System
.
clearProperty
(
"my.property"
);
System
.
clearProperty
(
"my.property"
);
System
.
clearProperty
(
"spring.config.location"
);
}
}
@Test
@Test
...
@@ -151,7 +153,7 @@ public class ConfigFileApplicationListenerTests {
...
@@ -151,7 +153,7 @@ public class ConfigFileApplicationListenerTests {
@Test
@Test
public
void
yamlProfileCanBeChanged
()
throws
Exception
{
public
void
yamlProfileCanBeChanged
()
throws
Exception
{
SpringBoo
tTestUtils
Environmen
tTestUtils
.
addEnviroment
(
this
.
environment
,
"spring.profiles.active:prod"
);
.
addEnviroment
(
this
.
environment
,
"spring.profiles.active:prod"
);
this
.
initializer
.
setNames
(
"testsetprofiles"
);
this
.
initializer
.
setNames
(
"testsetprofiles"
);
this
.
initializer
.
onApplicationEvent
(
this
.
event
);
this
.
initializer
.
onApplicationEvent
(
this
.
event
);
...
@@ -173,14 +175,17 @@ public class ConfigFileApplicationListenerTests {
...
@@ -173,14 +175,17 @@ public class ConfigFileApplicationListenerTests {
@Test
@Test
public
void
specificResource
()
throws
Exception
{
public
void
specificResource
()
throws
Exception
{
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
String
location
=
"classpath:specificlocation.properties"
;
map
.
put
(
"spring.config.location"
,
"classpath:/specificlocation.properties"
);
EnvironmentTestUtils
.
addEnviroment
(
this
.
environment
,
"spring.config.location:"
MapPropertySource
source
=
new
MapPropertySource
(
"map"
,
map
);
+
location
);
this
.
environment
.
getPropertySources
().
addFirst
(
source
);
this
.
initializer
.
onApplicationEvent
(
this
.
event
);
this
.
initializer
.
onApplicationEvent
(
this
.
event
);
String
property
=
this
.
environment
.
getProperty
(
"my.property"
);
String
property
=
this
.
environment
.
getProperty
(
"my.property"
);
assertThat
(
property
,
equalTo
(
"fromspecificlocation"
));
assertThat
(
property
,
equalTo
(
"fromspecificlocation"
));
assertThat
(
this
.
environment
.
getPropertySources
().
contains
(
location
),
is
(
true
));
// The default property source is still there
// The default property source is still there
assertThat
(
this
.
environment
.
getPropertySources
().
contains
(
"classpath:application.properties"
),
is
(
true
));
assertThat
(
this
.
environment
.
getProperty
(
"foo"
),
equalTo
(
"bucket"
));
assertThat
(
this
.
environment
.
getProperty
(
"foo"
),
equalTo
(
"bucket"
));
}
}
...
...
spring-boot/src/test/java/org/springframework/boot/context/listener/EnvironmentDelegateApplicationListenerTests.java
View file @
c8152bfc
...
@@ -22,7 +22,7 @@ import org.junit.Test;
...
@@ -22,7 +22,7 @@ import org.junit.Test;
import
org.junit.rules.ExpectedException
;
import
org.junit.rules.ExpectedException
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringApplicationEnvironmentAvailableEvent
;
import
org.springframework.boot.SpringApplicationEnvironmentAvailableEvent
;
import
org.springframework.boot.test.
SpringBoo
tTestUtils
;
import
org.springframework.boot.test.
Environmen
tTestUtils
;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.event.ContextRefreshedEvent
;
import
org.springframework.context.event.ContextRefreshedEvent
;
...
@@ -51,7 +51,7 @@ public class EnvironmentDelegateApplicationListenerTests {
...
@@ -51,7 +51,7 @@ public class EnvironmentDelegateApplicationListenerTests {
@Test
@Test
public
void
orderedInitialize
()
throws
Exception
{
public
void
orderedInitialize
()
throws
Exception
{
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"context.listener.classes:"
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"context.listener.classes:"
+
MockInitB
.
class
.
getName
()
+
","
+
MockInitA
.
class
.
getName
());
+
MockInitB
.
class
.
getName
()
+
","
+
MockInitA
.
class
.
getName
());
this
.
listener
.
onApplicationEvent
(
new
SpringApplicationEnvironmentAvailableEvent
(
this
.
listener
.
onApplicationEvent
(
new
SpringApplicationEnvironmentAvailableEvent
(
new
SpringApplication
(),
this
.
context
.
getEnvironment
(),
new
String
[
0
]));
new
SpringApplication
(),
this
.
context
.
getEnvironment
(),
new
String
[
0
]));
...
@@ -69,7 +69,7 @@ public class EnvironmentDelegateApplicationListenerTests {
...
@@ -69,7 +69,7 @@ public class EnvironmentDelegateApplicationListenerTests {
@Test
@Test
public
void
emptyInitializers
()
throws
Exception
{
public
void
emptyInitializers
()
throws
Exception
{
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"context.listener.classes:"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"context.listener.classes:"
);
this
.
listener
.
onApplicationEvent
(
new
SpringApplicationEnvironmentAvailableEvent
(
this
.
listener
.
onApplicationEvent
(
new
SpringApplicationEnvironmentAvailableEvent
(
new
SpringApplication
(),
this
.
context
.
getEnvironment
(),
new
String
[
0
]));
new
SpringApplication
(),
this
.
context
.
getEnvironment
(),
new
String
[
0
]));
}
}
...
...
spring-boot/src/test/java/org/springframework/boot/context/listener/FileEncodingApplicationListenerTests.java
View file @
c8152bfc
...
@@ -20,7 +20,7 @@ import org.junit.Assume;
...
@@ -20,7 +20,7 @@ import org.junit.Assume;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringApplicationEnvironmentAvailableEvent
;
import
org.springframework.boot.SpringApplicationEnvironmentAvailableEvent
;
import
org.springframework.boot.test.
SpringBoo
tTestUtils
;
import
org.springframework.boot.test.
Environmen
tTestUtils
;
import
org.springframework.core.env.ConfigurableEnvironment
;
import
org.springframework.core.env.ConfigurableEnvironment
;
import
org.springframework.core.env.StandardEnvironment
;
import
org.springframework.core.env.StandardEnvironment
;
...
@@ -36,7 +36,7 @@ public class FileEncodingApplicationListenerTests {
...
@@ -36,7 +36,7 @@ public class FileEncodingApplicationListenerTests {
@Test
(
expected
=
IllegalStateException
.
class
)
@Test
(
expected
=
IllegalStateException
.
class
)
public
void
testIllegalState
()
{
public
void
testIllegalState
()
{
SpringBoo
tTestUtils
.
addEnviroment
(
this
.
environment
,
"spring.mandatory_file_encoding:FOO"
);
Environmen
tTestUtils
.
addEnviroment
(
this
.
environment
,
"spring.mandatory_file_encoding:FOO"
);
this
.
initializer
.
onApplicationEvent
(
this
.
event
);
this
.
initializer
.
onApplicationEvent
(
this
.
event
);
}
}
...
@@ -48,7 +48,7 @@ public class FileEncodingApplicationListenerTests {
...
@@ -48,7 +48,7 @@ public class FileEncodingApplicationListenerTests {
@Test
@Test
public
void
testSunnyDayMandated
()
{
public
void
testSunnyDayMandated
()
{
Assume
.
assumeNotNull
(
System
.
getProperty
(
"file.encoding"
));
Assume
.
assumeNotNull
(
System
.
getProperty
(
"file.encoding"
));
SpringBoo
tTestUtils
.
addEnviroment
(
this
.
environment
,
"spring.mandatory_file_encoding:"
Environmen
tTestUtils
.
addEnviroment
(
this
.
environment
,
"spring.mandatory_file_encoding:"
+
System
.
getProperty
(
"file.encoding"
));
+
System
.
getProperty
(
"file.encoding"
));
this
.
initializer
.
onApplicationEvent
(
this
.
event
);
this
.
initializer
.
onApplicationEvent
(
this
.
event
);
}
}
...
...
spring-boot/src/test/java/org/springframework/boot/context/listener/LoggingApplicationListenerTests.java
View file @
c8152bfc
...
@@ -32,7 +32,7 @@ import org.springframework.boot.SpringApplication;
...
@@ -32,7 +32,7 @@ import org.springframework.boot.SpringApplication;
import
org.springframework.boot.SpringApplicationStartEvent
;
import
org.springframework.boot.SpringApplicationStartEvent
;
import
org.springframework.boot.logging.LogLevel
;
import
org.springframework.boot.logging.LogLevel
;
import
org.springframework.boot.logging.java.JavaLoggingSystem
;
import
org.springframework.boot.logging.java.JavaLoggingSystem
;
import
org.springframework.boot.test.
SpringBoo
tTestUtils
;
import
org.springframework.boot.test.
Environmen
tTestUtils
;
import
org.springframework.context.support.GenericApplicationContext
;
import
org.springframework.context.support.GenericApplicationContext
;
import
static
org
.
hamcrest
.
Matchers
.
containsString
;
import
static
org
.
hamcrest
.
Matchers
.
containsString
;
...
@@ -95,7 +95,7 @@ public class LoggingApplicationListenerTests {
...
@@ -95,7 +95,7 @@ public class LoggingApplicationListenerTests {
@Test
@Test
public
void
testOverrideConfigLocation
()
{
public
void
testOverrideConfigLocation
()
{
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"logging.config: classpath:logback-nondefault.xml"
);
"logging.config: classpath:logback-nondefault.xml"
);
this
.
initializer
.
initialize
(
this
.
context
.
getEnvironment
(),
this
.
initializer
.
initialize
(
this
.
context
.
getEnvironment
(),
this
.
context
.
getClassLoader
());
this
.
context
.
getClassLoader
());
...
@@ -108,7 +108,7 @@ public class LoggingApplicationListenerTests {
...
@@ -108,7 +108,7 @@ public class LoggingApplicationListenerTests {
@Test
@Test
public
void
testOverrideConfigDoesNotExist
()
throws
Exception
{
public
void
testOverrideConfigDoesNotExist
()
throws
Exception
{
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"logging.config: doesnotexist.xml"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"logging.config: doesnotexist.xml"
);
this
.
initializer
.
initialize
(
this
.
context
.
getEnvironment
(),
this
.
initializer
.
initialize
(
this
.
context
.
getEnvironment
(),
this
.
context
.
getClassLoader
());
this
.
context
.
getClassLoader
());
// Should not throw
// Should not throw
...
@@ -116,7 +116,7 @@ public class LoggingApplicationListenerTests {
...
@@ -116,7 +116,7 @@ public class LoggingApplicationListenerTests {
@Test
@Test
public
void
testAddLogFileProperty
()
{
public
void
testAddLogFileProperty
()
{
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"logging.config: classpath:logback-nondefault.xml"
,
"logging.config: classpath:logback-nondefault.xml"
,
"logging.file: foo.log"
);
"logging.file: foo.log"
);
this
.
initializer
.
initialize
(
this
.
context
.
getEnvironment
(),
this
.
initializer
.
initialize
(
this
.
context
.
getEnvironment
(),
...
@@ -129,7 +129,7 @@ public class LoggingApplicationListenerTests {
...
@@ -129,7 +129,7 @@ public class LoggingApplicationListenerTests {
@Test
@Test
public
void
testAddLogPathProperty
()
{
public
void
testAddLogPathProperty
()
{
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"logging.config: classpath:logback-nondefault.xml"
,
"logging.path: foo/"
);
"logging.config: classpath:logback-nondefault.xml"
,
"logging.path: foo/"
);
this
.
initializer
.
initialize
(
this
.
context
.
getEnvironment
(),
this
.
initializer
.
initialize
(
this
.
context
.
getEnvironment
(),
this
.
context
.
getClassLoader
());
this
.
context
.
getClassLoader
());
...
@@ -141,7 +141,7 @@ public class LoggingApplicationListenerTests {
...
@@ -141,7 +141,7 @@ public class LoggingApplicationListenerTests {
@Test
@Test
public
void
parseDebugArg
()
throws
Exception
{
public
void
parseDebugArg
()
throws
Exception
{
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"debug"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"debug"
);
this
.
initializer
.
initialize
(
this
.
context
.
getEnvironment
(),
this
.
initializer
.
initialize
(
this
.
context
.
getEnvironment
(),
this
.
context
.
getClassLoader
());
this
.
context
.
getClassLoader
());
this
.
logger
.
debug
(
"testatdebug"
);
this
.
logger
.
debug
(
"testatdebug"
);
...
@@ -152,7 +152,7 @@ public class LoggingApplicationListenerTests {
...
@@ -152,7 +152,7 @@ public class LoggingApplicationListenerTests {
@Test
@Test
public
void
parseTraceArg
()
throws
Exception
{
public
void
parseTraceArg
()
throws
Exception
{
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"trace"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"trace"
);
this
.
initializer
.
initialize
(
this
.
context
.
getEnvironment
(),
this
.
initializer
.
initialize
(
this
.
context
.
getEnvironment
(),
this
.
context
.
getClassLoader
());
this
.
context
.
getClassLoader
());
this
.
logger
.
debug
(
"testatdebug"
);
this
.
logger
.
debug
(
"testatdebug"
);
...
@@ -164,7 +164,7 @@ public class LoggingApplicationListenerTests {
...
@@ -164,7 +164,7 @@ public class LoggingApplicationListenerTests {
@Test
@Test
public
void
parseArgsDisabled
()
throws
Exception
{
public
void
parseArgsDisabled
()
throws
Exception
{
this
.
initializer
.
setParseArgs
(
false
);
this
.
initializer
.
setParseArgs
(
false
);
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"debug"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"debug"
);
this
.
initializer
.
initialize
(
this
.
context
.
getEnvironment
(),
this
.
initializer
.
initialize
(
this
.
context
.
getEnvironment
(),
this
.
context
.
getClassLoader
());
this
.
context
.
getClassLoader
());
this
.
logger
.
debug
(
"testatdebug"
);
this
.
logger
.
debug
(
"testatdebug"
);
...
...
spring-boot/src/test/java/org/springframework/boot/context/listener/VcapApplicationListenerTests.java
View file @
c8152bfc
...
@@ -19,7 +19,7 @@ package org.springframework.boot.context.listener;
...
@@ -19,7 +19,7 @@ package org.springframework.boot.context.listener;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringApplicationEnvironmentAvailableEvent
;
import
org.springframework.boot.SpringApplicationEnvironmentAvailableEvent
;
import
org.springframework.boot.test.
SpringBoo
tTestUtils
;
import
org.springframework.boot.test.
Environmen
tTestUtils
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
...
@@ -39,7 +39,7 @@ public class VcapApplicationListenerTests {
...
@@ -39,7 +39,7 @@ public class VcapApplicationListenerTests {
@Test
@Test
public
void
testApplicationProperties
()
{
public
void
testApplicationProperties
()
{
SpringBoo
tTestUtils
Environmen
tTestUtils
.
addEnvironment
(
.
addEnvironment
(
this
.
context
,
this
.
context
,
"VCAP_APPLICATION:{\"application_users\":[],\"instance_id\":\"bb7935245adf3e650dfb7c58a06e9ece\",\"instance_index\":0,\"version\":\"3464e092-1c13-462e-a47c-807c30318a50\",\"name\":\"foo\",\"uris\":[\"foo.cfapps.io\"],\"started_at\":\"2013-05-29 02:37:59 +0000\",\"started_at_timestamp\":1369795079,\"host\":\"0.0.0.0\",\"port\":61034,\"limits\":{\"mem\":128,\"disk\":1024,\"fds\":16384},\"version\":\"3464e092-1c13-462e-a47c-807c30318a50\",\"name\":\"dsyerenv\",\"uris\":[\"dsyerenv.cfapps.io\"],\"users\":[],\"start\":\"2013-05-29 02:37:59 +0000\",\"state_timestamp\":1369795079}"
);
"VCAP_APPLICATION:{\"application_users\":[],\"instance_id\":\"bb7935245adf3e650dfb7c58a06e9ece\",\"instance_index\":0,\"version\":\"3464e092-1c13-462e-a47c-807c30318a50\",\"name\":\"foo\",\"uris\":[\"foo.cfapps.io\"],\"started_at\":\"2013-05-29 02:37:59 +0000\",\"started_at_timestamp\":1369795079,\"host\":\"0.0.0.0\",\"port\":61034,\"limits\":{\"mem\":128,\"disk\":1024,\"fds\":16384},\"version\":\"3464e092-1c13-462e-a47c-807c30318a50\",\"name\":\"dsyerenv\",\"uris\":[\"dsyerenv.cfapps.io\"],\"users\":[],\"start\":\"2013-05-29 02:37:59 +0000\",\"state_timestamp\":1369795079}"
);
...
@@ -50,14 +50,14 @@ public class VcapApplicationListenerTests {
...
@@ -50,14 +50,14 @@ public class VcapApplicationListenerTests {
@Test
@Test
public
void
testUnparseableApplicationProperties
()
{
public
void
testUnparseableApplicationProperties
()
{
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"VCAP_APPLICATION:"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"VCAP_APPLICATION:"
);
this
.
initializer
.
onApplicationEvent
(
this
.
event
);
this
.
initializer
.
onApplicationEvent
(
this
.
event
);
assertEquals
(
null
,
this
.
context
.
getEnvironment
().
getProperty
(
"vcap"
));
assertEquals
(
null
,
this
.
context
.
getEnvironment
().
getProperty
(
"vcap"
));
}
}
@Test
@Test
public
void
testNullApplicationProperties
()
{
public
void
testNullApplicationProperties
()
{
SpringBoo
tTestUtils
Environmen
tTestUtils
.
addEnvironment
(
.
addEnvironment
(
this
.
context
,
this
.
context
,
"VCAP_APPLICATION:{\"application_users\":null,\"instance_id\":\"bb7935245adf3e650dfb7c58a06e9ece\",\"instance_index\":0,\"version\":\"3464e092-1c13-462e-a47c-807c30318a50\",\"name\":\"foo\",\"uris\":[\"foo.cfapps.io\"],\"started_at\":\"2013-05-29 02:37:59 +0000\",\"started_at_timestamp\":1369795079,\"host\":\"0.0.0.0\",\"port\":61034,\"limits\":{\"mem\":128,\"disk\":1024,\"fds\":16384},\"version\":\"3464e092-1c13-462e-a47c-807c30318a50\",\"name\":\"dsyerenv\",\"uris\":[\"dsyerenv.cfapps.io\"],\"users\":[],\"start\":\"2013-05-29 02:37:59 +0000\",\"state_timestamp\":1369795079}"
);
"VCAP_APPLICATION:{\"application_users\":null,\"instance_id\":\"bb7935245adf3e650dfb7c58a06e9ece\",\"instance_index\":0,\"version\":\"3464e092-1c13-462e-a47c-807c30318a50\",\"name\":\"foo\",\"uris\":[\"foo.cfapps.io\"],\"started_at\":\"2013-05-29 02:37:59 +0000\",\"started_at_timestamp\":1369795079,\"host\":\"0.0.0.0\",\"port\":61034,\"limits\":{\"mem\":128,\"disk\":1024,\"fds\":16384},\"version\":\"3464e092-1c13-462e-a47c-807c30318a50\",\"name\":\"dsyerenv\",\"uris\":[\"dsyerenv.cfapps.io\"],\"users\":[],\"start\":\"2013-05-29 02:37:59 +0000\",\"state_timestamp\":1369795079}"
);
...
@@ -67,7 +67,7 @@ public class VcapApplicationListenerTests {
...
@@ -67,7 +67,7 @@ public class VcapApplicationListenerTests {
@Test
@Test
public
void
testServiceProperties
()
{
public
void
testServiceProperties
()
{
SpringBoo
tTestUtils
Environmen
tTestUtils
.
addEnvironment
(
.
addEnvironment
(
this
.
context
,
this
.
context
,
"VCAP_SERVICES:{\"rds-mysql-n/a\":[{\"name\":\"mysql\",\"label\":\"rds-mysql-n/a\",\"plan\":\"10mb\",\"credentials\":{\"name\":\"d04fb13d27d964c62b267bbba1cffb9da\",\"hostname\":\"mysql-service-public.clqg2e2w3ecf.us-east-1.rds.amazonaws.com\",\"host\":\"mysql-service-public.clqg2e2w3ecf.us-east-1.rds.amazonaws.com\",\"port\":3306,\"user\":\"urpRuqTf8Cpe6\",\"username\":\"urpRuqTf8Cpe6\",\"password\":\"pxLsGVpsC9A5S\"}}]}"
);
"VCAP_SERVICES:{\"rds-mysql-n/a\":[{\"name\":\"mysql\",\"label\":\"rds-mysql-n/a\",\"plan\":\"10mb\",\"credentials\":{\"name\":\"d04fb13d27d964c62b267bbba1cffb9da\",\"hostname\":\"mysql-service-public.clqg2e2w3ecf.us-east-1.rds.amazonaws.com\",\"host\":\"mysql-service-public.clqg2e2w3ecf.us-east-1.rds.amazonaws.com\",\"port\":3306,\"user\":\"urpRuqTf8Cpe6\",\"username\":\"urpRuqTf8Cpe6\",\"password\":\"pxLsGVpsC9A5S\"}}]}"
);
...
...
spring-boot/src/test/java/org/springframework/boot/context/properties/EnableConfigurationPropertiesTests.java
View file @
c8152bfc
...
@@ -30,7 +30,7 @@ import org.junit.Rule;
...
@@ -30,7 +30,7 @@ import org.junit.Rule;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.rules.ExpectedException
;
import
org.junit.rules.ExpectedException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.
SpringBoo
tTestUtils
;
import
org.springframework.boot.test.
Environmen
tTestUtils
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
...
@@ -64,7 +64,7 @@ public class EnableConfigurationPropertiesTests {
...
@@ -64,7 +64,7 @@ public class EnableConfigurationPropertiesTests {
@Test
@Test
public
void
testBasicPropertiesBinding
()
{
public
void
testBasicPropertiesBinding
()
{
this
.
context
.
register
(
TestConfiguration
.
class
);
this
.
context
.
register
(
TestConfiguration
.
class
);
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"name:foo"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"name:foo"
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
assertEquals
(
1
,
this
.
context
.
getBeanNamesForType
(
TestProperties
.
class
).
length
);
assertEquals
(
1
,
this
.
context
.
getBeanNamesForType
(
TestProperties
.
class
).
length
);
assertEquals
(
"foo"
,
this
.
context
.
getBean
(
TestProperties
.
class
).
name
);
assertEquals
(
"foo"
,
this
.
context
.
getBean
(
TestProperties
.
class
).
name
);
...
@@ -105,7 +105,7 @@ public class EnableConfigurationPropertiesTests {
...
@@ -105,7 +105,7 @@ public class EnableConfigurationPropertiesTests {
public
void
testStrictPropertiesBinding
()
{
public
void
testStrictPropertiesBinding
()
{
removeSystemProperties
();
removeSystemProperties
();
this
.
context
.
register
(
StrictTestConfiguration
.
class
);
this
.
context
.
register
(
StrictTestConfiguration
.
class
);
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"name:foo"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"name:foo"
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
assertEquals
(
1
,
assertEquals
(
1
,
this
.
context
.
getBeanNamesForType
(
StrictTestProperties
.
class
).
length
);
this
.
context
.
getBeanNamesForType
(
StrictTestProperties
.
class
).
length
);
...
@@ -115,7 +115,7 @@ public class EnableConfigurationPropertiesTests {
...
@@ -115,7 +115,7 @@ public class EnableConfigurationPropertiesTests {
@Test
@Test
public
void
testPropertiesEmbeddedBinding
()
{
public
void
testPropertiesEmbeddedBinding
()
{
this
.
context
.
register
(
EmbeddedTestConfiguration
.
class
);
this
.
context
.
register
(
EmbeddedTestConfiguration
.
class
);
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"spring_foo_name:foo"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"spring_foo_name:foo"
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
assertEquals
(
1
,
assertEquals
(
1
,
this
.
context
.
getBeanNamesForType
(
EmbeddedTestProperties
.
class
).
length
);
this
.
context
.
getBeanNamesForType
(
EmbeddedTestProperties
.
class
).
length
);
...
@@ -126,7 +126,7 @@ public class EnableConfigurationPropertiesTests {
...
@@ -126,7 +126,7 @@ public class EnableConfigurationPropertiesTests {
public
void
testIgnoreNestedPropertiesBinding
()
{
public
void
testIgnoreNestedPropertiesBinding
()
{
removeSystemProperties
();
removeSystemProperties
();
this
.
context
.
register
(
IgnoreNestedTestConfiguration
.
class
);
this
.
context
.
register
(
IgnoreNestedTestConfiguration
.
class
);
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"name:foo"
,
"nested.name:bar"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"name:foo"
,
"nested.name:bar"
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
assertEquals
(
1
,
assertEquals
(
1
,
this
.
context
.
getBeanNamesForType
(
IgnoreNestedTestProperties
.
class
).
length
);
this
.
context
.
getBeanNamesForType
(
IgnoreNestedTestProperties
.
class
).
length
);
...
@@ -136,7 +136,7 @@ public class EnableConfigurationPropertiesTests {
...
@@ -136,7 +136,7 @@ public class EnableConfigurationPropertiesTests {
@Test
@Test
public
void
testExceptionOnValidation
()
{
public
void
testExceptionOnValidation
()
{
this
.
context
.
register
(
ExceptionIfInvalidTestConfiguration
.
class
);
this
.
context
.
register
(
ExceptionIfInvalidTestConfiguration
.
class
);
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"name:foo"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"name:foo"
);
this
.
expected
.
expectCause
(
Matchers
.<
Throwable
>
instanceOf
(
BindException
.
class
));
this
.
expected
.
expectCause
(
Matchers
.<
Throwable
>
instanceOf
(
BindException
.
class
));
this
.
context
.
refresh
();
this
.
context
.
refresh
();
}
}
...
@@ -144,7 +144,7 @@ public class EnableConfigurationPropertiesTests {
...
@@ -144,7 +144,7 @@ public class EnableConfigurationPropertiesTests {
@Test
@Test
public
void
testNoExceptionOnValidation
()
{
public
void
testNoExceptionOnValidation
()
{
this
.
context
.
register
(
NoExceptionIfInvalidTestConfiguration
.
class
);
this
.
context
.
register
(
NoExceptionIfInvalidTestConfiguration
.
class
);
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"name:foo"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"name:foo"
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
assertEquals
(
assertEquals
(
1
,
1
,
...
@@ -156,7 +156,7 @@ public class EnableConfigurationPropertiesTests {
...
@@ -156,7 +156,7 @@ public class EnableConfigurationPropertiesTests {
@Test
@Test
public
void
testNestedPropertiesBinding
()
{
public
void
testNestedPropertiesBinding
()
{
this
.
context
.
register
(
NestedConfiguration
.
class
);
this
.
context
.
register
(
NestedConfiguration
.
class
);
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"name:foo"
,
"nested.name:bar"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"name:foo"
,
"nested.name:bar"
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
assertEquals
(
1
,
this
.
context
.
getBeanNamesForType
(
NestedProperties
.
class
).
length
);
assertEquals
(
1
,
this
.
context
.
getBeanNamesForType
(
NestedProperties
.
class
).
length
);
assertEquals
(
"foo"
,
this
.
context
.
getBean
(
NestedProperties
.
class
).
name
);
assertEquals
(
"foo"
,
this
.
context
.
getBean
(
NestedProperties
.
class
).
name
);
...
@@ -166,7 +166,7 @@ public class EnableConfigurationPropertiesTests {
...
@@ -166,7 +166,7 @@ public class EnableConfigurationPropertiesTests {
@Test
@Test
public
void
testBasicPropertiesBindingWithAnnotationOnBaseClass
()
{
public
void
testBasicPropertiesBindingWithAnnotationOnBaseClass
()
{
this
.
context
.
register
(
DerivedConfiguration
.
class
);
this
.
context
.
register
(
DerivedConfiguration
.
class
);
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"name:foo"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"name:foo"
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
assertEquals
(
1
,
this
.
context
.
getBeanNamesForType
(
DerivedProperties
.
class
).
length
);
assertEquals
(
1
,
this
.
context
.
getBeanNamesForType
(
DerivedProperties
.
class
).
length
);
assertEquals
(
"foo"
,
this
.
context
.
getBean
(
BaseProperties
.
class
).
name
);
assertEquals
(
"foo"
,
this
.
context
.
getBean
(
BaseProperties
.
class
).
name
);
...
@@ -175,7 +175,7 @@ public class EnableConfigurationPropertiesTests {
...
@@ -175,7 +175,7 @@ public class EnableConfigurationPropertiesTests {
@Test
@Test
public
void
testArrayPropertiesBinding
()
{
public
void
testArrayPropertiesBinding
()
{
this
.
context
.
register
(
TestConfiguration
.
class
);
this
.
context
.
register
(
TestConfiguration
.
class
);
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"name:foo"
,
"array:1,2,3"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"name:foo"
,
"array:1,2,3"
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
assertEquals
(
1
,
this
.
context
.
getBeanNamesForType
(
TestProperties
.
class
).
length
);
assertEquals
(
1
,
this
.
context
.
getBeanNamesForType
(
TestProperties
.
class
).
length
);
assertEquals
(
3
,
this
.
context
.
getBean
(
TestProperties
.
class
).
getArray
().
length
);
assertEquals
(
3
,
this
.
context
.
getBean
(
TestProperties
.
class
).
getArray
().
length
);
...
@@ -184,7 +184,7 @@ public class EnableConfigurationPropertiesTests {
...
@@ -184,7 +184,7 @@ public class EnableConfigurationPropertiesTests {
@Test
@Test
public
void
testCollectionPropertiesBindingFromYamlArray
()
{
public
void
testCollectionPropertiesBindingFromYamlArray
()
{
this
.
context
.
register
(
TestConfiguration
.
class
);
this
.
context
.
register
(
TestConfiguration
.
class
);
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"name:foo"
,
"list[0]:1"
,
"list[1]:2"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"name:foo"
,
"list[0]:1"
,
"list[1]:2"
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
assertEquals
(
2
,
this
.
context
.
getBean
(
TestProperties
.
class
).
getList
().
size
());
assertEquals
(
2
,
this
.
context
.
getBean
(
TestProperties
.
class
).
getList
().
size
());
}
}
...
@@ -192,7 +192,7 @@ public class EnableConfigurationPropertiesTests {
...
@@ -192,7 +192,7 @@ public class EnableConfigurationPropertiesTests {
@Test
@Test
public
void
testPropertiesBindingWithoutAnnotation
()
{
public
void
testPropertiesBindingWithoutAnnotation
()
{
this
.
context
.
register
(
MoreConfiguration
.
class
);
this
.
context
.
register
(
MoreConfiguration
.
class
);
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"name:foo"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"name:foo"
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
assertEquals
(
1
,
this
.
context
.
getBeanNamesForType
(
MoreProperties
.
class
).
length
);
assertEquals
(
1
,
this
.
context
.
getBeanNamesForType
(
MoreProperties
.
class
).
length
);
assertEquals
(
"foo"
,
this
.
context
.
getBean
(
MoreProperties
.
class
).
name
);
assertEquals
(
"foo"
,
this
.
context
.
getBean
(
MoreProperties
.
class
).
name
);
...
@@ -227,7 +227,7 @@ public class EnableConfigurationPropertiesTests {
...
@@ -227,7 +227,7 @@ public class EnableConfigurationPropertiesTests {
@Test
@Test
public
void
testBindingDirectlyToFileResolvedFromEnvironment
()
{
public
void
testBindingDirectlyToFileResolvedFromEnvironment
()
{
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"binding.location:classpath:other.yml"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"binding.location:classpath:other.yml"
);
this
.
context
.
register
(
ResourceBindingProperties
.
class
,
TestConfiguration
.
class
);
this
.
context
.
register
(
ResourceBindingProperties
.
class
,
TestConfiguration
.
class
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
assertEquals
(
1
,
assertEquals
(
1
,
...
@@ -268,7 +268,7 @@ public class EnableConfigurationPropertiesTests {
...
@@ -268,7 +268,7 @@ public class EnableConfigurationPropertiesTests {
AnnotationConfigApplicationContext
parent
=
new
AnnotationConfigApplicationContext
();
AnnotationConfigApplicationContext
parent
=
new
AnnotationConfigApplicationContext
();
parent
.
register
(
TestConfiguration
.
class
);
parent
.
register
(
TestConfiguration
.
class
);
parent
.
refresh
();
parent
.
refresh
();
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"name:foo"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"name:foo"
);
this
.
context
.
setParent
(
parent
);
this
.
context
.
setParent
(
parent
);
this
.
context
.
register
(
TestConfiguration
.
class
,
TestConsumer
.
class
);
this
.
context
.
register
(
TestConfiguration
.
class
,
TestConsumer
.
class
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
...
@@ -280,7 +280,7 @@ public class EnableConfigurationPropertiesTests {
...
@@ -280,7 +280,7 @@ public class EnableConfigurationPropertiesTests {
@Test
@Test
public
void
testBindingOnlyParentContext
()
{
public
void
testBindingOnlyParentContext
()
{
AnnotationConfigApplicationContext
parent
=
new
AnnotationConfigApplicationContext
();
AnnotationConfigApplicationContext
parent
=
new
AnnotationConfigApplicationContext
();
SpringBoo
tTestUtils
.
addEnvironment
(
parent
,
"name:foo"
);
Environmen
tTestUtils
.
addEnvironment
(
parent
,
"name:foo"
);
parent
.
register
(
TestConfiguration
.
class
);
parent
.
register
(
TestConfiguration
.
class
);
parent
.
refresh
();
parent
.
refresh
();
this
.
context
.
setParent
(
parent
);
this
.
context
.
setParent
(
parent
);
...
@@ -293,7 +293,7 @@ public class EnableConfigurationPropertiesTests {
...
@@ -293,7 +293,7 @@ public class EnableConfigurationPropertiesTests {
@Test
@Test
public
void
testUnderscoresInPrefix
()
throws
Exception
{
public
void
testUnderscoresInPrefix
()
throws
Exception
{
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"spring_test_external_val:baz"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"spring_test_external_val:baz"
);
this
.
context
.
register
(
SystemExampleConfig
.
class
);
this
.
context
.
register
(
SystemExampleConfig
.
class
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
assertEquals
(
"baz"
,
this
.
context
.
getBean
(
SystemEnvVar
.
class
).
getVal
());
assertEquals
(
"baz"
,
this
.
context
.
getBean
(
SystemEnvVar
.
class
).
getVal
());
...
@@ -301,7 +301,7 @@ public class EnableConfigurationPropertiesTests {
...
@@ -301,7 +301,7 @@ public class EnableConfigurationPropertiesTests {
@Test
@Test
public
void
testSimpleAutoConfig
()
throws
Exception
{
public
void
testSimpleAutoConfig
()
throws
Exception
{
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"external.name:foo"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"external.name:foo"
);
this
.
context
.
register
(
ExampleConfig
.
class
);
this
.
context
.
register
(
ExampleConfig
.
class
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
assertEquals
(
"foo"
,
this
.
context
.
getBean
(
External
.
class
).
getName
());
assertEquals
(
"foo"
,
this
.
context
.
getBean
(
External
.
class
).
getName
());
...
@@ -309,7 +309,7 @@ public class EnableConfigurationPropertiesTests {
...
@@ -309,7 +309,7 @@ public class EnableConfigurationPropertiesTests {
@Test
@Test
public
void
testExplicitType
()
throws
Exception
{
public
void
testExplicitType
()
throws
Exception
{
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"external.name:foo"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"external.name:foo"
);
this
.
context
.
register
(
AnotherExampleConfig
.
class
);
this
.
context
.
register
(
AnotherExampleConfig
.
class
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
assertEquals
(
"foo"
,
this
.
context
.
getBean
(
External
.
class
).
getName
());
assertEquals
(
"foo"
,
this
.
context
.
getBean
(
External
.
class
).
getName
());
...
@@ -317,7 +317,7 @@ public class EnableConfigurationPropertiesTests {
...
@@ -317,7 +317,7 @@ public class EnableConfigurationPropertiesTests {
@Test
@Test
public
void
testMultipleExplicitTypes
()
throws
Exception
{
public
void
testMultipleExplicitTypes
()
throws
Exception
{
SpringBoo
tTestUtils
.
addEnvironment
(
this
.
context
,
"external.name:foo"
,
"another.name:bar"
);
Environmen
tTestUtils
.
addEnvironment
(
this
.
context
,
"external.name:foo"
,
"another.name:bar"
);
this
.
context
.
register
(
FurtherExampleConfig
.
class
);
this
.
context
.
register
(
FurtherExampleConfig
.
class
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
assertEquals
(
"foo"
,
this
.
context
.
getBean
(
External
.
class
).
getName
());
assertEquals
(
"foo"
,
this
.
context
.
getBean
(
External
.
class
).
getName
());
...
...
spring-boot/src/test/java/org/springframework/boot/test/
SpringBoo
tTestUtils.java
→
spring-boot/src/test/java/org/springframework/boot/test/
Environmen
tTestUtils.java
View file @
c8152bfc
...
@@ -24,18 +24,18 @@ import org.springframework.core.env.ConfigurableEnvironment;
...
@@ -24,18 +24,18 @@ import org.springframework.core.env.ConfigurableEnvironment;
import
org.springframework.core.env.MapPropertySource
;
import
org.springframework.core.env.MapPropertySource
;
/**
/**
*
General test utiliti
es.
*
Test utilities for setting environment valu
es.
*
*
* @author Dave Syer
* @author Dave Syer
*/
*/
public
abstract
class
SpringBoo
tTestUtils
{
public
abstract
class
Environmen
tTestUtils
{
public
static
void
addEnvironment
(
ConfigurableApplicationContext
context
,
public
static
void
addEnvironment
(
ConfigurableApplicationContext
context
,
String
...
pairs
)
{
String
...
pairs
)
{
addEnviroment
(
context
.
getEnvironment
(),
pairs
);
addEnviroment
(
context
.
getEnvironment
(),
pairs
);
}
}
public
static
void
addEnviroment
(
ConfigurableEnvironment
enviroment
,
String
...
pairs
)
{
public
static
void
addEnviroment
(
ConfigurableEnvironment
enviro
n
ment
,
String
...
pairs
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
for
(
String
pair
:
pairs
)
{
for
(
String
pair
:
pairs
)
{
int
index
=
pair
.
indexOf
(
":"
);
int
index
=
pair
.
indexOf
(
":"
);
...
@@ -43,7 +43,7 @@ public abstract class SpringBootTestUtils {
...
@@ -43,7 +43,7 @@ public abstract class SpringBootTestUtils {
String
value
=
index
>
0
?
pair
.
substring
(
index
+
1
)
:
""
;
String
value
=
index
>
0
?
pair
.
substring
(
index
+
1
)
:
""
;
map
.
put
(
key
.
trim
(),
value
.
trim
());
map
.
put
(
key
.
trim
(),
value
.
trim
());
}
}
enviroment
.
getPropertySources
().
addFirst
(
new
MapPropertySource
(
"test"
,
map
));
enviro
n
ment
.
getPropertySources
().
addFirst
(
new
MapPropertySource
(
"test"
,
map
));
}
}
}
}
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