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
4b55144d
Commit
4b55144d
authored
Feb 19, 2016
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
03dad33b
Changes
32
Hide whitespace changes
Inline
Side-by-side
Showing
32 changed files
with
158 additions
and
105 deletions
+158
-105
HealthIndicatorAutoConfiguration.java
...tuate/autoconfigure/HealthIndicatorAutoConfiguration.java
+1
-1
CouchbaseHealthIndicator.java
...amework/boot/actuate/health/CouchbaseHealthIndicator.java
+4
-2
HealthIndicatorAutoConfigurationTests.java
.../autoconfigure/HealthIndicatorAutoConfigurationTests.java
+2
-1
CouchbaseAutoConfiguration.java
...t/autoconfigure/couchbase/CouchbaseAutoConfiguration.java
+6
-5
CouchbaseProperties.java
...ork/boot/autoconfigure/couchbase/CouchbaseProperties.java
+5
-3
CouchbaseRepositoriesRegistrar.java
...figure/data/couchbase/CouchbaseRepositoriesRegistrar.java
+2
-1
RedisAutoConfiguration.java
...boot/autoconfigure/data/redis/RedisAutoConfiguration.java
+4
-3
RedisProperties.java
...mework/boot/autoconfigure/data/redis/RedisProperties.java
+2
-2
DataSourceConfiguration.java
...work/boot/autoconfigure/jdbc/DataSourceConfiguration.java
+8
-6
SolrAutoConfiguration.java
...mework/boot/autoconfigure/solr/SolrAutoConfiguration.java
+1
-1
ResourceProperties.java
...gframework/boot/autoconfigure/web/ResourceProperties.java
+2
-2
CouchbaseAutoConfigurationTests.java
...oconfigure/couchbase/CouchbaseAutoConfigurationTests.java
+28
-16
CouchbaseTestConfiguration.java
...t/autoconfigure/couchbase/CouchbaseTestConfiguration.java
+3
-1
CouchbaseRepositoriesAutoConfigurationTests.java
...ouchbase/CouchbaseRepositoriesAutoConfigurationTests.java
+2
-0
RedisAutoConfigurationTests.java
...autoconfigure/data/redis/RedisAutoConfigurationTests.java
+2
-3
DataSourceAutoConfigurationTests.java
.../autoconfigure/jdbc/DataSourceAutoConfigurationTests.java
+2
-2
ThymeleafAutoConfigurationTests.java
...oconfigure/thymeleaf/ThymeleafAutoConfigurationTests.java
+1
-0
appendix-configuration-metadata.adoc
...cs/src/main/asciidoc/appendix-configuration-metadata.adoc
+1
-0
pom.xml
...ng-boot-samples/spring-boot-sample-data-couchbase/pom.xml
+0
-1
SampleCouchbaseApplication.java
...ava/sample/data/couchbase/SampleCouchbaseApplication.java
+0
-2
User.java
...a-couchbase/src/main/java/sample/data/couchbase/User.java
+4
-6
HotelSummary.java
...pa/src/main/java/sample/data/jpa/domain/HotelSummary.java
+2
-1
RatingCount.java
...jpa/src/main/java/sample/data/jpa/domain/RatingCount.java
+2
-1
HotelRepository.java
...rc/main/java/sample/data/jpa/service/HotelRepository.java
+4
-3
ConfigurationMetadataRepositoryJsonBuilder.java
...nmetadata/ConfigurationMetadataRepositoryJsonBuilder.java
+15
-6
Hints.java
...org/springframework/boot/configurationmetadata/Hints.java
+7
-7
ConfigurationMetadataRepositoryJsonBuilderTests.java
...data/ConfigurationMetadataRepositoryJsonBuilderTests.java
+22
-13
JarWriter.java
...java/org/springframework/boot/loader/tools/JarWriter.java
+1
-0
EnableConfigurationPropertiesImportSelector.java
...operties/EnableConfigurationPropertiesImportSelector.java
+2
-2
DatabaseDriver.java
...in/java/org/springframework/boot/jdbc/DatabaseDriver.java
+3
-3
AtomikosProperties.java
...springframework/boot/jta/atomikos/AtomikosProperties.java
+2
-2
DatabaseDriverTests.java
...va/org/springframework/boot/jdbc/DatabaseDriverTests.java
+18
-9
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/HealthIndicatorAutoConfiguration.java
View file @
4b55144d
...
@@ -183,7 +183,7 @@ public class HealthIndicatorAutoConfiguration {
...
@@ -183,7 +183,7 @@ public class HealthIndicatorAutoConfiguration {
}
}
@Configuration
@Configuration
@ConditionalOnClass
({
CouchbaseOperations
.
class
,
Bucket
.
class
})
@ConditionalOnClass
({
CouchbaseOperations
.
class
,
Bucket
.
class
})
@ConditionalOnBean
(
CouchbaseOperations
.
class
)
@ConditionalOnBean
(
CouchbaseOperations
.
class
)
@ConditionalOnEnabledHealthIndicator
(
"couchbase"
)
@ConditionalOnEnabledHealthIndicator
(
"couchbase"
)
public
static
class
CouchbaseHealthIndicatorConfiguration
extends
public
static
class
CouchbaseHealthIndicatorConfiguration
extends
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/CouchbaseHealthIndicator.java
View file @
4b55144d
...
@@ -41,8 +41,10 @@ public class CouchbaseHealthIndicator extends AbstractHealthIndicator {
...
@@ -41,8 +41,10 @@ public class CouchbaseHealthIndicator extends AbstractHealthIndicator {
@Override
@Override
protected
void
doHealthCheck
(
Health
.
Builder
builder
)
throws
Exception
{
protected
void
doHealthCheck
(
Health
.
Builder
builder
)
throws
Exception
{
List
<
Version
>
versions
=
this
.
couchbaseOperations
.
getCouchbaseClusterInfo
().
getAllVersions
();
List
<
Version
>
versions
=
this
.
couchbaseOperations
.
getCouchbaseClusterInfo
()
builder
.
up
().
withDetail
(
"versions"
,
StringUtils
.
collectionToCommaDelimitedString
(
versions
));
.
getAllVersions
();
builder
.
up
().
withDetail
(
"versions"
,
StringUtils
.
collectionToCommaDelimitedString
(
versions
));
}
}
}
}
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/HealthIndicatorAutoConfigurationTests.java
View file @
4b55144d
...
@@ -449,7 +449,8 @@ public class HealthIndicatorAutoConfigurationTests {
...
@@ -449,7 +449,8 @@ public class HealthIndicatorAutoConfigurationTests {
Map
<
String
,
HealthIndicator
>
beans
=
this
.
context
Map
<
String
,
HealthIndicator
>
beans
=
this
.
context
.
getBeansOfType
(
HealthIndicator
.
class
);
.
getBeansOfType
(
HealthIndicator
.
class
);
assertThat
(
beans
.
size
()).
isEqualTo
(
1
);
assertThat
(
beans
.
size
()).
isEqualTo
(
1
);
assertThat
(
beans
.
values
().
iterator
().
next
().
getClass
()).
isEqualTo
(
CouchbaseHealthIndicator
.
class
);
assertThat
(
beans
.
values
().
iterator
().
next
().
getClass
())
.
isEqualTo
(
CouchbaseHealthIndicator
.
class
);
}
}
@Configuration
@Configuration
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseAutoConfiguration.java
View file @
4b55144d
...
@@ -23,6 +23,7 @@ import javax.validation.Validator;
...
@@ -23,6 +23,7 @@ import javax.validation.Validator;
import
com.couchbase.client.java.CouchbaseBucket
;
import
com.couchbase.client.java.CouchbaseBucket
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.autoconfigure.condition.AnyNestedCondition
;
import
org.springframework.boot.autoconfigure.condition.AnyNestedCondition
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
...
@@ -39,15 +40,14 @@ import org.springframework.data.couchbase.core.query.Consistency;
...
@@ -39,15 +40,14 @@ import org.springframework.data.couchbase.core.query.Consistency;
import
org.springframework.data.couchbase.repository.support.IndexManager
;
import
org.springframework.data.couchbase.repository.support.IndexManager
;
/**
/**
* {@link org.springframework.boot.autoconfigure.EnableAutoConfiguration
* {@link EnableAutoConfiguration Auto-Configuration} for Couchbase.
* Auto-Configuration} for Couchbase.
*
*
* @author Eddú Meléndez
* @author Eddú Meléndez
* @author Stephane Nicoll
* @author Stephane Nicoll
* @since 1.4.0
* @since 1.4.0
*/
*/
@Configuration
@Configuration
@ConditionalOnClass
({
CouchbaseBucket
.
class
,
AbstractCouchbaseConfiguration
.
class
})
@ConditionalOnClass
({
CouchbaseBucket
.
class
,
AbstractCouchbaseConfiguration
.
class
})
@Conditional
(
CouchbaseAutoConfiguration
.
CouchbaseCondition
.
class
)
@Conditional
(
CouchbaseAutoConfiguration
.
CouchbaseCondition
.
class
)
@EnableConfigurationProperties
(
CouchbaseProperties
.
class
)
@EnableConfigurationProperties
(
CouchbaseProperties
.
class
)
public
class
CouchbaseAutoConfiguration
{
public
class
CouchbaseAutoConfiguration
{
...
@@ -107,8 +107,9 @@ public class CouchbaseAutoConfiguration {
...
@@ -107,8 +107,9 @@ public class CouchbaseAutoConfiguration {
}
}
/**
/**
* Determine if Couchbase should be configured. This happens if either the user-configuration
* Determine if Couchbase should be configured. This happens if either the
* defines a couchbase configuration or if at least the bucket name is specified.
* user-configuration defines a couchbase configuration or if at least the bucket name
* is specified.
*/
*/
static
class
CouchbaseCondition
extends
AnyNestedCondition
{
static
class
CouchbaseCondition
extends
AnyNestedCondition
{
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseProperties.java
View file @
4b55144d
...
@@ -34,15 +34,16 @@ import org.springframework.data.couchbase.core.query.Consistency;
...
@@ -34,15 +34,16 @@ import org.springframework.data.couchbase.core.query.Consistency;
public
class
CouchbaseProperties
{
public
class
CouchbaseProperties
{
/**
/**
* Automatically create views and indexes. Use the meta-data provided by
"@ViewIndexed",
* Automatically create views and indexes. Use the meta-data provided by
* "@N1qlPrimaryIndexed" and "@N1qlSecondaryIndexed".
* "@
ViewIndexed", "@
N1qlPrimaryIndexed" and "@N1qlSecondaryIndexed".
*/
*/
private
boolean
autoIndex
;
private
boolean
autoIndex
;
/**
/**
* Couchbase nodes (host or IP address) to bootstrap from.
* Couchbase nodes (host or IP address) to bootstrap from.
*/
*/
private
List
<
String
>
bootstrapHosts
=
new
ArrayList
<
String
>(
Collections
.
singletonList
(
"localhost"
));
private
List
<
String
>
bootstrapHosts
=
new
ArrayList
<
String
>(
Collections
.
singletonList
(
"localhost"
));
private
final
Bucket
bucket
=
new
Bucket
();
private
final
Bucket
bucket
=
new
Bucket
();
...
@@ -106,6 +107,7 @@ public class CouchbaseProperties {
...
@@ -106,6 +107,7 @@ public class CouchbaseProperties {
public
void
setPassword
(
String
password
)
{
public
void
setPassword
(
String
password
)
{
this
.
password
=
password
;
this
.
password
=
password
;
}
}
}
}
}
}
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/couchbase/CouchbaseRepositoriesRegistrar.java
View file @
4b55144d
...
@@ -31,7 +31,8 @@ import org.springframework.data.repository.config.RepositoryConfigurationExtensi
...
@@ -31,7 +31,8 @@ import org.springframework.data.repository.config.RepositoryConfigurationExtensi
* @author Eddú Meléndez
* @author Eddú Meléndez
* @since 1.4.0
* @since 1.4.0
*/
*/
public
class
CouchbaseRepositoriesRegistrar
extends
AbstractRepositoryConfigurationSourceSupport
{
public
class
CouchbaseRepositoriesRegistrar
extends
AbstractRepositoryConfigurationSourceSupport
{
@Override
@Override
protected
Class
<?
extends
Annotation
>
getAnnotation
()
{
protected
Class
<?
extends
Annotation
>
getAnnotation
()
{
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfiguration.java
View file @
4b55144d
...
@@ -132,7 +132,8 @@ public class RedisAutoConfiguration {
...
@@ -132,7 +132,8 @@ public class RedisAutoConfiguration {
private
List
<
RedisNode
>
createSentinels
(
Sentinel
sentinel
)
{
private
List
<
RedisNode
>
createSentinels
(
Sentinel
sentinel
)
{
List
<
RedisNode
>
nodes
=
new
ArrayList
<
RedisNode
>();
List
<
RedisNode
>
nodes
=
new
ArrayList
<
RedisNode
>();
for
(
String
node
:
StringUtils
.
commaDelimitedListToStringArray
(
sentinel
.
getNodes
()))
{
for
(
String
node
:
StringUtils
.
commaDelimitedListToStringArray
(
sentinel
.
getNodes
()))
{
try
{
try
{
String
[]
parts
=
StringUtils
.
split
(
node
,
":"
);
String
[]
parts
=
StringUtils
.
split
(
node
,
":"
);
Assert
.
state
(
parts
.
length
==
2
,
"Must be defined as 'host:port'"
);
Assert
.
state
(
parts
.
length
==
2
,
"Must be defined as 'host:port'"
);
...
@@ -190,8 +191,8 @@ public class RedisAutoConfiguration {
...
@@ -190,8 +191,8 @@ public class RedisAutoConfiguration {
}
}
private
JedisConnectionFactory
createJedisConnectionFactory
()
{
private
JedisConnectionFactory
createJedisConnectionFactory
()
{
JedisPoolConfig
poolConfig
=
this
.
properties
.
getPool
()
!=
null
?
jedisPoolConfig
()
JedisPoolConfig
poolConfig
=
this
.
properties
.
getPool
()
!=
null
:
new
JedisPoolConfig
();
?
jedisPoolConfig
()
:
new
JedisPoolConfig
();
if
(
getSentinelConfig
()
!=
null
)
{
if
(
getSentinelConfig
()
!=
null
)
{
return
new
JedisConnectionFactory
(
getSentinelConfig
(),
poolConfig
);
return
new
JedisConnectionFactory
(
getSentinelConfig
(),
poolConfig
);
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/RedisProperties.java
View file @
4b55144d
...
@@ -195,8 +195,8 @@ public class RedisProperties {
...
@@ -195,8 +195,8 @@ public class RedisProperties {
public
static
class
Cluster
{
public
static
class
Cluster
{
/**
/**
* Comma-separated list of "host:port" pairs to bootstrap from. This represents
* Comma-separated list of "host:port" pairs to bootstrap from. This represents
an
*
an
"initial" list of cluster nodes and is required to have at least one entry.
* "initial" list of cluster nodes and is required to have at least one entry.
*/
*/
private
List
<
String
>
nodes
;
private
List
<
String
>
nodes
;
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration.java
View file @
4b55144d
...
@@ -52,9 +52,10 @@ abstract class DataSourceConfiguration {
...
@@ -52,9 +52,10 @@ abstract class DataSourceConfiguration {
@ConfigurationProperties
(
"spring.datasource.tomcat"
)
@ConfigurationProperties
(
"spring.datasource.tomcat"
)
public
org
.
apache
.
tomcat
.
jdbc
.
pool
.
DataSource
dataSource
(
public
org
.
apache
.
tomcat
.
jdbc
.
pool
.
DataSource
dataSource
(
DataSourceProperties
properties
)
{
DataSourceProperties
properties
)
{
org
.
apache
.
tomcat
.
jdbc
.
pool
.
DataSource
dataSource
=
createDataSource
(
properties
,
org
.
apache
.
tomcat
.
jdbc
.
pool
.
DataSource
dataSource
=
createDataSource
(
org
.
apache
.
tomcat
.
jdbc
.
pool
.
DataSource
.
class
);
properties
,
org
.
apache
.
tomcat
.
jdbc
.
pool
.
DataSource
.
class
);
DatabaseDriver
databaseDriver
=
DatabaseDriver
.
fromJdbcUrl
(
properties
.
determineUrl
());
DatabaseDriver
databaseDriver
=
DatabaseDriver
.
fromJdbcUrl
(
properties
.
determineUrl
());
String
validationQuery
=
databaseDriver
.
getValidationQuery
();
String
validationQuery
=
databaseDriver
.
getValidationQuery
();
if
(
validationQuery
!=
null
)
{
if
(
validationQuery
!=
null
)
{
dataSource
.
setTestOnBorrow
(
true
);
dataSource
.
setTestOnBorrow
(
true
);
...
@@ -84,9 +85,10 @@ abstract class DataSourceConfiguration {
...
@@ -84,9 +85,10 @@ abstract class DataSourceConfiguration {
@ConfigurationProperties
(
"spring.datasource.dbcp"
)
@ConfigurationProperties
(
"spring.datasource.dbcp"
)
public
org
.
apache
.
commons
.
dbcp
.
BasicDataSource
dataSource
(
public
org
.
apache
.
commons
.
dbcp
.
BasicDataSource
dataSource
(
DataSourceProperties
properties
)
{
DataSourceProperties
properties
)
{
org
.
apache
.
commons
.
dbcp
.
BasicDataSource
dataSource
=
createDataSource
(
properties
,
org
.
apache
.
commons
.
dbcp
.
BasicDataSource
dataSource
=
createDataSource
(
org
.
apache
.
commons
.
dbcp
.
BasicDataSource
.
class
);
properties
,
org
.
apache
.
commons
.
dbcp
.
BasicDataSource
.
class
);
DatabaseDriver
databaseDriver
=
DatabaseDriver
.
fromJdbcUrl
(
properties
.
determineUrl
());
DatabaseDriver
databaseDriver
=
DatabaseDriver
.
fromJdbcUrl
(
properties
.
determineUrl
());
String
validationQuery
=
databaseDriver
.
getValidationQuery
();
String
validationQuery
=
databaseDriver
.
getValidationQuery
();
if
(
validationQuery
!=
null
)
{
if
(
validationQuery
!=
null
)
{
dataSource
.
setTestOnBorrow
(
true
);
dataSource
.
setTestOnBorrow
(
true
);
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/solr/SolrAutoConfiguration.java
View file @
4b55144d
...
@@ -40,7 +40,7 @@ import org.springframework.util.StringUtils;
...
@@ -40,7 +40,7 @@ import org.springframework.util.StringUtils;
* @since 1.1.0
* @since 1.1.0
*/
*/
@Configuration
@Configuration
@ConditionalOnClass
({
HttpSolrClient
.
class
,
CloudSolrClient
.
class
})
@ConditionalOnClass
({
HttpSolrClient
.
class
,
CloudSolrClient
.
class
})
@EnableConfigurationProperties
(
SolrProperties
.
class
)
@EnableConfigurationProperties
(
SolrProperties
.
class
)
public
class
SolrAutoConfiguration
{
public
class
SolrAutoConfiguration
{
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ResourceProperties.java
View file @
4b55144d
...
@@ -170,8 +170,8 @@ public class ResourceProperties implements ResourceLoaderAware {
...
@@ -170,8 +170,8 @@ public class ResourceProperties implements ResourceLoaderAware {
private
boolean
htmlApplicationCache
=
false
;
private
boolean
htmlApplicationCache
=
false
;
/**
/**
* Enable resolution of already gzipped resources. Checks for a resource
* Enable resolution of already gzipped resources. Checks for a resource
name
*
name variant with the *.gz
extension.
*
variant with the {@code *.gz}
extension.
*/
*/
private
boolean
gzipped
=
false
;
private
boolean
gzipped
=
false
;
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseAutoConfigurationTests.java
View file @
4b55144d
...
@@ -65,18 +65,24 @@ public class CouchbaseAutoConfigurationTests {
...
@@ -65,18 +65,24 @@ public class CouchbaseAutoConfigurationTests {
load
(
null
);
load
(
null
);
assertThat
(
this
.
context
.
getBeansOfType
(
CouchbaseTemplate
.
class
)).
isEmpty
();
assertThat
(
this
.
context
.
getBeansOfType
(
CouchbaseTemplate
.
class
)).
isEmpty
();
assertThat
(
this
.
context
.
getBeansOfType
(
Bucket
.
class
)).
isEmpty
();
assertThat
(
this
.
context
.
getBeansOfType
(
Bucket
.
class
)).
isEmpty
();
assertThat
(
this
.
context
.
getBeansOfType
(
ValidatingCouchbaseEventListener
.
class
)).
isEmpty
();
assertThat
(
this
.
context
.
getBeansOfType
(
ValidatingCouchbaseEventListener
.
class
))
.
isEmpty
();
}
}
@Test
@Test
public
void
bucketNameIsNotRequiredIfCustomConfigurationIsSpecified
()
throws
Exception
{
public
void
bucketNameIsNotRequiredIfCustomConfigurationIsSpecified
()
throws
Exception
{
load
(
CouchbaseTestConfiguration
.
class
);
load
(
CouchbaseTestConfiguration
.
class
);
assertThat
(
this
.
context
.
getBeansOfType
(
AbstractCouchbaseConfiguration
.
class
))
assertThat
(
this
.
context
.
getBeansOfType
(
AbstractCouchbaseConfiguration
.
class
)).
hasSize
(
1
);
.
hasSize
(
1
);
CouchbaseTestConfiguration
configuration
=
this
.
context
.
getBean
(
CouchbaseTestConfiguration
.
class
);
CouchbaseTestConfiguration
configuration
=
this
.
context
assertThat
(
this
.
context
.
getBean
(
CouchbaseTemplate
.
class
)).
isSameAs
(
configuration
.
couchbaseTemplate
());
.
getBean
(
CouchbaseTestConfiguration
.
class
);
assertThat
(
this
.
context
.
getBean
(
Bucket
.
class
)).
isSameAs
(
configuration
.
couchbaseClient
());
assertThat
(
this
.
context
.
getBean
(
CouchbaseTemplate
.
class
))
assertThat
(
this
.
context
.
getBeansOfType
(
ValidatingCouchbaseEventListener
.
class
)).
isEmpty
();
.
isSameAs
(
configuration
.
couchbaseTemplate
());
assertThat
(
this
.
context
.
getBean
(
Bucket
.
class
))
.
isSameAs
(
configuration
.
couchbaseClient
());
assertThat
(
this
.
context
.
getBeansOfType
(
ValidatingCouchbaseEventListener
.
class
))
.
isEmpty
();
}
}
@Test
@Test
...
@@ -92,7 +98,8 @@ public class CouchbaseAutoConfigurationTests {
...
@@ -92,7 +98,8 @@ public class CouchbaseAutoConfigurationTests {
@Test
@Test
public
void
autoIndexIsDisabledByDefault
()
{
public
void
autoIndexIsDisabledByDefault
()
{
load
(
CouchbaseTestConfiguration
.
class
);
load
(
CouchbaseTestConfiguration
.
class
);
CouchbaseTestConfiguration
configuration
=
this
.
context
.
getBean
(
CouchbaseTestConfiguration
.
class
);
CouchbaseTestConfiguration
configuration
=
this
.
context
.
getBean
(
CouchbaseTestConfiguration
.
class
);
IndexManager
indexManager
=
configuration
.
indexManager
();
IndexManager
indexManager
=
configuration
.
indexManager
();
assertThat
(
indexManager
.
isIgnoreViews
()).
isTrue
();
assertThat
(
indexManager
.
isIgnoreViews
()).
isTrue
();
assertThat
(
indexManager
.
isIgnoreN1qlPrimary
()).
isTrue
();
assertThat
(
indexManager
.
isIgnoreN1qlPrimary
()).
isTrue
();
...
@@ -102,7 +109,8 @@ public class CouchbaseAutoConfigurationTests {
...
@@ -102,7 +109,8 @@ public class CouchbaseAutoConfigurationTests {
@Test
@Test
public
void
enableAutoIndex
()
{
public
void
enableAutoIndex
()
{
load
(
CouchbaseTestConfiguration
.
class
,
"spring.data.couchbase.auto-index=true"
);
load
(
CouchbaseTestConfiguration
.
class
,
"spring.data.couchbase.auto-index=true"
);
CouchbaseTestConfiguration
configuration
=
this
.
context
.
getBean
(
CouchbaseTestConfiguration
.
class
);
CouchbaseTestConfiguration
configuration
=
this
.
context
.
getBean
(
CouchbaseTestConfiguration
.
class
);
IndexManager
indexManager
=
configuration
.
indexManager
();
IndexManager
indexManager
=
configuration
.
indexManager
();
assertThat
(
indexManager
.
isIgnoreViews
()).
isFalse
();
assertThat
(
indexManager
.
isIgnoreViews
()).
isFalse
();
assertThat
(
indexManager
.
isIgnoreN1qlPrimary
()).
isFalse
();
assertThat
(
indexManager
.
isIgnoreN1qlPrimary
()).
isFalse
();
...
@@ -111,16 +119,21 @@ public class CouchbaseAutoConfigurationTests {
...
@@ -111,16 +119,21 @@ public class CouchbaseAutoConfigurationTests {
@Test
@Test
public
void
changeConsistency
()
{
public
void
changeConsistency
()
{
load
(
CouchbaseTestConfiguration
.
class
,
"spring.data.couchbase.consistency=eventually-consistent"
);
load
(
CouchbaseTestConfiguration
.
class
,
CouchbaseTestConfiguration
configuration
=
this
.
context
.
getBean
(
CouchbaseTestConfiguration
.
class
);
"spring.data.couchbase.consistency=eventually-consistent"
);
assertThat
(
configuration
.
getDefaultConsistency
()).
isEqualTo
(
Consistency
.
EVENTUALLY_CONSISTENT
);
CouchbaseTestConfiguration
configuration
=
this
.
context
.
getBean
(
CouchbaseTestConfiguration
.
class
);
assertThat
(
configuration
.
getDefaultConsistency
())
.
isEqualTo
(
Consistency
.
EVENTUALLY_CONSISTENT
);
}
}
@Test
@Test
public
void
overrideCouchbaseOperations
()
{
public
void
overrideCouchbaseOperations
()
{
load
(
CouchbaseTemplateConfiguration
.
class
);
load
(
CouchbaseTemplateConfiguration
.
class
);
CouchbaseTemplateConfiguration
configuration
=
this
.
context
.
getBean
(
CouchbaseTemplateConfiguration
.
class
);
CouchbaseTemplateConfiguration
configuration
=
this
.
context
assertThat
(
this
.
context
.
getBean
(
CouchbaseTemplate
.
class
)).
isSameAs
(
configuration
.
myCouchbaseTemplate
());
.
getBean
(
CouchbaseTemplateConfiguration
.
class
);
assertThat
(
this
.
context
.
getBean
(
CouchbaseTemplate
.
class
))
.
isSameAs
(
configuration
.
myCouchbaseTemplate
());
}
}
private
void
load
(
Class
<?>
config
,
String
...
environment
)
{
private
void
load
(
Class
<?>
config
,
String
...
environment
)
{
...
@@ -146,7 +159,6 @@ public class CouchbaseAutoConfigurationTests {
...
@@ -146,7 +159,6 @@ public class CouchbaseAutoConfigurationTests {
}
}
@Configuration
@Configuration
@Import
(
CouchbaseTestConfiguration
.
class
)
@Import
(
CouchbaseTestConfiguration
.
class
)
static
class
CouchbaseTemplateConfiguration
{
static
class
CouchbaseTemplateConfiguration
{
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseTestConfiguration.java
View file @
4b55144d
...
@@ -33,13 +33,15 @@ import static org.mockito.Mockito.mock;
...
@@ -33,13 +33,15 @@ import static org.mockito.Mockito.mock;
* @author Stephane Nicoll
* @author Stephane Nicoll
*/
*/
@Configuration
@Configuration
public
class
CouchbaseTestConfiguration
extends
CouchbaseAutoConfiguration
.
CouchbaseConfiguration
{
public
class
CouchbaseTestConfiguration
extends
CouchbaseAutoConfiguration
.
CouchbaseConfiguration
{
@Override
@Override
public
Cluster
couchbaseCluster
()
throws
Exception
{
public
Cluster
couchbaseCluster
()
throws
Exception
{
return
mock
(
CouchbaseCluster
.
class
);
return
mock
(
CouchbaseCluster
.
class
);
}
}
@Override
@Bean
@Bean
public
ClusterInfo
couchbaseClusterInfo
()
{
public
ClusterInfo
couchbaseClusterInfo
()
{
return
mock
(
ClusterInfo
.
class
);
return
mock
(
ClusterInfo
.
class
);
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/couchbase/CouchbaseRepositoriesAutoConfigurationTests.java
View file @
4b55144d
...
@@ -35,6 +35,8 @@ import org.springframework.context.annotation.Import;
...
@@ -35,6 +35,8 @@ import org.springframework.context.annotation.Import;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
/**
* Tests for {@link CouchbaseRepositoriesAutoConfiguration}.
*
* @author Eddú Meléndez
* @author Eddú Meléndez
*/
*/
public
class
CouchbaseRepositoriesAutoConfigurationTests
{
public
class
CouchbaseRepositoriesAutoConfigurationTests
{
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfigurationTests.java
View file @
4b55144d
...
@@ -110,9 +110,8 @@ public class RedisAutoConfigurationTests {
...
@@ -110,9 +110,8 @@ public class RedisAutoConfigurationTests {
if
(
isAtLeastOneNodeAvailable
(
clusterNodes
))
{
if
(
isAtLeastOneNodeAvailable
(
clusterNodes
))
{
load
(
"spring.redis.cluster.nodes[0]:"
+
clusterNodes
.
get
(
0
),
load
(
"spring.redis.cluster.nodes[0]:"
+
clusterNodes
.
get
(
0
),
"spring.redis.cluster.nodes[1]:"
+
clusterNodes
.
get
(
1
));
"spring.redis.cluster.nodes[1]:"
+
clusterNodes
.
get
(
1
));
assertThat
(
assertThat
(
this
.
context
.
getBean
(
JedisConnectionFactory
.
class
)
this
.
context
.
getBean
(
JedisConnectionFactory
.
class
)
.
getClusterConnection
()).
isNotNull
();
.
getClusterConnection
()).
isNotNull
();
}
}
}
}
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfigurationTests.java
View file @
4b55144d
...
@@ -134,7 +134,8 @@ public class DataSourceAutoConfigurationTests {
...
@@ -134,7 +134,8 @@ public class DataSourceAutoConfigurationTests {
public
void
hikariValidatesConnectionByDefault
()
throws
Exception
{
public
void
hikariValidatesConnectionByDefault
()
throws
Exception
{
HikariDataSource
dataSource
=
autoConfigureDataSource
(
HikariDataSource
.
class
,
HikariDataSource
dataSource
=
autoConfigureDataSource
(
HikariDataSource
.
class
,
"org.apache.tomcat"
);
"org.apache.tomcat"
);
assertThat
(
dataSource
.
getConnectionTestQuery
()).
isNull
();
// Use Connection#isValid()
assertThat
(
dataSource
.
getConnectionTestQuery
()).
isNull
();
// Use
// Connection#isValid()
}
}
@Test
@Test
...
@@ -161,7 +162,6 @@ public class DataSourceAutoConfigurationTests {
...
@@ -161,7 +162,6 @@ public class DataSourceAutoConfigurationTests {
assertThat
(
dataSource
.
getUrl
()).
isEqualTo
(
"jdbc:hsqldb:mem:testdb"
);
assertThat
(
dataSource
.
getUrl
()).
isEqualTo
(
"jdbc:hsqldb:mem:testdb"
);
}
}
@Test
@Test
public
void
commonsDbcp2ValidatesConnectionByDefault
()
throws
Exception
{
public
void
commonsDbcp2ValidatesConnectionByDefault
()
throws
Exception
{
org
.
apache
.
commons
.
dbcp2
.
BasicDataSource
dataSource
=
autoConfigureDataSource
(
org
.
apache
.
commons
.
dbcp2
.
BasicDataSource
dataSource
=
autoConfigureDataSource
(
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfigurationTests.java
View file @
4b55144d
...
@@ -254,6 +254,7 @@ public class ThymeleafAutoConfigurationTests {
...
@@ -254,6 +254,7 @@ public class ThymeleafAutoConfigurationTests {
public
LayoutDialect
layoutDialect
()
{
public
LayoutDialect
layoutDialect
()
{
return
new
LayoutDialect
(
new
GroupingStrategy
());
return
new
LayoutDialect
(
new
GroupingStrategy
());
}
}
}
}
}
}
spring-boot-docs/src/main/asciidoc/appendix-configuration-metadata.adoc
View file @
4b55144d
...
@@ -257,6 +257,7 @@ methods can be removed from your public API, the automatic deprecation hint in t
...
@@ -257,6 +257,7 @@ methods can be removed from your public API, the automatic deprecation hint in t
meta-data will go away as well.
meta-data will go away as well.
[[configuration-metadata-hints-attributes]]
[[configuration-metadata-hints-attributes]]
==== Hint Attributes
==== Hint Attributes
The JSON object contained in the `hints` array can contain the following attributes:
The JSON object contained in the `hints` array can contain the following attributes:
...
...
spring-boot-samples/spring-boot-sample-data-couchbase/pom.xml
View file @
4b55144d
...
@@ -50,5 +50,4 @@
...
@@ -50,5 +50,4 @@
</plugin>
</plugin>
</plugins>
</plugins>
</build>
</build>
</project>
</project>
spring-boot-samples/spring-boot-sample-data-couchbase/src/main/java/sample/data/couchbase/SampleCouchbaseApplication.java
View file @
4b55144d
...
@@ -37,7 +37,6 @@ public class SampleCouchbaseApplication implements CommandLineRunner {
...
@@ -37,7 +37,6 @@ public class SampleCouchbaseApplication implements CommandLineRunner {
public
void
run
(
String
...
args
)
throws
Exception
{
public
void
run
(
String
...
args
)
throws
Exception
{
this
.
userRepository
.
deleteAll
();
this
.
userRepository
.
deleteAll
();
User
user
=
saveUser
();
User
user
=
saveUser
();
System
.
out
.
println
(
this
.
userRepository
.
findOne
(
user
.
getId
()));
System
.
out
.
println
(
this
.
userRepository
.
findOne
(
user
.
getId
()));
}
}
...
@@ -46,7 +45,6 @@ public class SampleCouchbaseApplication implements CommandLineRunner {
...
@@ -46,7 +45,6 @@ public class SampleCouchbaseApplication implements CommandLineRunner {
user
.
setId
(
UUID
.
randomUUID
().
toString
());
user
.
setId
(
UUID
.
randomUUID
().
toString
());
user
.
setFirstName
(
"Alice"
);
user
.
setFirstName
(
"Alice"
);
user
.
setLastName
(
"Smith"
);
user
.
setLastName
(
"Smith"
);
return
this
.
userRepository
.
save
(
user
);
return
this
.
userRepository
.
save
(
user
);
}
}
...
...
spring-boot-samples/spring-boot-sample-data-couchbase/src/main/java/sample/data/couchbase/User.java
View file @
4b55144d
...
@@ -16,9 +16,9 @@
...
@@ -16,9 +16,9 @@
package
sample
.
data
.
couchbase
;
package
sample
.
data
.
couchbase
;
import
com.couchbase.client.java.repository.annotation.Field
;
import
com.couchbase.client.java.repository.annotation.Field
;
import
com.couchbase.client.java.repository.annotation.Id
;
import
com.couchbase.client.java.repository.annotation.Id
;
import
org.springframework.data.couchbase.core.mapping.Document
;
import
org.springframework.data.couchbase.core.mapping.Document
;
@Document
@Document
...
@@ -59,10 +59,8 @@ public class User {
...
@@ -59,10 +59,8 @@ public class User {
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
"User{"
+
return
"User{"
+
"id='"
+
this
.
id
+
'\''
+
", firstName='"
+
this
.
firstName
+
'\''
"id='"
+
this
.
id
+
'\''
+
+
", lastName='"
+
this
.
lastName
+
'\''
+
'}'
;
", firstName='"
+
this
.
firstName
+
'\''
+
", lastName='"
+
this
.
lastName
+
'\''
+
'}'
;
}
}
}
}
spring-boot-samples/spring-boot-sample-data-jpa/src/main/java/sample/data/jpa/domain/HotelSummary.java
View file @
4b55144d
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
6
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.
...
@@ -27,4 +27,5 @@ public interface HotelSummary {
...
@@ -27,4 +27,5 @@ public interface HotelSummary {
default
Integer
getAverageRatingRounded
()
{
default
Integer
getAverageRatingRounded
()
{
return
getAverageRating
()
==
null
?
null
:
(
int
)
Math
.
round
(
getAverageRating
());
return
getAverageRating
()
==
null
?
null
:
(
int
)
Math
.
round
(
getAverageRating
());
}
}
}
}
spring-boot-samples/spring-boot-sample-data-jpa/src/main/java/sample/data/jpa/domain/RatingCount.java
View file @
4b55144d
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
6
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -21,4 +21,5 @@ public interface RatingCount {
...
@@ -21,4 +21,5 @@ public interface RatingCount {
Rating
getRating
();
Rating
getRating
();
long
getCount
();
long
getCount
();
}
}
spring-boot-samples/spring-boot-sample-data-jpa/src/main/java/sample/data/jpa/service/HotelRepository.java
View file @
4b55144d
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
6
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.
...
@@ -16,13 +16,13 @@
...
@@ -16,13 +16,13 @@
package
sample
.
data
.
jpa
.
service
;
package
sample
.
data
.
jpa
.
service
;
import
java.util.List
;
import
sample.data.jpa.domain.City
;
import
sample.data.jpa.domain.City
;
import
sample.data.jpa.domain.Hotel
;
import
sample.data.jpa.domain.Hotel
;
import
sample.data.jpa.domain.HotelSummary
;
import
sample.data.jpa.domain.HotelSummary
;
import
sample.data.jpa.domain.RatingCount
;
import
sample.data.jpa.domain.RatingCount
;
import
java.util.List
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.data.jpa.repository.Query
;
...
@@ -39,4 +39,5 @@ interface HotelRepository extends Repository<Hotel, Long> {
...
@@ -39,4 +39,5 @@ interface HotelRepository extends Repository<Hotel, Long> {
@Query
(
"select r.rating as rating, count(r) as count "
@Query
(
"select r.rating as rating, count(r) as count "
+
"from Review r where r.hotel = ?1 group by r.rating order by r.rating DESC"
)
+
"from Review r where r.hotel = ?1 group by r.rating order by r.rating DESC"
)
List
<
RatingCount
>
findRatingCounts
(
Hotel
hotel
);
List
<
RatingCount
>
findRatingCounts
(
Hotel
hotel
);
}
}
spring-boot-tools/spring-boot-configuration-metadata/src/main/java/org/springframework/boot/configurationmetadata/ConfigurationMetadataRepositoryJsonBuilder.java
View file @
4b55144d
...
@@ -127,20 +127,17 @@ public final class ConfigurationMetadataRepositoryJsonBuilder {
...
@@ -127,20 +127,17 @@ public final class ConfigurationMetadataRepositoryJsonBuilder {
for
(
ConfigurationMetadataHint
hint
:
metadata
.
getHints
())
{
for
(
ConfigurationMetadataHint
hint
:
metadata
.
getHints
())
{
ConfigurationMetadataProperty
property
=
allProperties
.
get
(
hint
.
getId
());
ConfigurationMetadataProperty
property
=
allProperties
.
get
(
hint
.
getId
());
if
(
property
!=
null
)
{
if
(
property
!=
null
)
{
property
.
getHints
().
getValueHints
().
addAll
(
hint
.
getValueHints
());
addValueHints
(
property
,
hint
);
property
.
getHints
().
getValueProviders
().
addAll
(
hint
.
getValueProviders
());
}
}
else
{
else
{
String
id
=
hint
.
resolveId
();
String
id
=
hint
.
resolveId
();
property
=
allProperties
.
get
(
id
);
property
=
allProperties
.
get
(
id
);
if
(
property
!=
null
)
{
if
(
property
!=
null
)
{
if
(
hint
.
isMapKeyHints
())
{
if
(
hint
.
isMapKeyHints
())
{
property
.
getHints
().
getKeyHints
().
addAll
(
hint
.
getValueHints
());
addMapHints
(
property
,
hint
);
property
.
getHints
().
getKeyProviders
().
addAll
(
hint
.
getValueProviders
());
}
}
else
{
else
{
property
.
getHints
().
getValueHints
().
addAll
(
hint
.
getValueHints
());
addValueHints
(
property
,
hint
);
property
.
getHints
().
getValueProviders
().
addAll
(
hint
.
getValueProviders
());
}
}
}
}
}
}
...
@@ -148,6 +145,18 @@ public final class ConfigurationMetadataRepositoryJsonBuilder {
...
@@ -148,6 +145,18 @@ public final class ConfigurationMetadataRepositoryJsonBuilder {
return
repository
;
return
repository
;
}
}
private
void
addValueHints
(
ConfigurationMetadataProperty
property
,
ConfigurationMetadataHint
hint
)
{
property
.
getHints
().
getValueHints
().
addAll
(
hint
.
getValueHints
());
property
.
getHints
().
getValueProviders
().
addAll
(
hint
.
getValueProviders
());
}
private
void
addMapHints
(
ConfigurationMetadataProperty
property
,
ConfigurationMetadataHint
hint
)
{
property
.
getHints
().
getKeyHints
().
addAll
(
hint
.
getValueHints
());
property
.
getHints
().
getKeyProviders
().
addAll
(
hint
.
getValueProviders
());
}
private
ConfigurationMetadataSource
getSource
(
RawConfigurationMetadata
metadata
,
private
ConfigurationMetadataSource
getSource
(
RawConfigurationMetadata
metadata
,
ConfigurationMetadataItem
item
)
{
ConfigurationMetadataItem
item
)
{
if
(
item
.
getSourceType
()
!=
null
)
{
if
(
item
.
getSourceType
()
!=
null
)
{
...
...
spring-boot-tools/spring-boot-configuration-metadata/src/main/java/org/springframework/boot/configurationmetadata/Hints.java
View file @
4b55144d
...
@@ -21,8 +21,8 @@ import java.util.List;
...
@@ -21,8 +21,8 @@ import java.util.List;
/**
/**
* Hints of an item to provide the list of values and/or the name of the provider
* Hints of an item to provide the list of values and/or the name of the provider
* responsible to identify suitable values. If the type of the related item is
* responsible to identify suitable values. If the type of the related item is
a
*
a
{@link java.util.Map} it can have both key and value hints.
* {@link java.util.Map} it can have both key and value hints.
*
*
* @author Stephane Nicoll
* @author Stephane Nicoll
* @since 1.4.0
* @since 1.4.0
...
@@ -39,9 +39,9 @@ public class Hints {
...
@@ -39,9 +39,9 @@ public class Hints {
/**
/**
* The list of well-defined keys, if any. Only applicable if the type of the related
* The list of well-defined keys, if any. Only applicable if the type of the related
* item is a {@link java.util.Map}. If no extra {@link ValueProvider provider}
* item is a {@link java.util.Map}. If no extra {@link ValueProvider provider}
is
*
is specified, these values are to be considered a closed-set of the available
*
specified, these values are to be considered a closed-set of the available keys for
*
keys for
the map.
* the map.
* @return the key hints
* @return the key hints
*/
*/
public
List
<
ValueHint
>
getKeyHints
()
{
public
List
<
ValueHint
>
getKeyHints
()
{
...
@@ -51,8 +51,8 @@ public class Hints {
...
@@ -51,8 +51,8 @@ public class Hints {
/**
/**
* The value providers that are applicable to the keys of this item. Only applicable
* The value providers that are applicable to the keys of this item. Only applicable
* if the type of the related item is a {@link java.util.Map}. Only one
* if the type of the related item is a {@link java.util.Map}. Only one
* {@link ValueProvider} is enabled for a key: the first in the list that is
* {@link ValueProvider} is enabled for a key: the first in the list that is
supported
* s
upported s
hould be used.
* should be used.
* @return the key providers
* @return the key providers
*/
*/
public
List
<
ValueProvider
>
getKeyProviders
()
{
public
List
<
ValueProvider
>
getKeyProviders
()
{
...
...
spring-boot-tools/spring-boot-configuration-metadata/src/test/java/org/springframework/boot/configurationmetadata/ConfigurationMetadataRepositoryJsonBuilderTests.java
View file @
4b55144d
...
@@ -205,38 +205,47 @@ public class ConfigurationMetadataRepositoryJsonBuilderTests
...
@@ -205,38 +205,47 @@ public class ConfigurationMetadataRepositoryJsonBuilderTests
contains
(
source
.
getProperties
(),
"spring.map.first"
,
"spring.map.second"
,
contains
(
source
.
getProperties
(),
"spring.map.first"
,
"spring.map.second"
,
"spring.map.keys"
,
"spring.map.values"
);
"spring.map.keys"
,
"spring.map.values"
);
assertThat
(
source
.
getProperties
()).
hasSize
(
4
);
assertThat
(
source
.
getProperties
()).
hasSize
(
4
);
ConfigurationMetadataProperty
first
=
repo
.
getAllProperties
().
get
(
"spring.map.first"
);
ConfigurationMetadataProperty
first
=
repo
.
getAllProperties
()
.
get
(
"spring.map.first"
);
assertThat
(
first
.
getHints
().
getKeyHints
()).
hasSize
(
2
);
assertThat
(
first
.
getHints
().
getKeyHints
()).
hasSize
(
2
);
assertThat
(
first
.
getHints
().
getValueProviders
()).
hasSize
(
0
);
assertThat
(
first
.
getHints
().
getValueProviders
()).
hasSize
(
0
);
assertThat
(
first
.
getHints
().
getKeyHints
().
get
(
0
).
getValue
()).
isEqualTo
(
"one"
);
assertThat
(
first
.
getHints
().
getKeyHints
().
get
(
0
).
getValue
()).
isEqualTo
(
"one"
);
assertThat
(
first
.
getHints
().
getKeyHints
().
get
(
0
).
getDescription
()).
isEqualTo
(
"First."
);
assertThat
(
first
.
getHints
().
getKeyHints
().
get
(
0
).
getDescription
())
.
isEqualTo
(
"First."
);
assertThat
(
first
.
getHints
().
getKeyHints
().
get
(
1
).
getValue
()).
isEqualTo
(
"two"
);
assertThat
(
first
.
getHints
().
getKeyHints
().
get
(
1
).
getValue
()).
isEqualTo
(
"two"
);
assertThat
(
first
.
getHints
().
getKeyHints
().
get
(
1
).
getDescription
()).
isEqualTo
(
"Second."
);
assertThat
(
first
.
getHints
().
getKeyHints
().
get
(
1
).
getDescription
())
ConfigurationMetadataProperty
second
=
repo
.
getAllProperties
().
get
(
"spring.map.second"
);
.
isEqualTo
(
"Second."
);
ConfigurationMetadataProperty
second
=
repo
.
getAllProperties
()
.
get
(
"spring.map.second"
);
assertThat
(
second
.
getHints
().
getValueHints
()).
hasSize
(
2
);
assertThat
(
second
.
getHints
().
getValueHints
()).
hasSize
(
2
);
assertThat
(
second
.
getHints
().
getValueProviders
()).
hasSize
(
0
);
assertThat
(
second
.
getHints
().
getValueProviders
()).
hasSize
(
0
);
assertThat
(
second
.
getHints
().
getValueHints
().
get
(
0
).
getValue
()).
isEqualTo
(
"42"
);
assertThat
(
second
.
getHints
().
getValueHints
().
get
(
0
).
getValue
()).
isEqualTo
(
"42"
);
assertThat
(
second
.
getHints
().
getValueHints
().
get
(
0
).
getDescription
()).
isEqualTo
(
"Choose me."
);
assertThat
(
second
.
getHints
().
getValueHints
().
get
(
0
).
getDescription
())
.
isEqualTo
(
"Choose me."
);
assertThat
(
second
.
getHints
().
getValueHints
().
get
(
1
).
getValue
()).
isEqualTo
(
"24"
);
assertThat
(
second
.
getHints
().
getValueHints
().
get
(
1
).
getValue
()).
isEqualTo
(
"24"
);
assertThat
(
second
.
getHints
().
getValueHints
().
get
(
1
).
getDescription
()).
isNull
();
assertThat
(
second
.
getHints
().
getValueHints
().
get
(
1
).
getDescription
()).
isNull
();
ConfigurationMetadataProperty
keys
=
repo
.
getAllProperties
().
get
(
"spring.map.keys"
);
ConfigurationMetadataProperty
keys
=
repo
.
getAllProperties
()
.
get
(
"spring.map.keys"
);
assertThat
(
keys
.
getHints
().
getValueHints
()).
hasSize
(
0
);
assertThat
(
keys
.
getHints
().
getValueHints
()).
hasSize
(
0
);
assertThat
(
keys
.
getHints
().
getValueProviders
()).
hasSize
(
1
);
assertThat
(
keys
.
getHints
().
getValueProviders
()).
hasSize
(
1
);
assertThat
(
keys
.
getHints
().
getValueProviders
().
get
(
0
).
getName
()).
isEqualTo
(
"any"
);
assertThat
(
keys
.
getHints
().
getValueProviders
().
get
(
0
).
getName
()).
isEqualTo
(
"any"
);
ConfigurationMetadataProperty
values
=
repo
.
getAllProperties
().
get
(
"spring.map.values"
);
ConfigurationMetadataProperty
values
=
repo
.
getAllProperties
()
.
get
(
"spring.map.values"
);
assertThat
(
values
.
getHints
().
getValueHints
()).
hasSize
(
0
);
assertThat
(
values
.
getHints
().
getValueHints
()).
hasSize
(
0
);
assertThat
(
values
.
getHints
().
getValueProviders
()).
hasSize
(
1
);
assertThat
(
values
.
getHints
().
getValueProviders
()).
hasSize
(
1
);
assertThat
(
values
.
getHints
().
getValueProviders
().
get
(
0
).
getName
()).
isEqualTo
(
"handle-as"
);
assertThat
(
values
.
getHints
().
getValueProviders
().
get
(
0
).
getName
())
assertThat
(
values
.
getHints
().
getValueProviders
().
get
(
0
).
getParameters
()).
hasSize
(
1
);
.
isEqualTo
(
"handle-as"
);
assertThat
(
values
.
getHints
().
getValueProviders
().
get
(
0
).
getParameters
().
get
(
"target"
))
assertThat
(
values
.
getHints
().
getValueProviders
().
get
(
0
).
getParameters
())
.
isEqualTo
(
"java.lang.Integer"
);
.
hasSize
(
1
);
assertThat
(
values
.
getHints
().
getValueProviders
().
get
(
0
).
getParameters
()
.
get
(
"target"
)).
isEqualTo
(
"java.lang.Integer"
);
}
}
private
void
validatePropertyHints
(
ConfigurationMetadataProperty
property
,
private
void
validatePropertyHints
(
ConfigurationMetadataProperty
property
,
int
valueHints
,
int
valueProviders
)
{
int
valueHints
,
int
valueProviders
)
{
assertThat
(
property
.
getHints
().
getValueHints
().
size
()).
isEqualTo
(
valueHints
);
assertThat
(
property
.
getHints
().
getValueHints
().
size
()).
isEqualTo
(
valueHints
);
assertThat
(
property
.
getHints
().
getValueProviders
().
size
()).
isEqualTo
(
valueProviders
);
assertThat
(
property
.
getHints
().
getValueProviders
().
size
())
.
isEqualTo
(
valueProviders
);
}
}
private
void
contains
(
Map
<
String
,
?>
source
,
String
...
keys
)
{
private
void
contains
(
Map
<
String
,
?>
source
,
String
...
keys
)
{
...
...
spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/JarWriter.java
View file @
4b55144d
...
@@ -389,6 +389,7 @@ public class JarWriter {
...
@@ -389,6 +389,7 @@ public class JarWriter {
interface
EntryTransformer
{
interface
EntryTransformer
{
JarEntry
transform
(
JarEntry
jarEntry
);
JarEntry
transform
(
JarEntry
jarEntry
);
}
}
/**
/**
...
...
spring-boot/src/main/java/org/springframework/boot/context/properties/EnableConfigurationPropertiesImportSelector.java
View file @
4b55144d
...
@@ -76,8 +76,8 @@ class EnableConfigurationPropertiesImportSelector implements ImportSelector {
...
@@ -76,8 +76,8 @@ class EnableConfigurationPropertiesImportSelector implements ImportSelector {
List
<
Class
<?>>
types
=
collectClasses
(
attributes
.
get
(
"value"
));
List
<
Class
<?>>
types
=
collectClasses
(
attributes
.
get
(
"value"
));
for
(
Class
<?>
type
:
types
)
{
for
(
Class
<?>
type
:
types
)
{
String
prefix
=
extractPrefix
(
type
);
String
prefix
=
extractPrefix
(
type
);
String
name
=
(
StringUtils
.
hasText
(
prefix
)
String
name
=
(
StringUtils
.
hasText
(
prefix
)
?
prefix
+
"-"
+
type
.
getName
()
?
prefix
+
"-"
+
type
.
getName
()
:
type
.
getName
());
:
type
.
getName
());
if
(!
registry
.
containsBeanDefinition
(
name
))
{
if
(!
registry
.
containsBeanDefinition
(
name
))
{
registerBeanDefinition
(
registry
,
type
,
name
);
registerBeanDefinition
(
registry
,
type
,
name
);
}
}
...
...
spring-boot/src/main/java/org/springframework/boot/jdbc/DatabaseDriver.java
View file @
4b55144d
...
@@ -26,7 +26,7 @@ import org.springframework.util.StringUtils;
...
@@ -26,7 +26,7 @@ import org.springframework.util.StringUtils;
* @author Maciej Walkowiak
* @author Maciej Walkowiak
* @author Marten Deinum
* @author Marten Deinum
* @author Stephane Nicoll
* @author Stephane Nicoll
* @since 1.
2
.0
* @since 1.
4
.0
*/
*/
public
enum
DatabaseDriver
{
public
enum
DatabaseDriver
{
...
@@ -88,8 +88,8 @@ public enum DatabaseDriver {
...
@@ -88,8 +88,8 @@ public enum DatabaseDriver {
"SELECT 1"
),
"SELECT 1"
),
/**
/**
* jTDS. As it can be used for several databases, there isn't a single product name
* jTDS. As it can be used for several databases, there isn't a single product name
we
*
we
could rely on.
* could rely on.
*/
*/
JTDS
(
null
,
"net.sourceforge.jtds.jdbc.Driver"
),
JTDS
(
null
,
"net.sourceforge.jtds.jdbc.Driver"
),
...
...
spring-boot/src/main/java/org/springframework/boot/jta/atomikos/AtomikosProperties.java
View file @
4b55144d
...
@@ -92,8 +92,8 @@ public class AtomikosProperties {
...
@@ -92,8 +92,8 @@ public class AtomikosProperties {
private
String
logBaseDir
;
private
String
logBaseDir
;
/**
/**
* Interval between checkpoints. A checkpoint reduces the log file size at the
* Interval between checkpoints. A checkpoint reduces the log file size at the
expense
*
expense
of adding some overhead in the runtime.
* of adding some overhead in the runtime.
*/
*/
private
long
checkpointInterval
=
500
;
private
long
checkpointInterval
=
500
;
...
...
spring-boot/src/test/java/org/springframework/boot/jdbc/DatabaseDriverTests.java
View file @
4b55144d
...
@@ -68,18 +68,27 @@ public class DatabaseDriverTests {
...
@@ -68,18 +68,27 @@ public class DatabaseDriverTests {
@Test
@Test
public
void
databaseProductNameLookups
()
throws
Exception
{
public
void
databaseProductNameLookups
()
throws
Exception
{
assertThat
(
DatabaseDriver
.
fromProductName
(
"newone"
)).
isEqualTo
(
DatabaseDriver
.
UNKNOWN
);
assertThat
(
DatabaseDriver
.
fromProductName
(
"newone"
))
assertThat
(
DatabaseDriver
.
fromProductName
(
"HSQL Database Engine"
)).
isEqualTo
(
DatabaseDriver
.
HSQLDB
);
.
isEqualTo
(
DatabaseDriver
.
UNKNOWN
);
assertThat
(
DatabaseDriver
.
fromProductName
(
"Oracle"
)).
isEqualTo
(
DatabaseDriver
.
ORACLE
);
assertThat
(
DatabaseDriver
.
fromProductName
(
"HSQL Database Engine"
))
assertThat
(
DatabaseDriver
.
fromProductName
(
"Apache Derby"
)).
isEqualTo
(
DatabaseDriver
.
DERBY
);
.
isEqualTo
(
DatabaseDriver
.
HSQLDB
);
assertThat
(
DatabaseDriver
.
fromProductName
(
"Oracle"
))
.
isEqualTo
(
DatabaseDriver
.
ORACLE
);
assertThat
(
DatabaseDriver
.
fromProductName
(
"Apache Derby"
))
.
isEqualTo
(
DatabaseDriver
.
DERBY
);
assertThat
(
DatabaseDriver
.
fromProductName
(
"DB2"
)).
isEqualTo
(
DatabaseDriver
.
DB2
);
assertThat
(
DatabaseDriver
.
fromProductName
(
"DB2"
)).
isEqualTo
(
DatabaseDriver
.
DB2
);
assertThat
(
DatabaseDriver
.
fromProductName
(
"DB2/LINUXX8664"
)).
isEqualTo
(
DatabaseDriver
.
DB2
);
assertThat
(
DatabaseDriver
.
fromProductName
(
"DB2/LINUXX8664"
))
assertThat
(
DatabaseDriver
.
fromProductName
(
"DB2 UDB for AS/400"
)).
isEqualTo
(
DatabaseDriver
.
DB2_AS400
);
.
isEqualTo
(
DatabaseDriver
.
DB2
);
assertThat
(
DatabaseDriver
.
fromProductName
(
"DB3 XDB for AS/400"
)).
isEqualTo
(
DatabaseDriver
.
DB2_AS400
);
assertThat
(
DatabaseDriver
.
fromProductName
(
"DB2 UDB for AS/400"
))
.
isEqualTo
(
DatabaseDriver
.
DB2_AS400
);
assertThat
(
DatabaseDriver
.
fromProductName
(
"DB3 XDB for AS/400"
))
.
isEqualTo
(
DatabaseDriver
.
DB2_AS400
);
assertThat
(
DatabaseDriver
.
fromProductName
(
"Informix Dynamic Server"
))
assertThat
(
DatabaseDriver
.
fromProductName
(
"Informix Dynamic Server"
))
.
isEqualTo
(
DatabaseDriver
.
INFORMIX
);
.
isEqualTo
(
DatabaseDriver
.
INFORMIX
);
assertThat
(
DatabaseDriver
.
fromProductName
(
"Firebird 2.5.WI"
)).
isEqualTo
(
DatabaseDriver
.
FIREBIRD
);
assertThat
(
DatabaseDriver
.
fromProductName
(
"Firebird 2.5.WI"
))
assertThat
(
DatabaseDriver
.
fromProductName
(
"Firebird 2.1.LI"
)).
isEqualTo
(
DatabaseDriver
.
FIREBIRD
);
.
isEqualTo
(
DatabaseDriver
.
FIREBIRD
);
assertThat
(
DatabaseDriver
.
fromProductName
(
"Firebird 2.1.LI"
))
.
isEqualTo
(
DatabaseDriver
.
FIREBIRD
);
}
}
}
}
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