Add missing handshake-interceptor namespace support
Issue: SPR-11845
This commit is contained in:
@@ -48,7 +48,9 @@ import org.springframework.web.socket.server.support.DefaultHandshakeHandler;
|
||||
import org.springframework.web.socket.server.support.WebSocketHttpRequestHandler;
|
||||
import org.springframework.web.socket.sockjs.SockJsService;
|
||||
import org.springframework.web.socket.sockjs.support.SockJsHttpRequestHandler;
|
||||
import org.springframework.web.socket.sockjs.transport.TransportHandler;
|
||||
import org.springframework.web.socket.sockjs.transport.TransportHandlingSockJsService;
|
||||
import org.springframework.web.socket.sockjs.transport.TransportType;
|
||||
import org.springframework.web.socket.sockjs.transport.handler.DefaultSockJsService;
|
||||
import org.springframework.web.socket.sockjs.transport.handler.EventSourceTransportHandler;
|
||||
import org.springframework.web.socket.sockjs.transport.handler.HtmlFileTransportHandler;
|
||||
@@ -79,8 +81,8 @@ public class HandlersBeanDefinitionParserTests {
|
||||
this.appContext = new GenericWebApplicationContext();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@Test
|
||||
public void webSocketHandlers() {
|
||||
loadBeanDefinitions("websocket-config-handlers.xml");
|
||||
|
||||
@@ -132,7 +134,6 @@ public class HandlersBeanDefinitionParserTests {
|
||||
assertNotNull(handshakeHandler);
|
||||
assertTrue(handshakeHandler instanceof TestHandshakeHandler);
|
||||
List<HandshakeInterceptor> interceptors = handler.getHandshakeInterceptors();
|
||||
assertNotNull(interceptors);
|
||||
assertThat(interceptors, contains(instanceOf(FooTestInterceptor.class), instanceOf(BarTestInterceptor.class)));
|
||||
|
||||
handler = (WebSocketHttpRequestHandler) urlHandlerMapping.getUrlMap().get("/test");
|
||||
@@ -142,7 +143,6 @@ public class HandlersBeanDefinitionParserTests {
|
||||
assertNotNull(handshakeHandler);
|
||||
assertTrue(handshakeHandler instanceof TestHandshakeHandler);
|
||||
interceptors = handler.getHandshakeInterceptors();
|
||||
assertNotNull(interceptors);
|
||||
assertThat(interceptors, contains(instanceOf(FooTestInterceptor.class), instanceOf(BarTestInterceptor.class)));
|
||||
|
||||
}
|
||||
@@ -171,7 +171,9 @@ public class HandlersBeanDefinitionParserTests {
|
||||
assertThat(sockJsService, instanceOf(DefaultSockJsService.class));
|
||||
DefaultSockJsService defaultSockJsService = (DefaultSockJsService) sockJsService;
|
||||
assertThat(defaultSockJsService.getTaskScheduler(), instanceOf(ThreadPoolTaskScheduler.class));
|
||||
assertThat(defaultSockJsService.getTransportHandlers().values(),
|
||||
|
||||
Map<TransportType, TransportHandler> transportHandlers = defaultSockJsService.getTransportHandlers();
|
||||
assertThat(transportHandlers.values(),
|
||||
containsInAnyOrder(
|
||||
instanceOf(XhrPollingTransportHandler.class),
|
||||
instanceOf(XhrReceivingTransportHandler.class),
|
||||
@@ -181,6 +183,12 @@ public class HandlersBeanDefinitionParserTests {
|
||||
instanceOf(EventSourceTransportHandler.class),
|
||||
instanceOf(HtmlFileTransportHandler.class),
|
||||
instanceOf(WebSocketTransportHandler.class)));
|
||||
|
||||
WebSocketTransportHandler handler = (WebSocketTransportHandler) transportHandlers.get(TransportType.WEBSOCKET);
|
||||
assertEquals(TestHandshakeHandler.class, handler.getHandshakeHandler().getClass());
|
||||
|
||||
List<HandshakeInterceptor> interceptors = defaultSockJsService.getHandshakeInterceptors();
|
||||
assertThat(interceptors, contains(instanceOf(FooTestInterceptor.class), instanceOf(BarTestInterceptor.class)));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -75,16 +75,19 @@ import org.springframework.web.socket.sockjs.transport.handler.WebSocketTranspor
|
||||
*
|
||||
* @author Brian Clozel
|
||||
* @author Artem Bilan
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class MessageBrokerBeanDefinitionParserTests {
|
||||
|
||||
private GenericWebApplicationContext appContext;
|
||||
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
this.appContext = new GenericWebApplicationContext();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void simpleBroker() {
|
||||
loadBeanDefinitions("websocket-config-broker-simple.xml");
|
||||
@@ -103,6 +106,8 @@ public class MessageBrokerBeanDefinitionParserTests {
|
||||
HandshakeHandler handshakeHandler = wsHttpRequestHandler.getHandshakeHandler();
|
||||
assertNotNull(handshakeHandler);
|
||||
assertTrue(handshakeHandler instanceof TestHandshakeHandler);
|
||||
List<HandshakeInterceptor> interceptors = wsHttpRequestHandler.getHandshakeInterceptors();
|
||||
assertThat(interceptors, contains(instanceOf(FooTestInterceptor.class), instanceOf(BarTestInterceptor.class)));
|
||||
|
||||
WebSocketHandler wsHandler = unwrapWebSocketHandler(wsHttpRequestHandler.getWebSocketHandler());
|
||||
assertNotNull(wsHandler);
|
||||
@@ -140,6 +145,9 @@ public class MessageBrokerBeanDefinitionParserTests {
|
||||
assertEquals(Runtime.getRuntime().availableProcessors(), scheduler.getScheduledThreadPoolExecutor().getCorePoolSize());
|
||||
assertTrue(scheduler.getScheduledThreadPoolExecutor().getRemoveOnCancelPolicy());
|
||||
|
||||
interceptors = defaultSockJsService.getHandshakeInterceptors();
|
||||
assertThat(interceptors, contains(instanceOf(FooTestInterceptor.class), instanceOf(BarTestInterceptor.class)));
|
||||
|
||||
UserSessionRegistry userSessionRegistry = this.appContext.getBean(UserSessionRegistry.class);
|
||||
assertNotNull(userSessionRegistry);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user