use of org.springframework.messaging.simp.stomp.StompClientSupport in project spring-integration by spring-projects.
the class StompSessionManagerTests method testDoConnectFailure.
@Test
public void testDoConnectFailure() throws Exception {
StompClientSupport stompClient = mock(StompClientSupport.class);
stompClient.setTaskScheduler(new ConcurrentTaskScheduler());
AbstractStompSessionManager sessionManager = new AbstractStompSessionManager(stompClient) {
private final AtomicBoolean thrown = new AtomicBoolean();
@Override
protected ListenableFuture<StompSession> doConnect(StompSessionHandler handler) {
if (!this.thrown.getAndSet(true)) {
throw new RuntimeException("intentional");
} else {
SettableListenableFuture<StompSession> future = new SettableListenableFuture<StompSession>();
StompSession stompSession = mock(StompSession.class);
future.set(stompSession);
handler.afterConnected(stompSession, getConnectHeaders());
return future;
}
}
};
sessionManager.start();
final SettableListenableFuture<StompSession> stompSessionFuture = new SettableListenableFuture<StompSession>();
sessionManager.connect(new StompSessionHandlerAdapter() {
@Override
public void afterConnected(StompSession session, StompHeaders connectedHeaders) {
stompSessionFuture.set(session);
}
});
assertNotNull(stompSessionFuture.get(10, TimeUnit.SECONDS));
sessionManager.stop();
}
Aggregations