@@ -415,20 +415,16 @@ func TestStompConn_Subscribe(t *testing.T) {
415
415
frame .Id , "sub-id" ,
416
416
frame .Destination , "/topic/test" )
417
417
418
- rawConn .incomingFrames <- frame .New (frame .SEND , frame .Destination , "/topic/dest" )
419
-
420
- // verify that there will be no SubscribeToTopic con event for the
421
- // the second request.
422
- e = <- events
423
- assert .Equal (t , e .eventType , IncomingMessage )
418
+ // verify that there was no second subscription created for the same subscription id
419
+ assert .Equal (t , e .sub , stompConn .subscriptions ["sub-id" ])
424
420
}
425
421
426
422
func TestStompConn_SendNotConnected (t * testing.T ) {
427
- _ , rawConn , events := getTestStompConn (NewStompConfig (0 , []string {}), nil )
423
+ _ , rawConn , events := getTestStompConn (NewStompConfig (0 , []string {"/pub/" }), nil )
428
424
429
425
rawConn .incomingFrames <- frame .New (
430
426
frame .SEND ,
431
- frame .Destination , "/topic /test" )
427
+ frame .Destination , "/pub /test" )
432
428
433
429
e := <- events
434
430
assert .Equal (t , e .eventType , ConnectionClosed )
@@ -439,7 +435,7 @@ func TestStompConn_SendNotConnected(t *testing.T) {
439
435
}
440
436
441
437
func TestStompConn_SendMissingDestinationHeader (t * testing.T ) {
442
- stompConn , rawConn , events := getTestStompConn (NewStompConfig (0 , []string {}), nil )
438
+ stompConn , rawConn , events := getTestStompConn (NewStompConfig (0 , []string {"/pub/" }), nil )
443
439
444
440
rawConn .SendConnectFrame ()
445
441
@@ -458,15 +454,36 @@ func TestStompConn_SendMissingDestinationHeader(t *testing.T) {
458
454
assert .Equal (t , stompConn .state , closed )
459
455
}
460
456
457
+ func TestStompConn_Send_InvalidSend (t * testing.T ) {
458
+ _ , rawConn , events := getTestStompConn (NewStompConfig (0 , []string {"/pub/" }), nil )
459
+
460
+ rawConn .SendConnectFrame ()
461
+
462
+ e := <- events
463
+ assert .Equal (t , e .eventType , ConnectionEstablished )
464
+ assert .Equal (t , len (rawConn .sentFrames ), 1 )
465
+ verifyFrame (t , rawConn .sentFrames [0 ], frame .New (frame .CONNECTED ), false )
466
+
467
+ // try sending a frame to a topic channel directly not request channel
468
+ rawConn .incomingFrames <- frame .New (frame .SEND ,
469
+ frame .Destination , "/topic/test" )
470
+ e = <- events
471
+
472
+ assert .Equal (t , e .eventType , ConnectionClosed )
473
+ assert .Equal (t , len (rawConn .sentFrames ), 2 )
474
+ verifyFrame (t , rawConn .sentFrames [1 ], frame .New (frame .ERROR ,
475
+ frame .Message , invalidSendDestinationError .Error ()), true )
476
+ }
477
+
461
478
func TestStompConn_Send (t * testing.T ) {
462
- _ , rawConn , events := getTestStompConn (NewStompConfig (0 , []string {}), nil )
479
+ _ , rawConn , events := getTestStompConn (NewStompConfig (0 , []string {"/pub/" }), nil )
463
480
464
481
rawConn .SendConnectFrame ()
465
482
466
483
e := <- events
467
484
assert .Equal (t , e .eventType , ConnectionEstablished )
468
485
469
- msgF := frame .New (frame .SEND , frame .Destination , "/topic /test" )
486
+ msgF := frame .New (frame .SEND , frame .Destination , "/pub /test" )
470
487
471
488
rawConn .incomingFrames <- msgF
472
489
@@ -476,7 +493,7 @@ func TestStompConn_Send(t *testing.T) {
476
493
assert .Equal (t , e .frame .Command , frame .MESSAGE )
477
494
478
495
rawConn .incomingFrames <- frame .New (frame .SEND ,
479
- frame .Destination , "/topic /test" , frame .Receipt , "receipt-id" )
496
+ frame .Destination , "/pub /test" , frame .Receipt , "receipt-id" )
480
497
481
498
e = <- events
482
499
assert .Equal (t , e .eventType , IncomingMessage )
@@ -710,7 +727,7 @@ func TestStompConn_WriteErrorDuringConnect(t *testing.T) {
710
727
}
711
728
712
729
func TestStompConn_WriteErrorDuringSend (t * testing.T ) {
713
- stompConn , rawConn , events := getTestStompConn (NewStompConfig (0 , []string {}), nil )
730
+ stompConn , rawConn , events := getTestStompConn (NewStompConfig (0 , []string {"/pub/" }), nil )
714
731
715
732
rawConn .SendConnectFrame ()
716
733
@@ -720,7 +737,7 @@ func TestStompConn_WriteErrorDuringSend(t *testing.T) {
720
737
rawConn .nextWriteErr = errors .New ("write error" )
721
738
rawConn .incomingFrames <- frame .New (
722
739
frame .SEND ,
723
- frame .Destination , "/topic " ,
740
+ frame .Destination , "/pub/ " ,
724
741
frame .Receipt , "receipt-id" )
725
742
726
743
e = <- events
0 commit comments