use of org.jboss.resteasy.client.jaxrs.ResteasyClient in project scheduling by ow2-proactive.
the class SchedulerRestClient method createRestProxy.
private static SchedulerRestInterface createRestProxy(ResteasyProviderFactory provider, String restEndpointURL, ClientHttpEngine httpEngine) {
ResteasyClient client = buildResteasyClient(provider);
ResteasyWebTarget target = client.target(restEndpointURL);
SchedulerRestInterface schedulerRestClient = target.proxy(SchedulerRestInterface.class);
return createExceptionProxy(schedulerRestClient);
}
use of org.jboss.resteasy.client.jaxrs.ResteasyClient in project scheduling by ow2-proactive.
the class SchedulerRestClient method list.
public ListFile list(String sessionId, String dataspacePath, String pathname) throws Exception {
StringBuffer uriTmpl = (new StringBuffer()).append(restEndpointURL).append(addSlashIfMissing(restEndpointURL)).append("data/").append(dataspacePath).append('/');
ResteasyClient client = buildResteasyClient(providerFactory);
ResteasyWebTarget target = client.target(uriTmpl.toString()).path(pathname).queryParam("comp", "list");
Response response = null;
try {
response = target.request().header("sessionid", sessionId).get();
if (response.getStatus() != HttpURLConnection.HTTP_OK) {
if (response.getStatus() == HttpURLConnection.HTTP_UNAUTHORIZED) {
throw new NotConnectedRestException("User not authenticated or session timeout.");
} else {
throwException(String.format("Cannot list the specified location: %s", pathname), response);
}
}
return response.readEntity(ListFile.class);
} finally {
if (response != null) {
response.close();
}
}
}
use of org.jboss.resteasy.client.jaxrs.ResteasyClient in project eap-additional-testsuite by jboss-set.
the class ApacheHttpClient431TestCase method createEngine.
@SuppressWarnings(value = "unchecked")
private ResteasyClient createEngine(Class engine) {
RequestConfig reqConfig = // apache HttpClient specific
RequestConfig.custom().setConnectTimeout(5000).setSocketTimeout(5000).setConnectionRequestTimeout(5000).build();
CloseableHttpClient httpClient = HttpClientBuilder.create().setDefaultRequestConfig(reqConfig).setMaxConnTotal(3).build();
final ClientHttpEngine executor;
if (engine.isAssignableFrom(ApacheHttpClient43Engine.class)) {
executor = new ApacheHttpClient43Engine(httpClient);
} else {
executor = new URLConnectionEngine();
}
ResteasyClient client = new ResteasyClientBuilder().httpEngine(executor).build();
return client;
}
use of org.jboss.resteasy.client.jaxrs.ResteasyClient in project eap-additional-testsuite by jboss-set.
the class ApacheHttpClient43TestCase method createEngine.
@SuppressWarnings(value = "unchecked")
private ResteasyClient createEngine(Class engine) {
RequestConfig reqConfig = // apache HttpClient specific
RequestConfig.custom().setConnectTimeout(5000).setSocketTimeout(5000).setConnectionRequestTimeout(5000).build();
CloseableHttpClient httpClient = HttpClientBuilder.create().setDefaultRequestConfig(reqConfig).setMaxConnTotal(3).build();
final ClientHttpEngine executor;
if (engine.isAssignableFrom(ApacheHttpClient43Engine.class)) {
executor = new ApacheHttpClient43Engine(httpClient);
} else {
executor = new URLConnectionEngine();
}
ResteasyClient client = new ResteasyClientBuilder().httpEngine(executor).build();
return client;
}
use of org.jboss.resteasy.client.jaxrs.ResteasyClient in project eap-additional-testsuite by jboss-set.
the class ApacheHttpClient43TestCase method testConnectionWithRequestBody.
public void testConnectionWithRequestBody(Class engine) throws InterruptedException {
final ResteasyClient client = createEngine(engine);
final ApacheHttpClient4Resource proxy = client.target("http://127.0.0.1:8080/" + ApacheHttpClient43TestCase.class.getSimpleName()).proxy(ApacheHttpClient4Resource.class);
counter.set(0);
Thread[] threads = new Thread[3];
for (int i = 0; i < 3; i++) {
threads[i] = new Thread() {
@Override
public void run() {
for (int j = 0; j < 10; j++) {
String res = proxy.getData(String.valueOf(j));
Assert.assertNotNull("Response should not be null", res);
counter.incrementAndGet();
}
}
};
}
for (int i = 0; i < 3; i++) {
threads[i].start();
}
for (int i = 0; i < 3; i++) {
threads[i].join();
}
Assert.assertEquals("Wrong count of requests", 30L, counter.get());
}
Aggregations