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) {
159159 this (uri , new MongoClientOptions .Builder ());
160160 }
161161
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 ) {
163172 try {
164173 this .uri = uri ;
165174 if (!uri .startsWith (PREFIX ))
Original file line number Diff line number Diff line change @@ -31,6 +31,11 @@ public void testUnsupportedOption() {
3131 new MongoClientURI ("mongodb://localhost/?unknownOption=true" );
3232 }
3333
34+ @ Test
35+ public void testURIGetter () {
36+ assertEquals ("mongodb://localhost" , new MongoClientURI ("mongodb://localhost" ).getURI ());
37+ }
38+
3439 @ Test
3540 public void testOptionsWithoutTrailingSlash () {
3641 try {
@@ -197,6 +202,14 @@ public void testOptions() {
197202 assertOnOptions (uMixed .getOptions ());
198203 }
199204
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+
200213 @ Test ()
201214 public void testURIDefaults () throws UnknownHostException {
202215 MongoClientURI uri = new MongoClientURI ("mongodb://localhost" );
You can’t perform that action at this time.
0 commit comments