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
6381fdcb
Commit
6381fdcb
authored
May 26, 2014
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
96adb87b
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
77 additions
and
29 deletions
+77
-29
FlywayDataSource.java
...framework/boot/autoconfigure/flyway/FlywayDataSource.java
+2
-1
FlywayProperties.java
...framework/boot/autoconfigure/flyway/FlywayProperties.java
+1
-2
DeviceResolverAutoConfiguration.java
...autoconfigure/mobile/DeviceResolverAutoConfiguration.java
+2
-2
SitePreferenceAutoConfiguration.java
...autoconfigure/mobile/SitePreferenceAutoConfiguration.java
+4
-4
FlywayAutoConfigurationTests.java
...ot/autoconfigure/flyway/FlywayAutoConfigurationTests.java
+1
-2
DeviceResolverAutoConfigurationTests.java
...onfigure/mobile/DeviceResolverAutoConfigurationTests.java
+5
-4
howto.adoc
spring-boot-docs/src/main/asciidoc/howto.adoc
+2
-2
spring-boot-features.adoc
spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
+13
-7
PropertySourcesPropertyValues.java
...ingframework/boot/bind/PropertySourcesPropertyValues.java
+1
-1
ConfigFileApplicationListener.java
...rk/boot/context/config/ConfigFileApplicationListener.java
+2
-2
PropertySourcesBindingTests.java
...pringframework/boot/bind/PropertySourcesBindingTests.java
+22
-1
SimplerPropertySourcesBindingTests.java
...amework/boot/bind/SimplerPropertySourcesBindingTests.java
+22
-1
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayDataSource.java
View file @
6381fdcb
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -29,6 +29,7 @@ import org.springframework.beans.factory.annotation.Qualifier;
...
@@ -29,6 +29,7 @@ import org.springframework.beans.factory.annotation.Qualifier;
* data source, the other (main) one would normally be marked as <code>@Primary</code>.
* data source, the other (main) one would normally be marked as <code>@Primary</code>.
*
*
* @author Dave Syer
* @author Dave Syer
* @since 1.1.0
*/
*/
@Target
({
ElementType
.
FIELD
,
ElementType
.
METHOD
,
ElementType
.
PARAMETER
,
ElementType
.
TYPE
,
@Target
({
ElementType
.
FIELD
,
ElementType
.
METHOD
,
ElementType
.
PARAMETER
,
ElementType
.
TYPE
,
ElementType
.
ANNOTATION_TYPE
})
ElementType
.
ANNOTATION_TYPE
})
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java
View file @
6381fdcb
...
@@ -30,7 +30,6 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
...
@@ -30,7 +30,6 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
* properties into the {@link Flyway} instance.
* properties into the {@link Flyway} instance.
*
*
* @author Dave Syer
* @author Dave Syer
*
* @since 1.1.0
* @since 1.1.0
*/
*/
@ConfigurationProperties
(
prefix
=
"flyway"
,
ignoreUnknownFields
=
true
)
@ConfigurationProperties
(
prefix
=
"flyway"
,
ignoreUnknownFields
=
true
)
...
@@ -83,7 +82,7 @@ public class FlywayProperties {
...
@@ -83,7 +82,7 @@ public class FlywayProperties {
}
}
public
String
getPassword
()
{
public
String
getPassword
()
{
return
this
.
password
==
null
?
""
:
this
.
password
;
return
(
this
.
password
==
null
?
""
:
this
.
password
)
;
}
}
public
void
setPassword
(
String
password
)
{
public
void
setPassword
(
String
password
)
{
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mobile/DeviceResolverAutoConfiguration.java
View file @
6381fdcb
...
@@ -42,7 +42,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
...
@@ -42,7 +42,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
*/
*/
@Configuration
@Configuration
@ConditionalOnClass
({
DeviceResolverHandlerInterceptor
.
class
,
@ConditionalOnClass
({
DeviceResolverHandlerInterceptor
.
class
,
DeviceHandlerMethodArgumentResolver
.
class
})
DeviceHandlerMethodArgumentResolver
.
class
})
@AutoConfigureAfter
(
WebMvcAutoConfiguration
.
class
)
@AutoConfigureAfter
(
WebMvcAutoConfiguration
.
class
)
public
class
DeviceResolverAutoConfiguration
{
public
class
DeviceResolverAutoConfiguration
{
...
@@ -67,7 +67,7 @@ public class DeviceResolverAutoConfiguration {
...
@@ -67,7 +67,7 @@ public class DeviceResolverAutoConfiguration {
@Override
@Override
public
void
addInterceptors
(
InterceptorRegistry
registry
)
{
public
void
addInterceptors
(
InterceptorRegistry
registry
)
{
registry
.
addInterceptor
(
deviceResolverHandlerInterceptor
);
registry
.
addInterceptor
(
this
.
deviceResolverHandlerInterceptor
);
}
}
@Override
@Override
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mobile/SitePreferenceAutoConfiguration.java
View file @
6381fdcb
...
@@ -39,13 +39,13 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
...
@@ -39,13 +39,13 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
* {@link EnableAutoConfiguration Auto-configuration} for Spring Mobile's
* {@link EnableAutoConfiguration Auto-configuration} for Spring Mobile's
* {@link SitePreferenceHandler}. The site preference feature depends on a
* {@link SitePreferenceHandler}. The site preference feature depends on a
* {@link DeviceResolver} first being registered.
* {@link DeviceResolver} first being registered.
*
*
* @author Roy Clarkson
* @author Roy Clarkson
* @since 1.1
* @since 1.1
.0
*/
*/
@Configuration
@Configuration
@ConditionalOnClass
({
SitePreferenceHandlerInterceptor
.
class
,
@ConditionalOnClass
({
SitePreferenceHandlerInterceptor
.
class
,
SitePreferenceHandlerMethodArgumentResolver
.
class
})
SitePreferenceHandlerMethodArgumentResolver
.
class
})
@AutoConfigureAfter
(
DeviceResolverAutoConfiguration
.
class
)
@AutoConfigureAfter
(
DeviceResolverAutoConfiguration
.
class
)
@ConditionalOnExpression
(
"${spring.mobile.enableSitePreference:true}"
)
@ConditionalOnExpression
(
"${spring.mobile.enableSitePreference:true}"
)
public
class
SitePreferenceAutoConfiguration
{
public
class
SitePreferenceAutoConfiguration
{
...
@@ -71,7 +71,7 @@ public class SitePreferenceAutoConfiguration {
...
@@ -71,7 +71,7 @@ public class SitePreferenceAutoConfiguration {
@Override
@Override
public
void
addInterceptors
(
InterceptorRegistry
registry
)
{
public
void
addInterceptors
(
InterceptorRegistry
registry
)
{
registry
.
addInterceptor
(
sitePreferenceHandlerInterceptor
);
registry
.
addInterceptor
(
this
.
sitePreferenceHandlerInterceptor
);
}
}
@Override
@Override
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java
View file @
6381fdcb
...
@@ -30,7 +30,6 @@ import org.springframework.beans.factory.BeanCreationException;
...
@@ -30,7 +30,6 @@ import org.springframework.beans.factory.BeanCreationException;
import
org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
;
import
org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder
;
import
org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration
;
import
org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration
;
import
org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration
;
import
org.springframework.boot.test.EnvironmentTestUtils
;
import
org.springframework.boot.test.EnvironmentTestUtils
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
...
@@ -40,7 +39,7 @@ import static org.junit.Assert.assertEquals;
...
@@ -40,7 +39,7 @@ import static org.junit.Assert.assertEquals;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
/**
/**
* Tests for {@link
Liquibase
AutoConfiguration}.
* Tests for {@link
Flyway
AutoConfiguration}.
*
*
* @author Dave Syer
* @author Dave Syer
*/
*/
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mobile/DeviceResolverAutoConfigurationTests.java
View file @
6381fdcb
...
@@ -16,9 +16,6 @@
...
@@ -16,9 +16,6 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
mobile
;
package
org
.
springframework
.
boot
.
autoconfigure
.
mobile
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
fail
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Field
;
import
java.util.List
;
import
java.util.List
;
...
@@ -39,6 +36,9 @@ import org.springframework.util.ReflectionUtils;
...
@@ -39,6 +36,9 @@ import org.springframework.util.ReflectionUtils;
import
org.springframework.web.context.support.AnnotationConfigWebApplicationContext
;
import
org.springframework.web.context.support.AnnotationConfigWebApplicationContext
;
import
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping
;
import
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
fail
;
/**
/**
* Tests for {@link DeviceResolverAutoConfiguration}.
* Tests for {@link DeviceResolverAutoConfiguration}.
*
*
...
@@ -82,7 +82,8 @@ public class DeviceResolverAutoConfigurationTests {
...
@@ -82,7 +82,8 @@ public class DeviceResolverAutoConfigurationTests {
DeviceResolverAutoConfiguration
.
class
,
DeviceResolverAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
);
PropertyPlaceholderAutoConfiguration
.
class
);
context
.
refresh
();
context
.
refresh
();
RequestMappingHandlerMapping
mapping
=
(
RequestMappingHandlerMapping
)
context
.
getBean
(
"requestMappingHandlerMapping"
);
RequestMappingHandlerMapping
mapping
=
(
RequestMappingHandlerMapping
)
context
.
getBean
(
"requestMappingHandlerMapping"
);
Field
interceptorsField
=
ReflectionUtils
.
findField
(
Field
interceptorsField
=
ReflectionUtils
.
findField
(
RequestMappingHandlerMapping
.
class
,
"interceptors"
);
RequestMappingHandlerMapping
.
class
,
"interceptors"
);
interceptorsField
.
setAccessible
(
true
);
interceptorsField
.
setAccessible
(
true
);
...
...
spring-boot-docs/src/main/asciidoc/howto.adoc
View file @
6381fdcb
...
@@ -1210,8 +1210,8 @@ that can be used to disable the migrations, or switch off the location checking.
...
@@ -1210,8 +1210,8 @@ that can be used to disable the migrations, or switch off the location checking.
By default Flyway will autowire the (`@Primary`) `DataSource` in your context and
By default Flyway will autowire the (`@Primary`) `DataSource` in your context and
use that for migrations. If you like to use a different `DataSource` you can create
use that for migrations. If you like to use a different `DataSource` you can create
one and mark its `@Bean` as `@FlywayDataSource` - if you do that remember to create
one and mark its `@Bean` as `@FlywayDataSource` - if you do that remember to create
another one and mark it as `@Primary` if you want 2 data sources.
another one and mark it as `@Primary` if you want 2 data sources.
Or you can use Flyway's native `DataSource` by setting `flyway.[url,user,password]`
Or you can use Flyway's native `DataSource` by setting `flyway.[url,user,password]`
in external properties.
in external properties.
There is a {github-code}/spring-boot-samples/spring-boot-sample-flyway[Flyway sample] so
There is a {github-code}/spring-boot-samples/spring-boot-sample-flyway[Flyway sample] so
...
...
spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
View file @
6381fdcb
...
@@ -1646,14 +1646,15 @@ interaction. For Example:
...
@@ -1646,14 +1646,15 @@ interaction. For Example:
}
}
----
----
NOTE: Spring's test framework will cache application contexts between tests. Therefore,
as long as your tests share the same configuration, the time consuming process of starting
and stopping the server will only happen once, regardless of the number of tests that
actually run.
To change the port you can add environment properties to `@IntegrationTest` as colon- or
To change the port you can add environment properties to `@IntegrationTest` as colon- or
equals-separated name-value pairs, e.g. `@IntegrationTest("server.port:9000")`.
equals-separated name-value pairs, e.g. `@IntegrationTest("server.port:9000")`.
Additionally you can set the `server.port` and `management.port` properties to `0`
As long as you use the same configuration, the context will be cached amongst different
in order to run your integration tests using random ports. For example:
tests by default. You can therefore use this feature to run a battery of integration tests
where the server would actually start prior to the tests. In that case, it would be better
to make sure that your integration tests use a random port for the main server and the
management one, something like:
[source,java,indent=0,subs="verbatim,quotes,attributes"]
[source,java,indent=0,subs="verbatim,quotes,attributes"]
----
----
...
@@ -1661,13 +1662,18 @@ management one, something like:
...
@@ -1661,13 +1662,18 @@ management one, something like:
@SpringApplicationConfiguration(classes = MyApplication.class)
@SpringApplicationConfiguration(classes = MyApplication.class)
@WebAppConfiguration
@WebAppConfiguration
@IntegrationTest({"server.port=0", "management.port=0"})
@IntegrationTest({"server.port=0", "management.port=0"})
public class SomeIntegrationTests { ... }
public class SomeIntegrationTests {
// ...
}
----
----
See <<howto-discover-the-http-port-at-runtime>> for a description of how you can discover
See <<howto-discover-the-http-port-at-runtime>> for a description of how you can discover
the actual port that was allocated for the duration of the tests.
the actual port that was allocated for the duration of the tests.
[[boot-features-test-utilities]]
[[boot-features-test-utilities]]
=== Test utilities
=== Test utilities
A few test utility classes are packaged as part of `spring-boot` that are generally
A few test utility classes are packaged as part of `spring-boot` that are generally
...
...
spring-boot/src/main/java/org/springframework/boot/bind/PropertySourcesPropertyValues.java
View file @
6381fdcb
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
...
spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java
View file @
6381fdcb
...
@@ -179,8 +179,8 @@ public class ConfigFileApplicationListener implements
...
@@ -179,8 +179,8 @@ public class ConfigFileApplicationListener implements
try
{
try
{
binder
.
bindPropertiesToTarget
();
binder
.
bindPropertiesToTarget
();
}
}
catch
(
BindException
e
)
{
catch
(
BindException
e
x
)
{
throw
new
IllegalStateException
(
"Cannot bind to SpringApplication"
,
e
);
throw
new
IllegalStateException
(
"Cannot bind to SpringApplication"
,
e
x
);
}
}
}
}
...
...
spring-boot/src/test/java/org/springframework/boot/bind/PropertySourcesBindingTests.java
View file @
6381fdcb
/*
* Copyright 2012-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
bind
;
package
org
.
springframework
.
boot
.
bind
;
import
org.junit.Test
;
import
org.junit.Test
;
...
@@ -20,6 +36,11 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
...
@@ -20,6 +36,11 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import
static
org
.
hamcrest
.
Matchers
.
is
;
import
static
org
.
hamcrest
.
Matchers
.
is
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
static
org
.
junit
.
Assert
.
assertThat
;
/**
* Tests for {@link PropertySourcesPropertyValues} binding.
*
* @author Dave Syer
*/
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringApplicationConfiguration
(
classes
=
TestConfig
.
class
)
@SpringApplicationConfiguration
(
classes
=
TestConfig
.
class
)
@IntegrationTest
@IntegrationTest
...
@@ -69,4 +90,4 @@ public class PropertySourcesBindingTests {
...
@@ -69,4 +90,4 @@ public class PropertySourcesBindingTests {
}
}
}
}
}
}
\ No newline at end of file
spring-boot/src/test/java/org/springframework/boot/bind/SimplerPropertySourcesBindingTests.java
View file @
6381fdcb
/*
* Copyright 2012-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
bind
;
package
org
.
springframework
.
boot
.
bind
;
import
org.junit.Test
;
import
org.junit.Test
;
...
@@ -19,6 +35,11 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
...
@@ -19,6 +35,11 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import
static
org
.
hamcrest
.
Matchers
.
is
;
import
static
org
.
hamcrest
.
Matchers
.
is
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
static
org
.
junit
.
Assert
.
assertThat
;
/**
* Tests for {@link PropertySourcesPropertyValues} binding.
*
* @author Dave Syer
*/
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringApplicationConfiguration
(
classes
=
TestConfig
.
class
)
@SpringApplicationConfiguration
(
classes
=
TestConfig
.
class
)
@IntegrationTest
@IntegrationTest
...
@@ -61,4 +82,4 @@ public class SimplerPropertySourcesBindingTests {
...
@@ -61,4 +82,4 @@ public class SimplerPropertySourcesBindingTests {
}
}
}
}
}
}
\ No newline at end of file
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