Fix default target destination when using "." as path separator

Issue: SPR-11660
This commit is contained in:
Sebastien Deleuze
2014-07-17 07:51:36 +02:00
committed by Rossen Stoyanchev
parent e8d8c3390a
commit 59f39706dc
2 changed files with 37 additions and 1 deletions

View File

@@ -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 {
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 {