Search in sources :

Example 1 with TestService

use of com.palantir.conjure.java.client.jaxrs.TestService in project conjure-java-runtime by palantir.

the class ServiceConfigTest method testResource.

@Test
public void testResource() {
    ServiceConfigurationFactory factory = ServiceConfigurationFactory.of(rule.getConfiguration().getServiceDiscoveryConfiguration());
    TestService full = JaxRsClient.create(TestService.class, AGENT, new HostMetricsRegistry(), ClientConfigurations.of(factory.get("full")));
    TestService minimal = JaxRsClient.create(TestService.class, AGENT, new HostMetricsRegistry(), ClientConfigurations.of(factory.get("minimal")));
    assertThat(full.string()).isEqualTo("string");
    assertThat(minimal.string()).isEqualTo("string");
}
Also used : TestService(com.palantir.conjure.java.client.jaxrs.TestService) ServiceConfigurationFactory(com.palantir.conjure.java.api.config.service.ServiceConfigurationFactory) HostMetricsRegistry(com.palantir.conjure.java.okhttp.HostMetricsRegistry) Test(org.junit.Test)

Example 2 with TestService

use of com.palantir.conjure.java.client.jaxrs.TestService in project conjure-java-runtime by palantir.

the class UserAgentTest method testUserAgent_usesUnknownAgentWhenProvidedWithBogusAgentString.

@Test
public void testUserAgent_usesUnknownAgentWhenProvidedWithBogusAgentString() throws InterruptedException {
    TestService service = JaxRsClient.create(TestService.class, UserAgents.tryParse("bogus version string"), new HostMetricsRegistry(), createTestConfig(endpointUri));
    service.string();
    RecordedRequest request = server.takeRequest();
    assertThat(request.getHeader("User-Agent")).startsWith("unknown/0.0.0");
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) TestService(com.palantir.conjure.java.client.jaxrs.TestService) HostMetricsRegistry(com.palantir.conjure.java.okhttp.HostMetricsRegistry) Test(org.junit.Test)

Example 3 with TestService

use of com.palantir.conjure.java.client.jaxrs.TestService in project conjure-java-runtime by palantir.

the class UserAgentTest method testUserAgent_augmentedByHttpRemotingAndServiceComponents.

@Test
public void testUserAgent_augmentedByHttpRemotingAndServiceComponents() throws Exception {
    TestService service = JaxRsClient.create(TestService.class, AGENT, new HostMetricsRegistry(), createTestConfig(endpointUri));
    service.string();
    RecordedRequest request = server.takeRequest();
    String dialogueVersion = Channel.class.getPackage().getImplementationVersion();
    UserAgent expected = AGENT.addAgent(UserAgent.Agent.of("TestService", "0.0.0")).addAgent(UserAgent.Agent.of("dialogue", MoreObjects.firstNonNull(dialogueVersion, "0.0.0")));
    assertThat(request.getHeader("User-Agent")).isEqualTo(UserAgents.format(expected));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) TestService(com.palantir.conjure.java.client.jaxrs.TestService) Channel(com.palantir.dialogue.Channel) UserAgent(com.palantir.conjure.java.api.config.service.UserAgent) HostMetricsRegistry(com.palantir.conjure.java.okhttp.HostMetricsRegistry) Test(org.junit.Test)

Example 4 with TestService

use of com.palantir.conjure.java.client.jaxrs.TestService in project conjure-java-runtime by palantir.

the class UserAgentTest method testUserAgent_default.

@Test
public void testUserAgent_default() throws InterruptedException {
    TestService service = JaxRsClient.create(TestService.class, AGENT, new HostMetricsRegistry(), createTestConfig(endpointUri));
    service.string();
    RecordedRequest request = server.takeRequest();
    assertThat(request.getHeader("User-Agent")).startsWith(UserAgents.format(AGENT));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) TestService(com.palantir.conjure.java.client.jaxrs.TestService) HostMetricsRegistry(com.palantir.conjure.java.okhttp.HostMetricsRegistry) Test(org.junit.Test)

Aggregations

TestService (com.palantir.conjure.java.client.jaxrs.TestService)4 HostMetricsRegistry (com.palantir.conjure.java.okhttp.HostMetricsRegistry)4 Test (org.junit.Test)4 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)3 ServiceConfigurationFactory (com.palantir.conjure.java.api.config.service.ServiceConfigurationFactory)1 UserAgent (com.palantir.conjure.java.api.config.service.UserAgent)1 Channel (com.palantir.dialogue.Channel)1