Skip to content

Commit 28c1844

Browse files
committed
Update tests.
JAVA-5854
1 parent 2a684bf commit 28c1844

File tree

11 files changed

+89
-71
lines changed

11 files changed

+89
-71
lines changed

driver-core/src/main/com/mongodb/internal/connection/InternalStreamConnectionFactory.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ class InternalStreamConnectionFactory implements InternalConnectionFactory {
4545
final StreamFactory streamFactory,
4646
@Nullable final MongoCredentialWithCache credential,
4747
final ClientMetadata clientMetadata,
48-
final List<MongoCompressor> compressorList,
49-
final LoggerSettings loggerSettings, @Nullable final CommandListener commandListener, @Nullable final ServerApi serverApi) {
48+
final List<MongoCompressor> compressorList,
49+
final LoggerSettings loggerSettings, @Nullable final CommandListener commandListener,
50+
@Nullable final ServerApi serverApi) {
5051
this(clusterConnectionMode, false, streamFactory, credential, clientMetadata, compressorList,
5152
loggerSettings, commandListener, serverApi);
5253
}

driver-core/src/test/functional/com/mongodb/internal/connection/CommandHelperSpecification.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import spock.lang.Specification
2929

3030
import java.util.concurrent.CountDownLatch
3131

32+
import static com.mongodb.ClusterFixture.CLIENT_METADATA
3233
import static com.mongodb.ClusterFixture.LEGACY_HELLO
3334
import static com.mongodb.ClusterFixture.OPERATION_CONTEXT
3435
import static com.mongodb.ClusterFixture.getClusterConnectionMode
@@ -44,7 +45,7 @@ class CommandHelperSpecification extends Specification {
4445
def setup() {
4546
connection = new InternalStreamConnectionFactory(ClusterConnectionMode.SINGLE,
4647
new NettyStreamFactory(SocketSettings.builder().build(), getSslSettings()),
47-
getCredentialWithCache(), null, null, [], LoggerSettings.builder().build(), null, getServerApi())
48+
getCredentialWithCache(), CLIENT_METADATA, [], LoggerSettings.builder().build(), null, getServerApi())
4849
.create(new ServerId(new ClusterId(), getPrimary()))
4950
connection.open(OPERATION_CONTEXT)
5051
}

driver-core/src/test/functional/com/mongodb/internal/connection/ServerMonitorSpecification.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import org.bson.types.ObjectId
3434
import java.util.concurrent.CountDownLatch
3535
import java.util.concurrent.TimeUnit
3636

