Search in sources :

Example 56 with Headers

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));
}
Also used : HeaderResponseDatetimeHeaders(fixtures.header.models.HeaderResponseDatetimeHeaders) HeaderResponseEnumHeaders(fixtures.header.models.HeaderResponseEnumHeaders) HeaderResponseLongHeaders(fixtures.header.models.HeaderResponseLongHeaders) HeaderResponseProtectedKeyHeaders(fixtures.header.models.HeaderResponseProtectedKeyHeaders) Headers(okhttp3.Headers) HeaderResponseDurationHeaders(fixtures.header.models.HeaderResponseDurationHeaders) HeaderResponseDatetimeRfc1123Headers(fixtures.header.models.HeaderResponseDatetimeRfc1123Headers) ServiceResponseWithHeaders(com.microsoft.rest.ServiceResponseWithHeaders) HeaderResponseDateHeaders(fixtures.header.models.HeaderResponseDateHeaders) HeaderResponseByteHeaders(fixtures.header.models.HeaderResponseByteHeaders) HeaderResponseDoubleHeaders(fixtures.header.models.HeaderResponseDoubleHeaders) HeaderResponseBoolHeaders(fixtures.header.models.HeaderResponseBoolHeaders) HeaderResponseStringHeaders(fixtures.header.models.HeaderResponseStringHeaders) HeaderResponseExistingKeyHeaders(fixtures.header.models.HeaderResponseExistingKeyHeaders) HeaderResponseFloatHeaders(fixtures.header.models.HeaderResponseFloatHeaders) HeaderResponseIntegerHeaders(fixtures.header.models.HeaderResponseIntegerHeaders) CountDownLatch(java.util.concurrent.CountDownLatch) ServiceResponseWithHeaders(com.microsoft.rest.ServiceResponseWithHeaders) HeaderResponseByteHeaders(fixtures.header.models.HeaderResponseByteHeaders) Test(org.junit.Test)

Example 57 with Headers

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));
}
Also used : HeaderResponseDatetimeHeaders(fixtures.header.models.HeaderResponseDatetimeHeaders) HeaderResponseEnumHeaders(fixtures.header.models.HeaderResponseEnumHeaders) HeaderResponseLongHeaders(fixtures.header.models.HeaderResponseLongHeaders) HeaderResponseProtectedKeyHeaders(fixtures.header.models.HeaderResponseProtectedKeyHeaders) Headers(okhttp3.Headers) HeaderResponseDurationHeaders(fixtures.header.models.HeaderResponseDurationHeaders) HeaderResponseDatetimeRfc1123Headers(fixtures.header.models.HeaderResponseDatetimeRfc1123Headers) ServiceResponseWithHeaders(com.microsoft.rest.ServiceResponseWithHeaders) HeaderResponseDateHeaders(fixtures.header.models.HeaderResponseDateHeaders) HeaderResponseByteHeaders(fixtures.header.models.HeaderResponseByteHeaders) HeaderResponseDoubleHeaders(fixtures.header.models.HeaderResponseDoubleHeaders) HeaderResponseBoolHeaders(fixtures.header.models.HeaderResponseBoolHeaders) HeaderResponseStringHeaders(fixtures.header.models.HeaderResponseStringHeaders) HeaderResponseExistingKeyHeaders(fixtures.header.models.HeaderResponseExistingKeyHeaders) HeaderResponseFloatHeaders(fixtures.header.models.HeaderResponseFloatHeaders) HeaderResponseIntegerHeaders(fixtures.header.models.HeaderResponseIntegerHeaders) CountDownLatch(java.util.concurrent.CountDownLatch) ServiceResponseWithHeaders(com.microsoft.rest.ServiceResponseWithHeaders) HeaderResponseBoolHeaders(fixtures.header.models.HeaderResponseBoolHeaders) Test(org.junit.Test)

Example 58 with Headers

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));
}
Also used : HeaderResponseDatetimeHeaders(fixtures.header.models.HeaderResponseDatetimeHeaders) HeaderResponseEnumHeaders(fixtures.header.models.HeaderResponseEnumHeaders) HeaderResponseLongHeaders(fixtures.header.models.HeaderResponseLongHeaders) HeaderResponseProtectedKeyHeaders(fixtures.header.models.HeaderResponseProtectedKeyHeaders) Headers(okhttp3.Headers) HeaderResponseDurationHeaders(fixtures.header.models.HeaderResponseDurationHeaders) HeaderResponseDatetimeRfc1123Headers(fixtures.header.models.HeaderResponseDatetimeRfc1123Headers) ServiceResponseWithHeaders(com.microsoft.rest.ServiceResponseWithHeaders) HeaderResponseDateHeaders(fixtures.header.models.HeaderResponseDateHeaders) HeaderResponseByteHeaders(fixtures.header.models.HeaderResponseByteHeaders) HeaderResponseDoubleHeaders(fixtures.header.models.HeaderResponseDoubleHeaders) HeaderResponseBoolHeaders(fixtures.header.models.HeaderResponseBoolHeaders) HeaderResponseStringHeaders(fixtures.header.models.HeaderResponseStringHeaders) HeaderResponseExistingKeyHeaders(fixtures.header.models.HeaderResponseExistingKeyHeaders) HeaderResponseFloatHeaders(fixtures.header.models.HeaderResponseFloatHeaders) HeaderResponseIntegerHeaders(fixtures.header.models.HeaderResponseIntegerHeaders) HeaderResponseStringHeaders(fixtures.header.models.HeaderResponseStringHeaders) CountDownLatch(java.util.concurrent.CountDownLatch) ServiceResponseWithHeaders(com.microsoft.rest.ServiceResponseWithHeaders) Test(org.junit.Test)

