use of org.springframework.messaging.simp.TestPrincipal in project spring-framework by spring-projects.
the class DefaultUserDestinationResolverTests method handleSubscribe.
@Test
public void handleSubscribe() {
TestPrincipal user = new TestPrincipal("joe");
String sourceDestination = "/user/queue/foo";
Message<?> message = createMessage(SimpMessageType.SUBSCRIBE, user, "123", sourceDestination);
UserDestinationResult actual = this.resolver.resolveDestination(message);
assertEquals(sourceDestination, actual.getSourceDestination());
assertEquals(1, actual.getTargetDestinations().size());
assertEquals("/queue/foo-user123", actual.getTargetDestinations().iterator().next());
assertEquals(sourceDestination, actual.getSubscribeDestination());
assertEquals(user.getName(), actual.getUser());
}
use of org.springframework.messaging.simp.TestPrincipal in project spring-framework by spring-projects.
the class StompBrokerRelayMessageHandlerTests method message.
private Message<byte[]> message(StompCommand command, String sessionId, String user, String destination) {
StompHeaderAccessor accessor = StompHeaderAccessor.create(command);
if (sessionId != null) {
accessor.setSessionId(sessionId);
}
if (user != null) {
accessor.setUser(new TestPrincipal(user));
}
if (destination != null) {
accessor.setDestination(destination);
}
accessor.setLeaveMutable(true);
return MessageBuilder.createMessage(new byte[0], accessor.getMessageHeaders());
}
use of org.springframework.messaging.simp.TestPrincipal in project spring-framework by spring-projects.
the class StompBrokerRelayMessageHandlerTests method connectMessage.
private Message<byte[]> connectMessage(String sessionId, String user) {
StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.CONNECT);
headers.setSessionId(sessionId);
headers.setUser(new TestPrincipal(user));
return MessageBuilder.createMessage(new byte[0], headers.getMessageHeaders());
}
Aggregations