use of com.amazonaws.services.s3.Headers in project autorest.java by Azure.
the class HeaderOperationsTests method responseByte.
@Test
public void responseByte() throws Exception {
lock = new CountDownLatch(1);
client.headers().responseByteWithServiceResponseAsync("valid").subscribe(new Action1<ServiceResponseWithHeaders<Void, HeaderResponseByteHeaders>>() {
@Override
public void call(ServiceResponseWithHeaders<Void, HeaderResponseByteHeaders> response) {
Headers headers = response.response().headers();
if (headers.get("value") != null) {
byte[] value = Base64.decodeBase64(headers.get("value"));
String actual = new String(value, Charset.forName("UTF-8"));
Assert.assertEquals("啊齄丂狛狜隣郎隣兀﨩", actual);
lock.countDown();
}
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
fail();
}
});
Assert.assertTrue(lock.await(1000, TimeUnit.MILLISECONDS));
}
use of com.amazonaws.services.s3.Headers in project autorest.java by Azure.
the class HeaderOperationsTests method responseBool.
@Test
public void responseBool() throws Exception {
lock = new CountDownLatch(1);
client.headers().responseBoolWithServiceResponseAsync("true").subscribe(new Action1<ServiceResponseWithHeaders<Void, HeaderResponseBoolHeaders>>() {
@Override
public void call(ServiceResponseWithHeaders<Void, HeaderResponseBoolHeaders> response) {
Headers headers = response.response().headers();
if (headers.get("value") != null) {
Assert.assertEquals("true", headers.get("value"));
lock.countDown();
}
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
fail();
}
});
Assert.assertTrue(lock.await(1000, TimeUnit.MILLISECONDS));
lock = new CountDownLatch(1);
client.headers().responseBoolWithServiceResponseAsync("false").subscribe(new Action1<ServiceResponseWithHeaders<Void, HeaderResponseBoolHeaders>>() {
@Override
public void call(ServiceResponseWithHeaders<Void, HeaderResponseBoolHeaders> response) {
Headers headers = response.response().headers();
if (headers.get("value") != null) {
Assert.assertEquals("false", headers.get("value"));
lock.countDown();
}
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
fail();
}
});
Assert.assertTrue(lock.await(1000, TimeUnit.MILLISECONDS));
}
use of com.amazonaws.services.s3.Headers in project autorest.java by Azure.
the class HeaderOperationsTests method responseString.
@Test
public void responseString() throws Exception {
lock = new CountDownLatch(1);
client.headers().responseStringWithServiceResponseAsync("valid").subscribe(new Action1<ServiceResponseWithHeaders<Void, HeaderResponseStringHeaders>>() {
@Override
public void call(ServiceResponseWithHeaders<Void, HeaderResponseStringHeaders> response) {
Headers headers = response.response().headers();
if (headers.get("value") != null) {
Assert.assertEquals("The quick brown fox jumps over the lazy dog", headers.get("value"));
lock.countDown();
}
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
fail();
}
});
Assert.assertTrue(lock.await(1000, TimeUnit.MILLISECONDS));
lock = new CountDownLatch(1);
client.headers().responseStringWithServiceResponseAsync("null").subscribe(new Action1<ServiceResponseWithHeaders<Void, HeaderResponseStringHeaders>>() {
@Override
public void call(ServiceResponseWithHeaders<Void, HeaderResponseStringHeaders> response) {
Headers headers = response.response().headers();
if (headers.get("value") != null) {
Assert.assertEquals("null", headers.get("value"));
lock.countDown();
}
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
fail();
}
});
Assert.assertTrue(lock.await(1000, TimeUnit.MILLISECONDS));
lock = new CountDownLatch(1);
client.headers().responseStringWithServiceResponseAsync("empty").subscribe(new Action1<ServiceResponseWithHeaders<Void, HeaderResponseStringHeaders>>() {
@Override
public void call(ServiceResponseWithHeaders<Void, HeaderResponseStringHeaders> response) {
Headers headers = response.response().headers();
if (headers.get("value") != null) {
Assert.assertEquals("", headers.get("value"));
lock.countDown();
}
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
fail();
}
});
Assert.assertTrue(lock.await(1000, TimeUnit.MILLISECONDS));
}
use of com.amazonaws.services.s3.Headers in project autorest.java by Azure.
the class HeaderOperationsTests method responseInteger.
@Test
public void responseInteger() throws Exception {
lock = new CountDownLatch(1);
client.headers().responseIntegerWithServiceResponseAsync("positive").subscribe(new Action1<ServiceResponseWithHeaders<Void, HeaderResponseIntegerHeaders>>() {
@Override
public void call(ServiceResponseWithHeaders<Void, HeaderResponseIntegerHeaders> response) {
Headers headers = response.response().headers();
if (headers.get("value") != null) {
Assert.assertEquals("1", headers.get("value"));
lock.countDown();
}
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
fail();
}
});
Assert.assertTrue(lock.await(1000, TimeUnit.MILLISECONDS));
lock = new CountDownLatch(1);
client.headers().responseIntegerWithServiceResponseAsync("negative").subscribe(new Action1<ServiceResponseWithHeaders<Void, HeaderResponseIntegerHeaders>>() {
@Override
public void call(ServiceResponseWithHeaders<Void, HeaderResponseIntegerHeaders> response) {
Headers headers = response.response().headers();
if (headers.get("value") != null) {
Assert.assertEquals("-2", headers.get("value"));
lock.countDown();
}
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
fail();
}
});
Assert.assertTrue(lock.await(1000, TimeUnit.MILLISECONDS));
}
use of com.amazonaws.services.s3.Headers in project autorest.java by Azure.
the class HeaderOperationsTests method responseDatetimeRfc1123.
@Test
public void responseDatetimeRfc1123() throws Exception {
lock = new CountDownLatch(1);
client.headers().responseDatetimeRfc1123WithServiceResponseAsync("valid").subscribe(new Action1<ServiceResponseWithHeaders<Void, HeaderResponseDatetimeRfc1123Headers>>() {
@Override
public void call(ServiceResponseWithHeaders<Void, HeaderResponseDatetimeRfc1123Headers> response) {
Headers headers = response.response().headers();
if (headers.get("value") != null) {
Assert.assertEquals("Fri, 01 Jan 2010 12:34:56 GMT", headers.get("value"));
lock.countDown();
}
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
fail();
}
});
Assert.assertTrue(lock.await(100000, TimeUnit.MILLISECONDS));
lock = new CountDownLatch(1);
client.headers().responseDatetimeRfc1123WithServiceResponseAsync("min").subscribe(new Action1<ServiceResponseWithHeaders<Void, HeaderResponseDatetimeRfc1123Headers>>() {
@Override
public void call(ServiceResponseWithHeaders<Void, HeaderResponseDatetimeRfc1123Headers> response) {
Headers headers = response.response().headers();
if (headers.get("value") != null) {
Assert.assertEquals("Mon, 01 Jan 0001 00:00:00 GMT", headers.get("value"));
lock.countDown();
}
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
fail();
}
});
Assert.assertTrue(lock.await(1000, TimeUnit.MILLISECONDS));
}
Aggregations