37+
import static com.mongodb.ClusterFixture.CLIENT_METADATA
3738
import static com.mongodb.ClusterFixture.OPERATION_CONTEXT_FACTORY
3839
import static com.mongodb.ClusterFixture.getClusterConnectionMode
3940
import static com.mongodb.ClusterFixture.getCredentialWithCache
@@ -223,7 +224,7 @@ class ServerMonitorSpecification extends OperationFunctionalSpecification {
223224
serverMonitor = new DefaultServerMonitor(new ServerId(new ClusterId(), address), ServerSettings.builder().build(),
224225
new InternalStreamConnectionFactory(SINGLE, new SocketStreamFactory(new DefaultInetAddressResolver(),
225226
SocketSettings.builder().connectTimeout(500, TimeUnit.MILLISECONDS).build(), getSslSettings()),
226-
getCredentialWithCache(), null, null, [], LoggerSettings.builder().build(), null,
227+
getCredentialWithCache(), CLIENT_METADATA, [], LoggerSettings.builder().build(), null,
227228
getServerApi()),
228229
getClusterConnectionMode(), getServerApi(), false, SameObjectProvider.initialized(sdam),
229230
OPERATION_CONTEXT_FACTORY)

driver-core/src/test/unit/com/mongodb/internal/connection/BaseClusterSpecification.groovy

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,12 @@ import com.mongodb.internal.selector.ReadPreferenceServerSelector
3636
import com.mongodb.internal.selector.ServerAddressSelector
3737
import com.mongodb.internal.selector.WritableServerSelector
3838
import com.mongodb.internal.time.Timeout
39-
import spock.lang.Specification
4039
import com.mongodb.spock.Slow
40+
import spock.lang.Specification
4141

4242
import java.util.concurrent.CountDownLatch
4343

44+
import static com.mongodb.ClusterFixture.CLIENT_METADATA
4445
import static com.mongodb.ClusterFixture.OPERATION_CONTEXT
4546
import static com.mongodb.ClusterFixture.TIMEOUT_SETTINGS
4647
import static com.mongodb.ClusterFixture.createOperationContext
@@ -68,7 +69,7 @@ class BaseClusterSpecification extends Specification {
6869
.hosts([firstServer, secondServer, thirdServer])
6970
.serverSelector(new ServerAddressSelector(firstServer))
7071
.build()
71-
def cluster = new BaseCluster(new ClusterId(), clusterSettings, factory) {
72+
def cluster = new BaseCluster(new ClusterId(), clusterSettings, factory, CLIENT_METADATA) {
7273
@Override
7374
protected void connect() {
7475
}
@@ -114,7 +115,7 @@ class BaseClusterSpecification extends Specification {
114115
.serverSelectionTimeout(1, SECONDS)
115116
.serverSelector(new ServerAddressSelector(firstServer))
116117
.build()
117-
def cluster = new MultiServerCluster(new ClusterId(), clusterSettings, factory)
118+
def cluster = new MultiServerCluster(new ClusterId(), clusterSettings, factory, CLIENT_METADATA)
118119

119120
expect:
120121
cluster.getSettings() == clusterSettings
@@ -128,7 +129,7 @@ class BaseClusterSpecification extends Specification {
128129
.serverSelectionTimeout(1, SECONDS)
129130
.serverSelector(new ServerAddressSelector(firstServer))
130131
.build(),
131-
factory)
132+
factory, CLIENT_METADATA)
132133
factory.sendNotification(firstServer, REPLICA_SET_SECONDARY, allServers)
133134
factory.sendNotification(secondServer, REPLICA_SET_SECONDARY, allServers)
134135
factory.sendNotification(thirdServer, REPLICA_SET_PRIMARY, allServers)
@@ -144,7 +145,7 @@ class BaseClusterSpecification extends Specification {
144145
builder().mode(MULTIPLE)
145146
.hosts([firstServer, secondServer, thirdServer])
146147
.build(),
147-
factory)
148+
factory, CLIENT_METADATA)
148149
factory.sendNotification(firstServer, REPLICA_SET_SECONDARY, allServers)
149150
factory.sendNotification(secondServer, REPLICA_SET_SECONDARY, allServers)
150151
factory.sendNotification(thirdServer, REPLICA_SET_PRIMARY, allServers)
@@ -164,7 +165,7 @@ class BaseClusterSpecification extends Specification {
164165
.serverSelector(new ReadPreferenceServerSelector(ReadPreference.secondary()))
165166
.localThreshold(5, MILLISECONDS)
166167
.build(),
167-
factory)
168+
factory, CLIENT_METADATA)
168169
factory.sendNotification(firstServer, 1, REPLICA_SET_SECONDARY, allServers)
169170
factory.sendNotification(secondServer, 7, REPLICA_SET_SECONDARY, allServers)
170171
factory.sendNotification(thirdServer, 1, REPLICA_SET_PRIMARY, allServers)
@@ -182,7 +183,7 @@ class BaseClusterSpecification extends Specification {
182183
.hosts([firstServer, secondServer, thirdServer])
183184
.localThreshold(5, MILLISECONDS)
184185
.build(),
185-
factory)
186+
factory, CLIENT_METADATA)
186187
factory.sendNotification(firstServer, 1, REPLICA_SET_SECONDARY, allServers)
187188
factory.sendNotification(secondServer, 7, REPLICA_SET_SECONDARY, allServers)
188189
factory.sendNotification(thirdServer, 1, REPLICA_SET_PRIMARY, allServers)
@@ -198,7 +199,7 @@ class BaseClusterSpecification extends Specification {
198199
builder().mode(MULTIPLE)
199200
.hosts([firstServer, secondServer])
200201
.build(),
201-
factory)
202+
factory, CLIENT_METADATA)
202203

