1
1
/*
2
- * Copyright 2002-2017 the original author or authors.
2
+ * Copyright 2002-2018 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -76,7 +76,7 @@ public class DefaultStompSessionTests {
76
76
77
77
78
78
@ Before
79
- public void setUp () throws Exception {
79
+ public void setUp () {
80
80
MockitoAnnotations .initMocks (this );
81
81
82
82
this .sessionHandler = mock (StompSessionHandler .class );
@@ -91,14 +91,14 @@ public void setUp() throws Exception {
91
91
92
92
93
93
@ Test
94
- public void afterConnected () throws Exception {
94
+ public void afterConnected () {
95
95
assertFalse (this .session .isConnected ());
96
96
this .connectHeaders .setHost ("my-host" );
97
97
this .connectHeaders .setHeartbeat (new long [] {11 , 12 });
98
98
99
99
this .session .afterConnected (this .connection );
100
- assertTrue (this .session .isConnected ());
101
100
101
+ assertTrue (this .session .isConnected ());
102
102
Message <byte []> message = this .messageCaptor .getValue ();
103
103
StompHeaderAccessor accessor = MessageHeaderAccessor .getAccessor (message , StompHeaderAccessor .class );
104
104
assertEquals (StompCommand .CONNECT , accessor .getCommand ());
@@ -107,16 +107,29 @@ public void afterConnected() throws Exception {
107
107
assertArrayEquals (new long [] {11 , 12 }, accessor .getHeartbeat ());
108
108
}
109
109
110
+ @ Test // SPR-16844
111
+ public void afterConnectedWithSpecificVersion () {
112
+ assertFalse (this .session .isConnected ());
113
+ this .connectHeaders .setAcceptVersion (new String [] {"1.1" });
114
+
115
+ this .session .afterConnected (this .connection );
116
+
117
+ Message <byte []> message = this .messageCaptor .getValue ();
118
+ StompHeaderAccessor accessor = MessageHeaderAccessor .getAccessor (message , StompHeaderAccessor .class );
119
+ assertEquals (StompCommand .CONNECT , accessor .getCommand ());
120
+ assertThat (accessor .getAcceptVersion (), containsInAnyOrder ("1.1" ));
121
+ }
122
+
110
123
@ Test
111
- public void afterConnectFailure () throws Exception {
124
+ public void afterConnectFailure () {
112
125
IllegalStateException exception = new IllegalStateException ("simulated exception" );
113
126
this .session .afterConnectFailure (exception );
114
127
verify (this .sessionHandler ).handleTransportError (this .session , exception );
115
128
verifyNoMoreInteractions (this .sessionHandler );
116
129
}
117
130
118
131
@ Test
119
- public void handleConnectedFrame () throws Exception {
132
+ public void handleConnectedFrame () {
120
133
this .session .afterConnected (this .connection );
121
134
assertTrue (this .session .isConnected ());
122
135
@@ -134,7 +147,7 @@ public void handleConnectedFrame() throws Exception {
134
147
}
135
148
136
149
@ Test
137
- public void heartbeatValues () throws Exception {
150
+ public void heartbeatValues () {
138
151
this .session .afterConnected (this .connection );
139
152
assertTrue (this .session .isConnected ());
140
153
@@ -156,7 +169,7 @@ public void heartbeatValues() throws Exception {
156
169
}
157
170
158
171
@ Test
159
- public void heartbeatNotSupportedByServer () throws Exception {
172
+ public void heartbeatNotSupportedByServer () {
160
173
this .session .afterConnected (this .connection );
161
174
verify (this .connection ).send (any ());
162
175
@@ -172,7 +185,7 @@ public void heartbeatNotSupportedByServer() throws Exception {
172
185
}
173
186
174
187
@ Test
175
- public void heartbeatTasks () throws Exception {
188
+ public void heartbeatTasks () {
176
189
this .session .afterConnected (this .connection );
177
190
verify (this .connection ).send (any ());
178
191
@@ -207,7 +220,7 @@ public void heartbeatTasks() throws Exception {
207
220
}
208
221
209
222
@ Test
210
- public void handleErrorFrame () throws Exception {
223
+ public void handleErrorFrame () {
211
224
StompHeaderAccessor accessor = StompHeaderAccessor .create (StompCommand .ERROR );
212
225
accessor .setContentType (new MimeType ("text" , "plain" , StandardCharsets .UTF_8 ));
213
226
accessor .addNativeHeader ("foo" , "bar" );
@@ -226,7 +239,7 @@ public void handleErrorFrame() throws Exception {
226
239
}
227
240
228
241
@ Test
229
- public void handleErrorFrameWithEmptyPayload () throws Exception {
242
+ public void handleErrorFrameWithEmptyPayload () {
230
243
StompHeaderAccessor accessor = StompHeaderAccessor .create (StompCommand .ERROR );
231
244
accessor .addNativeHeader ("foo" , "bar" );
232
245
accessor .setLeaveMutable (true );
@@ -238,7 +251,7 @@ public void handleErrorFrameWithEmptyPayload() throws Exception {
238
251
}
239
252
240
253
@ Test
241
- public void handleErrorFrameWithConversionException () throws Exception {
254
+ public void handleErrorFrameWithConversionException () {
242
255
StompHeaderAccessor accessor = StompHeaderAccessor .create (StompCommand .ERROR );
243
256
accessor .setContentType (MimeTypeUtils .APPLICATION_JSON );
244
257
accessor .addNativeHeader ("foo" , "bar" );
@@ -257,7 +270,7 @@ public void handleErrorFrameWithConversionException() throws Exception {
257
270
}
258
271
259
272
@ Test
260
- public void handleMessageFrame () throws Exception {
273
+ public void handleMessageFrame () {
261
274
this .session .afterConnected (this .connection );
262
275
263
276
StompFrameHandler frameHandler = mock (StompFrameHandler .class );
@@ -284,7 +297,7 @@ public void handleMessageFrame() throws Exception {
284
297
}
285
298
286
299
@ Test
287
- public void handleMessageFrameWithConversionException () throws Exception {
300
+ public void handleMessageFrameWithConversionException () {
288
301
this .session .afterConnected (this .connection );
289
302
assertTrue (this .session .isConnected ());
290
303
@@ -314,7 +327,7 @@ public void handleMessageFrameWithConversionException() throws Exception {
314
327
}
315
328
316
329
@ Test
317
- public void handleFailure () throws Exception {
330
+ public void handleFailure () {
318
331
IllegalStateException exception = new IllegalStateException ("simulated exception" );
319
332
this .session .handleFailure (exception );
320
333
@@ -323,15 +336,15 @@ public void handleFailure() throws Exception {
323
336
}
324
337
325
338
@ Test
326
- public void afterConnectionClosed () throws Exception {
339
+ public void afterConnectionClosed () {
327
340
this .session .afterConnectionClosed ();
328
341
329
342
verify (this .sessionHandler ).handleTransportError (same (this .session ), any (ConnectionLostException .class ));
330
343
verifyNoMoreInteractions (this .sessionHandler );
331
344
}
332
345
333
346
@ Test
334
- public void send () throws Exception {
347
+ public void send () {
335
348
this .session .afterConnected (this .connection );
336
349
assertTrue (this .session .isConnected ());
337
350
@@ -353,7 +366,7 @@ public void send() throws Exception {
353
366
}
354
367
355
368
@ Test
356
- public void sendWithReceipt () throws Exception {
369
+ public void sendWithReceipt () {
357
370
this .session .afterConnected (this .connection );
358
371
assertTrue (this .session .isConnected ());
359
372
@@ -376,7 +389,7 @@ public void sendWithReceipt() throws Exception {
376
389
}
377
390
378
391
@ Test
379
- public void sendWithConversionException () throws Exception {
392
+ public void sendWithConversionException () {
380
393
this .session .afterConnected (this .connection );
381
394
assertTrue (this .session .isConnected ());
382
395
@@ -391,7 +404,7 @@ public void sendWithConversionException() throws Exception {
391
404
}
392
405
393
406
@ Test
394
- public void sendWithExecutionException () throws Exception {
407
+ public void sendWithExecutionException () {
395
408
this .session .afterConnected (this .connection );
396
409
assertTrue (this .session .isConnected ());
397
410
@@ -409,7 +422,7 @@ public void sendWithExecutionException() throws Exception {
409
422
}
410
423
411
424
@ Test
412
- public void subscribe () throws Exception {
425
+ public void subscribe () {
413
426
this .session .afterConnected (this .connection );
414
427
assertTrue (this .session .isConnected ());
415
428
@@ -428,7 +441,7 @@ public void subscribe() throws Exception {
428
441
}
429
442
430
443
@ Test
431
- public void subscribeWithHeaders () throws Exception {
444
+ public void subscribeWithHeaders () {
432
445
this .session .afterConnected (this .connection );
433
446
assertTrue (this .session .isConnected ());
434
447
@@ -454,7 +467,7 @@ public void subscribeWithHeaders() throws Exception {
454
467
}
455
468
456
469
@ Test
457
- public void unsubscribe () throws Exception {
470
+ public void unsubscribe () {
458
471
this .session .afterConnected (this .connection );
459
472
assertTrue (this .session .isConnected ());
460
473
@@ -473,7 +486,7 @@ public void unsubscribe() throws Exception {
473
486
}
474
487
475
488
@ Test // SPR-15131
476
- public void unsubscribeWithCustomHeader () throws Exception {
489
+ public void unsubscribeWithCustomHeader () {
477
490
this .session .afterConnected (this .connection );
478
491
assertTrue (this .session .isConnected ());
479
492
@@ -501,7 +514,7 @@ public void unsubscribeWithCustomHeader() throws Exception {
501
514
}
502
515
503
516
@ Test
504
- public void ack () throws Exception {
517
+ public void ack () {
505
518
this .session .afterConnected (this .connection );
506
519
assertTrue (this .session .isConnected ());
507
520
@@ -518,7 +531,7 @@ public void ack() throws Exception {
518
531
}
519
532
520
533
@ Test
521
- public void nack () throws Exception {
534
+ public void nack () {
522
535
this .session .afterConnected (this .connection );
523
536
assertTrue (this .session .isConnected ());
524
537
@@ -535,7 +548,7 @@ public void nack() throws Exception {
535
548
}
536
549
537
550
@ Test
538
- public void receiptReceived () throws Exception {
551
+ public void receiptReceived () {
539
552
this .session .afterConnected (this .connection );
540
553
this .session .setTaskScheduler (mock (TaskScheduler .class ));
541
554
@@ -559,7 +572,7 @@ public void receiptReceived() throws Exception {
559
572
}
560
573
561
574
@ Test
562
- public void receiptReceivedBeforeTaskAdded () throws Exception {
575
+ public void receiptReceivedBeforeTaskAdded () {
563
576
this .session .afterConnected (this .connection );
564
577
this .session .setTaskScheduler (mock (TaskScheduler .class ));
565
578
@@ -583,7 +596,7 @@ public void receiptReceivedBeforeTaskAdded() throws Exception {
583
596
584
597
@ Test
585
598
@ SuppressWarnings ({ "unchecked" , "rawtypes" })
586
- public void receiptNotReceived () throws Exception {
599
+ public void receiptNotReceived () {
587
600
TaskScheduler taskScheduler = mock (TaskScheduler .class );
588
601
589
602
this .session .afterConnected (this .connection );
@@ -614,7 +627,7 @@ public void receiptNotReceived() throws Exception {
614
627
}
615
628
616
629
@ Test
617
- public void disconnect () throws Exception {
630
+ public void disconnect () {
618
631
this .session .afterConnected (this .connection );
619
632
assertTrue (this .session .isConnected ());
620
633
0 commit comments