Package org.springframework.messaging.simp

Examples of org.springframework.messaging.simp.SimpMessageHeaderAccessor


    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.foo.bar", headers.getDestination());
  }
View Full Code Here


    handler.handleReturnValue(PAYLOAD, this.noAnnotationsReturnType, inputMessage);

    ArgumentCaptor<MessageHeaders> captor = ArgumentCaptor.forClass(MessageHeaders.class);
    verify(messagingTemplate).convertAndSend(eq("/topic/dest"), eq(PAYLOAD), captor.capture());

    SimpMessageHeaderAccessor headerAccessor =
        MessageHeaderAccessor.getAccessor(captor.getValue(), SimpMessageHeaderAccessor.class);

    assertNotNull(headerAccessor);
    assertTrue(headerAccessor.isMutable());
    assertEquals("sess1", headerAccessor.getSessionId());
    assertNull("Subscription id should not be copied", headerAccessor.getSubscriptionId());
  }
View Full Code Here

    this.handler.handleReturnValue(PAYLOAD, this.sendToUserReturnType, inputMessage);

    verify(this.messageChannel, times(2)).send(this.messageCaptor.capture());

    Message<?> message = this.messageCaptor.getAllValues().get(0);
    SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor.wrap(message);
    assertNull(headers.getSessionId());
    assertNull(headers.getSubscriptionId());
    assertEquals("/user/" + user.getName() + "/dest1", headers.getDestination());

    message = this.messageCaptor.getAllValues().get(1);
    headers = SimpMessageHeaderAccessor.wrap(message);
    assertNull(headers.getSessionId());
    assertNull(headers.getSubscriptionId());
    assertEquals("/user/" + user.getName() + "/dest2", headers.getDestination());
  }
View Full Code Here

    this.handler.handleReturnValue(PAYLOAD, this.sendToUserSingleSessionReturnType, inputMessage);

    verify(this.messageChannel, times(2)).send(this.messageCaptor.capture());

    Message<?> message = this.messageCaptor.getAllValues().get(0);
    SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor.wrap(message);
    assertEquals(sessionId, headers.getSessionId());
    assertEquals(MIME_TYPE, headers.getContentType());
    assertEquals("/user/" + user.getName() + "/dest1", headers.getDestination());
    assertNull("Subscription id should not be copied", headers.getSubscriptionId());

    message = this.messageCaptor.getAllValues().get(1);
    headers = SimpMessageHeaderAccessor.wrap(message);
    assertEquals(sessionId, headers.getSessionId());
    assertEquals("/user/" + user.getName() + "/dest2", headers.getDestination());
    assertEquals(MIME_TYPE, headers.getContentType());
    assertNull("Subscription id should not be copied", headers.getSubscriptionId());
  }
View Full Code Here

    Message<?> inputMessage = createInputMessage(sessionId, "sub1", null, null, user);
    this.handler.handleReturnValue(PAYLOAD, this.sendToUserReturnType, inputMessage);

    verify(this.messageChannel, times(2)).send(this.messageCaptor.capture());

    SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor.wrap(this.messageCaptor.getAllValues().get(0));
    assertEquals("/user/Me myself and I/dest1", headers.getDestination());

    headers = SimpMessageHeaderAccessor.wrap(this.messageCaptor.getAllValues().get(1));
    assertEquals("/user/Me myself and I/dest2", headers.getDestination());
  }
View Full Code Here

    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);
    assertNull(headers.getSessionId());
    assertNull(headers.getSubscriptionId());
    assertEquals("/user/" + user.getName() + "/queue/dest", headers.getDestination());
  }
View Full Code Here

    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.foo.bar", headers.getDestination());
  }
View Full Code Here

    this.handler.handleReturnValue(PAYLOAD, this.sendToUserSingleSessionDefaultDestReturnType, inputMessage);

    verify(this.messageChannel, times(1)).send(this.messageCaptor.capture());

    Message<?> message = this.messageCaptor.getAllValues().get(0);
    SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor.wrap(message);
    assertEquals(sessionId, headers.getSessionId());
    assertEquals("/user/" + user.getName() + "/queue/dest", headers.getDestination());
    assertEquals(MIME_TYPE, headers.getContentType());
    assertNull("Subscription id should not be copied", headers.getSubscriptionId());
  }
View Full Code Here

    Message<?> inputMessage = createInputMessage(sessionId, "sub1", null, null, null);
    this.handler.handleReturnValue(PAYLOAD, this.sendToUserReturnType, inputMessage);

    verify(this.messageChannel, times(2)).send(this.messageCaptor.capture());

    SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor.wrap(this.messageCaptor.getAllValues().get(0));
    assertEquals("/user/sess1/dest1", headers.getDestination());
    assertEquals("sess1", headers.getSessionId());

    headers = SimpMessageHeaderAccessor.wrap(this.messageCaptor.getAllValues().get(1));
    assertEquals("/user/sess1/dest2", headers.getDestination());
    assertEquals("sess1", headers.getSessionId());
  }
View Full Code Here


  private Message<?> createInputMessage(String sessId, String subsId, String destinationPrefix,
            String destination, Principal principal) {

    SimpMessageHeaderAccessor headerAccessor = SimpMessageHeaderAccessor.create();
    headerAccessor.setSessionId(sessId);
    headerAccessor.setSubscriptionId(subsId);
    if (destination != null && destinationPrefix != null) {
      headerAccessor.setDestination(destinationPrefix + destination);
      headerAccessor.setHeader(DestinationPatternsMessageCondition.LOOKUP_DESTINATION_HEADER, destination);
    }
    if (principal != null) {
      headerAccessor.setUser(principal);
    }
    return MessageBuilder.createMessage(new byte[0], headerAccessor.getMessageHeaders());
  }
View Full Code Here

TOP

Related Classes of org.springframework.messaging.simp.SimpMessageHeaderAccessor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.