@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
/ *
* Copyright 2002 - 2014 the original author or authors .
* Copyright 2002 - 2015 the original author or authors .
*
* Licensed under the Apache License , Version 2 . 0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
@ -17,16 +17,18 @@
@@ -17,16 +17,18 @@
package org.springframework.web.socket.config.annotation ;
import static org.junit.Assert.* ;
import static org.mockito.Mockito.* ;
import java.util.Map ;
import org.junit.Before ;
import org.junit.Test ;
import org.mockito.Mockito ;
import org.springframework.messaging.SubscribableChannel ;
import org.springframework.scheduling.TaskScheduler ;
import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping ;
import org.springframework.web.socket.messaging.StompSubProtocolErrorHandler ;
import org.springframework.web.socket.messaging.StompSubProtocolHandler ;
import org.springframework.web.socket.messaging.SubProtocolHandler ;
import org.springframework.web.socket.messaging.SubProtocolWebSocketHandler ;
import org.springframework.web.util.UrlPathHelper ;
@ -46,12 +48,12 @@ public class WebMvcStompEndpointRegistryTests {
@@ -46,12 +48,12 @@ public class WebMvcStompEndpointRegistryTests {
@Before
public void setup ( ) {
SubscribableChannel inChannel = Mockito . mock ( SubscribableChannel . class ) ;
SubscribableChannel outChannel = Mockito . mock ( SubscribableChannel . class ) ;
SubscribableChannel inChannel = mock ( SubscribableChannel . class ) ;
SubscribableChannel outChannel = mock ( SubscribableChannel . class ) ;
this . webSocketHandler = new SubProtocolWebSocketHandler ( inChannel , outChannel ) ;
WebSocketTransportRegistration transport = new WebSocketTransportRegistration ( ) ;
TaskScheduler scheduler = Mockito . mock ( TaskScheduler . class ) ;
TaskScheduler scheduler = mock ( TaskScheduler . class ) ;
this . endpointRegistry = new WebMvcStompEndpointRegistry ( this . webSocketHandler , transport , null , scheduler ) ;
}
@ -87,4 +89,15 @@ public class WebMvcStompEndpointRegistryTests {
@@ -87,4 +89,15 @@ public class WebMvcStompEndpointRegistryTests {
assertSame ( pathHelper , hm . getUrlPathHelper ( ) ) ;
}
@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" ) ;
assertSame ( errorHandler , stompHandler . getErrorHandler ( ) ) ;
}
}