Search in sources :

Example 16 with JerseyClientBuilder

use of io.dropwizard.client.JerseyClientBuilder in project textdb by TextDB.

the class SystemResourceTest method checkSampleEndpoint.

@Test
public void checkSampleEndpoint() throws Exception {
    Client client = new JerseyClientBuilder(RULE.getEnvironment()).build("test client");
    client.property(ClientProperties.CONNECT_TIMEOUT, 5000);
    client.property(ClientProperties.READ_TIMEOUT, 5000);
    Response response = client.target(String.format("http://localhost:%d/api/resources/metadata", RULE.getLocalPort())).request().get();
    assertThat(response.getStatus()).isEqualTo(200);
}
Also used : Response(javax.ws.rs.core.Response) Client(javax.ws.rs.client.Client) JerseyClientBuilder(io.dropwizard.client.JerseyClientBuilder) Test(org.junit.Test)

Example 17 with JerseyClientBuilder

use of io.dropwizard.client.JerseyClientBuilder in project dropwizard by dropwizard.

the class DropwizardSSLConnectionSocketFactoryTest method shouldBeOkIfHostnameVerificationOffAndServerHostnameMatchesAndFailVerfierSpecified.

@Test
public void shouldBeOkIfHostnameVerificationOffAndServerHostnameMatchesAndFailVerfierSpecified() throws Exception {
    tlsConfiguration.setVerifyHostname(false);
    final Client client = new JerseyClientBuilder(TLS_APP_RULE.getEnvironment()).using(jerseyClientConfiguration).using(new FailVerifier()).build("bad_host_fail_verifier_working");
    final Response response = client.target(String.format("https://localhost:%d", TLS_APP_RULE.getLocalPort())).request().get();
    assertThat(response.getStatus()).isEqualTo(200);
}
Also used : ClientResponse(org.glassfish.jersey.client.ClientResponse) Response(javax.ws.rs.core.Response) Client(javax.ws.rs.client.Client) JerseyClientBuilder(io.dropwizard.client.JerseyClientBuilder) Test(org.junit.Test)

Example 18 with JerseyClientBuilder

use of io.dropwizard.client.JerseyClientBuilder in project dropwizard by dropwizard.

the class DropwizardSSLConnectionSocketFactoryTest method shouldRejectNonSupportedProtocols.

@Test
public void shouldRejectNonSupportedProtocols() throws Exception {
    tlsConfiguration.setSupportedProtocols(Collections.singletonList("TLSv1.2"));
    final Client client = new JerseyClientBuilder(TLS_APP_RULE.getEnvironment()).using(jerseyClientConfiguration).build("reject_non_supported");
    assertThatThrownBy(() -> client.target(String.format("https://localhost:%d", TLS_APP_RULE.getPort(4))).request().get()).isInstanceOf(ProcessingException.class).hasRootCauseInstanceOf(SSLException.class);
}
Also used : Client(javax.ws.rs.client.Client) JerseyClientBuilder(io.dropwizard.client.JerseyClientBuilder) ProcessingException(javax.ws.rs.ProcessingException) Test(org.junit.Test)

Example 19 with JerseyClientBuilder

use of io.dropwizard.client.JerseyClientBuilder in project dropwizard by dropwizard.

the class App1Test method custom204OnEmptyOptional.

@Test
public void custom204OnEmptyOptional() {
    final Client client = new JerseyClientBuilder(RULE.getEnvironment()).build("test client 1");
    final String url = String.format("http://localhost:%d/empty-optional", RULE.getLocalPort());
    final Response response = client.target(url).request().get();
    assertThat(response.getStatus()).isEqualTo(204);
}
Also used : Response(javax.ws.rs.core.Response) Client(javax.ws.rs.client.Client) JerseyClientBuilder(io.dropwizard.client.JerseyClientBuilder) Test(org.junit.Test)

Aggregations

JerseyClientBuilder (io.dropwizard.client.JerseyClientBuilder)19 Client (javax.ws.rs.client.Client)18 Test (org.junit.Test)18 Response (javax.ws.rs.core.Response)11 ClientResponse (org.glassfish.jersey.client.ClientResponse)7 File (java.io.File)3 ProcessingException (javax.ws.rs.ProcessingException)3 Assertions.catchThrowable (org.assertj.core.api.Assertions.catchThrowable)3 FormDataBodyPart (org.glassfish.jersey.media.multipart.FormDataBodyPart)2 FormDataMultiPart (org.glassfish.jersey.media.multipart.FormDataMultiPart)2 MultiPart (org.glassfish.jersey.media.multipart.MultiPart)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 JerseyClientConfiguration (io.dropwizard.client.JerseyClientConfiguration)1 ErrorMessage (io.dropwizard.jersey.errors.ErrorMessage)1 NoopHostnameVerifier (org.apache.http.conn.ssl.NoopHostnameVerifier)1 Before (org.junit.Before)1