use of org.glassfish.jersey.client.ClientConfig in project open-kilda by telstra.
the class TopologyDiscoveryBasicTest method sendMalformedLldpPacket.
@When("^send malformed lldp packet$")
public void sendMalformedLldpPacket() throws Throwable {
System.out.println("=====> Send malformed packet");
long current = System.currentTimeMillis();
Client client = ClientBuilder.newClient(new ClientConfig());
Response result = client.target(trafficEndpoint).path("/send_malformed_packet").request().post(null);
System.out.println(String.format("======> Response = %s", result.toString()));
System.out.println(String.format("======> Send malformed packet Time: %,.3f", getTimeDuration(current)));
assertEquals(200, result.getStatus());
}
use of org.glassfish.jersey.client.ClientConfig in project scylla-jmx by scylladb.
the class APIClient method get.
public Invocation.Builder get(String path, MultivaluedMap<String, String> queryParams) {
Client client = ClientBuilder.newClient(new ClientConfig());
WebTarget webTarget = client.target(getBaseUrl()).path(path);
if (queryParams != null) {
for (Entry<String, List<String>> qp : queryParams.entrySet()) {
for (String e : qp.getValue()) {
webTarget = webTarget.queryParam(qp.getKey(), e);
}
}
}
return webTarget.request(MediaType.APPLICATION_JSON);
}
use of org.glassfish.jersey.client.ClientConfig in project linuxtools by eclipse.
the class AbstractRegistry method isVersion2.
@Override
public boolean isVersion2() {
if (isV2 != null) {
return isV2;
}
// We haven't cached the result, so let's evaluate
final ClientConfig DEFAULT_CONFIG = new ClientConfig(ObjectMapperProvider.class, JacksonFeature.class);
final Client client = ClientBuilder.newClient(DEFAULT_CONFIG);
final WebTarget pingApiv2Resource = client.target(getHTTPServerAddress()).path(// $NON-NLS-1$
"v2");
try {
final Response response = pingApiv2Resource.request(APPLICATION_JSON_TYPE).async().get().get();
if (response.getStatus() == Status.OK.getStatusCode()) {
isV2 = true;
return true;
}
} catch (ExecutionException | InterruptedException e) {
// do nothing
}
isV2 = false;
return false;
}
use of org.glassfish.jersey.client.ClientConfig in project linuxtools by eclipse.
the class AbstractRegistry method getHTTPServerAddress.
private String getHTTPServerAddress() {
if (cachedHTTPServerAddress != null) {
return cachedHTTPServerAddress;
/*
* This is wrong because serverAddress prefixed with http won't work
* for push/pull API but let's support this.
*/
} else if (getServerAddress().startsWith("http")) {
// $NON-NLS-1$
return getServerAddress();
}
// We haven't cached the result, so let's evaluate
// $NON-NLS-1$ //$NON-NLS-2$
String[] versions = new String[] { "v1", "v2" };
// $NON-NLS-1$ //$NON-NLS-2$
String[] schemes = new String[] { "http://", "https://" };
final ClientConfig DEFAULT_CONFIG = new ClientConfig(ObjectMapperProvider.class, JacksonFeature.class);
final Client client = ClientBuilder.newClient(DEFAULT_CONFIG);
for (String scheme : schemes) {
for (String ver : versions) {
String url = scheme + getServerAddress();
WebTarget queryServer = client.target(url).path(ver);
try {
enableDockerAuthenticator();
Response resp = queryServer.request(APPLICATION_JSON_TYPE).async().method(GET).get();
int code = resp.getStatus();
if (code >= 200 && code < 300) {
cachedHTTPServerAddress = url;
return url;
}
} catch (InterruptedException | ExecutionException e) {
} finally {
restoreAuthenticator();
}
}
}
// $NON-NLS-1$
return "http://" + getServerAddress();
}
use of org.glassfish.jersey.client.ClientConfig in project cu-kfs by CU-CommunityApps.
the class PaymentWorksWebServiceCallsServiceImpl method buildJsonResponse.
private Response buildJsonResponse(URI uri, String jsonString) {
Client client = null;
Response response = null;
try {
ClientConfig clientConfig = new ClientConfig();
client = ClientBuilder.newClient(clientConfig);
Invocation request = buildJsonClientRequest(client, uri, jsonString);
response = request.invoke();
response.bufferEntity();
return response;
} finally {
CURestClientUtils.closeQuietly(client);
}
}
Aggregations