Examples of SimpMessageHeaderAccessor


Examples of org.springframework.messaging.simp.SimpMessageHeaderAccessor

    this.messageHandler.handleMessage(createMessage(SimpMessageType.MESSAGE, "joe", "123", "/user/joe/queue/foo"));

    ArgumentCaptor<Message> captor = ArgumentCaptor.forClass(Message.class);
    Mockito.verify(this.brokerChannel).send(captor.capture());

    SimpMessageHeaderAccessor accessor = SimpMessageHeaderAccessor.wrap(captor.getValue());
    assertEquals("/queue/foo-user123", accessor.getDestination());
    assertEquals("/user/queue/foo", accessor.getFirstNativeHeader(SimpMessageHeaderAccessor.ORIGINAL_DESTINATION));
  }
View Full Code Here

Examples of org.springframework.messaging.simp.SimpMessageHeaderAccessor

    Mockito.verifyZeroInteractions(this.brokerChannel);
  }


  private Message<?> createMessage(SimpMessageType messageType, String user, String sessionId, String destination) {
    SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor.create(messageType);
    if (destination != null) {
      headers.setDestination(destination);
    }
    if (user != null) {
      headers.setUser(new TestPrincipal(user));
    }
    if (sessionId != null) {
      headers.setSessionId(sessionId);
    }
    return MessageBuilder.withPayload(new byte[0]).setHeaders(headers).build();
  }
View Full Code Here

Examples of org.springframework.messaging.simp.SimpMessageHeaderAccessor

    this.messageHandler.handleMessage(createSubscriptionMessage(sess2, "sub1", "/foo"));
    this.messageHandler.handleMessage(createSubscriptionMessage(sess2, "sub2", "/foo"));
    this.messageHandler.handleMessage(createSubscriptionMessage(sess2, "sub3", "/bar"));

    SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor.create(SimpMessageType.DISCONNECT);
    headers.setSessionId(sess1);
    Message<byte[]> message = MessageBuilder.createMessage(new byte[0], headers.getMessageHeaders());
    this.messageHandler.handleMessage(message);

    this.messageHandler.handleMessage(createMessage("/foo", "message1"));
    this.messageHandler.handleMessage(createMessage("/bar", "message2"));
View Full Code Here

Examples of org.springframework.messaging.simp.SimpMessageHeaderAccessor

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

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

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

Examples of org.springframework.messaging.simp.SimpMessageHeaderAccessor

    this.messageHandler.handleMessage(connectMessage);

    verify(this.clientOutboundChannel, times(1)).send(this.messageCaptor.capture());
    Message<?> connectAckMessage = this.messageCaptor.getValue();

    SimpMessageHeaderAccessor connectAckHeaders = SimpMessageHeaderAccessor.wrap(connectAckMessage);
    assertEquals(connectMessage, connectAckHeaders.getHeader(SimpMessageHeaderAccessor.CONNECT_MESSAGE_HEADER));
    assertEquals(sess1, connectAckHeaders.getSessionId());
  }
View Full Code Here

Examples of org.springframework.messaging.simp.SimpMessageHeaderAccessor


  @Test
  @SuppressWarnings("unchecked")
  public void headerArgumentResolution() {
    SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor.create();
    headers.setSessionId("session1");
    headers.setSessionAttributes(new ConcurrentHashMap<>());
    headers.setDestination("/pre/headers");
    headers.setHeader("foo", "bar");
    Message<?> message = MessageBuilder.withPayload(new byte[0]).setHeaders(headers).build();
    this.messageHandler.handleMessage(message);

    assertEquals("headers", this.testController.method);
    assertEquals("bar", this.testController.arguments.get("foo"));
View Full Code Here

Examples of org.springframework.messaging.simp.SimpMessageHeaderAccessor

    assertEquals("bar", ((Map<String, Object>) this.testController.arguments.get("headers")).get("foo"));
  }

  @Test
  public void optionalHeaderArgumentResolutionWhenPresent() {
    SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor.create();
    headers.setSessionId("session1");
    headers.setSessionAttributes(new ConcurrentHashMap<>());
    headers.setDestination("/pre/optionalHeaders");
    headers.setHeader("foo", "bar");
    Message<?> message = MessageBuilder.withPayload(new byte[0]).setHeaders(headers).build();
    this.messageHandler.handleMessage(message);

    assertEquals("optionalHeaders", this.testController.method);
    assertEquals("bar", this.testController.arguments.get("foo1"));
View Full Code Here

Examples of org.springframework.messaging.simp.SimpMessageHeaderAccessor

    assertEquals("bar", this.testController.arguments.get("foo2"));
  }

  @Test
  public void optionalHeaderArgumentResolutionWhenNotPresent() {
    SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor.create();
    headers.setSessionId("session1");
    headers.setSessionAttributes(new ConcurrentHashMap<>());
    headers.setDestination("/pre/optionalHeaders");
    Message<?> message = MessageBuilder.withPayload(new byte[0]).setHeaders(headers).build();
    this.messageHandler.handleMessage(message);

    assertEquals("optionalHeaders", this.testController.method);
    assertNull(this.testController.arguments.get("foo1"));
View Full Code Here

Examples of org.springframework.messaging.simp.SimpMessageHeaderAccessor

    assertNull(this.testController.arguments.get("foo2"));
  }

  @Test
  public void messageMappingDestinationVariableResolution() {
    SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor.create();
    headers.setSessionId("session1");
    headers.setSessionAttributes(new ConcurrentHashMap<>());
    headers.setDestination("/pre/message/bar/value");
    Message<?> message = MessageBuilder.withPayload(new byte[0]).setHeaders(headers).build();
    this.messageHandler.handleMessage(message);

    assertEquals("messageMappingDestinationVariable", this.testController.method);
    assertEquals("bar", this.testController.arguments.get("foo"));
View Full Code Here

Examples of org.springframework.messaging.simp.SimpMessageHeaderAccessor

    assertEquals("value", this.testController.arguments.get("name"));
  }

  @Test
  public void subscribeEventDestinationVariableResolution() {
    SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor.create(SimpMessageType.SUBSCRIBE);
    headers.setSessionId("session1");
    headers.setSessionAttributes(new ConcurrentHashMap<>());
    headers.setDestination("/pre/sub/bar/value");
    Message<?> message = MessageBuilder.withPayload(new byte[0]).copyHeaders(headers.toMap()).build();
    this.messageHandler.handleMessage(message);

    assertEquals("subscribeEventDestinationVariable", this.testController.method);
    assertEquals("bar", this.testController.arguments.get("foo"));
    assertEquals("value", this.testController.arguments.get("name"));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.