@ -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 .
@ -21,7 +21,6 @@ import java.util.Arrays;
@@ -21,7 +21,6 @@ import java.util.Arrays;
import java.util.List ;
import org.hamcrest.Matchers ;
import org.junit.Before ;
import org.junit.Test ;
import org.springframework.beans.DirectFieldAccessor ;
@ -77,15 +76,8 @@ import org.springframework.web.socket.sockjs.transport.TransportType;
@@ -77,15 +76,8 @@ 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.WebSocketTransportHandler ;
import static org.hamcrest.Matchers.contains ;
import static org.hamcrest.Matchers.instanceOf ;
import static org.junit.Assert.assertEquals ;
import static org.junit.Assert.assertFalse ;
import static org.junit.Assert.assertNotNull ;
import static org.junit.Assert.assertSame ;
import static org.junit.Assert.assertThat ;
import static org.junit.Assert.assertTrue ;
import static org.junit.Assert.fail ;
import static org.hamcrest.Matchers.* ;
import static org.junit.Assert.* ;
/ * *
* Test fixture for MessageBrokerBeanDefinitionParser .
@ -97,16 +89,11 @@ import static org.junit.Assert.fail;
@@ -97,16 +89,11 @@ import static org.junit.Assert.fail;
* /
public class MessageBrokerBeanDefinitionParserTests {
private GenericWebApplicationContext appContext ;
@Before
public void setup ( ) {
this . appContext = new GenericWebApplicationContext ( ) ;
}
private final GenericWebApplicationContext appContext = new GenericWebApplicationContext ( ) ;
@Test
@SuppressWarnings ( "unchecked" )
public void simpleBroker ( ) throws Exception {
loadBeanDefinitions ( "websocket-config-broker-simple.xml" ) ;
@ -178,7 +165,8 @@ public class MessageBrokerBeanDefinitionParserTests {
@@ -178,7 +165,8 @@ public class MessageBrokerBeanDefinitionParserTests {
interceptors = defaultSockJsService . getHandshakeInterceptors ( ) ;
assertThat ( interceptors , contains ( instanceOf ( FooTestInterceptor . class ) ,
instanceOf ( BarTestInterceptor . class ) , instanceOf ( OriginHandshakeInterceptor . class ) ) ) ;
assertEquals ( Arrays . asList ( "http://mydomain3.com" , "http://mydomain4.com" ) , defaultSockJsService . getAllowedOrigins ( ) ) ;
assertTrue ( defaultSockJsService . getAllowedOrigins ( ) . contains ( "http://mydomain3.com" ) ) ;
assertTrue ( defaultSockJsService . getAllowedOrigins ( ) . contains ( "http://mydomain4.com" ) ) ;
UserSessionRegistry userSessionRegistry = this . appContext . getBean ( UserSessionRegistry . class ) ;
assertNotNull ( userSessionRegistry ) ;
@ -221,7 +209,7 @@ public class MessageBrokerBeanDefinitionParserTests {
@@ -221,7 +209,7 @@ public class MessageBrokerBeanDefinitionParserTests {
assertNotNull ( this . appContext . getBean ( "webSocketScopeConfigurer" , CustomScopeConfigurer . class ) ) ;
DirectFieldAccessor subscriptionRegistryAccessor = new DirectFieldAccessor ( brokerMessageHandler . getSubscriptionRegistry ( ) ) ;
String pathSeparator = ( String ) new DirectFieldAccessor ( subscriptionRegistryAccessor . getPropertyValue ( "pathMatcher" ) ) . getPropertyValue ( "pathSeparator" ) ;
String pathSeparator = ( String ) new DirectFieldAccessor ( subscriptionRegistryAccessor . getPropertyValue ( "pathMatcher" ) ) . getPropertyValue ( "pathSeparator" ) ;
assertEquals ( "." , pathSeparator ) ;
}
@ -330,7 +318,7 @@ public class MessageBrokerBeanDefinitionParserTests {
@@ -330,7 +318,7 @@ public class MessageBrokerBeanDefinitionParserTests {
assertEquals ( MimeTypeUtils . APPLICATION_JSON , ( ( DefaultContentTypeResolver ) resolver ) . getDefaultMimeType ( ) ) ;
DirectFieldAccessor handlerAccessor = new DirectFieldAccessor ( annotationMethodMessageHandler ) ;
String pathSeparator = ( String ) new DirectFieldAccessor ( handlerAccessor . getPropertyValue ( "pathMatcher" ) ) . getPropertyValue ( "pathSeparator" ) ;
String pathSeparator = ( String ) new DirectFieldAccessor ( handlerAccessor . getPropertyValue ( "pathMatcher" ) ) . getPropertyValue ( "pathSeparator" ) ;
assertEquals ( "." , pathSeparator ) ;
}
@ -445,9 +433,9 @@ public class MessageBrokerBeanDefinitionParserTests {
@@ -445,9 +433,9 @@ public class MessageBrokerBeanDefinitionParserTests {
return ( handler instanceof WebSocketHandlerDecorator ) ?
( ( WebSocketHandlerDecorator ) handler ) . getLastHandler ( ) : handler ;
}
}
class CustomArgumentResolver implements HandlerMethodArgumentResolver {
@Override
@ -461,6 +449,7 @@ class CustomArgumentResolver implements HandlerMethodArgumentResolver {
@@ -461,6 +449,7 @@ class CustomArgumentResolver implements HandlerMethodArgumentResolver {
}
}
class CustomReturnValueHandler implements HandlerMethodReturnValueHandler {
@Override
@ -474,6 +463,7 @@ class CustomReturnValueHandler implements HandlerMethodReturnValueHandler {
@@ -474,6 +463,7 @@ class CustomReturnValueHandler implements HandlerMethodReturnValueHandler {
}
}
class TestWebSocketHandlerDecoratorFactory implements WebSocketHandlerDecoratorFactory {
@Override
@ -482,6 +472,7 @@ class TestWebSocketHandlerDecoratorFactory implements WebSocketHandlerDecoratorF
@@ -482,6 +472,7 @@ class TestWebSocketHandlerDecoratorFactory implements WebSocketHandlerDecoratorF
}
}
class TestWebSocketHandlerDecorator extends WebSocketHandlerDecorator {
public TestWebSocketHandlerDecorator ( WebSocketHandler delegate ) {
@ -493,4 +484,4 @@ class TestWebSocketHandlerDecorator extends WebSocketHandlerDecorator {
@@ -493,4 +484,4 @@ class TestWebSocketHandlerDecorator extends WebSocketHandlerDecorator {
session . getAttributes ( ) . put ( "decorated" , true ) ;
super . afterConnectionEstablished ( session ) ;
}
}
}