1717package com.mongodb.connection
1818
1919import com.mongodb.OperationFunctionalSpecification
20+ import com.mongodb.internal.connection.OperationContext
2021import com.mongodb.internal.operation.CommandReadOperation
2122import org.bson.BsonDocument
2223import org.bson.BsonInt32
@@ -32,8 +33,9 @@ class ConnectionSpecification extends OperationFunctionalSpecification {
3233
3334 def ' should have id' () {
3435 when :
35- def source = getBinding(). getReadConnectionSource(createOperationContext())
36- def connection = source. getConnection(createOperationContext())
36+ def operationContext = createOperationContext()
37+ def source = getBinding(). getReadConnectionSource(operationContext)
38+ def connection = source. getConnection(operationContext)
3739
3840 then :
3941 connection. getDescription(). getConnectionId() != null
@@ -45,13 +47,14 @@ class ConnectionSpecification extends OperationFunctionalSpecification {
4547
4648 def ' should have description' () {
4749 when :
48- def commandResult = getHelloResult()
50+ def operationContext = createOperationContext()
51+ def commandResult = getHelloResult(operationContext)
4952 def expectedMaxMessageSize = commandResult. getNumber(' maxMessageSizeBytes' ,
5053 new BsonInt32 (getDefaultMaxMessageSize())). intValue()
5154 def expectedMaxBatchCount = commandResult. getNumber(' maxWriteBatchSize' ,
5255 new BsonInt32 (getDefaultMaxWriteBatchSize())). intValue()
53- def source = getBinding(). getReadConnectionSource(createOperationContext() )
54- def connection = source. getConnection(createOperationContext() )
56+ def source = getBinding(). getReadConnectionSource(operationContext )
57+ def connection = source. getConnection(operationContext )
5558
5659 then :
5760 connection. description. serverAddress == source. getServerDescription(). getAddress()
@@ -64,8 +67,8 @@ class ConnectionSpecification extends OperationFunctionalSpecification {
6467 connection?. release()
6568 source?. release()
6669 }
67- private static BsonDocument getHelloResult () {
70+ private static BsonDocument getHelloResult (OperationContext operationContext ) {
6871 new CommandReadOperation<BsonDocument > (' admin' , new BsonDocument (LEGACY_HELLO , new BsonInt32 (1 )),
69- new BsonDocumentCodec ()). execute(getBinding(), createOperationContext() )
72+ new BsonDocumentCodec ()). execute(getBinding(), operationContext )
7073 }
7174}
0 commit comments