@Override public String toString() { return "StompSubProtocolHandler" + getSupportedProtocols(); }
@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); assertEquals(stompHandler.getSupportedProtocols(), sockJsHandler.getSubProtocols()); }
@Override public String toString() { return "StompSubProtocolHandler" + getSupportedProtocols(); }
@Override public String toString() { return "StompSubProtocolHandler" + getSupportedProtocols(); }
@Test public void testProtocolHandlers() { SubProtocolHandler defaultProtocolHandler = mock(SubProtocolHandler.class); SubProtocolHandlerRegistry subProtocolHandlerRegistry = new SubProtocolHandlerRegistry( Collections.<SubProtocolHandler>singletonList(new StompSubProtocolHandler()), defaultProtocolHandler); WebSocketSession session = mock(WebSocketSession.class); when(session.getAcceptedProtocol()).thenReturn("v10.stomp", (String) null); SubProtocolHandler protocolHandler = subProtocolHandlerRegistry.findProtocolHandler(session); assertNotNull(protocolHandler); assertThat(protocolHandler, instanceOf(StompSubProtocolHandler.class)); protocolHandler = subProtocolHandlerRegistry.findProtocolHandler(session); assertNotNull(protocolHandler); assertSame(protocolHandler, defaultProtocolHandler); assertEquals(subProtocolHandlerRegistry.getSubProtocols(), new StompSubProtocolHandler().getSupportedProtocols()); }