Search in sources :

Example 6 with JerseyClientBuilder

use of org.glassfish.jersey.client.JerseyClientBuilder in project dropwizard by dropwizard.

the class Http2IntegrationTest method testHttp11.

@Test
public void testHttp11() throws Exception {
    final String hostname = "localhost";
    final int port = appRule.getLocalPort();
    final JerseyClient http11Client = new JerseyClientBuilder().sslContext(sslContextFactory.getSslContext()).build();
    final Response response = http11Client.target("https://" + hostname + ":" + port + "/api/test").request().get();
    assertThat(response.getHeaderString(HttpHeaders.CONTENT_TYPE)).isEqualTo(MediaType.APPLICATION_JSON);
    assertThat(response.readEntity(String.class)).isEqualTo(FakeApplication.HELLO_WORLD);
    http11Client.close();
}
Also used : Response(javax.ws.rs.core.Response) JerseyClient(org.glassfish.jersey.client.JerseyClient) JerseyClientBuilder(org.glassfish.jersey.client.JerseyClientBuilder) Test(org.junit.Test)

Example 7 with JerseyClientBuilder

use of org.glassfish.jersey.client.JerseyClientBuilder in project perry by ca-cwds.

the class PerryRealm method onInit.

@Override
protected void onInit() {
    super.onInit();
    JerseyClientBuilder clientBuilder = new JerseyClientBuilder().property(ClientProperties.CONNECT_TIMEOUT, 5000).property(ClientProperties.READ_TIMEOUT, 20000);
    client = clientBuilder.build();
}
Also used : JerseyClientBuilder(org.glassfish.jersey.client.JerseyClientBuilder)

Example 8 with JerseyClientBuilder

use of org.glassfish.jersey.client.JerseyClientBuilder in project api-core by ca-cwds.

the class TokenResource method getClient.

private synchronized Client getClient() {
    if (client == null) {
        JerseyClientBuilder clientBuilder = new JerseyClientBuilder().property(ClientProperties.CONNECT_TIMEOUT, 5000).property(ClientProperties.READ_TIMEOUT, 30000).hostnameVerifier((hostName, sslSession) -> true);
        this.client = clientBuilder.build();
    }
    return client;
}
Also used : JerseyClientBuilder(org.glassfish.jersey.client.JerseyClientBuilder)

Example 9 with JerseyClientBuilder

use of org.glassfish.jersey.client.JerseyClientBuilder in project athenz by yahoo.

the class ZTSClientTimeoutTest method testZTSClientReadTimeoutForJerseyContainer.

@Test
public void testZTSClientReadTimeoutForJerseyContainer() throws Exception {
    ZTSClientMock.setClientBuilder(new JerseyClientBuilder());
    server = new JettyServer(port);
    server.start();
    String baseUri = "http://localhost:" + port;
    ZTSClientMock ztsClient = new ZTSClientMock(baseUri);
    try {
        ztsClient.getRoleAccess("testDomain", "testPrincipal");
        fail("read timeout not set");
    } catch (ZTSClientException expected) {
        assertEquals(expected.code, ResourceException.BAD_REQUEST);
        assertEquals(expected.getMessage(), "ResourceException (400): java.net.SocketTimeoutException: Read timed out");
    }
    ztsClient.close();
    ZTSClientMock.setClientBuilder(null);
}
Also used : JerseyClientBuilder(org.glassfish.jersey.client.JerseyClientBuilder) Test(org.testng.annotations.Test)

Example 10 with JerseyClientBuilder

use of org.glassfish.jersey.client.JerseyClientBuilder in project athenz by yahoo.

the class ZMSClientTimeoutTest method testZMSClientReadTimeoutForJerseyContainer.

@Test
public void testZMSClientReadTimeoutForJerseyContainer() throws Exception {
    ZMSClientExt.setClientBuilder(new JerseyClientBuilder());
    server = new JettyServer(port);
    server.start();
    String baseUri = "http://localhost:" + port;
    ZMSClientExt zmsClient = new ZMSClientExt(baseUri);
    try {
        zmsClient.getDomain("test");
        fail("read timeout not set");
    } catch (ZMSClientException expected) {
        assertEquals(expected.code, ResourceException.BAD_REQUEST);
        assertEquals(expected.getMessage(), "ResourceException (400): java.net.SocketTimeoutException: Read timed out");
    }
    zmsClient.close();
    ZMSClientExt.setClientBuilder(null);
}
Also used : JerseyClientBuilder(org.glassfish.jersey.client.JerseyClientBuilder) Test(org.testng.annotations.Test)

Aggregations

JerseyClientBuilder (org.glassfish.jersey.client.JerseyClientBuilder)11 Test (org.testng.annotations.Test)4 JerseyClient (org.glassfish.jersey.client.JerseyClient)3 Test (org.junit.Test)3 JacksonJsonProvider (com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider)2 SecureRandom (java.security.SecureRandom)2 SSLContext (javax.net.ssl.SSLContext)2 Response (javax.ws.rs.core.Response)2 Statement (org.junit.runners.model.Statement)2 X509Certificate (java.security.cert.X509Certificate)1 TrustManager (javax.net.ssl.TrustManager)1 X509TrustManager (javax.net.ssl.X509TrustManager)1 JerseyTest (org.glassfish.jersey.test.JerseyTest)1