Package org.springframework.messaging.simp.user

Examples of org.springframework.messaging.simp.user.DefaultUserSessionRegistry


  }

  @Test
  public void handleMessageToClientConnected() {

    UserSessionRegistry registry = new DefaultUserSessionRegistry();
    this.protocolHandler.setUserSessionRegistry(registry);

    StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.CONNECTED);
    Message<byte[]> message = MessageBuilder.createMessage(EMPTY_PAYLOAD, headers.getMessageHeaders());
    this.protocolHandler.handleMessageToClient(this.session, message);

    assertEquals(1, this.session.getSentMessages().size());
    WebSocketMessage<?> textMessage = this.session.getSentMessages().get(0);
    assertEquals("CONNECTED\n" + "user-name:joe\n" + "\n" + "\u0000", textMessage.getPayload());

    assertEquals(Collections.singleton("s1"), registry.getSessionIds("joe"));
  }
View Full Code Here


  @Test
  public void handleMessageToClientConnectedUniqueUserName() {

    this.session.setPrincipal(new UniqueUser("joe"));

    UserSessionRegistry registry = new DefaultUserSessionRegistry();
    this.protocolHandler.setUserSessionRegistry(registry);

    StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.CONNECTED);
    Message<byte[]> message = MessageBuilder.createMessage(EMPTY_PAYLOAD, headers.getMessageHeaders());
    this.protocolHandler.handleMessageToClient(this.session, message);

    assertEquals(1, this.session.getSentMessages().size());
    WebSocketMessage<?> textMessage = this.session.getSentMessages().get(0);
    assertEquals("CONNECTED\n" + "user-name:joe\n" + "\n" + "\u0000", textMessage.getPayload());

    assertEquals(Collections.<String>emptySet(), registry.getSessionIds("joe"));
    assertEquals(Collections.singleton("s1"), registry.getSessionIds("Me myself and I"));
  }
View Full Code Here

  @Test
  public void eventPublication() {

    TestPublisher publisher = new TestPublisher();

    UserSessionRegistry registry = new DefaultUserSessionRegistry();
    this.protocolHandler.setUserSessionRegistry(registry);
    this.protocolHandler.setApplicationEventPublisher(publisher);
    this.protocolHandler.afterSessionStarted(this.session, this.channel);

    StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.CONNECT);
View Full Code Here

  @Test
  public void eventPublicationWithExceptions() {

    ApplicationEventPublisher publisher = mock(ApplicationEventPublisher.class);

    UserSessionRegistry registry = new DefaultUserSessionRegistry();
    this.protocolHandler.setUserSessionRegistry(registry);
    this.protocolHandler.setApplicationEventPublisher(publisher);
    this.protocolHandler.afterSessionStarted(this.session, this.channel);

    StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.CONNECT);
View Full Code Here

  @Before
  public void setup() {
    SubscribableChannel inChannel = Mockito.mock(SubscribableChannel.class);
    SubscribableChannel outChannel = Mockito.mock(SubscribableChannel.class);
    this.webSocketHandler = new SubProtocolWebSocketHandler(inChannel, outChannel);
    this.userSessionRegistry = new DefaultUserSessionRegistry();
    this.endpointRegistry = new WebMvcStompEndpointRegistry(this.webSocketHandler,
        new WebSocketTransportRegistration(), this.userSessionRegistry, Mockito.mock(TaskScheduler.class));
  }
View Full Code Here

    return resolver;
  }

  @Bean
  public UserSessionRegistry userSessionRegistry() {
    return new DefaultUserSessionRegistry();
  }
View Full Code Here

TOP

Related Classes of org.springframework.messaging.simp.user.DefaultUserSessionRegistry

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.