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
7b5df365
Commit
7b5df365
authored
Jun 17, 2016
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable SSL from MongoClientOptions
Closes gh-5099
parent
fa0a137c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
0 deletions
+36
-0
MongoProperties.java
...ngframework/boot/autoconfigure/mongo/MongoProperties.java
+2
-0
MongoAutoConfigurationTests.java
...boot/autoconfigure/mongo/MongoAutoConfigurationTests.java
+34
-0
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoProperties.java
View file @
7b5df365
...
...
@@ -39,6 +39,7 @@ import org.springframework.core.env.Environment;
* @author Josh Long
* @author Andy Wilkinson
* @author Eddú Meléndez
* @author Stephane Nicoll
*/
@ConfigurationProperties
(
prefix
=
"spring.data.mongodb"
)
public
class
MongoProperties
{
...
...
@@ -257,6 +258,7 @@ public class MongoProperties {
builder
.
description
(
options
.
getDescription
());
builder
.
maxWaitTime
(
options
.
getMaxWaitTime
());
builder
.
readPreference
(
options
.
getReadPreference
());
builder
.
sslEnabled
(
options
.
isSslEnabled
());
builder
.
socketFactory
(
options
.
getSocketFactory
());
builder
.
socketKeepAlive
(
options
.
isSocketKeepAlive
());
builder
.
socketTimeout
(
options
.
getSocketTimeout
());
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoAutoConfigurationTests.java
View file @
7b5df365
...
...
@@ -16,7 +16,10 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
mongo
;
import
javax.net.SocketFactory
;
import
com.mongodb.Mongo
;
import
com.mongodb.MongoClient
;
import
com.mongodb.MongoClientOptions
;
import
org.junit.After
;
import
org.junit.Test
;
...
...
@@ -28,11 +31,13 @@ import org.springframework.context.annotation.Bean;
import
org.springframework.context.annotation.Configuration
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
mockito
.
Mockito
.
mock
;
/**
* Tests for {@link MongoAutoConfiguration}.
*
* @author Dave Syer
* @author Stephane Nicoll
*/
public
class
MongoAutoConfigurationTests
{
...
...
@@ -78,6 +83,20 @@ public class MongoAutoConfigurationTests {
.
isEqualTo
(
300
);
}
@Test
public
void
optionsSslConfig
()
{
this
.
context
=
new
AnnotationConfigApplicationContext
();
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.data.mongodb.uri:mongodb://localhost/test"
);
this
.
context
.
register
(
SslOptionsConfig
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
,
MongoAutoConfiguration
.
class
);
this
.
context
.
refresh
();
MongoClient
mongo
=
this
.
context
.
getBean
(
MongoClient
.
class
);
MongoClientOptions
options
=
mongo
.
getMongoClientOptions
();
assertThat
(
options
.
isSslEnabled
()).
isTrue
();
assertThat
(
options
.
getSocketFactory
()).
isSameAs
(
this
.
context
.
getBean
(
"mySocketFactory"
));
}
@Configuration
protected
static
class
OptionsConfig
{
...
...
@@ -88,4 +107,19 @@ public class MongoAutoConfigurationTests {
}
@Configuration
protected
static
class
SslOptionsConfig
{
@Bean
public
MongoClientOptions
mongoClientOptions
()
{
return
MongoClientOptions
.
builder
().
sslEnabled
(
true
).
socketFactory
(
mySocketFactory
()).
build
();
}
@Bean
public
SocketFactory
mySocketFactory
()
{
return
mock
(
SocketFactory
.
class
);
}
}
}
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