@Before public void before() { hostRegistry = new HostMetricsRegistry(); }
@Test public void testIoExceptionsUpdated() { assertThat(hostRegistry.getMetrics()).isEmpty(); hostRegistry.recordIoException("service", "host", 8080); HostMetrics hostMetrics = Iterables.getOnlyElement(hostRegistry.getMetrics()); assertThat(hostMetrics.getIoExceptions().getCount()).isEqualTo(1); } }
private HostMetrics hostMetrics(String hostname, int port) { Collection<HostMetrics> matching = Collections2.filter(hostMetrics.getMetrics(), metrics -> metrics.hostname().equals(hostname) && metrics.port() == port); return Iterables.getOnlyElement(matching); }
@Test public void testIoExceptionRecorded() throws IOException { when(chain.request()).thenReturn(REQUEST_A); when(chain.proceed(any())).thenThrow(IOException.class); assertThat(hostMetrics.getMetrics()).isEmpty(); assertThatExceptionOfType(IOException.class) .isThrownBy(() -> interceptor.intercept(chain)); HostMetrics metrics = Iterables.getOnlyElement(hostMetrics.getMetrics()); assertThat(metrics.getIoExceptions().getCount()).isEqualTo(1); }
public static AutoDeserializeService autoDeserializeService(VerificationServerRule server) { return JaxRsClient.create( AutoDeserializeService.class, getUserAgent(), new HostMetricsRegistry(), server.getClientConfiguration()); }
@Test public void verifyIoExceptionMetricsAreRegistered() { Call call = createRetryingClient(0, "http://bogus").newCall(new Request.Builder().url("http://bogus").build()); assertThatExceptionOfType(IOException.class) .isThrownBy(call::execute); List<HostMetrics> hostMetrics = hostEventsSink.getMetrics().stream() .filter(metrics -> metrics.hostname().equals("bogus")) .filter(metrics -> metrics.serviceName().equals("OkHttpClientsTest")) .collect(Collectors.toList()); HostMetrics actualMetrics = Iterables.getOnlyElement(hostMetrics); assertThat(actualMetrics.getIoExceptions().getCount()).isEqualTo(1); }
@Before public void before() { url = server.url("/"); service = Retrofit2Client.create(TestService.class, AGENT, new HostMetricsRegistry(), createTestConfig(url.toString())); }
@Test public void verifyResponseMetricsAreRegistered() throws IOException { server.enqueue(new MockResponse().setBody("pong")); createRetryingClient(1).newCall(new Request.Builder().url(url).build()).execute(); List<HostMetrics> hostMetrics = hostEventsSink.getMetrics().stream() .filter(metrics -> metrics.hostname().equals("localhost")) .filter(metrics -> metrics.serviceName().equals("OkHttpClientsTest")) .filter(metrics -> metrics.port() == server.getPort()) .collect(Collectors.toList()); HostMetrics actualMetrics = Iterables.getOnlyElement(hostMetrics); assertThat(actualMetrics.get2xx().getCount()).isGreaterThanOrEqualTo(1); }
public static SingleHeaderService singleHeaderService(VerificationServerRule server) { return JaxRsClient.create( SingleHeaderService.class, getUserAgent(), new HostMetricsRegistry(), server.getClientConfiguration()); }
public static AutoDeserializeConfirmService confirmService(VerificationServerRule server) { return JaxRsClient.create( AutoDeserializeConfirmService.class, getUserAgent(), new HostMetricsRegistry(), server.getClientConfiguration()); }
public static SinglePathParamService singlePathParamService(VerificationServerRule server) { return JaxRsClient.create( SinglePathParamService.class, getUserAgent(), new HostMetricsRegistry(), server.getClientConfiguration()); }
@Before public void before() { registry = new DefaultTaggedMetricRegistry(); hostMetrics = new HostMetricsRegistry(); interceptor = new InstrumentedInterceptor(registry, hostMetrics, "client"); }
@Before public void before() { delegate = mock(Decoder.class); headers = Maps.newHashMap(); textDelegateDecoder = new ConjureTextDelegateDecoder(delegate); String endpointUri = "http://localhost:" + APP.getLocalPort(); service = JaxRsClient.create( GuavaTestServer.TestService.class, AGENT, new HostMetricsRegistry(), createTestConfig(endpointUri)); }
public static SingleQueryParamService singleQueryParamService(VerificationServerRule server) { return JaxRsClient.create(SingleQueryParamService.class, getUserAgent(), new HostMetricsRegistry(), server.getClientConfiguration()); }
@Before public void before() { delegate = Mockito.mock(Decoder.class); inputStreamDelegateDecoder = new ConjureInputStreamDelegateDecoder(delegate); String endpointUri = "http://localhost:" + APP.getLocalPort(); service = JaxRsClient.create( GuavaTestServer.TestService.class, AGENT, new HostMetricsRegistry(), createTestConfig(endpointUri)); }
@Before public void before() { String endpointUri = "http://localhost:" + APP.getLocalPort(); service = JaxRsClient.create( Java8TestServer.TestService.class, AGENT, new HostMetricsRegistry(), createTestConfig(endpointUri)); }
@Test public void testCannotDecorateInterfaceWithOptionalPathParam() { try { JaxRsClient.create( CannotDecorateInterface.class, AGENT, new HostMetricsRegistry(), createTestConfig("http://localhost:" + server.getPort())); fail(); } catch (RuntimeException e) { assertThat(e.getMessage(), is("Cannot use Guava Optionals with PathParams. (Class: com.palantir.conjure" + ".java.client.jaxrs.JaxRsClientGuavaOptionalHandlingTest$CannotDecorateInterface," + " Method: path, Param: arg0)")); } }
@Test public void testCannotDecorateInterfaceWithOptionalPathParam() { try { JaxRsClient.create( CannotDecorateInterface.class, AGENT, new HostMetricsRegistry(), createTestConfig("http://localhost:" + server.getPort())); fail(); } catch (RuntimeException e) { assertThat(e.getMessage(), is("Cannot use Java8 Optionals with PathParams. (Class: com.palantir.conjure." + "java.client.jaxrs.JaxRsClientJava8OptionalHandlingTest$CannotDecorateInterface," + " Method: path, Param: arg0)")); } }
@Before public void before() { String endpointUri = "http://localhost:" + APP.getLocalPort(); service = JaxRsClient.create(TestService.class, AGENT, new HostMetricsRegistry(), createTestConfig(endpointUri)); }
@Before public void before() { String endpointUri = "http://localhost:" + APP.getLocalPort(); service = JaxRsClient.create( GuavaTestServer.TestService.class, AGENT, new HostMetricsRegistry(), createTestConfig(endpointUri)); }