Search in sources :

Example 1 with DefaultClientConfig

use of com.sun.jersey.api.client.config.DefaultClientConfig in project hadoop by apache.

the class TestTimelineReaderWebServicesHBaseStorage method createClient.

private static Client createClient() {
    ClientConfig cfg = new DefaultClientConfig();
    cfg.getClasses().add(YarnJacksonJaxbJsonProvider.class);
    return new Client(new URLConnectionClientHandler(new DummyURLConnectionFactory()), cfg);
}
Also used : DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) URLConnectionClientHandler(com.sun.jersey.client.urlconnection.URLConnectionClientHandler) ClientConfig(com.sun.jersey.api.client.config.ClientConfig) DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) Client(com.sun.jersey.api.client.Client)

Example 2 with DefaultClientConfig

use of com.sun.jersey.api.client.config.DefaultClientConfig in project hadoop by apache.

the class TestTimelineReaderWebServices method createClient.

private static Client createClient() {
    ClientConfig cfg = new DefaultClientConfig();
    cfg.getClasses().add(YarnJacksonJaxbJsonProvider.class);
    return new Client(new URLConnectionClientHandler(new DummyURLConnectionFactory()), cfg);
}
Also used : DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) URLConnectionClientHandler(com.sun.jersey.client.urlconnection.URLConnectionClientHandler) ClientConfig(com.sun.jersey.api.client.config.ClientConfig) DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) Client(com.sun.jersey.api.client.Client)

Example 3 with DefaultClientConfig

use of com.sun.jersey.api.client.config.DefaultClientConfig in project hadoop by apache.

the class TestRMHA method checkActiveRMWebServices.

// Do some sanity testing of the web-services after fail-over.
private void checkActiveRMWebServices() throws JSONException {
    // Validate web-service
    Client webServiceClient = Client.create(new DefaultClientConfig());
    InetSocketAddress rmWebappAddr = NetUtils.getConnectAddress(rm.getWebapp().getListenerAddress());
    String webappURL = "http://" + rmWebappAddr.getHostName() + ":" + rmWebappAddr.getPort();
    WebResource webResource = webServiceClient.resource(webappURL);
    String path = app.getApplicationId().toString();
    ClientResponse response = webResource.path("ws").path("v1").path("cluster").path("apps").path(path).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
    assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
    JSONObject json = response.getEntity(JSONObject.class);
    assertEquals("incorrect number of elements", 1, json.length());
    JSONObject appJson = json.getJSONObject("app");
    assertEquals("ACCEPTED", appJson.getString("state"));
// Other stuff is verified in the regular web-services related tests
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) JSONObject(org.codehaus.jettison.json.JSONObject) InetSocketAddress(java.net.InetSocketAddress) WebResource(com.sun.jersey.api.client.WebResource) Client(com.sun.jersey.api.client.Client)

Example 4 with DefaultClientConfig

use of com.sun.jersey.api.client.config.DefaultClientConfig in project nhin-d by DirectProject.

the class TestUtils method getResource.

public static WebResource getResource(String serviceURL) {
    final ClientConfig config = new DefaultClientConfig();
    config.getSingletons().add(new TxJSONProvider());
    // need to set timeouts so we don't block forever in the event of a bad URL or hung web server
    config.getProperties().put(ClientConfig.PROPERTY_CONNECT_TIMEOUT, CONNECTION_TIMEOUT);
    config.getProperties().put(ClientConfig.PROPERTY_READ_TIMEOUT, READ_TIMEOUT);
    final Client client = Client.create(config);
    WebResource resource = client.resource(serviceURL);
    return resource;
}
Also used : DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) WebResource(com.sun.jersey.api.client.WebResource) DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) ClientConfig(com.sun.jersey.api.client.config.ClientConfig) Client(com.sun.jersey.api.client.Client) TxJSONProvider(org.nhindirect.monitor.providers.TxJSONProvider)

Example 5 with DefaultClientConfig

use of com.sun.jersey.api.client.config.DefaultClientConfig in project ORCID-Source by ORCID.

the class CrossRefManagerImpl method createClient.

private Client createClient() {
    Set<Class<?>> providers = new HashSet<Class<?>>();
    providers.add(JacksonJsonProvider.class);
    ClientConfig config = new DefaultClientConfig(providers);
    config.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
    Client client = ApacheHttpClient4.create(config);
    client.setFollowRedirects(true);
    client.addFilter(new ContentTypeFromTextToJsonClientFilter());
    return client;
}
Also used : ContentTypeFromTextToJsonClientFilter(org.orcid.core.utils.ContentTypeFromTextToJsonClientFilter) DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) ClientConfig(com.sun.jersey.api.client.config.ClientConfig) Client(com.sun.jersey.api.client.Client) HashSet(java.util.HashSet)

Aggregations

DefaultClientConfig (com.sun.jersey.api.client.config.DefaultClientConfig)65 ClientConfig (com.sun.jersey.api.client.config.ClientConfig)55 Client (com.sun.jersey.api.client.Client)42 WebResource (com.sun.jersey.api.client.WebResource)21 HTTPBasicAuthFilter (com.sun.jersey.api.client.filter.HTTPBasicAuthFilter)15 ClientResponse (com.sun.jersey.api.client.ClientResponse)14 HTTPSProperties (com.sun.jersey.client.urlconnection.HTTPSProperties)9 HostnameVerifier (javax.net.ssl.HostnameVerifier)7 SSLSession (javax.net.ssl.SSLSession)7 TrustManager (javax.net.ssl.TrustManager)7 ClientHandlerException (com.sun.jersey.api.client.ClientHandlerException)6 URLConnectionClientHandler (com.sun.jersey.client.urlconnection.URLConnectionClientHandler)6 IOException (java.io.IOException)6 VisibleForTesting (com.google.common.annotations.VisibleForTesting)5 ClientFilter (com.sun.jersey.api.client.filter.ClientFilter)5 LoggingFilter (com.sun.jersey.api.client.filter.LoggingFilter)5 SecureRandom (java.security.SecureRandom)5 SSLContext (javax.net.ssl.SSLContext)5 URISyntaxException (java.net.URISyntaxException)4 ArrayList (java.util.ArrayList)4