@ -113,8 +113,9 @@ abstract class AbstractSockJsIntegrationTests {
@@ -113,8 +113,9 @@ abstract class AbstractSockJsIntegrationTests {
this . baseUrl = "http://localhost:" + this . server . getPort ( ) ;
}
@AfterEach
void teardown ( ) throws Exception {
void teardown ( ) {
try {
this . sockJsClient . stop ( ) ;
}
@ -141,6 +142,7 @@ abstract class AbstractSockJsIntegrationTests {
@@ -141,6 +142,7 @@ abstract class AbstractSockJsIntegrationTests {
}
}
protected abstract Class < ? > upgradeStrategyConfigClass ( ) ;
protected abstract WebSocketTestServer createWebSocketTestServer ( ) ;
@ -154,6 +156,7 @@ abstract class AbstractSockJsIntegrationTests {
@@ -154,6 +156,7 @@ abstract class AbstractSockJsIntegrationTests {
this . sockJsClient . start ( ) ;
}
@Test
void echoWebSocket ( ) throws Exception {
testEcho ( 100 , createWebSocketTransport ( ) , null ) ;
@ -305,8 +308,8 @@ abstract class AbstractSockJsIntegrationTests {
@@ -305,8 +308,8 @@ abstract class AbstractSockJsIntegrationTests {
try {
Thread . sleep ( timeToSleep ) ;
}
catch ( InterruptedException e ) {
throw new IllegalStateException ( "Interrupted while waiting for " + description , e ) ;
catch ( InterruptedException ex ) {
throw new IllegalStateException ( "Interrupted while waiting for " + description , ex ) ;
}
}
throw new IllegalStateException ( "Timed out waiting for " + description ) ;
@ -333,6 +336,7 @@ abstract class AbstractSockJsIntegrationTests {
@@ -333,6 +336,7 @@ abstract class AbstractSockJsIntegrationTests {
}
}
private static class TestClientHandler extends TextWebSocketHandler {
private final BlockingQueue < TextMessage > receivedMessages = new LinkedBlockingQueue < > ( ) ;
@ -341,7 +345,6 @@ abstract class AbstractSockJsIntegrationTests {
@@ -341,7 +345,6 @@ abstract class AbstractSockJsIntegrationTests {
private volatile Throwable transportError ;
@Override
public void afterConnectionEstablished ( WebSocketSession session ) throws Exception {
this . session = session ;
@ -376,6 +379,7 @@ abstract class AbstractSockJsIntegrationTests {
@@ -376,6 +379,7 @@ abstract class AbstractSockJsIntegrationTests {
}
}
private static class EchoHandler extends TextWebSocketHandler {
@Override
@ -384,21 +388,23 @@ abstract class AbstractSockJsIntegrationTests {
@@ -384,21 +388,23 @@ abstract class AbstractSockJsIntegrationTests {
}
}
private static class TestServerHandler extends TextWebSocketHandler {
private WebSocketSession session ;
@Override
public void afterConnectionEstablished ( WebSocketSession session ) throws Exception {
public void afterConnectionEstablished ( WebSocketSession session ) {
this . session = session ;
}
public WebSocketSession awaitSession ( long timeToWait ) throws InterruptedException {
public WebSocketSession awaitSession ( long timeToWait ) {
awaitEvent ( ( ) - > this . session ! = null , timeToWait , " session" ) ;
return this . session ;
}
}
private static class TestFilter implements Filter {
private final Map < String , HttpHeaders > requests = new HashMap < > ( ) ;
@ -407,7 +413,6 @@ abstract class AbstractSockJsIntegrationTests {
@@ -407,7 +413,6 @@ abstract class AbstractSockJsIntegrationTests {
private final Map < String , Integer > sendErrorMap = new HashMap < > ( ) ;
@Override
public void doFilter ( ServletRequest request , ServletResponse response , FilterChain chain )
throws IOException , ServletException {
@ -418,18 +423,18 @@ abstract class AbstractSockJsIntegrationTests {
@@ -418,18 +423,18 @@ abstract class AbstractSockJsIntegrationTests {
this . requests . put ( uri , headers ) ;
for ( String suffix : this . sleepDelayMap . keySet ( ) ) {
if ( ( httpRequest ) . getRequestURI ( ) . endsWith ( suffix ) ) {
if ( httpRequest . getRequestURI ( ) . endsWith ( suffix ) ) {
try {
Thread . sleep ( this . sleepDelayMap . get ( suffix ) ) ;
break ;
}
catch ( InterruptedException e ) {
e . printStackTrace ( ) ;
catch ( InterruptedException ex ) {
ex . printStackTrace ( ) ;
}
}
}
for ( String suffix : this . sendErrorMap . keySet ( ) ) {
if ( ( httpRequest ) . getRequestURI ( ) . endsWith ( suffix ) ) {
if ( httpRequest . getRequestURI ( ) . endsWith ( suffix ) ) {
( ( HttpServletResponse ) response ) . sendError ( this . sendErrorMap . get ( suffix ) ) ;
return ;
}