use of com.azure.android.core.rest.ResponseBase in project azure-sdk-for-android by Azure.
the class RestProxyTests method service20PutOnlyHeaders.
@Test
public void service20PutOnlyHeaders() {
CountDownLatch latch = new CountDownLatch(1);
CallbackResultBase<HttpBinHeaders, Void> cbResult = new CallbackResultBase<>();
createService(Service20.class).putOnlyHeaders("body string", new Callback<ResponseBase<HttpBinHeaders, Void>>() {
@Override
public void onSuccess(ResponseBase<HttpBinHeaders, Void> response) {
cbResult.response = response;
latch.countDown();
}
@Override
public void onFailure(Throwable error) {
cbResult.error = error;
latch.countDown();
}
});
awaitOnLatch(latch, "service20PutOnlyHeaders");
if (cbResult.error != null) {
Assertions.fail(cbResult.error);
} else {
final ResponseBase<HttpBinHeaders, Void> response = cbResult.response;
assertNotNull(response);
assertEquals(200, response.getStatusCode());
final HttpBinHeaders headers = response.getDeserializedHeaders();
assertNotNull(headers);
assertTrue(headers.accessControlAllowCredentials());
assertNotNull(headers.date());
assertNotEquals(0, (Object) headers.xProcessedTime());
}
}
use of com.azure.android.core.rest.ResponseBase in project azure-sdk-for-android by Azure.
the class RestProxyTests method service20GetBytes100BodyAndHeaders.
@Test
public void service20GetBytes100BodyAndHeaders() {
CountDownLatch latch = new CountDownLatch(1);
CallbackResultBase<HttpBinHeaders, byte[]> cbResult = new CallbackResultBase<>();
createService(Service20.class).getBytes100BodyAndHeaders(new Callback<ResponseBase<HttpBinHeaders, byte[]>>() {
@Override
public void onSuccess(ResponseBase<HttpBinHeaders, byte[]> response) {
cbResult.response = response;
latch.countDown();
}
@Override
public void onFailure(Throwable error) {
cbResult.error = error;
latch.countDown();
}
});
awaitOnLatch(latch, "service20GetBytes100BodyAndHeaders");
if (cbResult.error != null) {
Assertions.fail(cbResult.error);
} else {
final ResponseBase<HttpBinHeaders, byte[]> response = cbResult.response;
assertNotNull(response);
assertEquals(200, response.getStatusCode());
final byte[] body = response.getValue();
assertNotNull(body);
assertEquals(100, body.length);
final HttpBinHeaders headers = response.getDeserializedHeaders();
assertNotNull(headers);
assertTrue(headers.accessControlAllowCredentials());
assertNotNull(headers.date());
assertNotEquals(0, (Object) headers.xProcessedTime());
}
}
use of com.azure.android.core.rest.ResponseBase in project azure-sdk-for-android by Azure.
the class RestProxyTests method service20GetBytesOnlyStatus.
@Test
public void service20GetBytesOnlyStatus() {
CountDownLatch latch = new CountDownLatch(1);
CallbackResultBase<Void, Void> cbResult = new CallbackResultBase<>();
createService(Service20.class).getBytesOnlyStatus(new Callback<ResponseBase<Void, Void>>() {
@Override
public void onSuccess(ResponseBase<Void, Void> response) {
cbResult.response = response;
latch.countDown();
}
@Override
public void onFailure(Throwable error) {
cbResult.error = error;
latch.countDown();
}
});
awaitOnLatch(latch, "service20GetBytesOnlyStatus");
if (cbResult.error != null) {
Assertions.fail(cbResult.error);
} else {
final ResponseBase<Void, Void> response = cbResult.response;
assertNotNull(response);
assertEquals(200, response.getStatusCode());
}
}
use of com.azure.android.core.rest.ResponseBase in project azure-sdk-for-android by Azure.
the class RestProxyTests method service20PutBodyAndHeaders.
@Test
public void service20PutBodyAndHeaders() {
CountDownLatch latch = new CountDownLatch(1);
CallbackResultBase<HttpBinHeaders, HttpBinJSON> cbResult = new CallbackResultBase<>();
createService(Service20.class).putBodyAndHeaders("body string", new Callback<ResponseBase<HttpBinHeaders, HttpBinJSON>>() {
@Override
public void onSuccess(ResponseBase<HttpBinHeaders, HttpBinJSON> response) {
cbResult.response = response;
latch.countDown();
}
@Override
public void onFailure(Throwable error) {
cbResult.error = error;
latch.countDown();
}
});
awaitOnLatch(latch, "service20PutBodyAndHeaders");
if (cbResult.error != null) {
Assertions.fail(cbResult.error);
} else {
final ResponseBase<HttpBinHeaders, HttpBinJSON> response = cbResult.response;
assertNotNull(response);
assertEquals(200, response.getStatusCode());
final HttpBinJSON body = response.getValue();
assertNotNull(body);
assertMatchWithHttpOrHttps("localhost/put", body.url());
assertEquals("body string", body.data());
final HttpBinHeaders headers = response.getDeserializedHeaders();
assertNotNull(headers);
assertTrue(headers.accessControlAllowCredentials());
assertNotNull(headers.date());
assertNotEquals(0, (Object) headers.xProcessedTime());
}
}
use of com.azure.android.core.rest.ResponseBase in project azure-sdk-for-android by Azure.
the class RestProxyTests method service20GetBytesOnlyHeaders.
@Test
public void service20GetBytesOnlyHeaders() {
CountDownLatch latch = new CountDownLatch(1);
CallbackResultBase<HttpBinHeaders, Void> cbResult = new CallbackResultBase<>();
createService(Service20.class).getBytes100OnlyRawHeaders(new Callback<ResponseBase<HttpBinHeaders, Void>>() {
@Override
public void onSuccess(ResponseBase<HttpBinHeaders, Void> response) {
cbResult.response = response;
latch.countDown();
}
@Override
public void onFailure(Throwable error) {
cbResult.error = error;
latch.countDown();
}
});
awaitOnLatch(latch, "service20GetBytesOnlyHeaders");
if (cbResult.error != null) {
Assertions.fail(cbResult.error);
} else {
final ResponseBase<HttpBinHeaders, Void> response = cbResult.response;
assertNotNull(response);
assertEquals(200, response.getStatusCode());
assertNotNull(response.getHeaders());
assertNotEquals(0, response.getHeaders().getSize());
}
}
Aggregations