use of io.reactivex.netty.protocol.http.sse.ServerSentEvent in project Hystrix by Netflix.
the class HystrixMetricsStreamHandlerTest method testMetricsAreDeliveredAsSseStream.
@Test
public void testMetricsAreDeliveredAsSseStream() throws Exception {
replayAll();
Observable<ServerSentEvent> objectObservable = client.submit(HttpClientRequest.createGet(DEFAULT_HYSTRIX_PREFIX)).flatMap(new Func1<HttpClientResponse<ServerSentEvent>, Observable<? extends ServerSentEvent>>() {
@Override
public Observable<? extends ServerSentEvent> call(HttpClientResponse<ServerSentEvent> httpClientResponse) {
return httpClientResponse.getContent().take(1);
}
});
Object first = Observable.amb(objectObservable, Observable.timer(5000, TimeUnit.MILLISECONDS)).toBlocking().first();
assertTrue("Expected SSE message", first instanceof ServerSentEvent);
ServerSentEvent sse = (ServerSentEvent) first;
JsonNode jsonNode = mapper.readTree(sse.contentAsString());
assertEquals("Expected hystrix key name", HystrixCommandMetricsSamples.SAMPLE_1.getCommandKey().name(), jsonNode.get("name").asText());
}
Aggregations