use of com.netflix.eventbus.spi.EventBus in project eureka by Netflix.
the class DiscoveryClientEventBusTest method testStatusChangeEvent.
@Test
public void testStatusChangeEvent() throws Exception {
final CountDownLatch eventLatch = new CountDownLatch(1);
final List<StatusChangeEvent> receivedEvents = new ArrayList<StatusChangeEvent>();
EventBus eventBus = discoveryClientResource.getEventBus();
eventBus.registerSubscriber(new Object() {
@Subscribe
public void consume(StatusChangeEvent event) {
receivedEvents.add(event);
eventLatch.countDown();
}
});
Applications initialApps = toApplications(discoveryClientResource.getMyInstanceInfo());
when(requestHandler.getApplications()).thenReturn(anEurekaHttpResponse(200, initialApps).type(MediaType.APPLICATION_JSON_TYPE).build());
// Activates the client
discoveryClientResource.getClient();
assertThat(eventLatch.await(10, TimeUnit.SECONDS), is(true));
assertThat(receivedEvents.size(), is(equalTo(1)));
assertThat(receivedEvents.get(0), is(notNullValue()));
}
Aggregations