Search in sources :

Example 1 with BrokerAvailabilityEvent

use of org.springframework.messaging.simp.broker.BrokerAvailabilityEvent in project spring-framework by spring-projects.

the class UserRegistryMessageHandlerTests method brokerUnavailableEvent.

@SuppressWarnings("unchecked")
@Test
public void brokerUnavailableEvent() throws Exception {
    ScheduledFuture future = Mockito.mock(ScheduledFuture.class);
    when(this.taskScheduler.scheduleWithFixedDelay(any(Runnable.class), any(Long.class))).thenReturn(future);
    BrokerAvailabilityEvent event = new BrokerAvailabilityEvent(true, this);
    this.handler.onApplicationEvent(event);
    verifyNoMoreInteractions(future);
    event = new BrokerAvailabilityEvent(false, this);
    this.handler.onApplicationEvent(event);
    verify(future).cancel(true);
}
Also used : BrokerAvailabilityEvent(org.springframework.messaging.simp.broker.BrokerAvailabilityEvent) ScheduledFuture(java.util.concurrent.ScheduledFuture) Test(org.junit.Test)

Example 2 with BrokerAvailabilityEvent

use of org.springframework.messaging.simp.broker.BrokerAvailabilityEvent in project spring-framework by spring-projects.

the class UserRegistryMessageHandlerTests method getUserRegistryTask.

private Runnable getUserRegistryTask() {
    BrokerAvailabilityEvent event = new BrokerAvailabilityEvent(true, this);
    this.handler.onApplicationEvent(event);
    ArgumentCaptor<? extends Runnable> captor = ArgumentCaptor.forClass(Runnable.class);
    verify(this.taskScheduler).scheduleWithFixedDelay(captor.capture(), eq(10000L));
    return captor.getValue();
}
Also used : BrokerAvailabilityEvent(org.springframework.messaging.simp.broker.BrokerAvailabilityEvent)

Aggregations

BrokerAvailabilityEvent (org.springframework.messaging.simp.broker.BrokerAvailabilityEvent)2 ScheduledFuture (java.util.concurrent.ScheduledFuture)1 Test (org.junit.Test)1