use of io.vertx.core.http.HttpClient in project mod-inventory-storage by folio-org.
the class LoanTypeTest method send.
private void send(URL url, HttpMethod method, String content, Handler<HttpClientResponse> handler) {
HttpClient client = StorageTestSuite.getVertx().createHttpClient();
HttpClientRequest request;
if (content == null) {
content = "";
}
Buffer buffer = Buffer.buffer(content);
switch(method) {
case POST:
request = client.postAbs(url.toString());
break;
case DELETE:
request = client.deleteAbs(url.toString());
break;
case GET:
request = client.getAbs(url.toString());
break;
default:
request = client.putAbs(url.toString());
}
request.exceptionHandler(error -> {
Assert.fail(error.getLocalizedMessage());
}).handler(handler);
request.putHeader("Authorization", "test_tenant");
request.putHeader("x-okapi-tenant", "test_tenant");
request.putHeader("Accept", "application/json,text/plain");
request.putHeader("Content-type", SUPPORTED_CONTENT_TYPE_JSON_DEF);
request.end(buffer);
}
use of io.vertx.core.http.HttpClient in project mod-inventory-storage by folio-org.
the class LocationsTest method send.
// /////////////////////////// helpers
private static void send(URL url, HttpMethod method, String content, String contentType, Handler<HttpClientResponse> handler) {
HttpClient client = StorageTestSuite.getVertx().createHttpClient();
HttpClientRequest request;
if (content == null) {
content = "";
}
Buffer buffer = Buffer.buffer(content);
if (method == HttpMethod.POST) {
request = client.postAbs(url.toString());
} else if (method == HttpMethod.DELETE) {
request = client.deleteAbs(url.toString());
} else if (method == HttpMethod.GET) {
request = client.getAbs(url.toString());
} else {
request = client.putAbs(url.toString());
}
request.exceptionHandler(error -> {
Assert.fail(error.getLocalizedMessage());
}).handler(handler);
request.putHeader("Authorization", "test_tenant");
request.putHeader("x-okapi-tenant", "test_tenant");
request.putHeader("Accept", "application/json,text/plain");
request.putHeader("Content-type", contentType);
request.end(buffer);
}
use of io.vertx.core.http.HttpClient in project mod-inventory-storage by folio-org.
the class LocationUnitTest method send.
// //////////////// General helpers
/*
private JsonObject createItemRequest(String temporaryLocationId) {
JsonObject item = new JsonObject();
item.put("holdingsRecordId", UUID.randomUUID().toString());
item.put("barcode", "12345");
item.put("permanentLoanTypeId", canCirculateLoanTypeID);
item.put("materialTypeId", journalMaterialTypeID);
item.put("temporaryLocationId", temporaryLocationId);
return item;
}
*/
private static void send(URL url, HttpMethod method, String content, String contentType, Handler<HttpClientResponse> handler) {
HttpClient client = StorageTestSuite.getVertx().createHttpClient();
HttpClientRequest request;
if (content == null) {
content = "";
}
Buffer buffer = Buffer.buffer(content);
if (method == HttpMethod.POST) {
request = client.postAbs(url.toString());
} else if (method == HttpMethod.DELETE) {
request = client.deleteAbs(url.toString());
} else if (method == HttpMethod.GET) {
request = client.getAbs(url.toString());
} else {
request = client.putAbs(url.toString());
}
request.exceptionHandler(error -> {
Assert.fail(error.getLocalizedMessage());
}).handler(handler);
request.putHeader("Authorization", "test_tenant");
request.putHeader("x-okapi-tenant", "test_tenant");
request.putHeader("Accept", "application/json,text/plain");
request.putHeader("Content-type", contentType);
request.end(buffer);
}
use of io.vertx.core.http.HttpClient in project mod-inventory-storage by folio-org.
the class MaterialTypeTest method send.
private void send(String url, HttpMethod method, String content, String contentType, Handler<HttpClientResponse> handler) {
HttpClient client = StorageTestSuite.getVertx().createHttpClient();
HttpClientRequest request;
if (content == null) {
content = "";
}
Buffer buffer = Buffer.buffer(content);
if (method == HttpMethod.POST) {
request = client.postAbs(url);
} else if (method == HttpMethod.DELETE) {
request = client.deleteAbs(url);
} else if (method == HttpMethod.GET) {
request = client.getAbs(url);
} else {
request = client.putAbs(url);
}
request.exceptionHandler(error -> {
Assert.fail(error.getLocalizedMessage());
}).handler(handler);
request.putHeader("Authorization", "test_tenant");
request.putHeader("x-okapi-tenant", "test_tenant");
request.putHeader("Accept", "application/json,text/plain");
request.putHeader("Content-type", contentType);
request.end(buffer);
}
use of io.vertx.core.http.HttpClient in project pinpoint by naver.
the class VertxPluginTestStarter method request.
public void request(int port, String host, String uri) {
final HttpClient client = vertx.createHttpClient();
client.request(HttpMethod.GET, port, host, uri, new Handler<HttpClientResponse>() {
@Override
public void handle(HttpClientResponse httpClientResponse) {
httpClientResponse.exceptionHandler(new Handler<Throwable>() {
@Override
public void handle(Throwable throwable) {
}
});
httpClientResponse.endHandler(new Handler<Void>() {
@Override
public void handle(Void aVoid) {
}
});
}
}).end();
}
Aggregations