@@ -664,70 +664,48 @@ public void receiptNotReceived() {
664664	}
665665
666666	@ Test 
667- 	void  unsubscribeWithReceipt () {
667+ 	void  unsubscribeWithoutReceipt () {
668668		this .session .afterConnected (this .connection );
669669		assertThat (this .session .isConnected ()).isTrue ();
670670		Subscription  subscription  = this .session .subscribe ("/topic/foo" , mock ());
671671
672672		Receiptable  receipt  = subscription .unsubscribe ();
673673		assertThat (receipt ).isNotNull ();
674674		assertThat (receipt .getReceiptId ()).isNull ();
675- 
676- 		Message <byte []> message  = this .messageCaptor .getValue ();
677- 		StompHeaderAccessor  accessor  = MessageHeaderAccessor .getAccessor (message , StompHeaderAccessor .class );
678- 		assertThat (accessor .getCommand ()).isEqualTo (StompCommand .UNSUBSCRIBE );
679- 
680- 		StompHeaders  stompHeaders  = StompHeaders .readOnlyStompHeaders (accessor .getNativeHeaders ());
681- 		assertThat (stompHeaders ).hasSize (1 );
682- 		assertThat (stompHeaders .getId ()).isEqualTo (subscription .getSubscriptionId ());
683675	}
684676
685677	@ Test 
686- 	void  unsubscribeWithCustomHeaderAndReceipt () {
678+ 	void  unsubscribeWithReceipt () {
687679		this .session .afterConnected (this .connection );
688680		this .session .setTaskScheduler (mock ());
689681		this .session .setAutoReceipt (true );
682+ 		Subscription  subscription  = this .session .subscribe ("/topic/foo" , mock ());
690683
691- 		StompHeaders  subHeaders  = new  StompHeaders ();
692- 		subHeaders .setDestination ("/topic/foo" );
693- 		Subscription  subscription  = this .session .subscribe (subHeaders , mock ());
694- 
695- 		StompHeaders  custom  = new  StompHeaders ();
696- 		custom .set ("x-cust" , "value" );
697- 
698- 		Receiptable  receipt  = subscription .unsubscribe (custom );
684+ 		Receiptable  receipt  = subscription .unsubscribe ();
699685		assertThat (receipt ).isNotNull ();
700686		assertThat (receipt .getReceiptId ()).isNotNull ();
701687
702688		Message <byte []> message  = this .messageCaptor .getValue ();
703689		StompHeaderAccessor  accessor  = MessageHeaderAccessor .getAccessor (message , StompHeaderAccessor .class );
704- 		assertThat (accessor .getCommand ()).isEqualTo (StompCommand .UNSUBSCRIBE );
705- 
706- 		StompHeaders  stompHeaders  = StompHeaders .readOnlyStompHeaders (accessor .getNativeHeaders ());
707- 		assertThat (stompHeaders .getId ()).isEqualTo (subscription .getSubscriptionId ());
708- 		assertThat (stompHeaders .get ("x-cust" )).containsExactly ("value" );
709- 		assertThat (stompHeaders .getReceipt ()).isEqualTo (receipt .getReceiptId ());
690+ 		assertThat (accessor .getReceipt ()).isEqualTo (receipt .getReceiptId ());
710691	}
711692
712693	@ Test 
713694	void  receiptReceivedOnUnsubscribe () {
714695		this .session .afterConnected (this .connection );
715- 		TaskScheduler  scheduler  = mock ();
716- 		this .session .setTaskScheduler (scheduler );
696+ 		this .session .setTaskScheduler (mock ());
717697		this .session .setAutoReceipt (true );
718698
719699		Subscription  subscription  = this .session .subscribe ("/topic/foo" , mock ());
720700		Receiptable  receipt  = subscription .unsubscribe ();
721701
722- 		StompHeaderAccessor  ack  = StompHeaderAccessor .create (StompCommand .RECEIPT );
723- 		ack .setReceiptId (receipt .getReceiptId ());
724- 		ack .setLeaveMutable (true );
725- 		Message <byte []> receiptMessage  = MessageBuilder .createMessage (new  byte [0 ], ack .getMessageHeaders ());
726- 
727702		AtomicBoolean  called  = new  AtomicBoolean (false );
728703		receipt .addReceiptTask (() -> called .set (true ));
729704
730- 		this .session .handleMessage (receiptMessage );
705+ 		StompHeaderAccessor  ack  = StompHeaderAccessor .create (StompCommand .RECEIPT );
706+ 		ack .setReceiptId (receipt .getReceiptId ());
707+ 		ack .setLeaveMutable (true );
708+ 		this .session .handleMessage (MessageBuilder .createMessage (new  byte [0 ], ack .getMessageHeaders ()));
731709
732710		assertThat (called .get ()).isTrue ();
733711	}
0 commit comments