@@ -19,6 +19,7 @@ package com.mongodb.internal.connection
19
19
import com.mongodb.MongoQueryException
20
20
import com.mongodb.OperationFunctionalSpecification
21
21
import com.mongodb.client.model.CreateCollectionOptions
22
+ import com.mongodb.connection.AsynchronousSocketChannelStreamFactory
22
23
import com.mongodb.connection.ClusterId
23
24
import com.mongodb.connection.ServerId
24
25
import com.mongodb.connection.SocketSettings
@@ -35,28 +36,38 @@ import org.bson.BsonInt64
35
36
import org.bson.BsonString
36
37
import org.bson.BsonTimestamp
37
38
import org.bson.codecs.BsonDocumentCodec
39
+ import spock.lang.IgnoreIf
38
40
import spock.lang.Shared
39
41
40
- import static org.bson.BsonDocument.parse
41
42
import static com.mongodb.ClusterFixture.getPrimary
42
43
import static com.mongodb.ClusterFixture.getSslSettings
44
+ import static com.mongodb.ClusterFixture.isNotAtLeastJava7
43
45
import static com.mongodb.connection.ConnectionFixture.getCredentialListWithCache
44
46
import static com.mongodb.internal.connection.ProtocolTestHelper.execute
47
+ import static org.bson.BsonDocument.parse
45
48
46
-
49
+ @IgnoreIf ({ isNotAtLeastJava7() })
47
50
class QueryProtocolCommandEventSpecification extends OperationFunctionalSpecification {
48
51
@Shared
49
- InternalStreamConnection connection;
52
+ InternalStreamConnection nettyConnection
53
+ @Shared
54
+ InternalStreamConnection nioConnection
50
55
51
56
def setupSpec () {
52
- connection = new InternalStreamConnectionFactory (new NettyStreamFactory (SocketSettings . builder(). build(), getSslSettings()),
57
+ nettyConnection = new InternalStreamConnectionFactory (new NettyStreamFactory (SocketSettings . builder(). build(), getSslSettings()),
53
58
getCredentialListWithCache(), null , null , [], null )
54
59
.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()
56
66
}
57
67
58
68
def cleanupSpec () {
59
- connection?. close()
69
+ nettyConnection?. close()
70
+ nioConnection?. close()
60
71
}
61
72
62
73
def ' should deliver start and completed command events with numberToReturn' () {
@@ -93,7 +104,7 @@ class QueryProtocolCommandEventSpecification extends OperationFunctionalSpecific
93
104
new CommandSucceededEvent (1 , connection. getDescription(), ' find' , response, 0 )])
94
105
95
106
where :
96
- async << [false , true ]
107
+ [ async, connection] << [[ false , true ], [nettyConnection, nioConnection]] . combinations()
97
108
}
98
109
99
110
def ' should deliver start and completed command events with limit and batchSize' () {
@@ -134,7 +145,7 @@ class QueryProtocolCommandEventSpecification extends OperationFunctionalSpecific
134
145
new CommandSucceededEvent (1 , connection. getDescription(), ' find' , response, 0 )])
135
146
136
147
where :
137
- async << [false , true ]
148
+ [ async, connection] << [[ false , true ], [nettyConnection, nioConnection]] . combinations()
138
149
}
139
150
140
151
def ' should deliver start and completed command events when there is no projection' () {
@@ -164,7 +175,7 @@ class QueryProtocolCommandEventSpecification extends OperationFunctionalSpecific
164
175
new CommandSucceededEvent (1 , connection. getDescription(), ' find' , response, 0 )])
165
176
166
177
where :
167
- async << [false , true ]
178
+ [ async, connection] << [[ false , true ], [nettyConnection, nioConnection]] . combinations()
168
179
}
169
180
170
181
def ' should deliver start and completed command events when there are boolean options' () {
@@ -206,7 +217,7 @@ class QueryProtocolCommandEventSpecification extends OperationFunctionalSpecific
206
217
new CommandSucceededEvent (1 , connection. getDescription(), ' find' , response, 0 )])
207
218
208
219
where :
209
- async << [false , true ]
220
+ [ async, connection] << [[ false , true ], [nettyConnection, nioConnection]] . combinations()
210
221
}
211
222
212
223
def ' should deliver start and completed command events with meta operators' () {
@@ -279,7 +290,7 @@ class QueryProtocolCommandEventSpecification extends OperationFunctionalSpecific
279
290
new CommandSucceededEvent (1 , connection. getDescription(), ' find' , response, 0 )])
280
291
281
292
where :
282
- async << [false , true ]
293
+ [ async, connection] << [[ false , true ], [nettyConnection, nioConnection]] . combinations()
283
294
}
284
295
285
296
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
312
323
new CommandSucceededEvent (1 , connection. getDescription(), ' explain' , expectedResponse, 0 )])
313
324
314
325
where :
315
- async << [false , true ]
326
+ [ async, connection] << [[ false , true ], [nettyConnection, nioConnection]] . combinations()
316
327
}
317
328
318
329
def ' should deliver start and failed command events' () {
@@ -338,6 +349,6 @@ class QueryProtocolCommandEventSpecification extends OperationFunctionalSpecific
338
349
new CommandFailedEvent (1 , connection. getDescription(), ' find' , 0 , e)])
339
350
340
351
where :
341
- async << [false , true ]
352
+ [ async, connection] << [[ false , true ], [nettyConnection, nioConnection]] . combinations()
342
353
}
343
354
}
0 commit comments