Example 59 with Headers

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));
}
Also used : HeaderResponseDatetimeHeaders(fixtures.header.models.HeaderResponseDatetimeHeaders) HeaderResponseEnumHeaders(fixtures.header.models.HeaderResponseEnumHeaders) HeaderResponseLongHeaders(fixtures.header.models.HeaderResponseLongHeaders) HeaderResponseProtectedKeyHeaders(fixtures.header.models.HeaderResponseProtectedKeyHeaders) Headers(okhttp3.Headers) HeaderResponseDurationHeaders(fixtures.header.models.HeaderResponseDurationHeaders) HeaderResponseDatetimeRfc1123Headers(fixtures.header.models.HeaderResponseDatetimeRfc1123Headers) ServiceResponseWithHeaders(com.microsoft.rest.ServiceResponseWithHeaders) HeaderResponseDateHeaders(fixtures.header.models.HeaderResponseDateHeaders) HeaderResponseByteHeaders(fixtures.header.models.HeaderResponseByteHeaders) HeaderResponseDoubleHeaders(fixtures.header.models.HeaderResponseDoubleHeaders) HeaderResponseBoolHeaders(fixtures.header.models.HeaderResponseBoolHeaders) HeaderResponseStringHeaders(fixtures.header.models.HeaderResponseStringHeaders) HeaderResponseExistingKeyHeaders(fixtures.header.models.HeaderResponseExistingKeyHeaders) HeaderResponseFloatHeaders(fixtures.header.models.HeaderResponseFloatHeaders) HeaderResponseIntegerHeaders(fixtures.header.models.HeaderResponseIntegerHeaders) CountDownLatch(java.util.concurrent.CountDownLatch) ServiceResponseWithHeaders(com.microsoft.rest.ServiceResponseWithHeaders) HeaderResponseIntegerHeaders(fixtures.header.models.HeaderResponseIntegerHeaders) Test(org.junit.Test)

Example 60 with Headers

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));
}
Also used : HeaderResponseDatetimeRfc1123Headers(fixtures.header.models.HeaderResponseDatetimeRfc1123Headers) HeaderResponseDatetimeHeaders(fixtures.header.models.HeaderResponseDatetimeHeaders) HeaderResponseEnumHeaders(fixtures.header.models.HeaderResponseEnumHeaders) HeaderResponseLongHeaders(fixtures.header.models.HeaderResponseLongHeaders) HeaderResponseProtectedKeyHeaders(fixtures.header.models.HeaderResponseProtectedKeyHeaders) Headers(okhttp3.Headers) HeaderResponseDurationHeaders(fixtures.header.models.HeaderResponseDurationHeaders) HeaderResponseDatetimeRfc1123Headers(fixtures.header.models.HeaderResponseDatetimeRfc1123Headers) ServiceResponseWithHeaders(com.microsoft.rest.ServiceResponseWithHeaders) HeaderResponseDateHeaders(fixtures.header.models.HeaderResponseDateHeaders) HeaderResponseByteHeaders(fixtures.header.models.HeaderResponseByteHeaders) HeaderResponseDoubleHeaders(fixtures.header.models.HeaderResponseDoubleHeaders) HeaderResponseBoolHeaders(fixtures.header.models.HeaderResponseBoolHeaders) HeaderResponseStringHeaders(fixtures.header.models.HeaderResponseStringHeaders) HeaderResponseExistingKeyHeaders(fixtures.header.models.HeaderResponseExistingKeyHeaders) HeaderResponseFloatHeaders(fixtures.header.models.HeaderResponseFloatHeaders) HeaderResponseIntegerHeaders(fixtures.header.models.HeaderResponseIntegerHeaders) CountDownLatch(java.util.concurrent.CountDownLatch) ServiceResponseWithHeaders(com.microsoft.rest.ServiceResponseWithHeaders) Test(org.junit.Test)

Aggregations

Headers (okhttp3.Headers)128 Request (okhttp3.Request)61 Response (okhttp3.Response)54 Test (org.junit.Test)40 IOException (java.io.IOException)32 Call (okhttp3.Call)30 RequestBody (okhttp3.RequestBody)25 CancelledException (com.hippo.ehviewer.client.exception.CancelledException)20 EhException (com.hippo.ehviewer.client.exception.EhException)20 NoHAtHClientException (com.hippo.ehviewer.client.exception.NoHAtHClientException)20 ParseException (com.hippo.ehviewer.client.exception.ParseException)20 StatusCodeException (com.hippo.network.StatusCodeException)20 ResponseBody (okhttp3.ResponseBody)18 HttpHeaders (okhttp3.internal.http.HttpHeaders)18 MediaType (okhttp3.MediaType)15 ServiceResponseWithHeaders (com.microsoft.rest.ServiceResponseWithHeaders)14 HeaderResponseBoolHeaders (fixtures.header.models.HeaderResponseBoolHeaders)14 HeaderResponseByteHeaders (fixtures.header.models.HeaderResponseByteHeaders)14 HeaderResponseDateHeaders (fixtures.header.models.HeaderResponseDateHeaders)14 HeaderResponseDatetimeHeaders (fixtures.header.models.HeaderResponseDatetimeHeaders)14