Package org.springframework.web.socket.messaging

Examples of org.springframework.web.socket.messaging.SubProtocolWebSocketHandler$Stats



  @Test
  public void getSubProtocols() throws Exception {
    SubscribableChannel channel = mock(SubscribableChannel.class);
    SubProtocolWebSocketHandler handler = new SubProtocolWebSocketHandler(channel, channel);
    StompSubProtocolHandler stompHandler = new StompSubProtocolHandler();
    handler.addProtocolHandler(stompHandler);

    TaskScheduler scheduler = mock(TaskScheduler.class);
    DefaultSockJsService service = new DefaultSockJsService(scheduler);
    WebSocketServerSockJsSession session = new WebSocketServerSockJsSession("1", service, handler, null);
    SockJsWebSocketHandler sockJsHandler = new SockJsWebSocketHandler(service, handler, session);
View Full Code Here


    WebSocketHandler wsHandler = unwrapWebSocketHandler(wsHttpRequestHandler.getWebSocketHandler());
    assertNotNull(wsHandler);
    assertThat(wsHandler, Matchers.instanceOf(SubProtocolWebSocketHandler.class));

    SubProtocolWebSocketHandler subProtocolWsHandler = (SubProtocolWebSocketHandler) wsHandler;
    assertEquals(Arrays.asList("v10.stomp", "v11.stomp", "v12.stomp"), subProtocolWsHandler.getSubProtocols());
    assertEquals(25 * 1000, subProtocolWsHandler.getSendTimeLimit());
    assertEquals(1024 * 1024, subProtocolWsHandler.getSendBufferSizeLimit());

    StompSubProtocolHandler stompHandler = (StompSubProtocolHandler) subProtocolWsHandler.getProtocolHandlerMap().get("v12.stomp");
    assertNotNull(stompHandler);
    assertEquals(128 * 1024, stompHandler.getMessageSizeLimit());

    assertNotNull(new DirectFieldAccessor(stompHandler).getPropertyValue("eventPublisher"));

View Full Code Here

  @Test
  public void clientInboundChannelSendMessage() throws Exception {
    ApplicationContext config = createConfig(TestChannelConfig.class, TestConfigurer.class);
    TestChannel channel = config.getBean("clientInboundChannel", TestChannel.class);
    SubProtocolWebSocketHandler webSocketHandler = config.getBean(SubProtocolWebSocketHandler.class);

    List<ChannelInterceptor> interceptors = channel.getInterceptors();
    assertEquals(ImmutableMessageChannelInterceptor.class, interceptors.get(interceptors.size()-1).getClass());

    WebSocketSession session = new TestWebSocketSession("s1");
    webSocketHandler.afterConnectionEstablished(session);

    TextMessage textMessage = StompTextMessageBuilder.create(StompCommand.SEND).headers("destination:/foo").build();
    webSocketHandler.handleMessage(session, textMessage);

    Message<?> message = channel.messages.get(0);
    StompHeaderAccessor accessor = StompHeaderAccessor.getAccessor(message, StompHeaderAccessor.class);
    assertNotNull(accessor);
    assertFalse(accessor.isMutable());
View Full Code Here

  }

  @Test
  public void webSocketTransportOptions() {
    ApplicationContext config = createConfig(TestChannelConfig.class, TestConfigurer.class);
    SubProtocolWebSocketHandler subProtocolWebSocketHandler =
        config.getBean("subProtocolWebSocketHandler", SubProtocolWebSocketHandler.class);

    assertEquals(1024 * 1024, subProtocolWebSocketHandler.getSendBufferSizeLimit());
    assertEquals(25 * 1000, subProtocolWebSocketHandler.getSendTimeLimit());

    List<SubProtocolHandler> protocolHandlers = subProtocolWebSocketHandler.getProtocolHandlers();
    for(SubProtocolHandler protocolHandler : protocolHandlers) {
      assertTrue(protocolHandler instanceof StompSubProtocolHandler);
      assertEquals(128 * 1024, ((StompSubProtocolHandler) protocolHandler).getMessageSizeLimit());
    }
  }
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

  private TaskScheduler scheduler;


  @Before
  public void setup() {
    this.handler = new SubProtocolWebSocketHandler(mock(MessageChannel.class), mock(SubscribableChannel.class));
    this.scheduler = mock(TaskScheduler.class);
  }
View Full Code Here

    return registry.getHandlerMapping();
  }

  @Bean
  public WebSocketHandler subProtocolWebSocketHandler() {
    return new SubProtocolWebSocketHandler(clientInboundChannel(), clientOutboundChannel());
  }
View Full Code Here

TOP

Related Classes of org.springframework.web.socket.messaging.SubProtocolWebSocketHandler$Stats

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.