org.springframework.web.socket.sockjs.client.RestTemplateXhrTransport Java Examples
The following examples show how to use
org.springframework.web.socket.sockjs.client.RestTemplateXhrTransport.
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: Stomp.java From WeEvent with Apache License 2.0 | 7 votes |
private void testOverSockJS() throws InterruptedException { // sock js transport List<Transport> transports = new ArrayList<>(2); transports.add(new WebSocketTransport(new StandardWebSocketClient())); transports.add(new RestTemplateXhrTransport()); SockJsClient sockjsClient = new SockJsClient(transports); WebSocketStompClient stompClient = new WebSocketStompClient(sockjsClient); // StringMessageConverter stompClient.setMessageConverter(new MappingJackson2MessageConverter()); stompClient.setTaskScheduler(taskScheduler); // for heartbeats stompClient.connect(brokerSockJS, getSockJSSessionHandlerAdapter()); Thread.sleep(100000L); }
Example #2
Source File: QuotesWebSocketIntegrationTest.java From bearchoke with Apache License 2.0 | 6 votes |
@BeforeClass public static void setup() throws Exception { log.info("Setting up Quotes Web Socket Integration test...."); port = SocketUtils.findAvailableTcpPort(); server = new TomcatWebSocketTestServer(port); server.deployConfig(FrontendWebApplicationInitializer.class); server.start(); loginAndSaveXAuthToken("harrymitchell", "HarryMitchell5!", headers); List<Transport> transports = new ArrayList<>(); transports.add(new WebSocketTransport(new StandardWebSocketClient())); RestTemplateXhrTransport xhrTransport = new RestTemplateXhrTransport(new RestTemplate()); xhrTransport.setRequestHeaders(headers); transports.add(xhrTransport); sockJsClient = new SockJsClient(transports); sockJsClient.setHttpHeaderNames("X-Auth-Token"); log.info("Setup complete!"); }
Example #3
Source File: WebsocketTest.java From seppb with MIT License | 5 votes |
@Before public void setup() { List<Transport> transports = new ArrayList<>(); transports.add(new WebSocketTransport(new StandardWebSocketClient())); transports.add(new RestTemplateXhrTransport()); this.sockJsClient = new SockJsClient(transports); }
Example #4
Source File: ApplicationTests.java From spring-session with Apache License 2.0 | 5 votes |
@Test void run() { List<Transport> transports = new ArrayList<>(2); transports.add(new WebSocketTransport(new StandardWebSocketClient())); transports.add(new RestTemplateXhrTransport()); SockJsClient sockJsClient = new SockJsClient(transports); ListenableFuture<WebSocketSession> wsSession = sockJsClient.doHandshake(this.webSocketHandler, "ws://localhost:" + this.port + "/sockjs"); assertThatExceptionOfType(ExecutionException.class) .isThrownBy(() -> wsSession.get().sendMessage(new TextMessage("a"))); }
Example #5
Source File: AbstractStreamControllerTest.java From kafka-webview with MIT License | 4 votes |
private List<Transport> createTransportClient() { final List<Transport> transports = new ArrayList<>(); transports.add(new WebSocketTransport(new StandardWebSocketClient())); transports.add(new RestTemplateXhrTransport(new RestTemplate())); return transports; }