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
c201c1da
Commit
c201c1da
authored
Mar 15, 2018
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
9384e5c3
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
70 additions
and
81 deletions
+70
-81
WebEndpointPropertiesTests.java
...utoconfigure/endpoint/web/WebEndpointPropertiesTests.java
+1
-1
H2ConsoleProperties.java
...gframework/boot/autoconfigure/h2/H2ConsoleProperties.java
+3
-5
WebServicesProperties.java
...boot/autoconfigure/webservices/WebServicesProperties.java
+3
-5
CouchbaseAutoConfigurationIntegrationTests.java
...couchbase/CouchbaseAutoConfigurationIntegrationTests.java
+11
-13
CouchbaseAutoConfigurationTests.java
...oconfigure/couchbase/CouchbaseAutoConfigurationTests.java
+33
-38
WebClientAutoConfigurationTests.java
...tive/function/client/WebClientAutoConfigurationTests.java
+18
-14
CollectionBinderTests.java
...k/boot/context/properties/bind/CollectionBinderTests.java
+1
-5
No files found.
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointPropertiesTests.java
View file @
c201c1da
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/h2/H2ConsoleProperties.java
View file @
c201c1da
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -48,10 +48,8 @@ public class H2ConsoleProperties {
public
void
setPath
(
String
path
)
{
Assert
.
notNull
(
path
,
"Path must not be null"
);
Assert
.
isTrue
(
path
.
length
()
>
1
,
"Path must have length greater than 1"
);
Assert
.
isTrue
(
path
.
startsWith
(
"/"
),
"Path must start with '/'"
);
Assert
.
isTrue
(
path
.
length
()
>
1
,
"Path must have length greater than 1"
);
Assert
.
isTrue
(
path
.
startsWith
(
"/"
),
"Path must start with '/'"
);
this
.
path
=
path
;
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/webservices/WebServicesProperties.java
View file @
c201c1da
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -45,10 +45,8 @@ public class WebServicesProperties {
public
void
setPath
(
String
path
)
{
Assert
.
notNull
(
path
,
"Path must not be null"
);
Assert
.
isTrue
(
path
.
length
()
>
1
,
"Path must have length greater than 1"
);
Assert
.
isTrue
(
path
.
startsWith
(
"/"
),
"Path must start with '/'"
);
Assert
.
isTrue
(
path
.
length
()
>
1
,
"Path must have length greater than 1"
);
Assert
.
isTrue
(
path
.
startsWith
(
"/"
),
"Path must start with '/'"
);
this
.
path
=
path
;
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseAutoConfigurationIntegrationTests.java
View file @
c201c1da
...
...
@@ -41,33 +41,31 @@ import static org.mockito.Mockito.mock;
public
class
CouchbaseAutoConfigurationIntegrationTests
{
private
ApplicationContextRunner
contextRunner
=
new
ApplicationContextRunner
()
.
withConfiguration
(
AutoConfigurations
.
of
(
PropertyPlaceholderAutoConfiguration
.
class
,
CouchbaseAutoConfiguration
.
class
));
.
withConfiguration
(
AutoConfigurations
.
of
(
PropertyPlaceholderAutoConfiguration
.
class
,
CouchbaseAutoConfiguration
.
class
));
@Rule
public
final
CouchbaseTestServer
couchbase
=
new
CouchbaseTestServer
();
@Test
public
void
defaultConfiguration
()
{
this
.
contextRunner
.
withPropertyValues
(
"spring.couchbase.bootstrapHosts=localhost"
)
.
run
((
context
)
->
{
assertThat
(
context
).
hasSingleBean
(
Cluster
.
class
)
.
hasSingleBean
(
ClusterInfo
.
class
)
.
hasSingleBean
(
CouchbaseEnvironment
.
class
)
.
hasSingleBean
(
Bucket
.
class
);
});
this
.
contextRunner
.
withPropertyValues
(
"spring.couchbase.bootstrapHosts=localhost"
)
.
run
((
context
)
->
assertThat
(
context
).
hasSingleBean
(
Cluster
.
class
)
.
hasSingleBean
(
ClusterInfo
.
class
)
.
hasSingleBean
(
CouchbaseEnvironment
.
class
)
.
hasSingleBean
(
Bucket
.
class
));
}
@Test
public
void
customConfiguration
()
{
this
.
contextRunner
.
withUserConfiguration
(
CustomConfiguration
.
class
)
this
.
contextRunner
.
withUserConfiguration
(
CustomConfiguration
.
class
)
.
withPropertyValues
(
"spring.couchbase.bootstrapHosts=localhost"
)
.
run
((
context
)
->
{
assertThat
(
context
.
getBeansOfType
(
Cluster
.
class
)).
hasSize
(
2
);
assertThat
(
context
.
getBeansOfType
(
ClusterInfo
.
class
)).
hasSize
(
1
);
assertThat
(
context
.
getBeansOfType
(
CouchbaseEnvironment
.
class
)).
hasSize
(
1
);
assertThat
(
context
.
getBeansOfType
(
CouchbaseEnvironment
.
class
))
.
hasSize
(
1
);
assertThat
(
context
.
getBeansOfType
(
Bucket
.
class
)).
hasSize
(
2
);
});
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseAutoConfigurationTests.java
View file @
c201c1da
...
...
@@ -47,14 +47,13 @@ import static org.mockito.Mockito.mock;
public
class
CouchbaseAutoConfigurationTests
{
private
ApplicationContextRunner
contextRunner
=
new
ApplicationContextRunner
()
.
withConfiguration
(
AutoConfigurations
.
of
(
PropertyPlaceholderAutoConfiguration
.
class
,
CouchbaseAutoConfiguration
.
class
));
.
withConfiguration
(
AutoConfigurations
.
of
(
PropertyPlaceholderAutoConfiguration
.
class
,
CouchbaseAutoConfiguration
.
class
));
@Test
public
void
bootstrapHostsIsRequired
()
{
this
.
contextRunner
.
run
((
context
)
->
{
assertNoCouchbaseBeans
(
context
);
});
this
.
contextRunner
.
run
((
context
)
->
assertNoCouchbaseBeans
(
context
));
}
@Test
...
...
@@ -80,19 +79,17 @@ public class CouchbaseAutoConfigurationTests {
private
void
assertNoCouchbaseBeans
(
AssertableApplicationContext
context
)
{
// No beans are going to be created
assertThat
(
context
).
doesNotHaveBean
(
CouchbaseEnvironment
.
class
)
.
doesNotHaveBean
(
ClusterInfo
.
class
)
.
doesNotHaveBean
(
Cluster
.
class
)
.
doesNotHaveBean
(
ClusterInfo
.
class
).
doesNotHaveBean
(
Cluster
.
class
)
.
doesNotHaveBean
(
Bucket
.
class
);
}
@Test
public
void
customizeEnvEndpoints
()
{
testCouchbaseEnv
(
env
->
{
assertThat
(
env
.
kvEndpoints
()).
isEqualTo
(
4
);
assertThat
(
env
.
queryEndpoints
()).
isEqualTo
(
5
);
assertThat
(
env
.
viewEndpoints
()).
isEqualTo
(
6
);
},
"spring.couchbase.env.endpoints.keyValue=4"
,
assertThat
(
env
.
kvEndpoints
()).
isEqualTo
(
4
);
assertThat
(
env
.
queryEndpoints
()).
isEqualTo
(
5
);
assertThat
(
env
.
viewEndpoints
()).
isEqualTo
(
6
);
},
"spring.couchbase.env.endpoints.keyValue=4"
,
"spring.couchbase.env.endpoints.query=5"
,
"spring.couchbase.env.endpoints.view=6"
);
}
...
...
@@ -100,13 +97,12 @@ public class CouchbaseAutoConfigurationTests {
@Test
public
void
customizeEnvTimeouts
()
{
testCouchbaseEnv
(
env
->
{
assertThat
(
env
.
connectTimeout
()).
isEqualTo
(
100
);
assertThat
(
env
.
kvTimeout
()).
isEqualTo
(
200
);
assertThat
(
env
.
queryTimeout
()).
isEqualTo
(
300
);
assertThat
(
env
.
socketConnectTimeout
()).
isEqualTo
(
400
);
assertThat
(
env
.
viewTimeout
()).
isEqualTo
(
500
);
},
"spring.couchbase.env.timeouts.connect=100"
,
assertThat
(
env
.
connectTimeout
()).
isEqualTo
(
100
);
assertThat
(
env
.
kvTimeout
()).
isEqualTo
(
200
);
assertThat
(
env
.
queryTimeout
()).
isEqualTo
(
300
);
assertThat
(
env
.
socketConnectTimeout
()).
isEqualTo
(
400
);
assertThat
(
env
.
viewTimeout
()).
isEqualTo
(
500
);
},
"spring.couchbase.env.timeouts.connect=100"
,
"spring.couchbase.env.timeouts.keyValue=200"
,
"spring.couchbase.env.timeouts.query=300"
,
"spring.couchbase.env.timeouts.socket-connect=400"
,
...
...
@@ -116,34 +112,33 @@ public class CouchbaseAutoConfigurationTests {
@Test
public
void
enableSslNoEnabledFlag
()
{
testCouchbaseEnv
(
env
->
{
assertThat
(
env
.
sslEnabled
()).
isTrue
();
assertThat
(
env
.
sslKeystoreFile
()).
isEqualTo
(
"foo"
);
assertThat
(
env
.
sslKeystorePassword
()).
isEqualTo
(
"secret"
);
},
"spring.couchbase.env.ssl.keyStore=foo"
,
assertThat
(
env
.
sslEnabled
()).
isTrue
();
assertThat
(
env
.
sslKeystoreFile
()).
isEqualTo
(
"foo"
);
assertThat
(
env
.
sslKeystorePassword
()).
isEqualTo
(
"secret"
);
},
"spring.couchbase.env.ssl.keyStore=foo"
,
"spring.couchbase.env.ssl.keyStorePassword=secret"
);
}
@Test
public
void
disableSslEvenWithKeyStore
()
{
testCouchbaseEnv
(
env
->
{
assertThat
(
env
.
sslEnabled
()).
isFalse
();
assertThat
(
env
.
sslKeystoreFile
()).
isNull
();
assertThat
(
env
.
sslKeystorePassword
()).
isNull
();
},
"spring.couchbase.env.ssl.enabled=false"
,
assertThat
(
env
.
sslEnabled
()).
isFalse
();
assertThat
(
env
.
sslKeystoreFile
()).
isNull
();
assertThat
(
env
.
sslKeystorePassword
()).
isNull
();
},
"spring.couchbase.env.ssl.enabled=false"
,
"spring.couchbase.env.ssl.keyStore=foo"
,
"spring.couchbase.env.ssl.keyStorePassword=secret"
);
}
private
void
testCouchbaseEnv
(
Consumer
<
DefaultCouchbaseEnvironment
>
environmentConsumer
,
private
void
testCouchbaseEnv
(
Consumer
<
DefaultCouchbaseEnvironment
>
environmentConsumer
,
String
...
environment
)
{
this
.
contextRunner
.
withUserConfiguration
(
CouchbaseTestConfigurer
.
class
)
.
withPropertyValues
(
environment
)
.
run
((
context
)
->
{
CouchbaseProperties
properties
=
context
.
getBean
(
CouchbaseProperties
.
class
);
DefaultCouchbaseEnvironment
env
=
new
CouchbaseConfiguration
(
properties
)
.
couchbaseEnvironment
();
.
withPropertyValues
(
environment
)
.
run
((
context
)
->
{
CouchbaseProperties
properties
=
context
.
getBean
(
CouchbaseProperties
.
class
);
DefaultCouchbaseEnvironment
env
=
new
CouchbaseConfiguration
(
properties
)
.
couchbaseEnvironment
();
environmentConsumer
.
accept
(
env
);
});
}
...
...
@@ -151,12 +146,12 @@ public class CouchbaseAutoConfigurationTests {
@Test
public
void
customizeEnvWithCustomCouchbaseConfiguration
()
{
this
.
contextRunner
.
withUserConfiguration
(
CustomCouchbaseConfiguration
.
class
)
.
withPropertyValues
(
"spring.couchbase.bootstrap-hosts=localhost"
,
.
withPropertyValues
(
"spring.couchbase.bootstrap-hosts=localhost"
,
"spring.couchbase.env.timeouts.connect=100"
)
.
run
((
context
)
->
{
assertThat
(
context
).
hasSingleBean
(
CouchbaseConfiguration
.
class
);
DefaultCouchbaseEnvironment
env
=
context
.
getBean
(
DefaultCouchbaseEnvironment
.
class
);
DefaultCouchbaseEnvironment
env
=
context
.
getBean
(
DefaultCouchbaseEnvironment
.
class
);
assertThat
(
env
.
socketConnectTimeout
()).
isEqualTo
(
5000
);
assertThat
(
env
.
connectTimeout
()).
isEqualTo
(
2000
);
});
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/function/client/WebClientAutoConfigurationTests.java
View file @
c201c1da
...
...
@@ -53,12 +53,11 @@ public class WebClientAutoConfigurationTests {
@Test
public
void
shouldCreateBuilder
()
{
this
.
contextRunner
.
run
((
context
)
->
{
WebClient
.
Builder
builder
=
context
.
getBean
(
WebClient
.
Builder
.
class
);
WebClient
webClient
=
builder
.
build
();
assertThat
(
webClient
).
isNotNull
();
});
this
.
contextRunner
.
run
((
context
)
->
{
WebClient
.
Builder
builder
=
context
.
getBean
(
WebClient
.
Builder
.
class
);
WebClient
webClient
=
builder
.
build
();
assertThat
(
webClient
).
isNotNull
();
});
}
...
...
@@ -67,7 +66,8 @@ public class WebClientAutoConfigurationTests {
this
.
contextRunner
.
withUserConfiguration
(
CodecConfiguration
.
class
)
.
run
((
context
)
->
{
WebClient
.
Builder
builder
=
context
.
getBean
(
WebClient
.
Builder
.
class
);
CodecCustomizer
codecCustomizer
=
context
.
getBean
(
CodecCustomizer
.
class
);
CodecCustomizer
codecCustomizer
=
context
.
getBean
(
CodecCustomizer
.
class
);
WebClientCodecCustomizer
clientCustomizer
=
context
.
getBean
(
WebClientCodecCustomizer
.
class
);
builder
.
build
();
...
...
@@ -81,7 +81,8 @@ public class WebClientAutoConfigurationTests {
this
.
contextRunner
.
withUserConfiguration
(
WebClientCustomizerConfig
.
class
)
.
run
((
context
)
->
{
WebClient
.
Builder
builder
=
context
.
getBean
(
WebClient
.
Builder
.
class
);
WebClientCustomizer
customizer
=
context
.
getBean
(
WebClientCustomizer
.
class
);
WebClientCustomizer
customizer
=
context
.
getBean
(
WebClientCustomizer
.
class
);
builder
.
build
();
verify
(
customizer
).
customize
(
any
(
WebClient
.
Builder
.
class
));
});
...
...
@@ -95,12 +96,15 @@ public class WebClientAutoConfigurationTests {
ClientHttpConnector
firstConnector
=
mock
(
ClientHttpConnector
.
class
);
given
(
firstConnector
.
connect
(
any
(),
any
(),
any
()))
.
willReturn
(
Mono
.
just
(
response
));
WebClient
.
Builder
firstBuilder
=
context
.
getBean
(
WebClient
.
Builder
.
class
);
firstBuilder
.
clientConnector
(
firstConnector
).
baseUrl
(
"http://first.example.org"
);
WebClient
.
Builder
firstBuilder
=
context
.
getBean
(
WebClient
.
Builder
.
class
);
firstBuilder
.
clientConnector
(
firstConnector
)
.
baseUrl
(
"http://first.example.org"
);
ClientHttpConnector
secondConnector
=
mock
(
ClientHttpConnector
.
class
);
given
(
secondConnector
.
connect
(
any
(),
any
(),
any
()))
.
willReturn
(
Mono
.
just
(
response
));
WebClient
.
Builder
secondBuilder
=
context
.
getBean
(
WebClient
.
Builder
.
class
);
WebClient
.
Builder
secondBuilder
=
context
.
getBean
(
WebClient
.
Builder
.
class
);
secondBuilder
.
clientConnector
(
secondConnector
)
.
baseUrl
(
"http://second.example.org"
);
assertThat
(
firstBuilder
).
isNotEqualTo
(
secondBuilder
);
...
...
@@ -110,7 +114,8 @@ public class WebClientAutoConfigurationTests {
eq
(
URI
.
create
(
"http://first.example.org/foo"
)),
any
());
verify
(
secondConnector
).
connect
(
eq
(
HttpMethod
.
GET
),
eq
(
URI
.
create
(
"http://second.example.org/foo"
)),
any
());
WebClientCustomizer
customizer
=
context
.
getBean
(
WebClientCustomizer
.
class
);
WebClientCustomizer
customizer
=
context
.
getBean
(
WebClientCustomizer
.
class
);
verify
(
customizer
,
times
(
1
)).
customize
(
any
(
WebClient
.
Builder
.
class
));
});
}
...
...
@@ -118,8 +123,7 @@ public class WebClientAutoConfigurationTests {
@Test
public
void
shouldNotCreateClientBuilderIfAlreadyPresent
()
{
this
.
contextRunner
.
withUserConfiguration
(
WebClientCustomizerConfig
.
class
,
CustomWebClientBuilderConfig
.
class
)
.
run
((
context
)
->
{
CustomWebClientBuilderConfig
.
class
).
run
((
context
)
->
{
WebClient
.
Builder
builder
=
context
.
getBean
(
WebClient
.
Builder
.
class
);
assertThat
(
builder
).
isInstanceOf
(
MyWebClientBuilder
.
class
);
});
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/CollectionBinderTests.java
View file @
c201c1da
...
...
@@ -25,7 +25,6 @@ import java.util.Set;
import
java.util.stream.Collectors
;
import
org.junit.Before
;
import
org.junit.Ignore
;
import
org.junit.Test
;
import
org.springframework.boot.context.properties.bind.BinderTests.JavaBean
;
...
...
@@ -306,7 +305,6 @@ public class CollectionBinderTests {
}
@Test
@Ignore
public
void
bindToCollectionWithNoDefaultConstructor
()
{
MockConfigurationPropertySource
source
=
new
MockConfigurationPropertySource
();
source
.
put
(
"foo.items"
,
"a,b,c,c"
);
...
...
@@ -389,8 +387,7 @@ public class CollectionBinderTests {
MockConfigurationPropertySource
source
=
new
MockConfigurationPropertySource
();
source
.
put
(
"foo.bar[0]"
,
"hello"
);
this
.
sources
.
add
(
source
);
Bindable
<
ClonedArrayBean
>
target
=
Bindable
.
of
(
ClonedArrayBean
.
class
);
Bindable
<
ClonedArrayBean
>
target
=
Bindable
.
of
(
ClonedArrayBean
.
class
);
ClonedArrayBean
bean
=
this
.
binder
.
bind
(
"foo"
,
target
).
get
();
assertThat
(
bean
.
getBar
()).
contains
(
"hello"
);
}
...
...
@@ -468,7 +465,6 @@ public class CollectionBinderTests {
}
}
public
static
class
ClonedArrayBean
{
private
String
[]
bar
;
...
...
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