Java Code Examples for com.github.tomakehurst.wiremock.WireMockServer#baseUrl()
The following examples show how to use
com.github.tomakehurst.wiremock.WireMockServer#baseUrl() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MicrometerHttpClientInterceptorTest.java From micrometer with Apache License 2.0 | 6 votes |
@Test void uriIsReadFromHttpHeader(@WiremockResolver.Wiremock WireMockServer server) throws Exception { server.stubFor(any(anyUrl())); MicrometerHttpClientInterceptor interceptor = new MicrometerHttpClientInterceptor(registry, Tags.empty(), true); CloseableHttpAsyncClient client = asyncClient(interceptor); client.start(); HttpGet request = new HttpGet(server.baseUrl()); request.addHeader(DefaultUriMapper.URI_PATTERN_HEADER, "/some/pattern"); Future<HttpResponse> future = client.execute(request, null); HttpResponse response = future.get(); assertThat(response.getStatusLine().getStatusCode()).isEqualTo(200); assertThat(registry.get("httpcomponents.httpclient.request").tag("uri", "/some/pattern").tag("status", "200").timer().count()) .isEqualTo(1); client.close(); }
Example 2
Source File: HumioMeterRegistryTest.java From micrometer with Apache License 2.0 | 6 votes |
private HumioMeterRegistry humioMeterRegistry(WireMockServer server, String... tags) { return new HumioMeterRegistry(new HumioConfig() { @Override public String get(String key) { return null; } @Override public String uri() { return server.baseUrl(); } @Override public Map<String, String> tags() { Map<String, String> tagMap = new HashMap<>(); for (int i = 0; i < tags.length; i += 2) { tagMap.put(tags[i], tags[i + 1]); } return tagMap; } }, clock); }
Example 3
Source File: AtlasMeterRegistryTest.java From micrometer with Apache License 2.0 | 6 votes |
@Issue("#484") @Test void publishOneLastTimeOnClose(@WiremockResolver.Wiremock WireMockServer server) { AtlasConfig config = new AtlasConfig() { @Nullable @Override public String get(String k) { return null; } @Override public String uri() { return server.baseUrl() + "/api/v1/publish"; } }; server.stubFor(any(anyUrl())); new AtlasMeterRegistry(config, Clock.SYSTEM).close(); server.verify(postRequestedFor(urlEqualTo("/api/v1/publish"))); }
Example 4
Source File: MicrometerHttpRequestExecutorTest.java From micrometer with Apache License 2.0 | 5 votes |
@Test void uriIsReadFromHttpHeader(@WiremockResolver.Wiremock WireMockServer server) throws IOException { server.stubFor(any(anyUrl())); HttpClient client = client(executor(false)); HttpGet getWithHeader = new HttpGet(server.baseUrl()); getWithHeader.addHeader(DefaultUriMapper.URI_PATTERN_HEADER, "/some/pattern"); EntityUtils.consume(client.execute(getWithHeader).getEntity()); assertThat(registry.get(EXPECTED_METER_NAME) .tags("uri", "/some/pattern") .timer().count()).isEqualTo(1L); assertThrows(MeterNotFoundException.class, () -> registry.get(EXPECTED_METER_NAME) .tags("uri", "UNKNOWN") .timer()); }
Example 5
Source File: MicrometerHttpClientInterceptorTest.java From micrometer with Apache License 2.0 | 5 votes |
@Test void asyncRequest(@WiremockResolver.Wiremock WireMockServer server) throws Exception { server.stubFor(any(anyUrl())); CloseableHttpAsyncClient client = asyncClient(); client.start(); HttpGet request = new HttpGet(server.baseUrl()); Future<HttpResponse> future = client.execute(request, null); HttpResponse response = future.get(); assertThat(response.getStatusLine().getStatusCode()).isEqualTo(200); assertThat(registry.get("httpcomponents.httpclient.request").timer().count()).isEqualTo(1); client.close(); }
Example 6
Source File: DatadogMeterRegistryTest.java From micrometer with Apache License 2.0 | 4 votes |
@Issue("#463") @Test void encodeMetricName(@WiremockResolver.Wiremock WireMockServer server) { Clock clock = new MockClock(); DatadogMeterRegistry registry = new DatadogMeterRegistry(new DatadogConfig() { @Override public String uri() { return server.baseUrl(); } @Override public String get(String key) { return null; } @Override public String apiKey() { return "fake"; } @Override public String applicationKey() { return "fake"; } @Override public boolean descriptions() { return false; } @Override public boolean enabled() { return false; } }, clock); server.stubFor(any(anyUrl())); Counter.builder("my.counter#abc") .baseUnit(TimeUnit.MICROSECONDS.toString().toLowerCase()) .description("metric description") .register(registry) .increment(Math.PI); registry.publish(); server.verify(postRequestedFor( urlEqualTo("/api/v1/series?api_key=fake")) .withRequestBody(equalToJson("{\"series\":[{\"metric\":\"my.counter#abc\",\"points\":[[0,0.0]],\"type\":\"count\",\"unit\":\"microsecond\",\"tags\":[\"statistic:count\"]}]}") )); registry.close(); }
Example 7
Source File: DatadogMeterRegistryTest.java From micrometer with Apache License 2.0 | 4 votes |
@Test void testWithDescriptionEnabled(@WiremockResolver.Wiremock WireMockServer server) { Clock clock = new MockClock(); DatadogMeterRegistry registry = new DatadogMeterRegistry(new DatadogConfig() { @Override public String uri() { return server.baseUrl(); } @Override public String get(String key) { return null; } @Override public String apiKey() { return "fake"; } @Override public String applicationKey() { return "fake"; } @Override public boolean descriptions() { return true; } @Override public boolean enabled() { return false; } }, clock); server.stubFor(any(anyUrl())); Counter.builder("my.counter#abc") .baseUnit(TimeUnit.MICROSECONDS.toString().toLowerCase()) .description("metric description") .register(registry) .increment(Math.PI); registry.publish(); server.verify(postRequestedFor( urlEqualTo("/api/v1/series?api_key=fake")) .withRequestBody(equalToJson("{\"series\":[{\"metric\":\"my.counter#abc\",\"points\":[[0,0.0]],\"type\":\"count\",\"unit\":\"microsecond\",\"tags\":[\"statistic:count\"]}]}") )); server.verify(putRequestedFor( urlEqualTo("/api/v1/metrics/my.counter%23abc?api_key=fake&application_key=fake")) .withRequestBody(equalToJson("{\"description\":\"metric description\"}") )); registry.close(); }