org.springframework.web.socket.sockjs.support.SockJsHttpRequestHandler Java Examples
The following examples show how to use
org.springframework.web.socket.sockjs.support.SockJsHttpRequestHandler.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HandlersBeanDefinitionParser.java From spring-analysis-note with MIT License | 6 votes |
@Override public void addMapping(Element element, ManagedMap<String, Object> urlMap, ParserContext context) { String pathAttribute = element.getAttribute("path"); String[] mappings = StringUtils.tokenizeToStringArray(pathAttribute, ","); RuntimeBeanReference handlerReference = new RuntimeBeanReference(element.getAttribute("handler")); ConstructorArgumentValues cargs = new ConstructorArgumentValues(); cargs.addIndexedArgumentValue(0, this.sockJsService, "SockJsService"); cargs.addIndexedArgumentValue(1, handlerReference, "WebSocketHandler"); RootBeanDefinition requestHandlerDef = new RootBeanDefinition(SockJsHttpRequestHandler.class, cargs, null); requestHandlerDef.setSource(context.extractSource(element)); requestHandlerDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); String requestHandlerName = context.getReaderContext().registerWithGeneratedName(requestHandlerDef); RuntimeBeanReference requestHandlerRef = new RuntimeBeanReference(requestHandlerName); for (String mapping : mappings) { String pathPattern = (mapping.endsWith("/") ? mapping + "**" : mapping + "/**"); urlMap.put(pathPattern, requestHandlerRef); } }
Example #2
Source File: HandlersBeanDefinitionParser.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Override public void addMapping(Element element, ManagedMap<String, Object> urlMap, ParserContext context) { String pathAttribute = element.getAttribute("path"); List<String> mappings = Arrays.asList(StringUtils.tokenizeToStringArray(pathAttribute, ",")); RuntimeBeanReference handlerReference = new RuntimeBeanReference(element.getAttribute("handler")); ConstructorArgumentValues cavs = new ConstructorArgumentValues(); cavs.addIndexedArgumentValue(0, this.sockJsService, "SockJsService"); cavs.addIndexedArgumentValue(1, handlerReference, "WebSocketHandler"); RootBeanDefinition requestHandlerDef = new RootBeanDefinition(SockJsHttpRequestHandler.class, cavs, null); requestHandlerDef.setSource(context.extractSource(element)); requestHandlerDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); String requestHandlerName = context.getReaderContext().registerWithGeneratedName(requestHandlerDef); RuntimeBeanReference requestHandlerRef = new RuntimeBeanReference(requestHandlerName); for (String mapping : mappings) { String pathPattern = (mapping.endsWith("/") ? mapping + "**" : mapping + "/**"); urlMap.put(pathPattern, requestHandlerRef); } }
Example #3
Source File: HandlersBeanDefinitionParser.java From java-technology-stack with MIT License | 6 votes |
@Override public void addMapping(Element element, ManagedMap<String, Object> urlMap, ParserContext context) { String pathAttribute = element.getAttribute("path"); String[] mappings = StringUtils.tokenizeToStringArray(pathAttribute, ","); RuntimeBeanReference handlerReference = new RuntimeBeanReference(element.getAttribute("handler")); ConstructorArgumentValues cargs = new ConstructorArgumentValues(); cargs.addIndexedArgumentValue(0, this.sockJsService, "SockJsService"); cargs.addIndexedArgumentValue(1, handlerReference, "WebSocketHandler"); RootBeanDefinition requestHandlerDef = new RootBeanDefinition(SockJsHttpRequestHandler.class, cargs, null); requestHandlerDef.setSource(context.extractSource(element)); requestHandlerDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); String requestHandlerName = context.getReaderContext().registerWithGeneratedName(requestHandlerDef); RuntimeBeanReference requestHandlerRef = new RuntimeBeanReference(requestHandlerName); for (String mapping : mappings) { String pathPattern = (mapping.endsWith("/") ? mapping + "**" : mapping + "/**"); urlMap.put(pathPattern, requestHandlerRef); } }
Example #4
Source File: WebSocketConfigurer.java From computoser with GNU Affero General Public License v3.0 | 5 votes |
@Bean public SimpleUrlHandlerMapping handlerMapping() { SockJsService sockJsService = new DefaultSockJsService(taskScheduler()); Map<String, Object> urlMap = new HashMap<String, Object>(); urlMap.put("/game/websocket/**", new SockJsHttpRequestHandler(sockJsService, gameHandler)); SimpleUrlHandlerMapping hm = new SimpleUrlHandlerMapping(); hm.setUrlMap(urlMap); return hm; }
Example #5
Source File: ServletWebSocketHandlerRegistration.java From spring-analysis-note with MIT License | 5 votes |
@Override protected void addSockJsServiceMapping(MultiValueMap<HttpRequestHandler, String> mappings, SockJsService sockJsService, WebSocketHandler handler, String pathPattern) { SockJsHttpRequestHandler httpHandler = new SockJsHttpRequestHandler(sockJsService, handler); mappings.add(httpHandler, pathPattern); }
Example #6
Source File: HandlersBeanDefinitionParserTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test @SuppressWarnings("unchecked") public void sockJsAttributes() { loadBeanDefinitions("websocket-config-handlers-sockjs-attributes.xml"); SimpleUrlHandlerMapping handlerMapping = appContext.getBean(SimpleUrlHandlerMapping.class); assertNotNull(handlerMapping); SockJsHttpRequestHandler handler = (SockJsHttpRequestHandler) handlerMapping.getUrlMap().get("/test/**"); assertNotNull(handler); unwrapAndCheckDecoratedHandlerType(handler.getWebSocketHandler(), TestWebSocketHandler.class); SockJsService sockJsService = handler.getSockJsService(); assertNotNull(sockJsService); assertThat(sockJsService, instanceOf(TransportHandlingSockJsService.class)); TransportHandlingSockJsService transportService = (TransportHandlingSockJsService) sockJsService; assertThat(transportService.getTaskScheduler(), instanceOf(TestTaskScheduler.class)); assertThat(transportService.getTransportHandlers().values(), containsInAnyOrder( instanceOf(XhrPollingTransportHandler.class), instanceOf(XhrStreamingTransportHandler.class))); assertEquals("testSockJsService", transportService.getName()); assertFalse(transportService.isWebSocketEnabled()); assertFalse(transportService.isSessionCookieNeeded()); assertEquals(2048, transportService.getStreamBytesLimit()); assertEquals(256, transportService.getDisconnectDelay()); assertEquals(1024, transportService.getHttpMessageCacheSize()); assertEquals(20, transportService.getHeartbeatTime()); assertEquals("/js/sockjs.min.js", transportService.getSockJsClientLibraryUrl()); assertEquals(TestMessageCodec.class, transportService.getMessageCodec().getClass()); List<HandshakeInterceptor> interceptors = transportService.getHandshakeInterceptors(); assertThat(interceptors, contains(instanceOf(OriginHandshakeInterceptor.class))); assertTrue(transportService.shouldSuppressCors()); assertTrue(transportService.getAllowedOrigins().contains("http://mydomain1.com")); assertTrue(transportService.getAllowedOrigins().contains("http://mydomain2.com")); }
Example #7
Source File: WebMvcStompWebSocketEndpointRegistrationTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void handshakeHandlerInterceptorWithSockJsServiceAndAllowedOrigins() { WebMvcStompWebSocketEndpointRegistration registration = new WebMvcStompWebSocketEndpointRegistration(new String[] {"/foo"}, this.handler, this.scheduler); DefaultHandshakeHandler handshakeHandler = new DefaultHandshakeHandler(); HttpSessionHandshakeInterceptor interceptor = new HttpSessionHandshakeInterceptor(); String origin = "http://mydomain.com"; registration.setHandshakeHandler(handshakeHandler).addInterceptors(interceptor).setAllowedOrigins(origin).withSockJS(); MultiValueMap<HttpRequestHandler, String> mappings = registration.getMappings(); assertEquals(1, mappings.size()); Map.Entry<HttpRequestHandler, List<String>> entry = mappings.entrySet().iterator().next(); assertEquals(Arrays.asList("/foo/**"), entry.getValue()); SockJsHttpRequestHandler requestHandler = (SockJsHttpRequestHandler) entry.getKey(); assertNotNull(requestHandler.getWebSocketHandler()); DefaultSockJsService sockJsService = (DefaultSockJsService) requestHandler.getSockJsService(); assertNotNull(sockJsService); Map<TransportType, TransportHandler> handlers = sockJsService.getTransportHandlers(); WebSocketTransportHandler transportHandler = (WebSocketTransportHandler) handlers.get(TransportType.WEBSOCKET); assertSame(handshakeHandler, transportHandler.getHandshakeHandler()); assertEquals(2, sockJsService.getHandshakeInterceptors().size()); assertEquals(interceptor, sockJsService.getHandshakeInterceptors().get(0)); assertEquals(OriginHandshakeInterceptor.class, sockJsService.getHandshakeInterceptors().get(1).getClass()); assertTrue(sockJsService.getAllowedOrigins().contains(origin)); }
Example #8
Source File: WebMvcStompWebSocketEndpointRegistrationTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void handshakeHandlerInterceptorWithSockJsService() { WebMvcStompWebSocketEndpointRegistration registration = new WebMvcStompWebSocketEndpointRegistration(new String[] {"/foo"}, this.handler, this.scheduler); DefaultHandshakeHandler handshakeHandler = new DefaultHandshakeHandler(); HttpSessionHandshakeInterceptor interceptor = new HttpSessionHandshakeInterceptor(); registration.setHandshakeHandler(handshakeHandler).addInterceptors(interceptor).withSockJS(); MultiValueMap<HttpRequestHandler, String> mappings = registration.getMappings(); assertEquals(1, mappings.size()); Map.Entry<HttpRequestHandler, List<String>> entry = mappings.entrySet().iterator().next(); assertEquals(Arrays.asList("/foo/**"), entry.getValue()); SockJsHttpRequestHandler requestHandler = (SockJsHttpRequestHandler) entry.getKey(); assertNotNull(requestHandler.getWebSocketHandler()); DefaultSockJsService sockJsService = (DefaultSockJsService) requestHandler.getSockJsService(); assertNotNull(sockJsService); Map<TransportType, TransportHandler> handlers = sockJsService.getTransportHandlers(); WebSocketTransportHandler transportHandler = (WebSocketTransportHandler) handlers.get(TransportType.WEBSOCKET); assertSame(handshakeHandler, transportHandler.getHandshakeHandler()); assertEquals(2, sockJsService.getHandshakeInterceptors().size()); assertEquals(interceptor, sockJsService.getHandshakeInterceptors().get(0)); assertEquals(OriginHandshakeInterceptor.class, sockJsService.getHandshakeInterceptors().get(1).getClass()); }
Example #9
Source File: WebMvcStompWebSocketEndpointRegistrationTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test // SPR-12283 public void disableCorsWithSockJsService() { WebMvcStompWebSocketEndpointRegistration registration = new WebMvcStompWebSocketEndpointRegistration(new String[] {"/foo"}, this.handler, this.scheduler); registration.withSockJS().setSupressCors(true); MultiValueMap<HttpRequestHandler, String> mappings = registration.getMappings(); assertEquals(1, mappings.size()); SockJsHttpRequestHandler requestHandler = (SockJsHttpRequestHandler)mappings.entrySet().iterator().next().getKey(); assertNotNull(requestHandler.getSockJsService()); DefaultSockJsService sockJsService = (DefaultSockJsService)requestHandler.getSockJsService(); assertTrue(sockJsService.shouldSuppressCors()); }
Example #10
Source File: ServletWebSocketHandlerRegistration.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override protected void addSockJsServiceMapping(MultiValueMap<HttpRequestHandler, String> mappings, SockJsService sockJsService, WebSocketHandler handler, String pathPattern) { SockJsHttpRequestHandler httpHandler = new SockJsHttpRequestHandler(sockJsService, handler); mappings.add(httpHandler, pathPattern); }
Example #11
Source File: HandlersBeanDefinitionParserTests.java From java-technology-stack with MIT License | 5 votes |
@Test @SuppressWarnings("unchecked") public void sockJsAttributes() { loadBeanDefinitions("websocket-config-handlers-sockjs-attributes.xml"); SimpleUrlHandlerMapping handlerMapping = appContext.getBean(SimpleUrlHandlerMapping.class); assertNotNull(handlerMapping); SockJsHttpRequestHandler handler = (SockJsHttpRequestHandler) handlerMapping.getUrlMap().get("/test/**"); assertNotNull(handler); unwrapAndCheckDecoratedHandlerType(handler.getWebSocketHandler(), TestWebSocketHandler.class); SockJsService sockJsService = handler.getSockJsService(); assertNotNull(sockJsService); assertThat(sockJsService, instanceOf(TransportHandlingSockJsService.class)); TransportHandlingSockJsService transportService = (TransportHandlingSockJsService) sockJsService; assertThat(transportService.getTaskScheduler(), instanceOf(TestTaskScheduler.class)); assertThat(transportService.getTransportHandlers().values(), containsInAnyOrder( instanceOf(XhrPollingTransportHandler.class), instanceOf(XhrStreamingTransportHandler.class))); assertEquals("testSockJsService", transportService.getName()); assertFalse(transportService.isWebSocketEnabled()); assertFalse(transportService.isSessionCookieNeeded()); assertEquals(2048, transportService.getStreamBytesLimit()); assertEquals(256, transportService.getDisconnectDelay()); assertEquals(1024, transportService.getHttpMessageCacheSize()); assertEquals(20, transportService.getHeartbeatTime()); assertEquals("/js/sockjs.min.js", transportService.getSockJsClientLibraryUrl()); assertEquals(TestMessageCodec.class, transportService.getMessageCodec().getClass()); List<HandshakeInterceptor> interceptors = transportService.getHandshakeInterceptors(); assertThat(interceptors, contains(instanceOf(OriginHandshakeInterceptor.class))); assertTrue(transportService.shouldSuppressCors()); assertTrue(transportService.getAllowedOrigins().contains("http://mydomain1.com")); assertTrue(transportService.getAllowedOrigins().contains("http://mydomain2.com")); }
Example #12
Source File: WebMvcStompWebSocketEndpointRegistrationTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void handshakeHandlerInterceptorWithSockJsServiceAndAllowedOrigins() { WebMvcStompWebSocketEndpointRegistration registration = new WebMvcStompWebSocketEndpointRegistration(new String[] {"/foo"}, this.handler, this.scheduler); DefaultHandshakeHandler handshakeHandler = new DefaultHandshakeHandler(); HttpSessionHandshakeInterceptor interceptor = new HttpSessionHandshakeInterceptor(); String origin = "http://mydomain.com"; registration.setHandshakeHandler(handshakeHandler) .addInterceptors(interceptor).setAllowedOrigins(origin).withSockJS(); MultiValueMap<HttpRequestHandler, String> mappings = registration.getMappings(); assertEquals(1, mappings.size()); Map.Entry<HttpRequestHandler, List<String>> entry = mappings.entrySet().iterator().next(); assertEquals(Arrays.asList("/foo/**"), entry.getValue()); SockJsHttpRequestHandler requestHandler = (SockJsHttpRequestHandler) entry.getKey(); assertNotNull(requestHandler.getWebSocketHandler()); DefaultSockJsService sockJsService = (DefaultSockJsService) requestHandler.getSockJsService(); assertNotNull(sockJsService); Map<TransportType, TransportHandler> handlers = sockJsService.getTransportHandlers(); WebSocketTransportHandler transportHandler = (WebSocketTransportHandler) handlers.get(TransportType.WEBSOCKET); assertSame(handshakeHandler, transportHandler.getHandshakeHandler()); assertEquals(2, sockJsService.getHandshakeInterceptors().size()); assertEquals(interceptor, sockJsService.getHandshakeInterceptors().get(0)); assertEquals(OriginHandshakeInterceptor.class, sockJsService.getHandshakeInterceptors().get(1).getClass()); assertTrue(sockJsService.getAllowedOrigins().contains(origin)); }
Example #13
Source File: WebMvcStompWebSocketEndpointRegistrationTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void handshakeHandlerInterceptorWithSockJsService() { WebMvcStompWebSocketEndpointRegistration registration = new WebMvcStompWebSocketEndpointRegistration(new String[] {"/foo"}, this.handler, this.scheduler); DefaultHandshakeHandler handshakeHandler = new DefaultHandshakeHandler(); HttpSessionHandshakeInterceptor interceptor = new HttpSessionHandshakeInterceptor(); registration.setHandshakeHandler(handshakeHandler).addInterceptors(interceptor).withSockJS(); MultiValueMap<HttpRequestHandler, String> mappings = registration.getMappings(); assertEquals(1, mappings.size()); Map.Entry<HttpRequestHandler, List<String>> entry = mappings.entrySet().iterator().next(); assertEquals(Arrays.asList("/foo/**"), entry.getValue()); SockJsHttpRequestHandler requestHandler = (SockJsHttpRequestHandler) entry.getKey(); assertNotNull(requestHandler.getWebSocketHandler()); DefaultSockJsService sockJsService = (DefaultSockJsService) requestHandler.getSockJsService(); assertNotNull(sockJsService); Map<TransportType, TransportHandler> handlers = sockJsService.getTransportHandlers(); WebSocketTransportHandler transportHandler = (WebSocketTransportHandler) handlers.get(TransportType.WEBSOCKET); assertSame(handshakeHandler, transportHandler.getHandshakeHandler()); assertEquals(2, sockJsService.getHandshakeInterceptors().size()); assertEquals(interceptor, sockJsService.getHandshakeInterceptors().get(0)); assertEquals(OriginHandshakeInterceptor.class, sockJsService.getHandshakeInterceptors().get(1).getClass()); }
Example #14
Source File: WebMvcStompWebSocketEndpointRegistrationTests.java From java-technology-stack with MIT License | 5 votes |
@Test // SPR-12283 public void disableCorsWithSockJsService() { WebMvcStompWebSocketEndpointRegistration registration = new WebMvcStompWebSocketEndpointRegistration(new String[] {"/foo"}, this.handler, this.scheduler); registration.withSockJS().setSupressCors(true); MultiValueMap<HttpRequestHandler, String> mappings = registration.getMappings(); assertEquals(1, mappings.size()); SockJsHttpRequestHandler requestHandler = (SockJsHttpRequestHandler)mappings.entrySet().iterator().next().getKey(); assertNotNull(requestHandler.getSockJsService()); DefaultSockJsService sockJsService = (DefaultSockJsService)requestHandler.getSockJsService(); assertTrue(sockJsService.shouldSuppressCors()); }
Example #15
Source File: ServletWebSocketHandlerRegistration.java From java-technology-stack with MIT License | 5 votes |
@Override protected void addSockJsServiceMapping(MultiValueMap<HttpRequestHandler, String> mappings, SockJsService sockJsService, WebSocketHandler handler, String pathPattern) { SockJsHttpRequestHandler httpHandler = new SockJsHttpRequestHandler(sockJsService, handler); mappings.add(httpHandler, pathPattern); }
Example #16
Source File: HandlersBeanDefinitionParserTests.java From spring-analysis-note with MIT License | 5 votes |
@Test @SuppressWarnings("unchecked") public void sockJsAttributes() { loadBeanDefinitions("websocket-config-handlers-sockjs-attributes.xml"); SimpleUrlHandlerMapping handlerMapping = appContext.getBean(SimpleUrlHandlerMapping.class); assertNotNull(handlerMapping); SockJsHttpRequestHandler handler = (SockJsHttpRequestHandler) handlerMapping.getUrlMap().get("/test/**"); assertNotNull(handler); unwrapAndCheckDecoratedHandlerType(handler.getWebSocketHandler(), TestWebSocketHandler.class); SockJsService sockJsService = handler.getSockJsService(); assertNotNull(sockJsService); assertThat(sockJsService, instanceOf(TransportHandlingSockJsService.class)); TransportHandlingSockJsService transportService = (TransportHandlingSockJsService) sockJsService; assertThat(transportService.getTaskScheduler(), instanceOf(TestTaskScheduler.class)); assertThat(transportService.getTransportHandlers().values(), containsInAnyOrder( instanceOf(XhrPollingTransportHandler.class), instanceOf(XhrStreamingTransportHandler.class))); assertEquals("testSockJsService", transportService.getName()); assertFalse(transportService.isWebSocketEnabled()); assertFalse(transportService.isSessionCookieNeeded()); assertEquals(2048, transportService.getStreamBytesLimit()); assertEquals(256, transportService.getDisconnectDelay()); assertEquals(1024, transportService.getHttpMessageCacheSize()); assertEquals(20, transportService.getHeartbeatTime()); assertEquals("/js/sockjs.min.js", transportService.getSockJsClientLibraryUrl()); assertEquals(TestMessageCodec.class, transportService.getMessageCodec().getClass()); List<HandshakeInterceptor> interceptors = transportService.getHandshakeInterceptors(); assertThat(interceptors, contains(instanceOf(OriginHandshakeInterceptor.class))); assertTrue(transportService.shouldSuppressCors()); assertTrue(transportService.getAllowedOrigins().contains("https://mydomain1.com")); assertTrue(transportService.getAllowedOrigins().contains("https://mydomain2.com")); }
Example #17
Source File: WebMvcStompWebSocketEndpointRegistrationTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void handshakeHandlerInterceptorWithSockJsServiceAndAllowedOrigins() { WebMvcStompWebSocketEndpointRegistration registration = new WebMvcStompWebSocketEndpointRegistration(new String[] {"/foo"}, this.handler, this.scheduler); DefaultHandshakeHandler handshakeHandler = new DefaultHandshakeHandler(); HttpSessionHandshakeInterceptor interceptor = new HttpSessionHandshakeInterceptor(); String origin = "https://mydomain.com"; registration.setHandshakeHandler(handshakeHandler) .addInterceptors(interceptor).setAllowedOrigins(origin).withSockJS(); MultiValueMap<HttpRequestHandler, String> mappings = registration.getMappings(); assertEquals(1, mappings.size()); Map.Entry<HttpRequestHandler, List<String>> entry = mappings.entrySet().iterator().next(); assertEquals(Arrays.asList("/foo/**"), entry.getValue()); SockJsHttpRequestHandler requestHandler = (SockJsHttpRequestHandler) entry.getKey(); assertNotNull(requestHandler.getWebSocketHandler()); DefaultSockJsService sockJsService = (DefaultSockJsService) requestHandler.getSockJsService(); assertNotNull(sockJsService); Map<TransportType, TransportHandler> handlers = sockJsService.getTransportHandlers(); WebSocketTransportHandler transportHandler = (WebSocketTransportHandler) handlers.get(TransportType.WEBSOCKET); assertSame(handshakeHandler, transportHandler.getHandshakeHandler()); assertEquals(2, sockJsService.getHandshakeInterceptors().size()); assertEquals(interceptor, sockJsService.getHandshakeInterceptors().get(0)); assertEquals(OriginHandshakeInterceptor.class, sockJsService.getHandshakeInterceptors().get(1).getClass()); assertTrue(sockJsService.getAllowedOrigins().contains(origin)); }
Example #18
Source File: WebMvcStompWebSocketEndpointRegistrationTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void handshakeHandlerInterceptorWithSockJsService() { WebMvcStompWebSocketEndpointRegistration registration = new WebMvcStompWebSocketEndpointRegistration(new String[] {"/foo"}, this.handler, this.scheduler); DefaultHandshakeHandler handshakeHandler = new DefaultHandshakeHandler(); HttpSessionHandshakeInterceptor interceptor = new HttpSessionHandshakeInterceptor(); registration.setHandshakeHandler(handshakeHandler).addInterceptors(interceptor).withSockJS(); MultiValueMap<HttpRequestHandler, String> mappings = registration.getMappings(); assertEquals(1, mappings.size()); Map.Entry<HttpRequestHandler, List<String>> entry = mappings.entrySet().iterator().next(); assertEquals(Arrays.asList("/foo/**"), entry.getValue()); SockJsHttpRequestHandler requestHandler = (SockJsHttpRequestHandler) entry.getKey(); assertNotNull(requestHandler.getWebSocketHandler()); DefaultSockJsService sockJsService = (DefaultSockJsService) requestHandler.getSockJsService(); assertNotNull(sockJsService); Map<TransportType, TransportHandler> handlers = sockJsService.getTransportHandlers(); WebSocketTransportHandler transportHandler = (WebSocketTransportHandler) handlers.get(TransportType.WEBSOCKET); assertSame(handshakeHandler, transportHandler.getHandshakeHandler()); assertEquals(2, sockJsService.getHandshakeInterceptors().size()); assertEquals(interceptor, sockJsService.getHandshakeInterceptors().get(0)); assertEquals(OriginHandshakeInterceptor.class, sockJsService.getHandshakeInterceptors().get(1).getClass()); }
Example #19
Source File: WebMvcStompWebSocketEndpointRegistrationTests.java From spring-analysis-note with MIT License | 5 votes |
@Test // SPR-12283 public void disableCorsWithSockJsService() { WebMvcStompWebSocketEndpointRegistration registration = new WebMvcStompWebSocketEndpointRegistration(new String[] {"/foo"}, this.handler, this.scheduler); registration.withSockJS().setSupressCors(true); MultiValueMap<HttpRequestHandler, String> mappings = registration.getMappings(); assertEquals(1, mappings.size()); SockJsHttpRequestHandler requestHandler = (SockJsHttpRequestHandler)mappings.entrySet().iterator().next().getKey(); assertNotNull(requestHandler.getSockJsService()); DefaultSockJsService sockJsService = (DefaultSockJsService)requestHandler.getSockJsService(); assertTrue(sockJsService.shouldSuppressCors()); }
Example #20
Source File: HandlersBeanDefinitionParserTests.java From java-technology-stack with MIT License | 4 votes |
@Test @SuppressWarnings("unchecked") public void sockJs() { loadBeanDefinitions("websocket-config-handlers-sockjs.xml"); SimpleUrlHandlerMapping handlerMapping = this.appContext.getBean(SimpleUrlHandlerMapping.class); assertNotNull(handlerMapping); SockJsHttpRequestHandler testHandler = (SockJsHttpRequestHandler) handlerMapping.getUrlMap().get("/test/**"); assertNotNull(testHandler); unwrapAndCheckDecoratedHandlerType(testHandler.getWebSocketHandler(), TestWebSocketHandler.class); SockJsService testSockJsService = testHandler.getSockJsService(); SockJsHttpRequestHandler fooHandler = (SockJsHttpRequestHandler) handlerMapping.getUrlMap().get("/foo/**"); assertNotNull(fooHandler); unwrapAndCheckDecoratedHandlerType(fooHandler.getWebSocketHandler(), FooWebSocketHandler.class); SockJsService sockJsService = fooHandler.getSockJsService(); assertNotNull(sockJsService); assertSame(testSockJsService, sockJsService); assertThat(sockJsService, instanceOf(DefaultSockJsService.class)); DefaultSockJsService defaultSockJsService = (DefaultSockJsService) sockJsService; assertThat(defaultSockJsService.getTaskScheduler(), instanceOf(ThreadPoolTaskScheduler.class)); assertFalse(defaultSockJsService.shouldSuppressCors()); Map<TransportType, TransportHandler> handlerMap = defaultSockJsService.getTransportHandlers(); assertThat(handlerMap.values(), containsInAnyOrder( instanceOf(XhrPollingTransportHandler.class), instanceOf(XhrReceivingTransportHandler.class), instanceOf(XhrStreamingTransportHandler.class), instanceOf(EventSourceTransportHandler.class), instanceOf(HtmlFileTransportHandler.class), instanceOf(WebSocketTransportHandler.class))); WebSocketTransportHandler handler = (WebSocketTransportHandler) handlerMap.get(TransportType.WEBSOCKET); assertEquals(TestHandshakeHandler.class, handler.getHandshakeHandler().getClass()); List<HandshakeInterceptor> interceptors = defaultSockJsService.getHandshakeInterceptors(); assertThat(interceptors, contains(instanceOf(FooTestInterceptor.class), instanceOf(BarTestInterceptor.class), instanceOf(OriginHandshakeInterceptor.class))); }
Example #21
Source File: MessageBrokerBeanDefinitionParserTests.java From java-technology-stack with MIT License | 4 votes |
@Test public void stompBrokerRelay() { loadBeanDefinitions("websocket-config-broker-relay.xml"); HandlerMapping hm = this.appContext.getBean(HandlerMapping.class); assertNotNull(hm); assertThat(hm, Matchers.instanceOf(SimpleUrlHandlerMapping.class)); SimpleUrlHandlerMapping suhm = (SimpleUrlHandlerMapping) hm; assertThat(suhm.getUrlMap().keySet(), Matchers.hasSize(1)); assertThat(suhm.getUrlMap().values(), Matchers.hasSize(1)); assertEquals(2, suhm.getOrder()); HttpRequestHandler httpRequestHandler = (HttpRequestHandler) suhm.getUrlMap().get("/foo/**"); assertNotNull(httpRequestHandler); assertThat(httpRequestHandler, Matchers.instanceOf(SockJsHttpRequestHandler.class)); SockJsHttpRequestHandler sockJsHttpRequestHandler = (SockJsHttpRequestHandler) httpRequestHandler; WebSocketHandler wsHandler = unwrapWebSocketHandler(sockJsHttpRequestHandler.getWebSocketHandler()); assertNotNull(wsHandler); assertThat(wsHandler, Matchers.instanceOf(SubProtocolWebSocketHandler.class)); assertNotNull(sockJsHttpRequestHandler.getSockJsService()); UserDestinationResolver userDestResolver = this.appContext.getBean(UserDestinationResolver.class); assertNotNull(userDestResolver); assertThat(userDestResolver, Matchers.instanceOf(DefaultUserDestinationResolver.class)); DefaultUserDestinationResolver defaultUserDestResolver = (DefaultUserDestinationResolver) userDestResolver; assertEquals("/user/", defaultUserDestResolver.getDestinationPrefix()); StompBrokerRelayMessageHandler messageBroker = this.appContext.getBean(StompBrokerRelayMessageHandler.class); assertNotNull(messageBroker); assertEquals("clientlogin", messageBroker.getClientLogin()); assertEquals("clientpass", messageBroker.getClientPasscode()); assertEquals("syslogin", messageBroker.getSystemLogin()); assertEquals("syspass", messageBroker.getSystemPasscode()); assertEquals("relayhost", messageBroker.getRelayHost()); assertEquals(1234, messageBroker.getRelayPort()); assertEquals("spring.io", messageBroker.getVirtualHost()); assertEquals(5000, messageBroker.getSystemHeartbeatReceiveInterval()); assertEquals(5000, messageBroker.getSystemHeartbeatSendInterval()); assertThat(messageBroker.getDestinationPrefixes(), Matchers.containsInAnyOrder("/topic","/queue")); assertTrue(messageBroker.isPreservePublishOrder()); List<Class<? extends MessageHandler>> subscriberTypes = Arrays.asList(SimpAnnotationMethodMessageHandler.class, UserDestinationMessageHandler.class, StompBrokerRelayMessageHandler.class); testChannel("clientInboundChannel", subscriberTypes, 2); testExecutor("clientInboundChannel", Runtime.getRuntime().availableProcessors() * 2, Integer.MAX_VALUE, 60); subscriberTypes = Collections.singletonList(SubProtocolWebSocketHandler.class); testChannel("clientOutboundChannel", subscriberTypes, 2); testExecutor("clientOutboundChannel", Runtime.getRuntime().availableProcessors() * 2, Integer.MAX_VALUE, 60); subscriberTypes = Arrays.asList(StompBrokerRelayMessageHandler.class, UserDestinationMessageHandler.class); testChannel("brokerChannel", subscriberTypes, 1); try { this.appContext.getBean("brokerChannelExecutor", ThreadPoolTaskExecutor.class); fail("expected exception"); } catch (NoSuchBeanDefinitionException ex) { // expected } String destination = "/topic/unresolved-user-destination"; UserDestinationMessageHandler userDestHandler = this.appContext.getBean(UserDestinationMessageHandler.class); assertEquals(destination, userDestHandler.getBroadcastDestination()); assertNotNull(messageBroker.getSystemSubscriptions()); assertSame(userDestHandler, messageBroker.getSystemSubscriptions().get(destination)); destination = "/topic/simp-user-registry"; UserRegistryMessageHandler userRegistryHandler = this.appContext.getBean(UserRegistryMessageHandler.class); assertEquals(destination, userRegistryHandler.getBroadcastDestination()); assertNotNull(messageBroker.getSystemSubscriptions()); assertSame(userRegistryHandler, messageBroker.getSystemSubscriptions().get(destination)); SimpUserRegistry userRegistry = this.appContext.getBean(SimpUserRegistry.class); assertEquals(MultiServerUserRegistry.class, userRegistry.getClass()); String name = "webSocketMessageBrokerStats"; WebSocketMessageBrokerStats stats = this.appContext.getBean(name, WebSocketMessageBrokerStats.class); String actual = stats.toString(); String expected = "WebSocketSession\\[0 current WS\\(0\\)-HttpStream\\(0\\)-HttpPoll\\(0\\), " + "0 total, 0 closed abnormally \\(0 connect failure, 0 send limit, 0 transport error\\)\\], " + "stompSubProtocol\\[processed CONNECT\\(0\\)-CONNECTED\\(0\\)-DISCONNECT\\(0\\)\\], " + "stompBrokerRelay\\[0 sessions, relayhost:1234 \\(not available\\), " + "processed CONNECT\\(0\\)-CONNECTED\\(0\\)-DISCONNECT\\(0\\)\\], " + "inboundChannel\\[pool size = \\d, active threads = \\d, queued tasks = \\d, " + "completed tasks = \\d\\], " + "outboundChannel\\[pool size = \\d, active threads = \\d, queued tasks = \\d, " + "completed tasks = \\d\\], " + "sockJsScheduler\\[pool size = \\d, active threads = \\d, queued tasks = \\d, " + "completed tasks = \\d\\]"; assertTrue("\nExpected: " + expected.replace("\\", "") + "\n Actual: " + actual, actual.matches(expected)); }
Example #22
Source File: MessageBrokerBeanDefinitionParserTests.java From spring-analysis-note with MIT License | 4 votes |
@Test public void stompBrokerRelay() { loadBeanDefinitions("websocket-config-broker-relay.xml"); HandlerMapping hm = this.appContext.getBean(HandlerMapping.class); assertNotNull(hm); assertThat(hm, Matchers.instanceOf(SimpleUrlHandlerMapping.class)); SimpleUrlHandlerMapping suhm = (SimpleUrlHandlerMapping) hm; assertThat(suhm.getUrlMap().keySet(), Matchers.hasSize(1)); assertThat(suhm.getUrlMap().values(), Matchers.hasSize(1)); assertEquals(2, suhm.getOrder()); HttpRequestHandler httpRequestHandler = (HttpRequestHandler) suhm.getUrlMap().get("/foo/**"); assertNotNull(httpRequestHandler); assertThat(httpRequestHandler, Matchers.instanceOf(SockJsHttpRequestHandler.class)); SockJsHttpRequestHandler sockJsHttpRequestHandler = (SockJsHttpRequestHandler) httpRequestHandler; WebSocketHandler wsHandler = unwrapWebSocketHandler(sockJsHttpRequestHandler.getWebSocketHandler()); assertNotNull(wsHandler); assertThat(wsHandler, Matchers.instanceOf(SubProtocolWebSocketHandler.class)); assertNotNull(sockJsHttpRequestHandler.getSockJsService()); UserDestinationResolver userDestResolver = this.appContext.getBean(UserDestinationResolver.class); assertNotNull(userDestResolver); assertThat(userDestResolver, Matchers.instanceOf(DefaultUserDestinationResolver.class)); DefaultUserDestinationResolver defaultUserDestResolver = (DefaultUserDestinationResolver) userDestResolver; assertEquals("/user/", defaultUserDestResolver.getDestinationPrefix()); StompBrokerRelayMessageHandler messageBroker = this.appContext.getBean(StompBrokerRelayMessageHandler.class); assertNotNull(messageBroker); assertEquals("clientlogin", messageBroker.getClientLogin()); assertEquals("clientpass", messageBroker.getClientPasscode()); assertEquals("syslogin", messageBroker.getSystemLogin()); assertEquals("syspass", messageBroker.getSystemPasscode()); assertEquals("relayhost", messageBroker.getRelayHost()); assertEquals(1234, messageBroker.getRelayPort()); assertEquals("spring.io", messageBroker.getVirtualHost()); assertEquals(5000, messageBroker.getSystemHeartbeatReceiveInterval()); assertEquals(5000, messageBroker.getSystemHeartbeatSendInterval()); assertThat(messageBroker.getDestinationPrefixes(), Matchers.containsInAnyOrder("/topic","/queue")); assertTrue(messageBroker.isPreservePublishOrder()); List<Class<? extends MessageHandler>> subscriberTypes = Arrays.asList(SimpAnnotationMethodMessageHandler.class, UserDestinationMessageHandler.class, StompBrokerRelayMessageHandler.class); testChannel("clientInboundChannel", subscriberTypes, 2); testExecutor("clientInboundChannel", Runtime.getRuntime().availableProcessors() * 2, Integer.MAX_VALUE, 60); subscriberTypes = Collections.singletonList(SubProtocolWebSocketHandler.class); testChannel("clientOutboundChannel", subscriberTypes, 2); testExecutor("clientOutboundChannel", Runtime.getRuntime().availableProcessors() * 2, Integer.MAX_VALUE, 60); subscriberTypes = Arrays.asList(StompBrokerRelayMessageHandler.class, UserDestinationMessageHandler.class); testChannel("brokerChannel", subscriberTypes, 1); try { this.appContext.getBean("brokerChannelExecutor", ThreadPoolTaskExecutor.class); fail("expected exception"); } catch (NoSuchBeanDefinitionException ex) { // expected } String destination = "/topic/unresolved-user-destination"; UserDestinationMessageHandler userDestHandler = this.appContext.getBean(UserDestinationMessageHandler.class); assertEquals(destination, userDestHandler.getBroadcastDestination()); assertNotNull(messageBroker.getSystemSubscriptions()); assertSame(userDestHandler, messageBroker.getSystemSubscriptions().get(destination)); destination = "/topic/simp-user-registry"; UserRegistryMessageHandler userRegistryHandler = this.appContext.getBean(UserRegistryMessageHandler.class); assertEquals(destination, userRegistryHandler.getBroadcastDestination()); assertNotNull(messageBroker.getSystemSubscriptions()); assertSame(userRegistryHandler, messageBroker.getSystemSubscriptions().get(destination)); SimpUserRegistry userRegistry = this.appContext.getBean(SimpUserRegistry.class); assertEquals(MultiServerUserRegistry.class, userRegistry.getClass()); String name = "webSocketMessageBrokerStats"; WebSocketMessageBrokerStats stats = this.appContext.getBean(name, WebSocketMessageBrokerStats.class); String actual = stats.toString(); String expected = "WebSocketSession\\[0 current WS\\(0\\)-HttpStream\\(0\\)-HttpPoll\\(0\\), " + "0 total, 0 closed abnormally \\(0 connect failure, 0 send limit, 0 transport error\\)\\], " + "stompSubProtocol\\[processed CONNECT\\(0\\)-CONNECTED\\(0\\)-DISCONNECT\\(0\\)\\], " + "stompBrokerRelay\\[0 sessions, relayhost:1234 \\(not available\\), " + "processed CONNECT\\(0\\)-CONNECTED\\(0\\)-DISCONNECT\\(0\\)\\], " + "inboundChannel\\[pool size = \\d, active threads = \\d, queued tasks = \\d, " + "completed tasks = \\d\\], " + "outboundChannel\\[pool size = \\d, active threads = \\d, queued tasks = \\d, " + "completed tasks = \\d\\], " + "sockJsScheduler\\[pool size = \\d, active threads = \\d, queued tasks = \\d, " + "completed tasks = \\d\\]"; assertTrue("\nExpected: " + expected.replace("\\", "") + "\n Actual: " + actual, actual.matches(expected)); }
Example #23
Source File: HandlersBeanDefinitionParserTests.java From spring-analysis-note with MIT License | 4 votes |
@Test @SuppressWarnings("unchecked") public void sockJs() { loadBeanDefinitions("websocket-config-handlers-sockjs.xml"); SimpleUrlHandlerMapping handlerMapping = this.appContext.getBean(SimpleUrlHandlerMapping.class); assertNotNull(handlerMapping); SockJsHttpRequestHandler testHandler = (SockJsHttpRequestHandler) handlerMapping.getUrlMap().get("/test/**"); assertNotNull(testHandler); unwrapAndCheckDecoratedHandlerType(testHandler.getWebSocketHandler(), TestWebSocketHandler.class); SockJsService testSockJsService = testHandler.getSockJsService(); SockJsHttpRequestHandler fooHandler = (SockJsHttpRequestHandler) handlerMapping.getUrlMap().get("/foo/**"); assertNotNull(fooHandler); unwrapAndCheckDecoratedHandlerType(fooHandler.getWebSocketHandler(), FooWebSocketHandler.class); SockJsService sockJsService = fooHandler.getSockJsService(); assertNotNull(sockJsService); assertSame(testSockJsService, sockJsService); assertThat(sockJsService, instanceOf(DefaultSockJsService.class)); DefaultSockJsService defaultSockJsService = (DefaultSockJsService) sockJsService; assertThat(defaultSockJsService.getTaskScheduler(), instanceOf(ThreadPoolTaskScheduler.class)); assertFalse(defaultSockJsService.shouldSuppressCors()); Map<TransportType, TransportHandler> handlerMap = defaultSockJsService.getTransportHandlers(); assertThat(handlerMap.values(), containsInAnyOrder( instanceOf(XhrPollingTransportHandler.class), instanceOf(XhrReceivingTransportHandler.class), instanceOf(XhrStreamingTransportHandler.class), instanceOf(EventSourceTransportHandler.class), instanceOf(HtmlFileTransportHandler.class), instanceOf(WebSocketTransportHandler.class))); WebSocketTransportHandler handler = (WebSocketTransportHandler) handlerMap.get(TransportType.WEBSOCKET); assertEquals(TestHandshakeHandler.class, handler.getHandshakeHandler().getClass()); List<HandshakeInterceptor> interceptors = defaultSockJsService.getHandshakeInterceptors(); assertThat(interceptors, contains(instanceOf(FooTestInterceptor.class), instanceOf(BarTestInterceptor.class), instanceOf(OriginHandshakeInterceptor.class))); }
Example #24
Source File: HandlersBeanDefinitionParserTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Test @SuppressWarnings("unchecked") public void sockJs() { loadBeanDefinitions("websocket-config-handlers-sockjs.xml"); SimpleUrlHandlerMapping handlerMapping = this.appContext.getBean(SimpleUrlHandlerMapping.class); assertNotNull(handlerMapping); SockJsHttpRequestHandler testHandler = (SockJsHttpRequestHandler) handlerMapping.getUrlMap().get("/test/**"); assertNotNull(testHandler); unwrapAndCheckDecoratedHandlerType(testHandler.getWebSocketHandler(), TestWebSocketHandler.class); SockJsService testSockJsService = testHandler.getSockJsService(); SockJsHttpRequestHandler fooHandler = (SockJsHttpRequestHandler) handlerMapping.getUrlMap().get("/foo/**"); assertNotNull(fooHandler); unwrapAndCheckDecoratedHandlerType(fooHandler.getWebSocketHandler(), FooWebSocketHandler.class); SockJsService sockJsService = fooHandler.getSockJsService(); assertNotNull(sockJsService); assertSame(testSockJsService, sockJsService); assertThat(sockJsService, instanceOf(DefaultSockJsService.class)); DefaultSockJsService defaultSockJsService = (DefaultSockJsService) sockJsService; assertThat(defaultSockJsService.getTaskScheduler(), instanceOf(ThreadPoolTaskScheduler.class)); assertFalse(defaultSockJsService.shouldSuppressCors()); Map<TransportType, TransportHandler> transportHandlers = defaultSockJsService.getTransportHandlers(); assertThat(transportHandlers.values(), containsInAnyOrder( instanceOf(XhrPollingTransportHandler.class), instanceOf(XhrReceivingTransportHandler.class), instanceOf(JsonpPollingTransportHandler.class), instanceOf(JsonpReceivingTransportHandler.class), instanceOf(XhrStreamingTransportHandler.class), instanceOf(EventSourceTransportHandler.class), instanceOf(HtmlFileTransportHandler.class), instanceOf(WebSocketTransportHandler.class))); WebSocketTransportHandler handler = (WebSocketTransportHandler) transportHandlers.get(TransportType.WEBSOCKET); assertEquals(TestHandshakeHandler.class, handler.getHandshakeHandler().getClass()); List<HandshakeInterceptor> interceptors = defaultSockJsService.getHandshakeInterceptors(); assertThat(interceptors, contains(instanceOf(FooTestInterceptor.class), instanceOf(BarTestInterceptor.class), instanceOf(OriginHandshakeInterceptor.class))); }
Example #25
Source File: MessageBrokerBeanDefinitionParserTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Test public void stompBrokerRelay() { loadBeanDefinitions("websocket-config-broker-relay.xml"); HandlerMapping hm = this.appContext.getBean(HandlerMapping.class); assertNotNull(hm); assertThat(hm, Matchers.instanceOf(SimpleUrlHandlerMapping.class)); SimpleUrlHandlerMapping suhm = (SimpleUrlHandlerMapping) hm; assertThat(suhm.getUrlMap().keySet(), Matchers.hasSize(1)); assertThat(suhm.getUrlMap().values(), Matchers.hasSize(1)); assertEquals(2, suhm.getOrder()); HttpRequestHandler httpRequestHandler = (HttpRequestHandler) suhm.getUrlMap().get("/foo/**"); assertNotNull(httpRequestHandler); assertThat(httpRequestHandler, Matchers.instanceOf(SockJsHttpRequestHandler.class)); SockJsHttpRequestHandler sockJsHttpRequestHandler = (SockJsHttpRequestHandler) httpRequestHandler; WebSocketHandler wsHandler = unwrapWebSocketHandler(sockJsHttpRequestHandler.getWebSocketHandler()); assertNotNull(wsHandler); assertThat(wsHandler, Matchers.instanceOf(SubProtocolWebSocketHandler.class)); assertNotNull(sockJsHttpRequestHandler.getSockJsService()); UserDestinationResolver userDestResolver = this.appContext.getBean(UserDestinationResolver.class); assertNotNull(userDestResolver); assertThat(userDestResolver, Matchers.instanceOf(DefaultUserDestinationResolver.class)); DefaultUserDestinationResolver defaultUserDestResolver = (DefaultUserDestinationResolver) userDestResolver; assertEquals("/user/", defaultUserDestResolver.getDestinationPrefix()); StompBrokerRelayMessageHandler messageBroker = this.appContext.getBean(StompBrokerRelayMessageHandler.class); assertNotNull(messageBroker); assertEquals("clientlogin", messageBroker.getClientLogin()); assertEquals("clientpass", messageBroker.getClientPasscode()); assertEquals("syslogin", messageBroker.getSystemLogin()); assertEquals("syspass", messageBroker.getSystemPasscode()); assertEquals("relayhost", messageBroker.getRelayHost()); assertEquals(1234, messageBroker.getRelayPort()); assertEquals("spring.io", messageBroker.getVirtualHost()); assertEquals(5000, messageBroker.getSystemHeartbeatReceiveInterval()); assertEquals(5000, messageBroker.getSystemHeartbeatSendInterval()); assertThat(messageBroker.getDestinationPrefixes(), Matchers.containsInAnyOrder("/topic","/queue")); List<Class<? extends MessageHandler>> subscriberTypes = Arrays.<Class<? extends MessageHandler>>asList(SimpAnnotationMethodMessageHandler.class, UserDestinationMessageHandler.class, StompBrokerRelayMessageHandler.class); testChannel("clientInboundChannel", subscriberTypes, 2); testExecutor("clientInboundChannel", Runtime.getRuntime().availableProcessors() * 2, Integer.MAX_VALUE, 60); subscriberTypes = Collections.singletonList(SubProtocolWebSocketHandler.class); testChannel("clientOutboundChannel", subscriberTypes, 1); testExecutor("clientOutboundChannel", Runtime.getRuntime().availableProcessors() * 2, Integer.MAX_VALUE, 60); subscriberTypes = Arrays.<Class<? extends MessageHandler>>asList( StompBrokerRelayMessageHandler.class, UserDestinationMessageHandler.class); testChannel("brokerChannel", subscriberTypes, 1); try { this.appContext.getBean("brokerChannelExecutor", ThreadPoolTaskExecutor.class); fail("expected exception"); } catch (NoSuchBeanDefinitionException ex) { // expected } String destination = "/topic/unresolved-user-destination"; UserDestinationMessageHandler userDestHandler = this.appContext.getBean(UserDestinationMessageHandler.class); assertEquals(destination, userDestHandler.getBroadcastDestination()); assertNotNull(messageBroker.getSystemSubscriptions()); assertSame(userDestHandler, messageBroker.getSystemSubscriptions().get(destination)); destination = "/topic/simp-user-registry"; UserRegistryMessageHandler userRegistryHandler = this.appContext.getBean(UserRegistryMessageHandler.class); assertEquals(destination, userRegistryHandler.getBroadcastDestination()); assertNotNull(messageBroker.getSystemSubscriptions()); assertSame(userRegistryHandler, messageBroker.getSystemSubscriptions().get(destination)); SimpUserRegistry userRegistry = this.appContext.getBean(SimpUserRegistry.class); assertEquals(MultiServerUserRegistry.class, userRegistry.getClass()); String name = "webSocketMessageBrokerStats"; WebSocketMessageBrokerStats stats = this.appContext.getBean(name, WebSocketMessageBrokerStats.class); String actual = stats.toString(); String expected = "WebSocketSession\\[0 current WS\\(0\\)-HttpStream\\(0\\)-HttpPoll\\(0\\), " + "0 total, 0 closed abnormally \\(0 connect failure, 0 send limit, 0 transport error\\)\\], " + "stompSubProtocol\\[processed CONNECT\\(0\\)-CONNECTED\\(0\\)-DISCONNECT\\(0\\)\\], " + "stompBrokerRelay\\[0 sessions, relayhost:1234 \\(not available\\), processed CONNECT\\(0\\)-CONNECTED\\(0\\)-DISCONNECT\\(0\\)\\], " + "inboundChannel\\[pool size = \\d, active threads = \\d, queued tasks = \\d, completed tasks = \\d\\], " + "outboundChannelpool size = \\d, active threads = \\d, queued tasks = \\d, completed tasks = \\d\\], " + "sockJsScheduler\\[pool size = \\d, active threads = \\d, queued tasks = \\d, completed tasks = \\d\\]"; assertTrue("\nExpected: " + expected.replace("\\", "") + "\n Actual: " + actual, actual.matches(expected)); }