Search in sources :

Example 76 with HttpRequest

use of co.cask.common.http.HttpRequest in project cdap by caskdata.

the class DatasetInstanceHandlerTest method validatePut.

private void validatePut(URL url, String body, Integer... expected) throws IOException {
    HttpRequest request = HttpRequest.put(url).withBody(body).build();
    assertStatus(HttpRequests.execute(request).getResponseCode(), url, expected);
}
Also used : HttpRequest(co.cask.common.http.HttpRequest)

Example 77 with HttpRequest

use of co.cask.common.http.HttpRequest in project cdap by caskdata.

the class DatasetInstanceHandlerTest method getInstanceObject.

private ObjectResponse<DatasetMeta> getInstanceObject(String instanceName) throws IOException {
    HttpRequest request = HttpRequest.get(getUrl("/data/datasets/" + instanceName)).build();
    HttpResponse response = HttpRequests.execute(request);
    return ObjectResponse.fromJsonBody(response, DatasetMeta.class);
}
Also used : HttpRequest(co.cask.common.http.HttpRequest) HttpResponse(co.cask.common.http.HttpResponse)

Example 78 with HttpRequest

use of co.cask.common.http.HttpRequest in project cdap by caskdata.

the class DatasetInstanceHandlerTest method validateDelete.

private void validateDelete(URL url, Integer... expected) throws IOException {
    HttpRequest request = HttpRequest.delete(url).build();
    assertStatus(HttpRequests.execute(request).getResponseCode(), url, expected);
}
Also used : HttpRequest(co.cask.common.http.HttpRequest)

Example 79 with HttpRequest

use of co.cask.common.http.HttpRequest in project cdap by caskdata.

the class DatasetInstanceHandlerTest method getInstance.

private HttpResponse getInstance(DatasetId instance) throws IOException {
    URL instanceUrl = getUrl(instance.getNamespace(), "/data/datasets/" + instance.getEntityName());
    HttpRequest request = HttpRequest.get(instanceUrl).build();
    return HttpRequests.execute(request);
}
Also used : HttpRequest(co.cask.common.http.HttpRequest) URL(java.net.URL)

Example 80 with HttpRequest

use of co.cask.common.http.HttpRequest in project cdap by caskdata.

the class DatasetServiceTestBase method deployModule.

protected HttpResponse deployModule(DatasetModuleId module, Class moduleClass, boolean force) throws Exception {
    Location moduleJar = createModuleJar(moduleClass);
    String urlPath = "/data/modules/" + module.getEntityName();
    urlPath = force ? urlPath + "?force=true" : urlPath;
    HttpRequest request = HttpRequest.put(getUrl(module.getNamespace(), urlPath)).addHeader("X-Class-Name", moduleClass.getName()).withBody(Locations.newInputSupplier(moduleJar)).build();
    return HttpRequests.execute(request);
}
Also used : HttpRequest(co.cask.common.http.HttpRequest) Location(org.apache.twill.filesystem.Location)

Aggregations

HttpRequest (co.cask.common.http.HttpRequest)97 URL (java.net.URL)75 HttpResponse (co.cask.common.http.HttpResponse)71 Test (org.junit.Test)22 AccessToken (co.cask.cdap.security.authentication.client.AccessToken)13 BadRequestException (co.cask.cdap.common.BadRequestException)10 NotFoundException (co.cask.cdap.common.NotFoundException)9 ApplicationManager (co.cask.cdap.test.ApplicationManager)9 ServiceManager (co.cask.cdap.test.ServiceManager)9 ApplicationNotFoundException (co.cask.cdap.common.ApplicationNotFoundException)6 IOException (java.io.IOException)6 TopicNotFoundException (co.cask.cdap.api.messaging.TopicNotFoundException)5 StreamNotFoundException (co.cask.cdap.common.StreamNotFoundException)5 TypeToken (com.google.common.reflect.TypeToken)5 TypeToken (com.google.gson.reflect.TypeToken)5 ArtifactNotFoundException (co.cask.cdap.common.ArtifactNotFoundException)4 ProgramNotFoundException (co.cask.cdap.common.ProgramNotFoundException)4 Instances (co.cask.cdap.proto.Instances)4 SparkManager (co.cask.cdap.test.SparkManager)4 KeyValueTable (co.cask.cdap.api.dataset.lib.KeyValueTable)3