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
4e07003e
Commit
4e07003e
authored
Jun 27, 2016
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish "Use missing MongoClientOptions in MongoProperties"
Closes gh-6176
parent
59f9cfb8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
10 deletions
+59
-10
MongoProperties.java
...ngframework/boot/autoconfigure/mongo/MongoProperties.java
+9
-9
MongoPropertiesTests.java
...mework/boot/autoconfigure/mongo/MongoPropertiesTests.java
+50
-1
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoProperties.java
View file @
4e07003e
...
...
@@ -271,23 +271,23 @@ public class MongoProperties {
builder
.
dbDecoderFactory
(
options
.
getDbDecoderFactory
());
builder
.
dbEncoderFactory
(
options
.
getDbEncoderFactory
());
builder
.
description
(
options
.
getDescription
());
builder
.
heartbeatConnectTimeout
(
options
.
getHeartbeatConnectTimeout
());
builder
.
heartbeatFrequency
(
options
.
getHeartbeatFrequency
());
builder
.
heartbeatSocketTimeout
(
options
.
getHeartbeatSocketTimeout
());
builder
.
localThreshold
(
options
.
getLocalThreshold
());
builder
.
minConnectionsPerHost
(
options
.
getMinConnectionsPerHost
());
builder
.
minHeartbeatFrequency
(
options
.
getMinHeartbeatFrequency
());
builder
.
maxConnectionIdleTime
(
options
.
getMaxConnectionIdleTime
());
builder
.
maxConnectionLifeTime
(
options
.
getMaxConnectionLifeTime
());
builder
.
maxWaitTime
(
options
.
getMaxWaitTime
());
builder
.
readPreference
(
options
.
getReadPreference
());
builder
.
requiredReplicaSetName
(
options
.
getRequiredReplicaSetName
());
builder
.
socketFactory
(
options
.
getSocketFactory
());
builder
.
socketKeepAlive
(
options
.
isSocketKeepAlive
());
builder
.
socketTimeout
(
options
.
getSocketTimeout
());
builder
.
threadsAllowedToBlockForConnectionMultiplier
(
options
.
getThreadsAllowedToBlockForConnectionMultiplier
());
builder
.
writeConcern
(
options
.
getWriteConcern
());
builder
.
minConnectionsPerHost
(
options
.
getMinConnectionsPerHost
());
builder
.
maxConnectionIdleTime
(
options
.
getMaxConnectionIdleTime
());
builder
.
maxConnectionLifeTime
(
options
.
getMaxConnectionLifeTime
());
builder
.
heartbeatFrequency
(
options
.
getHeartbeatFrequency
());
builder
.
minHeartbeatFrequency
(
options
.
getMinHeartbeatFrequency
());
builder
.
heartbeatConnectTimeout
(
options
.
getHeartbeatConnectTimeout
());
builder
.
heartbeatSocketTimeout
(
options
.
getHeartbeatSocketTimeout
());
builder
.
localThreshold
(
options
.
getLocalThreshold
());
builder
.
requiredReplicaSetName
(
options
.
getRequiredReplicaSetName
());
}
return
builder
;
}
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoPropertiesTests.java
View file @
4e07003e
/*
* Copyright 2012-201
5
the original author or authors.
* Copyright 2012-201
6
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.
...
...
@@ -20,6 +20,7 @@ import java.net.UnknownHostException;
import
java.util.List
;
import
com.mongodb.MongoClient
;
import
com.mongodb.MongoClientOptions
;
import
com.mongodb.MongoCredential
;
import
com.mongodb.ServerAddress
;
import
org.junit.Test
;
...
...
@@ -120,6 +121,54 @@ public class MongoPropertiesTests {
assertMongoCredential
(
credentialsList
.
get
(
0
),
"user"
,
"secret"
,
"test"
);
}
@Test
public
void
allMongoClientOptionsCanBeSet
()
throws
UnknownHostException
{
MongoClientOptions
mco
=
MongoClientOptions
.
builder
()
.
alwaysUseMBeans
(
true
)
.
connectionsPerHost
(
101
)
.
connectTimeout
(
10001
)
.
cursorFinalizerEnabled
(
false
)
.
description
(
"test"
)
.
maxWaitTime
(
120001
)
.
socketKeepAlive
(
true
)
.
socketTimeout
(
1000
)
.
threadsAllowedToBlockForConnectionMultiplier
(
6
)
.
minConnectionsPerHost
(
0
)
.
maxConnectionIdleTime
(
60000
)
.
maxConnectionLifeTime
(
60000
)
.
heartbeatFrequency
(
10001
)
.
minHeartbeatFrequency
(
501
)
.
heartbeatConnectTimeout
(
20001
)
.
heartbeatSocketTimeout
(
20001
)
.
localThreshold
(
20
)
.
requiredReplicaSetName
(
"testReplicaSetName"
)
.
build
();
MongoProperties
properties
=
new
MongoProperties
();
MongoClient
client
=
properties
.
createMongoClient
(
mco
,
null
);
MongoClientOptions
wrappedMco
=
client
.
getMongoClientOptions
();
assertThat
(
wrappedMco
.
isAlwaysUseMBeans
(),
equalTo
(
mco
.
isAlwaysUseMBeans
()));
assertThat
(
wrappedMco
.
getConnectionsPerHost
(),
equalTo
(
mco
.
getConnectionsPerHost
()));
assertThat
(
wrappedMco
.
getConnectTimeout
(),
equalTo
(
mco
.
getConnectTimeout
()));
assertThat
(
wrappedMco
.
isCursorFinalizerEnabled
(),
equalTo
(
mco
.
isCursorFinalizerEnabled
()));
assertThat
(
wrappedMco
.
getDescription
(),
equalTo
(
mco
.
getDescription
()));
assertThat
(
wrappedMco
.
getMaxWaitTime
(),
equalTo
(
mco
.
getMaxWaitTime
()));
assertThat
(
wrappedMco
.
getSocketTimeout
(),
equalTo
(
mco
.
getSocketTimeout
()));
assertThat
(
wrappedMco
.
isSocketKeepAlive
(),
equalTo
(
mco
.
isSocketKeepAlive
()));
assertThat
(
wrappedMco
.
getThreadsAllowedToBlockForConnectionMultiplier
(),
equalTo
(
mco
.
getThreadsAllowedToBlockForConnectionMultiplier
()));
assertThat
(
wrappedMco
.
getMinConnectionsPerHost
(),
equalTo
(
mco
.
getMinConnectionsPerHost
()));
assertThat
(
wrappedMco
.
getMaxConnectionIdleTime
(),
equalTo
(
mco
.
getMaxConnectionIdleTime
()));
assertThat
(
wrappedMco
.
getMaxConnectionLifeTime
(),
equalTo
(
mco
.
getMaxConnectionLifeTime
()));
assertThat
(
wrappedMco
.
getHeartbeatFrequency
(),
equalTo
(
mco
.
getHeartbeatFrequency
()));
assertThat
(
wrappedMco
.
getMinHeartbeatFrequency
(),
equalTo
(
mco
.
getMinHeartbeatFrequency
()));
assertThat
(
wrappedMco
.
getHeartbeatConnectTimeout
(),
equalTo
(
mco
.
getHeartbeatConnectTimeout
()));
assertThat
(
wrappedMco
.
getHeartbeatSocketTimeout
(),
equalTo
(
mco
.
getHeartbeatSocketTimeout
()));
assertThat
(
wrappedMco
.
getLocalThreshold
(),
equalTo
(
mco
.
getLocalThreshold
()));
assertThat
(
wrappedMco
.
getRequiredReplicaSetName
(),
equalTo
(
mco
.
getRequiredReplicaSetName
()));
}
private
void
assertServerAddress
(
ServerAddress
serverAddress
,
String
expectedHost
,
int
expectedPort
)
{
assertThat
(
serverAddress
.
getHost
(),
equalTo
(
expectedHost
));
...
...
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