Search in sources :

Example 1 with ApacheConnectorProvider

use of org.glassfish.jersey.apache.connector.ApacheConnectorProvider in project jersey by jersey.

the class MultipartMixedWithApacheClientTest method configureClient.

@Override
protected void configureClient(ClientConfig config) {
    config.connectorProvider(new ApacheConnectorProvider());
    config.register(MultiPartFeature.class);
}
Also used : ApacheConnectorProvider(org.glassfish.jersey.apache.connector.ApacheConnectorProvider)

Example 2 with ApacheConnectorProvider

use of org.glassfish.jersey.apache.connector.ApacheConnectorProvider in project jersey by jersey.

the class SslConnectorConfigurationTest method testSSLAuth1.

/**
     * Test to see that SSLHandshakeException is thrown when client don't have
     * trusted key.
     *
     * @throws Exception in case of a test failure.
     */
@Test
public void testSSLAuth1() throws Exception {
    final SSLContext sslContext = getSslContext();
    final ClientConfig cc = new ClientConfig().connectorProvider(new ApacheConnectorProvider());
    final Client client = ClientBuilder.newBuilder().withConfig(cc).sslContext(sslContext).build();
    WebTarget target = client.target(Server.BASE_URI).register(LoggingFeature.class);
    boolean caught = false;
    try {
        target.path("/").request().get(String.class);
    } catch (Exception e) {
        caught = true;
    }
    assertTrue(caught);
}
Also used : ApacheConnectorProvider(org.glassfish.jersey.apache.connector.ApacheConnectorProvider) SSLContext(javax.net.ssl.SSLContext) WebTarget(javax.ws.rs.client.WebTarget) ClientConfig(org.glassfish.jersey.client.ClientConfig) Client(javax.ws.rs.client.Client) Test(org.junit.Test)

Example 3 with ApacheConnectorProvider

use of org.glassfish.jersey.apache.connector.ApacheConnectorProvider in project jersey by jersey.

the class Jersey2878ApacheITCase method configureClient.

@Override
protected void configureClient(final ClientConfig config) {
    config.connectorProvider(new ApacheConnectorProvider());
    super.configureClient(config);
}
Also used : ApacheConnectorProvider(org.glassfish.jersey.apache.connector.ApacheConnectorProvider)

Example 4 with ApacheConnectorProvider

use of org.glassfish.jersey.apache.connector.ApacheConnectorProvider in project storm by apache.

the class OpenTsdbClient method init.

private void init() {
    final ApacheConnectorProvider apacheConnectorProvider = new ApacheConnectorProvider();
    final ClientConfig clientConfig = new ClientConfig().connectorProvider(apacheConnectorProvider);
    // transfer encoding should be set as jersey sets it on by default.
    clientConfig.property(ClientProperties.REQUEST_ENTITY_PROCESSING, enableChunkedEncoding ? RequestEntityProcessing.CHUNKED : RequestEntityProcessing.BUFFERED);
    client = ClientBuilder.newClient(clientConfig);
    target = client.target(urlString).path(PUT_PATH);
    if (sync) {
        // need to add an empty string else it is nto added as query param.
        target = target.queryParam("sync", "").queryParam("sync_timeout", syncTimeout);
    }
    if (responseType != ResponseType.None) {
        // need to add an empty string else it is nto added as query param.
        target = target.queryParam(responseType.value, "");
    }
    LOG.info("target uri [{}]", target.getUri());
}
Also used : ApacheConnectorProvider(org.glassfish.jersey.apache.connector.ApacheConnectorProvider) ClientConfig(org.glassfish.jersey.client.ClientConfig)

Example 5 with ApacheConnectorProvider

use of org.glassfish.jersey.apache.connector.ApacheConnectorProvider in project jersey by jersey.

the class ItemStoreResourceTest method configureClient.

@Override
protected void configureClient(ClientConfig config) {
    // using AHC as a test client connector to avoid issues with HttpUrlConnection socket management.
    PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
    // adjusting max. connections just to be safe - the testEventSourceReconnect is quite greedy...
    cm.setMaxTotal(MAX_LISTENERS * MAX_ITEMS);
    cm.setDefaultMaxPerRoute(MAX_LISTENERS * MAX_ITEMS);
    config.register(SseFeature.class).property(ApacheClientProperties.CONNECTION_MANAGER, cm).property(ClientProperties.READ_TIMEOUT, 2000).connectorProvider(new ApacheConnectorProvider());
}
Also used : ApacheConnectorProvider(org.glassfish.jersey.apache.connector.ApacheConnectorProvider) SseFeature(org.glassfish.jersey.media.sse.SseFeature) PoolingHttpClientConnectionManager(org.apache.http.impl.conn.PoolingHttpClientConnectionManager)

Aggregations

ApacheConnectorProvider (org.glassfish.jersey.apache.connector.ApacheConnectorProvider)9 ClientConfig (org.glassfish.jersey.client.ClientConfig)6 Client (javax.ws.rs.client.Client)5 Test (org.junit.Test)5 Response (javax.ws.rs.core.Response)3 SSLContext (javax.net.ssl.SSLContext)2 WebTarget (javax.ws.rs.client.WebTarget)2 JerseyTest (org.glassfish.jersey.test.JerseyTest)2 PoolingHttpClientConnectionManager (org.apache.http.impl.conn.PoolingHttpClientConnectionManager)1 HttpServer (org.glassfish.grizzly.http.server.HttpServer)1 SseFeature (org.glassfish.jersey.media.sse.SseFeature)1 ResourceConfig (org.glassfish.jersey.server.ResourceConfig)1