Search in sources :

Example 6 with Header

use of com.artipie.http.headers.Header in project artipie by artipie.

the class PromuSliceTest method producesMetrics.

@ParameterizedTest
@CsvSource({ "http.response.length,500,counter,text/plain", "http.response.length,500,counter,application/openmetrics-text", "app.used.memory,200,gauge,text/plain", "app.used.memory,200,gauge,application/openmetrics-text" })
void producesMetrics(final String name, final long value, final String type, final String mimetype) {
    final Metrics metrics = new InMemoryMetrics();
    collect(metrics, name, value, type);
    MatcherAssert.assertThat(new PromuSlice(metrics), new SliceHasResponse(new AllOf<>(Arrays.asList(new RsHasStatus(RsStatus.OK), new RsHasHeaders(new IsEqual<>(new Header(ContentType.NAME, mimetype)), new IsAnything<>()), new RsHasBody(new MatchesPattern(Pattern.compile(metricFormatted(name, value, type, mimetype))), StandardCharsets.UTF_8))), new RequestLine(RqMethod.GET, "/prometheus/metrics"), new Headers.From(Accept.NAME, mimetype), Content.EMPTY));
}
Also used : SliceHasResponse(com.artipie.http.hm.SliceHasResponse) RsHasStatus(com.artipie.http.hm.RsHasStatus) MatchesPattern(org.hamcrest.text.MatchesPattern) RsHasHeaders(com.artipie.http.hm.RsHasHeaders) RequestLine(com.artipie.http.rq.RequestLine) Metrics(com.artipie.metrics.Metrics) InMemoryMetrics(com.artipie.metrics.memory.InMemoryMetrics) InMemoryMetrics(com.artipie.metrics.memory.InMemoryMetrics) Header(com.artipie.http.headers.Header) RsHasBody(com.artipie.http.hm.RsHasBody) AllOf(org.hamcrest.core.AllOf) CsvSource(org.junit.jupiter.params.provider.CsvSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

Header (com.artipie.http.headers.Header)6 RequestLine (com.artipie.http.rq.RequestLine)4 InMemoryMetrics (com.artipie.metrics.memory.InMemoryMetrics)3 Test (org.junit.jupiter.api.Test)3 Headers (com.artipie.http.Headers)2 Response (com.artipie.http.Response)2 ResponseMatcher (com.artipie.http.hm.ResponseMatcher)2 RsHasBody (com.artipie.http.hm.RsHasBody)2 SliceHasResponse (com.artipie.http.hm.SliceHasResponse)2 RsFull (com.artipie.http.rs.RsFull)2 RsStatus (com.artipie.http.rs.RsStatus)2 Metrics (com.artipie.metrics.Metrics)2 Flowable (io.reactivex.Flowable)2 ByteBuffer (java.nio.ByteBuffer)2 Map (java.util.Map)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 IsEqual (org.hamcrest.core.IsEqual)2 Content (com.artipie.asto.Content)1 Key (com.artipie.asto.Key)1 Cache (com.artipie.asto.cache.Cache)1