Package org.asynchttpclient

Examples of org.asynchttpclient.AsyncHttpClient.prepareGet()


    @Test(groups = { "standalone", "default_provider" })
    public void getShouldAllowBody() throws IOException {
        AsyncHttpClient client = getAsyncHttpClient(null);
        try {
            client.prepareGet(getTargetUrl()).setBody("Boo!").execute();
        } finally {
            client.close();
        }
    }
View Full Code Here


    @Test(groups = { "standalone", "default_provider" }, expectedExceptions = { NullPointerException.class })
    public void invalidUri() throws Exception {
        AsyncHttpClient client = getAsyncHttpClient(null);
        try {
            client.prepareGet(String.format("http:127.0.0.1:%d/foo/test", port1)).build();
        } finally {
            client.close();
        }
    }
View Full Code Here

    @Test(groups = { "standalone", "default_provider" })
    public void asyncHttpClientConfigBeanTest() throws Exception {
        AsyncHttpClient client = getAsyncHttpClient(new AsyncHttpClientConfigBean().setUserAgent("test"));
        try {
            Response response = client.executeRequest(client.prepareGet(getTargetUrl()).build()).get();
            assertEquals(200, response.getStatusCode());
        } finally {
            client.close();
        }
    }
View Full Code Here

    @Test(groups = { "default_provider", "async" })
    public void bodyAsByteTest() throws Exception {
        final AsyncHttpClient client = getAsyncHttpClient(null);
        try {
            Response response = client.prepareGet(getTargetUrl()).execute().get();
            assertEquals(response.getStatusCode(), 200);
            assertEquals(response.getResponseBodyAsBytes(), new byte[] {});
        } finally {
            client.close();
        }
View Full Code Here

    @Test(groups = { "online", "default_provider", "async" }, expectedExceptions = { NullPointerException.class })
    public void asyncNullSchemeTest() throws Exception {
        AsyncHttpClient client = getAsyncHttpClient(null);

        try {
            client.prepareGet("www.sun.com").execute();
        } finally {
            client.close();
        }
    }
View Full Code Here

    public void asyncDoGetTransferEncodingTest() throws Exception {
        AsyncHttpClient client = getAsyncHttpClient(null);
        try {
            final CountDownLatch l = new CountDownLatch(1);

            client.prepareGet(getTargetUrl()).execute(new AsyncCompletionHandlerAdapter() {

                @Override
                public Response onCompleted(Response response) throws Exception {
                    try {
                        assertEquals(response.getStatusCode(), 200);
View Full Code Here

            h.add("Test1", "Test1");
            h.add("Test2", "Test2");
            h.add("Test3", "Test3");
            h.add("Test4", "Test4");
            h.add("Test5", "Test5");
            client.prepareGet(getTargetUrl()).setHeaders(h).execute(new AsyncCompletionHandlerAdapter() {

                @Override
                public Response onCompleted(Response response) throws Exception {
                    try {
                        assertEquals(response.getStatusCode(), 200);
View Full Code Here

            h.add("Test3", "Test3");
            h.add("Test4", "Test4");
            h.add("Test5", "Test5");

            final Cookie coo = Cookie.newValidCookie("foo", "value", "value", "/", "/", -1L, -1, false, false);
            client.prepareGet(getTargetUrl()).setHeaders(h).addCookie(coo).execute(new AsyncCompletionHandlerAdapter() {

                @Override
                public Response onCompleted(Response response) throws Exception {
                    try {
                        assertEquals(response.getStatusCode(), 200);
View Full Code Here

    public void testListenableFuture() throws Exception {
        final AtomicInteger statusCode = new AtomicInteger(500);
        AsyncHttpClient ahc = getAsyncHttpClient(null);
        try {
            final CountDownLatch latch = new CountDownLatch(1);
            final ListenableFuture<Response> future = ahc.prepareGet(getTargetUrl()).execute();
            future.addListener(new Runnable() {

                public void run() {
                    try {
                        statusCode.set(future.get().getStatusCode());
View Full Code Here

    @Test(groups = { "standalone", "default_provider" })
    public void testRequestTimeout() throws IOException {
        AsyncHttpClient client = getAsyncHttpClient(null);
        try {
            Future<Response> responseFuture = client.prepareGet(getTargetUrl()).setRequestTimeoutInMs(100).execute();
            Response response = responseFuture.get(2000, TimeUnit.MILLISECONDS);
            assertNull(response);
        } catch (InterruptedException e) {
            fail("Interrupted.", e);
        } catch (ExecutionException e) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.