37
37
import org .mockito .ArgumentCaptor ;
38
38
import org .reactivestreams .Publisher ;
39
39
import reactor .core .publisher .Flux ;
40
+ import reactor .core .publisher .Mono ;
40
41
import reactor .test .StepVerifier ;
41
42
42
43
final class FragmentationDuplexConnectionTest {
@@ -93,6 +94,7 @@ void reassembleData() {
93
94
DEFAULT , 1 , createPayloadFrame (DEFAULT , false , false , null , data .slice (4 , 2 )));
94
95
95
96
when (delegate .receive ()).thenReturn (Flux .just (fragment1 , fragment2 , fragment3 ));
97
+ when (delegate .onClose ()).thenReturn (Mono .never ());
96
98
97
99
new FragmentationDuplexConnection (DEFAULT , delegate , 2 )
98
100
.receive ()
@@ -123,6 +125,7 @@ void reassembleMetadata() {
123
125
DEFAULT , 1 , createPayloadFrame (DEFAULT , false , true , metadata .slice (4 , 2 ), null ));
124
126
125
127
when (delegate .receive ()).thenReturn (Flux .just (fragment1 , fragment2 , fragment3 ));
128
+ when (delegate .onClose ()).thenReturn (Mono .never ());
126
129
127
130
new FragmentationDuplexConnection (DEFAULT , delegate , 2 )
128
131
.receive ()
@@ -165,6 +168,7 @@ void reassembleMetadataAndData() {
165
168
166
169
when (delegate .receive ())
167
170
.thenReturn (Flux .just (fragment1 , fragment2 , fragment3 , fragment4 , fragment5 ));
171
+ when (delegate .onClose ()).thenReturn (Mono .never ());
168
172
169
173
new FragmentationDuplexConnection (DEFAULT , delegate , 2 )
170
174
.receive ()
@@ -181,6 +185,7 @@ void reassembleNonFragment() {
181
185
DEFAULT , 1 , createPayloadFrame (DEFAULT , false , true , (ByteBuf ) null , null ));
182
186
183
187
when (delegate .receive ()).thenReturn (Flux .just (frame ));
188
+ when (delegate .onClose ()).thenReturn (Mono .never ());
184
189
185
190
new FragmentationDuplexConnection (DEFAULT , delegate , 2 )
186
191
.receive ()
@@ -195,6 +200,7 @@ void reassembleNonFragmentableFrame() {
195
200
Frame frame = toAbstractionLeakingFrame (DEFAULT , 1 , createTestCancelFrame ());
196
201
197
202
when (delegate .receive ()).thenReturn (Flux .just (frame ));
203
+ when (delegate .onClose ()).thenReturn (Mono .never ());
198
204
199
205
new FragmentationDuplexConnection (DEFAULT , delegate , 2 )
200
206
.receive ()
@@ -224,6 +230,8 @@ void sendData() {
224
230
toAbstractionLeakingFrame (
225
231
DEFAULT , 1 , createPayloadFrame (DEFAULT , false , false , null , data .slice (4 , 2 )));
226
232
233
+ when (delegate .onClose ()).thenReturn (Mono .never ());
234
+
227
235
new FragmentationDuplexConnection (DEFAULT , delegate , 2 ).sendOne (frame );
228
236
verify (delegate ).send (publishers .capture ());
229
237
@@ -241,6 +249,8 @@ void sendEqualToMaxFragmentLength() {
241
249
toAbstractionLeakingFrame (
242
250
DEFAULT , 1 , createPayloadFrame (DEFAULT , false , false , null , getRandomByteBuf (2 )));
243
251
252
+ when (delegate .onClose ()).thenReturn (Mono .never ());
253
+
244
254
new FragmentationDuplexConnection (DEFAULT , delegate , 2 ).sendOne (frame );
245
255
verify (delegate ).send (publishers .capture ());
246
256
@@ -254,6 +264,8 @@ void sendFragment() {
254
264
toAbstractionLeakingFrame (
255
265
DEFAULT , 1 , createPayloadFrame (DEFAULT , true , true , (ByteBuf ) null , null ));
256
266
267
+ when (delegate .onClose ()).thenReturn (Mono .never ());
268
+
257
269
new FragmentationDuplexConnection (DEFAULT , delegate , 2 ).sendOne (frame );
258
270
verify (delegate ).send (publishers .capture ());
259
271
@@ -267,6 +279,8 @@ void sendLessThanMaxFragmentLength() {
267
279
toAbstractionLeakingFrame (
268
280
DEFAULT , 1 , createPayloadFrame (DEFAULT , false , false , null , getRandomByteBuf (1 )));
269
281
282
+ when (delegate .onClose ()).thenReturn (Mono .never ());
283
+
270
284
new FragmentationDuplexConnection (DEFAULT , delegate , 2 ).sendOne (frame );
271
285
verify (delegate ).send (publishers .capture ());
272
286
@@ -294,6 +308,8 @@ void sendMetadata() {
294
308
toAbstractionLeakingFrame (
295
309
DEFAULT , 1 , createPayloadFrame (DEFAULT , false , true , metadata .slice (4 , 2 ), null ));
296
310
311
+ when (delegate .onClose ()).thenReturn (Mono .never ());
312
+
297
313
new FragmentationDuplexConnection (DEFAULT , delegate , 2 ).sendOne (frame );
298
314
verify (delegate ).send (publishers .capture ());
299
315
@@ -336,6 +352,8 @@ void sendMetadataAndData() {
336
352
toAbstractionLeakingFrame (
337
353
DEFAULT , 1 , createPayloadFrame (DEFAULT , false , false , null , data .slice (3 , 2 )));
338
354
355
+ when (delegate .onClose ()).thenReturn (Mono .never ());
356
+
339
357
new FragmentationDuplexConnection (DEFAULT , delegate , 2 ).sendOne (frame );
340
358
verify (delegate ).send (publishers .capture ());
341
359
@@ -353,6 +371,8 @@ void sendMetadataAndData() {
353
371
void sendNonFragmentable () {
354
372
Frame frame = toAbstractionLeakingFrame (DEFAULT , 1 , createTestCancelFrame ());
355
373
374
+ when (delegate .onClose ()).thenReturn (Mono .never ());
375
+
356
376
new FragmentationDuplexConnection (DEFAULT , delegate , 2 ).sendOne (frame );
357
377
verify (delegate ).send (publishers .capture ());
358
378
@@ -362,6 +382,8 @@ void sendNonFragmentable() {
362
382
@ DisplayName ("send throws NullPointerException with null frames" )
363
383
@ Test
364
384
void sendNullFrames () {
385
+ when (delegate .onClose ()).thenReturn (Mono .never ());
386
+
365
387
assertThatNullPointerException ()
366
388
.isThrownBy (() -> new FragmentationDuplexConnection (DEFAULT , delegate , 2 ).send (null ))
367
389
.withMessage ("frames must not be null" );
@@ -374,6 +396,8 @@ void sendZeroMaxFragmentLength() {
374
396
toAbstractionLeakingFrame (
375
397
DEFAULT , 1 , createPayloadFrame (DEFAULT , false , false , null , getRandomByteBuf (2 )));
376
398
399
+ when (delegate .onClose ()).thenReturn (Mono .never ());
400
+
377
401
new FragmentationDuplexConnection (DEFAULT , delegate , 0 ).sendOne (frame );
378
402
verify (delegate ).send (publishers .capture ());
379
403
0 commit comments