Deprecated as of 5.0 a TaskScheduler is not provided upfront, not until it is obvious that it is needed; call SockJsServiceRegistration.getTaskScheduler() to check and then SockJsServiceRegistration.setTaskScheduler(TaskScheduler) to set it before a call to SockJsServiceRegistration.createSockJsService()
@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()); }
sockJsServiceRegistration.setSupressCors(this.sockJsServiceOptions.suppressCors);
sockJsServiceRegistration.setSupressCors(this.sockJsServiceOptions.suppressCors);