203204
when:
204205
factory.sendNotification(firstServer, ServerDescription.builder().type(ServerType.UNKNOWN)
@@ -229,7 +230,7 @@ class BaseClusterSpecification extends Specification {
229230
builder().mode(MULTIPLE)
230231
.hosts([firstServer, secondServer, thirdServer])
231232
.build(),
232-
factory)
233+
factory, CLIENT_METADATA)
233234
factory.sendNotification(firstServer, REPLICA_SET_SECONDARY, allServers)
234235
factory.sendNotification(secondServer, REPLICA_SET_SECONDARY, allServers)
235236
factory.sendNotification(thirdServer, REPLICA_SET_PRIMARY, allServers)
@@ -253,7 +254,7 @@ class BaseClusterSpecification extends Specification {
253254
builder().mode(MULTIPLE)
254255
.hosts([firstServer, secondServer, thirdServer])
255256
.build(),
256-
factory)
257+
factory, CLIENT_METADATA)
257258

258259
when:
259260
def latch = new CountDownLatch(1)
@@ -283,7 +284,7 @@ class BaseClusterSpecification extends Specification {
283284
builder().mode(MULTIPLE)
284285
.hosts([firstServer, secondServer, thirdServer])
285286
.build(),
286-
factory)
287+
factory, CLIENT_METADATA)
287288
factory.sendNotification(firstServer, REPLICA_SET_SECONDARY, allServers)
288289

289290
when:
@@ -305,7 +306,7 @@ class BaseClusterSpecification extends Specification {
305306
builder().mode(MULTIPLE)
306307
.hosts([firstServer, secondServer, thirdServer])
307308
.build(),
308-
factory)
309+
factory, CLIENT_METADATA)
309310

310311
when:
311312
def secondServerLatch = selectServerAsync(cluster, secondServer, serverSelectionTimeoutMS)
@@ -330,7 +331,7 @@ class BaseClusterSpecification extends Specification {
330331
builder().mode(MULTIPLE)
331332
.hosts([firstServer, secondServer, thirdServer])
332333
.build(),
333-
factory)
334+
factory, CLIENT_METADATA)
334335

335336
when:
336337
def serverLatch = selectServerAsync(cluster, firstServer)
@@ -350,7 +351,7 @@ class BaseClusterSpecification extends Specification {
350351
builder().mode(MULTIPLE)
351352
.hosts([firstServer, secondServer, thirdServer])
352353
.build(),
353-
factory)
354+
factory, CLIENT_METADATA)
354355

355356
when:
356357
selectServerAsyncAndGet(cluster, firstServer, serverSelectionTimeoutMS)

driver-core/src/test/unit/com/mongodb/internal/connection/DefaultServerSpecification.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import spock.lang.Specification
4949

5050
import java.util.concurrent.CountDownLatch
5151

52+
import static com.mongodb.ClusterFixture.CLIENT_METADATA
5253
import static com.mongodb.ClusterFixture.OPERATION_CONTEXT
5354
import static com.mongodb.MongoCredential.createCredential
5455
import static com.mongodb.connection.ClusterConnectionMode.MULTIPLE
@@ -386,7 +387,7 @@ class DefaultServerSpecification extends Specification {
386387
}
387388

388389
private Cluster mockCluster() {
389-
new BaseCluster(new ClusterId(), ClusterSettings.builder().build(), Mock(ClusterableServerFactory)) {
390+
new BaseCluster(new ClusterId(), ClusterSettings.builder().build(), Mock(ClusterableServerFactory), CLIENT_METADATA) {
390391
@Override
391392
protected void connect() {
392393
}

driver-core/src/test/unit/com/mongodb/internal/connection/DnsMultiServerClusterSpecification.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.mongodb.internal.connection
1818

19+
import com.mongodb.ClusterFixture
1920
import com.mongodb.MongoConfigurationException
2021
import com.mongodb.ServerAddress
2122
import com.mongodb.connection.ClusterId
@@ -67,7 +68,7 @@ class DnsMultiServerClusterSpecification extends Specification {
6768
.srvHost(srvHost)
6869
.mode(MULTIPLE)
6970
.build(),
70-
factory, dnsSrvRecordMonitorFactory)
71+
factory, ClusterFixture.CLIENT_METADATA, dnsSrvRecordMonitorFactory)
7172

7273
then: 'the monitor is created and started'
7374
initializer != null

0 commit comments

Comments
 (0)