/** * An overloaded version of {@link #connect(StompSessionHandler)} that * accepts headers to use for the STOMP CONNECT frame. * @param connectHeaders headers to add to the CONNECT frame * @param handler the handler for the STOMP session * @return a ListenableFuture for access to the session when ready for use */ public ListenableFuture<StompSession> connect(@Nullable StompHeaders connectHeaders, StompSessionHandler handler) { ConnectionHandlingStompSession session = createSession(connectHeaders, handler); this.tcpClient.connect(session); return session.getSessionFuture(); }
@Test public void webSocketHandshakeFailure() throws Exception { connect(); IllegalStateException handshakeFailure = new IllegalStateException("simulated exception"); this.handshakeFuture.setException(handshakeFailure); verify(this.stompSession).afterConnectFailure(same(handshakeFailure)); }
@Test public void webSocketConnectionEstablished() throws Exception { connect().afterConnectionEstablished(this.webSocketSession); verify(this.stompSession).afterConnected(notNull()); }
@Test public void webSocketTransportError() throws Exception { IllegalStateException exception = new IllegalStateException("simulated exception"); connect().handleTransportError(this.webSocketSession, exception); verify(this.stompSession).handleFailure(same(exception)); }
@Test public void webSocketConnectionClosed() throws Exception { connect().afterConnectionClosed(this.webSocketSession, CloseStatus.NORMAL); verify(this.stompSession).afterConnectionClosed(); }
/** * An overloaded version of * {@link #connect(String, WebSocketHttpHeaders, StompSessionHandler, Object...)} * that accepts a fully prepared {@link java.net.URI}. * @param url the url to connect to * @param handshakeHeaders the headers for the WebSocket handshake * @param connectHeaders headers for the STOMP CONNECT frame * @param sessionHandler the STOMP session handler * @return a ListenableFuture for access to the session when ready for use */ public ListenableFuture<StompSession> connect(URI url, @Nullable WebSocketHttpHeaders handshakeHeaders, @Nullable StompHeaders connectHeaders, StompSessionHandler sessionHandler) { Assert.notNull(url, "'url' must not be null"); ConnectionHandlingStompSession session = createSession(connectHeaders, sessionHandler); WebSocketTcpConnectionHandlerAdapter adapter = new WebSocketTcpConnectionHandlerAdapter(session); getWebSocketClient().doHandshake(adapter, handshakeHeaders, url).addCallback(adapter); return session.getSessionFuture(); }
private WebSocketHandler connect() { this.stompClient.connect("/foo", mock(StompSessionHandler.class)); verify(this.stompSession).getSessionFuture(); verifyNoMoreInteractions(this.stompSession); WebSocketHandler webSocketHandler = this.webSocketHandlerCaptor.getValue(); assertNotNull(webSocketHandler); return webSocketHandler; }
/** * An overloaded version of {@link #connect(StompSessionHandler)} that * accepts headers to use for the STOMP CONNECT frame. * @param connectHeaders headers to add to the CONNECT frame * @param handler the handler for the STOMP session * @return a ListenableFuture for access to the session when ready for use */ public ListenableFuture<StompSession> connect(@Nullable StompHeaders connectHeaders, StompSessionHandler handler) { ConnectionHandlingStompSession session = createSession(connectHeaders, handler); this.tcpClient.connect(session); return session.getSessionFuture(); }
/** * An overloaded version of {@link #connect(StompSessionHandler)} that * accepts headers to use for the STOMP CONNECT frame. * @param connectHeaders headers to add to the CONNECT frame * @param handler the handler for the STOMP session * @return a ListenableFuture for access to the session when ready for use */ public ListenableFuture<StompSession> connect(@Nullable StompHeaders connectHeaders, StompSessionHandler handler) { ConnectionHandlingStompSession session = createSession(connectHeaders, handler); this.tcpClient.connect(session); return session.getSessionFuture(); }
/** * An overloaded version of {@link #connect(StompSessionHandler)} that * accepts headers to use for the STOMP CONNECT frame. * @param connectHeaders headers to add to the CONNECT frame * @param handler the handler for the STOMP session * @return a ListenableFuture for access to the session when ready for use */ public ListenableFuture<StompSession> connect(@Nullable StompHeaders connectHeaders, StompSessionHandler handler) { ConnectionHandlingStompSession session = createSession(connectHeaders, handler); this.tcpClient.connect(session); return session.getSessionFuture(); }
/** * An overloaded version of {@link #connect(StompSessionHandler)} that * accepts headers to use for the STOMP CONNECT frame. * @param connectHeaders headers to add to the CONNECT frame * @param handler the handler for the STOMP session * @return ListenableFuture for access to the session when ready for use */ public ListenableFuture<StompSession> connect(StompHeaders connectHeaders, StompSessionHandler handler) { ConnectionHandlingStompSession session = createSession(connectHeaders, handler); this.tcpClient.connect(session); return session.getSessionFuture(); }
/** * An overloaded version of * {@link #connect(String, WebSocketHttpHeaders, StompSessionHandler, Object...)} * that accepts a fully prepared {@link java.net.URI}. * @param url the url to connect to * @param handshakeHeaders the headers for the WebSocket handshake * @param connectHeaders headers for the STOMP CONNECT frame * @param sessionHandler the STOMP session handler * @return a ListenableFuture for access to the session when ready for use */ public ListenableFuture<StompSession> connect(URI url, @Nullable WebSocketHttpHeaders handshakeHeaders, @Nullable StompHeaders connectHeaders, StompSessionHandler sessionHandler) { Assert.notNull(url, "'url' must not be null"); ConnectionHandlingStompSession session = createSession(connectHeaders, sessionHandler); WebSocketTcpConnectionHandlerAdapter adapter = new WebSocketTcpConnectionHandlerAdapter(session); getWebSocketClient().doHandshake(adapter, handshakeHeaders, url).addCallback(adapter); return session.getSessionFuture(); }
/** * An overloaded version of * {@link #connect(String, WebSocketHttpHeaders, StompSessionHandler, Object...)} * that accepts a fully prepared {@link java.net.URI}. * @param url the url to connect to * @param handshakeHeaders the headers for the WebSocket handshake * @param connectHeaders headers for the STOMP CONNECT frame * @param sessionHandler the STOMP session handler * @return a ListenableFuture for access to the session when ready for use */ public ListenableFuture<StompSession> connect(URI url, @Nullable WebSocketHttpHeaders handshakeHeaders, @Nullable StompHeaders connectHeaders, StompSessionHandler sessionHandler) { Assert.notNull(url, "'url' must not be null"); ConnectionHandlingStompSession session = createSession(connectHeaders, sessionHandler); WebSocketTcpConnectionHandlerAdapter adapter = new WebSocketTcpConnectionHandlerAdapter(session); getWebSocketClient().doHandshake(adapter, handshakeHeaders, url).addCallback(adapter); return session.getSessionFuture(); }