@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
/ *
* Copyright 2002 - 2015 the original author or authors .
* Copyright 2002 - 2016 the original author or authors .
*
* Licensed under the Apache License , Version 2 . 0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
@ -491,6 +491,42 @@ public class DefaultStompSessionTests {
@@ -491,6 +491,42 @@ public class DefaultStompSessionTests {
assertEquals ( subscription . getSubscriptionId ( ) , stompHeaders . getId ( ) ) ;
}
@Test
public void ack ( ) throws Exception {
this . session . afterConnected ( this . connection ) ;
assertTrue ( this . session . isConnected ( ) ) ;
String messageId = "123" ;
this . session . acknowledge ( messageId , true ) ;
Message < byte [ ] > message = this . messageCaptor . getValue ( ) ;
StompHeaderAccessor accessor = MessageHeaderAccessor . getAccessor ( message , StompHeaderAccessor . class ) ;
assertEquals ( StompCommand . ACK , accessor . getCommand ( ) ) ;
StompHeaders stompHeaders = StompHeaders . readOnlyStompHeaders ( accessor . getNativeHeaders ( ) ) ;
assertEquals ( stompHeaders . toString ( ) , 1 , stompHeaders . size ( ) ) ;
assertEquals ( messageId , stompHeaders . getId ( ) ) ;
}
@Test
public void nack ( ) throws Exception {
this . session . afterConnected ( this . connection ) ;
assertTrue ( this . session . isConnected ( ) ) ;
String messageId = "123" ;
this . session . acknowledge ( messageId , false ) ;
Message < byte [ ] > message = this . messageCaptor . getValue ( ) ;
StompHeaderAccessor accessor = MessageHeaderAccessor . getAccessor ( message , StompHeaderAccessor . class ) ;
assertEquals ( StompCommand . NACK , accessor . getCommand ( ) ) ;
StompHeaders stompHeaders = StompHeaders . readOnlyStompHeaders ( accessor . getNativeHeaders ( ) ) ;
assertEquals ( stompHeaders . toString ( ) , 1 , stompHeaders . size ( ) ) ;
assertEquals ( messageId , stompHeaders . getId ( ) ) ;
}
@Test
public void receiptReceived ( ) throws Exception {