@ -185,6 +185,21 @@ public class SendToMethodReturnValueHandlerTests {
@@ -185,6 +185,21 @@ public class SendToMethodReturnValueHandlerTests {
assertNull ( "Subscription id should not be copied" , headers . getSubscriptionId ( ) ) ;
}
@Test
public void sendToDefaultDestinationWithoutLeadingSlash ( ) throws Exception {
when ( this . messageChannel . send ( any ( Message . class ) ) ) . thenReturn ( true ) ;
Message < ? > inputMessage = createInputMessage ( "sess1" , "sub1" , "/app" , "dest" , null ) ;
this . handler . handleReturnValue ( PAYLOAD , this . sendToDefaultDestReturnType , inputMessage ) ;
verify ( this . messageChannel , times ( 1 ) ) . send ( this . messageCaptor . capture ( ) ) ;
Message < ? > message = this . messageCaptor . getAllValues ( ) . get ( 0 ) ;
SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor . wrap ( message ) ;
assertEquals ( "/topic/dest" , headers . getDestination ( ) ) ;
}
@Test
public void testHeadersToSend ( ) throws Exception {
@ -297,6 +312,22 @@ public class SendToMethodReturnValueHandlerTests {
@@ -297,6 +312,22 @@ public class SendToMethodReturnValueHandlerTests {
assertEquals ( "/user/" + user . getName ( ) + "/queue/dest" , headers . getDestination ( ) ) ;
}
@Test
public void sendToUserDefaultDestinationWithoutLeadingSlash ( ) throws Exception {
when ( this . messageChannel . send ( any ( Message . class ) ) ) . thenReturn ( true ) ;
TestUser user = new TestUser ( ) ;
Message < ? > inputMessage = createInputMessage ( "sess1" , "sub1" , "/app" , "dest" , user ) ;
this . handler . handleReturnValue ( PAYLOAD , this . sendToUserDefaultDestReturnType , inputMessage ) ;
verify ( this . messageChannel , times ( 1 ) ) . send ( this . messageCaptor . capture ( ) ) ;
Message < ? > message = this . messageCaptor . getAllValues ( ) . get ( 0 ) ;
SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor . wrap ( message ) ;
assertEquals ( "/user/" + user . getName ( ) + "/queue/dest" , headers . getDestination ( ) ) ;
}
@Test
public void sendToUserDefaultDestinationSingleSession ( ) throws Exception {