Package org.springframework.messaging.simp.user

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


  }

  @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

    interceptors = defaultSockJsService.getHandshakeInterceptors();
    assertThat(interceptors, contains(instanceOf(FooTestInterceptor.class),
        instanceOf(BarTestInterceptor.class), instanceOf(OriginHandshakeInterceptor.class)));
    assertEquals(Arrays.asList("http://mydomain3.com", "http://mydomain4.com"), defaultSockJsService.getAllowedOrigins());

    UserSessionRegistry userSessionRegistry = this.appContext.getBean(UserSessionRegistry.class);
    assertNotNull(userSessionRegistry);

    UserDestinationResolver userDestResolver = this.appContext.getBean(UserDestinationResolver.class);
    assertNotNull(userDestResolver);
    assertThat(userDestResolver, Matchers.instanceOf(DefaultUserDestinationResolver.class));
View Full Code Here

TOP

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

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.