use of com.palantir.conjure.java.okhttp.HostMetricsRegistry in project conjure-java by palantir.
the class UndertowServiceEteTest method jaxrs_client_can_make_a_call_to_an_empty_path.
@Test
public void jaxrs_client_can_make_a_call_to_an_empty_path() {
EmptyPathService emptyPathClient = JaxRsClient.create(EmptyPathService.class, clientUserAgent(), new HostMetricsRegistry(), clientConfiguration());
assertThat(emptyPathClient.emptyPath()).isTrue();
}
use of com.palantir.conjure.java.okhttp.HostMetricsRegistry in project conjure-java-runtime by palantir.
the class JaxRsClientCollectionHandlingTest method before.
@Before
public void before() {
proxy = JaxRsClient.create(Service.class, AGENT, new HostMetricsRegistry(), createTestConfig("http://localhost:" + server.getPort()));
MockResponse mockResponse = new MockResponse().setResponseCode(code).setBody(body);
server.enqueue(mockResponse);
}
use of com.palantir.conjure.java.okhttp.HostMetricsRegistry in project conjure-java-runtime by palantir.
the class JaxRsClientConfigRefreshTest method testConfigRefresh.
@Test
public void testConfigRefresh() throws Exception {
ClientConfiguration config1 = createTestConfig("http://localhost:" + server1.getPort());
ClientConfiguration config2 = createTestConfig("http://localhost:" + server2.getPort());
Refreshable<ClientConfiguration> refreshableConfig = Refreshable.of(config1);
TestService proxy = JaxRsClient.create(TestService.class, UserAgents.tryParse("agent"), new HostMetricsRegistry(), refreshableConfig);
// Call 1
server1.enqueue(new MockResponse().setBody("\"server1\""));
assertThat(proxy.string()).isEqualTo("server1");
assertThat(server1.getRequestCount()).isEqualTo(1);
assertThat(server2.getRequestCount()).isZero();
// Call 2
server1.enqueue(new MockResponse().setBody("\"server1\""));
assertThat(proxy.string()).isEqualTo("server1");
assertThat(server1.getRequestCount()).isEqualTo(2);
assertThat(server2.getRequestCount()).isZero();
// Switch config
refreshableConfig.set(config2);
// Call 3
server2.enqueue(new MockResponse().setBody("\"server2\""));
assertThat(proxy.string()).isEqualTo("server2");
assertThat(server1.getRequestCount()).isEqualTo(2);
assertThat(server2.getRequestCount()).isEqualTo(1);
// Call 4
server2.enqueue(new MockResponse().setBody("\"server2\""));
assertThat(proxy.string()).isEqualTo("server2");
assertThat(server1.getRequestCount()).isEqualTo(2);
assertThat(server2.getRequestCount()).isEqualTo(2);
}
use of com.palantir.conjure.java.okhttp.HostMetricsRegistry in project conjure-java-runtime by palantir.
the class JaxRsClientFailoverTest method testQosError_performsRetryWithOneNodeAndCache.
@Test
public void testQosError_performsRetryWithOneNodeAndCache() throws Exception {
MockWebServer server1 = new MockWebServer();
server1.enqueue(new MockResponse().setResponseCode(503));
server1.enqueue(new MockResponse().setBody("\"foo\""));
TestService anotherProxy = JaxRsClient.create(TestService.class, AGENT, new HostMetricsRegistry(), ClientConfiguration.builder().from(createTestConfig("http://localhost:" + server1.getPort())).maxNumRetries(2).failedUrlCooldown(Duration.ofMillis(CACHE_DURATION)).build());
assertThat(anotherProxy.string()).isEqualTo("foo");
}
use of com.palantir.conjure.java.okhttp.HostMetricsRegistry in project conjure-java-runtime by palantir.
the class JaxRsClientFailoverTest method testQosError_performsRetryWithOneNode.
@Test
public void testQosError_performsRetryWithOneNode() throws Exception {
MockWebServer server1 = new MockWebServer();
server1.enqueue(new MockResponse().setResponseCode(503));
server1.enqueue(new MockResponse().setBody("\"foo\""));
TestService anotherProxy = JaxRsClient.create(TestService.class, AGENT, new HostMetricsRegistry(), ClientConfiguration.builder().from(createTestConfig("http://localhost:" + server1.getPort())).maxNumRetries(2).build());
assertThat(anotherProxy.string()).isEqualTo("foo");
}
Aggregations