use of com.artipie.http.hm.RsHasBody in project artipie by artipie.
the class PromuSliceTest method returnsMetricsThatMatchNames.
@Test
void returnsMetricsThatMatchNames() {
final Metrics metrics = new InMemoryMetrics();
metrics.counter("http.response.count").inc();
metrics.gauge("http.response.content").set(5000L);
metrics.gauge("app.workload").set(300L);
MatcherAssert.assertThat(new PromuSlice(metrics), new SliceHasResponse(new RsHasBody(new AnyOf<>(new IsEqual<>(String.join("\n", "# HELP http_response_content Http response content", "# TYPE http_response_content gauge", "http_response_content 5000.0", "# HELP app_workload App workload", "# TYPE app_workload gauge", "app_workload 300.0", "")), new IsEqual<>(String.join("\n", "# HELP app_workload App workload", "# TYPE app_workload gauge", "app_workload 300.0", "# HELP http_response_content Http response content", "# TYPE http_response_content gauge", "http_response_content 5000.0", ""))), StandardCharsets.UTF_8), new RequestLine(RqMethod.GET, "/prometheus/metrics?name=http_response_content&name=app_workload"), new Headers.From(new Header(Accept.NAME, PromuSliceTest.PLAIN_TEXT)), Content.EMPTY));
}
use of com.artipie.http.hm.RsHasBody in project maven-adapter by artipie.
the class ArtifactGetResponseTest method hasBodyIfExists.
@Test
void hasBodyIfExists() throws Exception {
final Storage storage = new InMemoryStorage();
final Key key = new Key.From("repo/artifact2.jar");
final byte[] data = "data".getBytes(StandardCharsets.UTF_8);
new BlockingStorage(storage).save(key, data);
MatcherAssert.assertThat(new ArtifactGetResponse(storage, key), new RsHasBody(data));
}
use of com.artipie.http.hm.RsHasBody in project maven-adapter by artipie.
the class CachedProxySliceTest method loadsOriginIfCacheNotFound.
@Test
void loadsOriginIfCacheNotFound() {
final byte[] data = "remote".getBytes();
MatcherAssert.assertThat(new CachedProxySlice((line, headers, body) -> new RsWithBody(ByteBuffer.wrap(data)), (key, supplier, control) -> supplier.get()), new SliceHasResponse(Matchers.allOf(new RsHasStatus(RsStatus.OK), new RsHasBody(data)), new RequestLine(RqMethod.GET, "/bar")));
}
use of com.artipie.http.hm.RsHasBody in project maven-adapter by artipie.
the class CachedProxySliceTest method loadsCachedContent.
@Test
void loadsCachedContent() {
final byte[] data = "cache".getBytes();
MatcherAssert.assertThat(new CachedProxySlice((line, headers, body) -> new RsWithBody(ByteBuffer.wrap("123".getBytes())), (key, supplier, control) -> CompletableFuture.supplyAsync(() -> Optional.of(new Content.From(data)))), new SliceHasResponse(Matchers.allOf(new RsHasStatus(RsStatus.OK), new RsHasBody(data)), new RequestLine(RqMethod.GET, "/foo")));
}
use of com.artipie.http.hm.RsHasBody in project maven-adapter by artipie.
the class ArtifactHeadResponseTest method noBodyIfExists.
@Test
void noBodyIfExists() throws Exception {
final Storage storage = new InMemoryStorage();
final Key key = new Key.From("repo/artifact2.jar");
new BlockingStorage(storage).save(key, "data".getBytes(StandardCharsets.UTF_8));
MatcherAssert.assertThat(new ArtifactHeadResponse(storage, key), new RsHasBody(new byte[0]));
}
Aggregations