@@ -19,6 +19,7 @@ package com.mongodb.internal.connection
1919import com.mongodb.MongoQueryException
2020import com.mongodb.OperationFunctionalSpecification
2121import com.mongodb.client.model.CreateCollectionOptions
22+ import com.mongodb.connection.AsynchronousSocketChannelStreamFactory
2223import com.mongodb.connection.ClusterId
2324import com.mongodb.connection.ServerId
2425import com.mongodb.connection.SocketSettings
@@ -35,28 +36,38 @@ import org.bson.BsonInt64
3536import org.bson.BsonString
3637import org.bson.BsonTimestamp
3738import org.bson.codecs.BsonDocumentCodec
39+ import spock.lang.IgnoreIf
3840import spock.lang.Shared
3941
40- import static org.bson.BsonDocument.parse
4142import static com.mongodb.ClusterFixture.getPrimary
4243import static com.mongodb.ClusterFixture.getSslSettings
44+ import static com.mongodb.ClusterFixture.isNotAtLeastJava7
4345import static com.mongodb.connection.ConnectionFixture.getCredentialListWithCache
4446import static com.mongodb.internal.connection.ProtocolTestHelper.execute
47+ import static org.bson.BsonDocument.parse
4548
46-
49+ @IgnoreIf ({ isNotAtLeastJava7() })
4750class QueryProtocolCommandEventSpecification extends OperationFunctionalSpecification {
4851 @Shared
49- InternalStreamConnection connection;
52+ InternalStreamConnection nettyConnection
53+ @Shared
54+ InternalStreamConnection nioConnection
5055
5156 def setupSpec () {
52- connection = new InternalStreamConnectionFactory (new NettyStreamFactory (SocketSettings . builder(). build(), getSslSettings()),
57+ nettyConnection = new InternalStreamConnectionFactory (new NettyStreamFactory (SocketSettings . builder(). build(), getSslSettings()),
5358 getCredentialListWithCache(), null , null , [], null )
5459 .create(new ServerId (new ClusterId (), getPrimary()))
55- connection. open();
60+ nettyConnection. open()
61+
62+ nioConnection = new InternalStreamConnectionFactory (new AsynchronousSocketChannelStreamFactory (SocketSettings . builder(). build(),
63+ getSslSettings()), getCredentialListWithCache(), null , null , [], null )
64+ .create(new ServerId (new ClusterId (), getPrimary()))
65+ nioConnection. open()
5666 }
5767
5868 def cleanupSpec () {
59- connection?. close()
69+ nettyConnection?. close()
70+ nioConnection?. close()
6071 }
6172
6273 def ' should deliver start and completed command events with numberToReturn' () {
@@ -93,7 +104,7 @@ class QueryProtocolCommandEventSpecification extends OperationFunctionalSpecific
93104 new CommandSucceededEvent (1 , connection. getDescription(), ' find' , response, 0 )])
94105
95106 where :
96- async << [false , true ]
107+ [ async, connection] << [[ false , true ], [nettyConnection, nioConnection]] . combinations()
97108 }
98109
99110 def ' should deliver start and completed command events with limit and batchSize' () {
@@ -134,7 +145,7 @@ class QueryProtocolCommandEventSpecification extends OperationFunctionalSpecific
134145 new CommandSucceededEvent (1 , connection. getDescription(), ' find' , response, 0 )])
135146
136147 where :
137- async << [false , true ]
148+ [ async, connection] << [[ false , true ], [nettyConnection, nioConnection]] . combinations()
138149 }
139150
140151 def ' should deliver start and completed command events when there is no projection' () {
@@ -164,7 +175,7 @@ class QueryProtocolCommandEventSpecification extends OperationFunctionalSpecific
164175 new CommandSucceededEvent (1 , connection. getDescription(), ' find' , response, 0 )])
165176
166177 where :
167- async << [false , true ]
178+ [ async, connection] << [[ false , true ], [nettyConnection, nioConnection]] . combinations()
168179 }
169180
170181 def ' should deliver start and completed command events when there are boolean options' () {
@@ -206,7 +217,7 @@ class QueryProtocolCommandEventSpecification extends OperationFunctionalSpecific
206217 new CommandSucceededEvent (1 , connection. getDescription(), ' find' , response, 0 )])
207218
208219 where :
209- async << [false , true ]
220+ [ async, connection] << [[ false , true ], [nettyConnection, nioConnection]] . combinations()
210221 }
211222
212223 def ' should deliver start and completed command events with meta operators' () {
@@ -279,7 +290,7 @@ class QueryProtocolCommandEventSpecification extends OperationFunctionalSpecific
279290 new CommandSucceededEvent (1 , connection. getDescription(), ' find' , response, 0 )])
280291
281292 where :
282- async << [false , true ]
293+ [ async, connection] << [[ false , true ], [nettyConnection, nioConnection]] . combinations()
283294 }
284295
285296 def ' should deliver start and completed command events for an explain command when there is a $explain meta operator' () {
@@ -312,7 +323,7 @@ class QueryProtocolCommandEventSpecification extends OperationFunctionalSpecific
312323 new CommandSucceededEvent (1 , connection. getDescription(), ' explain' , expectedResponse, 0 )])
313324
314325 where :
315- async << [false , true ]
326+ [ async, connection] << [[ false , true ], [nettyConnection, nioConnection]] . combinations()
316327 }
317328
318329 def ' should deliver start and failed command events' () {
@@ -338,6 +349,6 @@ class QueryProtocolCommandEventSpecification extends OperationFunctionalSpecific
338349 new CommandFailedEvent (1 , connection. getDescription(), ' find' , 0 , e)])
339350
340351 where :
341- async << [false , true ]
352+ [ async, connection] << [[ false , true ], [nettyConnection, nioConnection]] . combinations()
342353 }
343354}
0 commit comments