use of com.sun.jersey.api.client.Client in project neo4j by neo4j.
the class RedirectToBrowserTest method shouldRedirectToBrowser.
@Test
public void shouldRedirectToBrowser() throws Exception {
Client nonRedirectingClient = Client.create();
nonRedirectingClient.setFollowRedirects(false);
final JaxRsResponse response = new RestRequest(server.baseUri(), nonRedirectingClient).accept(MediaType.TEXT_HTML_TYPE).get(server.baseUri().toString());
assertEquals(303, response.getStatus());
assertEquals(new URI("http://localhost:7474/browser/"), response.getLocation());
response.close();
}
use of com.sun.jersey.api.client.Client in project neo4j by neo4j.
the class DiscoveryServiceIT method shouldRedirectOnHtmlRequest.
@Test
public void shouldRedirectOnHtmlRequest() throws Exception {
Client nonRedirectingClient = Client.create();
nonRedirectingClient.setFollowRedirects(false);
JaxRsResponse clientResponse = new RestRequest(null, nonRedirectingClient).get(server().baseUri().toString(), TEXT_HTML_TYPE);
assertEquals(303, clientResponse.getStatus());
}
use of com.sun.jersey.api.client.Client 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;
}
use of com.sun.jersey.api.client.Client in project ORCID-Source by ORCID.
the class TransformFundRefDataIntoCSV method fetchJsonFromGeoNames.
/**
* Queries GeoNames API for a given geonameId and return the JSON string
* */
private String fetchJsonFromGeoNames(String geoNameId) {
String result = null;
if (cache.containsKey("geoname_json_" + geoNameId)) {
return cache.get("geoname_json_" + geoNameId);
} else {
Client c = Client.create();
WebResource r = c.resource(geonamesApiUrl);
MultivaluedMap<String, String> params = new MultivaluedMapImpl();
params.add("geonameId", geoNameId);
params.add("username", apiUser);
result = r.queryParams(params).get(String.class);
cache.put("geoname_json_" + geoNameId, result);
}
return result;
}
use of com.sun.jersey.api.client.Client in project ORCID-Source by ORCID.
the class IdentityProviderManagerImpl method downloadMetadata.
private Document downloadMetadata(String metadataUrl) {
LOGGER.info("About to download idp metadata from {}", metadataUrl);
Client client = Client.create();
WebResource resource = client.resource(metadataUrl);
ClientResponse response = resource.accept(MediaType.APPLICATION_XML).get(ClientResponse.class);
Document document = response.getEntity(Document.class);
return document;
}
Aggregations