Search in sources :

Example 6 with SubProtocolHandler

use of org.springframework.web.socket.messaging.SubProtocolHandler in project spring-framework by spring-projects.

the class WebMvcStompEndpointRegistryTests method errorHandler.

@Test
public void errorHandler() throws Exception {
    StompSubProtocolErrorHandler errorHandler = mock(StompSubProtocolErrorHandler.class);
    this.endpointRegistry.setErrorHandler(errorHandler);
    this.endpointRegistry.addEndpoint("/stompOverWebSocket");
    Map<String, SubProtocolHandler> protocolHandlers = this.webSocketHandler.getProtocolHandlerMap();
    StompSubProtocolHandler stompHandler = (StompSubProtocolHandler) protocolHandlers.get("v12.stomp");
    assertThat(stompHandler.getErrorHandler()).isSameAs(errorHandler);
}
Also used : StompSubProtocolHandler(org.springframework.web.socket.messaging.StompSubProtocolHandler) StompSubProtocolHandler(org.springframework.web.socket.messaging.StompSubProtocolHandler) SubProtocolHandler(org.springframework.web.socket.messaging.SubProtocolHandler) StompSubProtocolErrorHandler(org.springframework.web.socket.messaging.StompSubProtocolErrorHandler) Test(org.junit.jupiter.api.Test)

Example 7 with SubProtocolHandler

use of org.springframework.web.socket.messaging.SubProtocolHandler in project spring-framework by spring-projects.

the class WebSocketMessageBrokerConfigurationSupportTests method webSocketHandler.

@Test
void webSocketHandler() {
    ApplicationContext context = createContext(TestChannelConfig.class, TestConfigurer.class);
    SubProtocolWebSocketHandler subWsHandler = context.getBean(SubProtocolWebSocketHandler.class);
    assertThat(subWsHandler.getSendBufferSizeLimit()).isEqualTo(1024 * 1024);
    assertThat(subWsHandler.getSendTimeLimit()).isEqualTo(25 * 1000);
    assertThat(subWsHandler.getTimeToFirstMessage()).isEqualTo(30 * 1000);
    Map<String, SubProtocolHandler> handlerMap = subWsHandler.getProtocolHandlerMap();
    StompSubProtocolHandler protocolHandler = (StompSubProtocolHandler) handlerMap.get("v12.stomp");
    assertThat(protocolHandler.getMessageSizeLimit()).isEqualTo(128 * 1024);
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) SubProtocolWebSocketHandler(org.springframework.web.socket.messaging.SubProtocolWebSocketHandler) StompSubProtocolHandler(org.springframework.web.socket.messaging.StompSubProtocolHandler) SubProtocolHandler(org.springframework.web.socket.messaging.SubProtocolHandler) StompSubProtocolHandler(org.springframework.web.socket.messaging.StompSubProtocolHandler) Test(org.junit.jupiter.api.Test)

Aggregations

SubProtocolHandler (org.springframework.web.socket.messaging.SubProtocolHandler)7 StompSubProtocolHandler (org.springframework.web.socket.messaging.StompSubProtocolHandler)6 WebSocketSession (org.springframework.web.socket.WebSocketSession)4 Test (org.junit.Test)3 Test (org.junit.jupiter.api.Test)3 SubProtocolWebSocketHandler (org.springframework.web.socket.messaging.SubProtocolWebSocketHandler)2 ArrayList (java.util.ArrayList)1 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)1 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)1 NoSuchBeanDefinitionException (org.springframework.beans.factory.NoSuchBeanDefinitionException)1 ApplicationContext (org.springframework.context.ApplicationContext)1 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)1 MessageHandler (org.springframework.messaging.MessageHandler)1 SimpAnnotationMethodMessageHandler (org.springframework.messaging.simp.annotation.support.SimpAnnotationMethodMessageHandler)1 DefaultSubscriptionRegistry (org.springframework.messaging.simp.broker.DefaultSubscriptionRegistry)1 SimpleBrokerMessageHandler (org.springframework.messaging.simp.broker.SimpleBrokerMessageHandler)1 StompBrokerRelayMessageHandler (org.springframework.messaging.simp.stomp.StompBrokerRelayMessageHandler)1 DefaultUserDestinationResolver (org.springframework.messaging.simp.user.DefaultUserDestinationResolver)1 SimpUserRegistry (org.springframework.messaging.simp.user.SimpUserRegistry)1 UserDestinationMessageHandler (org.springframework.messaging.simp.user.UserDestinationMessageHandler)1