File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -159,7 +159,16 @@ public MongoClientURI(final String uri) {
159
159
this (uri , new MongoClientOptions .Builder ());
160
160
}
161
161
162
- MongoClientURI (String uri , MongoClientOptions .Builder builder ) {
162
+ /**
163
+ * Creates a MongoURI from the given URI string, and MongoClientOptions.Builder. The builder can be configured
164
+ * with default options, which may be overridden by options specified in the URI string.
165
+ *
166
+ * @param uri the URI
167
+ * @param builder a Builder
168
+ * @see com.mongodb.MongoClientURI#getOptions()
169
+ * @since 2.11.0
170
+ */
171
+ public MongoClientURI (String uri , MongoClientOptions .Builder builder ) {
163
172
try {
164
173
this .uri = uri ;
165
174
if (!uri .startsWith (PREFIX ))
Original file line number Diff line number Diff line change @@ -31,6 +31,11 @@ public void testUnsupportedOption() {
31
31
new MongoClientURI ("mongodb://localhost/?unknownOption=true" );
32
32
}
33
33
34
+ @ Test
35
+ public void testURIGetter () {
36
+ assertEquals ("mongodb://localhost" , new MongoClientURI ("mongodb://localhost" ).getURI ());
37
+ }
38
+
34
39
@ Test
35
40
public void testOptionsWithoutTrailingSlash () {
36
41
try {
@@ -197,6 +202,14 @@ public void testOptions() {
197
202
assertOnOptions (uMixed .getOptions ());
198
203
}
199
204
205
+ @ Test
206
+ public void testBuilderOverrides () {
207
+ MongoClientURI uri = new MongoClientURI ("mongodb://localhost/?maxPoolSize=150" ,
208
+ MongoClientOptions .builder ().autoConnectRetry (true ).connectionsPerHost (200 ));
209
+ assertTrue (uri .getOptions ().isAutoConnectRetry ());
210
+ assertEquals (150 , uri .getOptions ().getConnectionsPerHost ());
211
+ }
212
+
200
213
@ Test ()
201
214
public void testURIDefaults () throws UnknownHostException {
202
215
MongoClientURI uri = new MongoClientURI ("mongodb://localhost" );
You can’t perform that action at this time.
0 commit comments