use of com.artipie.metrics.memory.TestMetricsOutput in project artipie by artipie.
the class TrafficMetricSliceTest method updatesMetrics.
@Test
void updatesMetrics() throws Exception {
final Metrics metrics = new InMemoryMetrics();
final int req = 100;
final int res = 50;
new TrafficMetricSlice((line, head, body) -> new RsWithBody(Flowable.fromPublisher(body).ignoreElements().andThen(Flowable.just(ByteBuffer.wrap(new byte[res])))), metrics).response(new RequestLine(RqMethod.GET, "/foo").toString(), Collections.emptyList(), Flowable.just(ByteBuffer.wrap(new byte[req]))).send((status, headers, body) -> Flowable.fromPublisher(body).ignoreElements().to(CompletableInterop.await())).toCompletableFuture().get();
final TestMetricsOutput out = new TestMetricsOutput();
metrics.publish(out);
MatcherAssert.assertThat("request body size wasn't updated", out.counters().get("request.body.size"), Matchers.equalTo((long) req));
MatcherAssert.assertThat("response body size wasn't updated", out.counters().get("response.body.size"), Matchers.equalTo((long) res));
}
Aggregations