use of io.micrometer.core.instrument.search.RequiredSearch in project cxf by apache.
the class SpringJaxrsApplicationTest method testJaxrsSuccessMetric.
@Test
public void testJaxrsSuccessMetric() {
final WebTarget target = createWebTarget();
try (Response r = target.request().get()) {
assertThat(r.getStatus()).isEqualTo(200);
}
await().atMost(Duration.ofSeconds(1)).ignoreException(MeterNotFoundException.class).until(() -> registry.get("cxf.server.requests").timers(), not(empty()));
RequiredSearch serverRequestMetrics = registry.get("cxf.server.requests");
Map<Object, Object> serverTags = serverRequestMetrics.timer().getId().getTags().stream().collect(toMap(Tag::getKey, Tag::getValue));
assertThat(serverTags).containsOnly(entry("exception", "None"), entry("method", "GET"), entry("operation", "getBooks"), entry("uri", "/api/app/library"), entry("outcome", "SUCCESS"), entry("status", "200"));
RequiredSearch clientRequestMetrics = registry.get("cxf.client.requests");
Map<Object, Object> clientTags = clientRequestMetrics.timer().getId().getTags().stream().collect(toMap(Tag::getKey, Tag::getValue));
assertThat(clientTags).containsOnly(entry("exception", "None"), entry("method", "GET"), entry("operation", "UNKNOWN"), entry("uri", "http://localhost:" + port + "/api/app/library"), entry("outcome", "SUCCESS"), entry("status", "200"));
}
use of io.micrometer.core.instrument.search.RequiredSearch in project webpieces by deanhiller.
the class TestLesson1Json method validate.
private void validate(SearchResponse resp) {
// next if you want, move assert logic into a validate method to re-use amongst tests
Assert.assertEquals("match1", resp.getMatches().get(0));
// check metrics are wired correctly here as well
RequiredSearch result = metrics.get("testCounter");
Counter counter = result.counter();
Assert.assertEquals(2.0, counter.count(), 0.1);
// check the mock system was called with 6
List<SendDataRequest> params = mockRemoteService.getSendMethodParameters();
Assert.assertEquals(2, params.size());
Assert.assertEquals(6, params.get(0).getNum());
}
use of io.micrometer.core.instrument.search.RequiredSearch in project webpieces by deanhiller.
the class TestSyncWebServer method testBasic.
@Test
public void testBasic() {
HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/myroute");
XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
response.assertContains("This is the first raw html page");
response.assertContentType("text/html; charset=utf-8");
List<Header> headers = response.getResponse().getHeaderLookupStruct().getHeaders(KnownHeaderName.CONTENT_TYPE);
Assert.assertEquals(1, headers.size());
// check metrics are wired correctly here as well
RequiredSearch result = meterRegistry.get("basicCounter");
Counter counter = result.counter();
Assert.assertEquals(1.0, counter.count(), 0.1);
}
Aggregations