Skip to content

Commit a2d3d15

Browse files
committed
Add URI options spec tests for minPoolSize/maxPoolSize of 0
JAVA-4160
1 parent 2139a85 commit a2d3d15

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

driver-core/src/test/resources/uri-options/connection-pool-options.json

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
"tests": [
33
{
44
"description": "Valid connection pool options are parsed correctly",
5-
"uri": "mongodb://example.com/?maxIdleTimeMS=50000",
5+
"uri": "mongodb://example.com/?maxIdleTimeMS=50000&maxPoolSize=5&minPoolSize=3",
66
"valid": true,
77
"warning": false,
88
"hosts": null,
99
"auth": null,
1010
"options": {
11-
"maxIdleTimeMS": 50000
11+
"maxIdleTimeMS": 50000,
12+
"maxPoolSize": 5,
13+
"minPoolSize": 3
1214
}
1315
},
1416
{
@@ -28,6 +30,28 @@
2830
"hosts": null,
2931
"auth": null,
3032
"options": {}
33+
},
34+
{
35+
"description": "maxPoolSize=0 does not error",
36+
"uri": "mongodb://example.com/?maxPoolSize=0",
37+
"valid": true,
38+
"warning": false,
39+
"hosts": null,
40+
"auth": null,
41+
"options": {
42+
"maxPoolSize": 0
43+
}
44+
},
45+
{
46+
"description": "minPoolSize=0 does not error",
47+
"uri": "mongodb://example.com/?minPoolSize=0",
48+
"valid": true,
49+
"warning": false,
50+
"hosts": null,
51+
"auth": null,
52+
"options": {
53+
"minPoolSize": 0
54+
}
3155
}
3256
]
3357
}

driver-core/src/test/unit/com/mongodb/AbstractConnectionStringTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,12 @@ protected void testValidOptions() {
211211
} else if (option.getKey().toLowerCase().equals("directconnection")) {
212212
Boolean expected = option.getValue().asBoolean().getValue();
213213
assertEquals(expected, connectionString.isDirectConnection());
214+
} else if (option.getKey().toLowerCase().equals("maxpoolsize")) {
215+
Integer expected = option.getValue().asNumber().intValue();
216+
assertEquals(expected, connectionString.getMaxConnectionPoolSize());
217+
} else if (option.getKey().toLowerCase().equals("minpoolsize")) {
218+
Integer expected = option.getValue().asNumber().intValue();
219+
assertEquals(expected, connectionString.getMinConnectionPoolSize());
214220
} else {
215221
assertTrue(String.format("Unsupported option '%s' in '%s'", option.getKey(), input), false);
216222
}

0 commit comments

Comments
 (0)