Buggy code:
public abstract class AbstractSockJsIntegrationTests { @ Rule public final TestName testName = new TestName ( ) ; protected Log logger = LogFactory . getLog ( getClass ( ) ) ; private SockJsClient sockJsClient ; private WebSocketTestServer server ; private AnnotationConfigWebApplicationContext wac ; private AbstractSockJsIntegrationTests . ErrorFilter errorFilter ; private String baseUrl ; @ Before public void setup ( ) throws Exception { } @ After public void teardown ( ) throws Exception { } protected abstract Class < ? > upgradeStrategyConfigClass ( ) { } protected abstract WebSocketTestServer createWebSocketTestServer ( ) { } protected abstract Transport createWebSocketTransport ( ) { } protected abstract AbstractXhrTransport createXhrTransport ( ) { } protected void initSockJsClient ( Transport ... transports ) { } @ Ignore @ Test public void echoWebSocket ( ) throws Exception { } @ Test public void echoXhrStreaming ( ) throws Exception { } @ Test public void echoXhr ( ) throws Exception { } @ Ignore @ Test public void receiveOneMessageWebSocket ( ) throws Exception { } @ Test public void receiveOneMessageXhrStreaming ( ) throws Exception { } @ Test public void receiveOneMessageXhr ( ) throws Exception { } @ Test public void infoRequestFailure ( ) throws Exception { } @ Test public void fallbackAfterTransportFailure ( ) throws Exception { } @ Test ( timeout = 5000 ) public void fallbackAfterConnectTimeout ( ) throws Exception { AbstractSockJsIntegrationTests . TestClientHandler clientHandler = new AbstractSockJsIntegrationTests . TestClientHandler ( ) ; this . errorFilter . sleepDelayMap . put ( "//xhr_streaming" , 10000L ) ; this . errorFilter . responseStatusMap . put ( "//xhr_streaming" , 503 ) ; initSockJsClient ( createXhrTransport ( ) ) ; <START_BUG> this . sockJsClient . setTaskScheduler ( this . wac . getBean ( ThreadPoolTaskScheduler . class ) ) ; <END_BUG> WebSocketSession clientSession = sockJsClient . doHandshake ( clientHandler , ( ( this . baseUrl ) + "//echo" ) ) . get ( ) ; assertEquals ( "Fallback<seq2seq4repair_space>didn't<seq2seq4repair_space>occur" , XhrClientSockJsSession . class , clientSession . getClass ( ) ) ; TextMessage message = new TextMessage ( "message1" ) ; clientSession . sendMessage ( message ) ; clientHandler . awaitMessage ( message , 5000 ) ; clientSession . close ( ) ; } private void testEcho ( int messageCount , Transport transport ) throws Exception { } private void testReceiveOneMessage ( Transport transport ) throws Exception { } @ Configuration @ EnableWebSocket static class TestConfig implements WebSocketConfigurer { @ Autowired private RequestUpgradeStrategy upgradeStrategy ; @ Override public void registerWebSocketHandlers ( WebSocketHandlerRegistry registry ) { } @ Bean public AbstractSockJsIntegrationTests . TestServerHandler testServerHandler ( ) { } } private static interface Condition { boolean match ( ) { } } private static void awaitEvent ( AbstractSockJsIntegrationTests . Condition condition , long timeToWait , String description ) { } private static class TestClientHandler extends TextWebSocketHandler { private final BlockingQueue < TextMessage > receivedMessages = new LinkedBlockingQueue < > ( ) ; private volatile WebSocketSession session ; private volatile Throwable transportError ; @ Override public void afterConnectionEstablished ( WebSocketSession session ) throws Exception { } @ Override protected void handleTextMessage ( WebSocketSession session , TextMessage message ) throws Exception { } @ Override public void handleTransportError ( WebSocketSession session , Throwable exception ) throws Exception { } public void awaitMessageCount ( final int count , long timeToWait ) throws Exception { } public void awaitMessage ( TextMessage expected , long timeToWait ) throws InterruptedException { } } private static class TestServerHandler extends TextWebSocketHandler { private WebSocketSession session ; @ Override public void afterConnectionEstablished ( WebSocketSession session ) throws Exception { } public WebSocketSession awaitSession ( long timeToWait ) throws InterruptedException { } } private static class EchoHandler extends TextWebSocketHandler { @ Override protected void handleTextMessage ( WebSocketSession session , TextMessage message ) throws Exception { } } private static class ErrorFilter implements Filter { private final Map < String , Integer > responseStatusMap = new HashMap < > ( ) ; private final Map < String , Long > sleepDelayMap = new HashMap < > ( ) ; @ Override public void doFilter ( ServletRequest req , ServletResponse resp , FilterChain chain ) throws IOException , ServletException { } @ Override public void init ( FilterConfig filterConfig ) throws ServletException { } @ Override public void destroy ( ) { } } }

Fix:
this . sockJsClient . setConnectTimeoutScheduler ( this . wac . getBean ( ThreadPoolTaskScheduler . class ) ) ;