Package org.asynchttpclient

Examples of org.asynchttpclient.Response


        });
        AsyncHttpClient c = getAsyncHttpClient(b.build());

        try {
            Response response = c.preparePost(getTargetUrl()).execute().get();

            assertNotNull(response);
            assertEquals(response.getStatusCode(), 200);
        } finally {
            c.close();
        }
    }
View Full Code Here


        });
        AsyncHttpClient c = getAsyncHttpClient(b.build());

        try {
            Response response = c.preparePost(getTargetUrl()).execute().get();

            assertNotNull(response);
            assertEquals(response.getStatusCode(), 200);
            assertEquals(response.getHeader("X-Replay"), "true");
        } finally {
            c.close();
        }
    }
View Full Code Here

        });
        AsyncHttpClient c = getAsyncHttpClient(b.build());

        try {
            Response response = c.preparePost(getTargetUrl()).execute().get();

            assertNotNull(response);
            assertEquals(response.getStatusCode(), 200);
            assertEquals(response.getHeader("X-Replay"), "true");
        } finally {
            c.close();
        }
    }
View Full Code Here

        });
        AsyncHttpClient c = getAsyncHttpClient(b.build());

        try {
            Response response = c.preparePost(getTargetUrl()).addHeader("Ping", "Pong").execute().get();

            assertNotNull(response);
            assertEquals(response.getStatusCode(), 200);
            assertEquals(response.getHeader("Ping"), "Pong");
        } finally {
            c.close();
        }
    }
View Full Code Here

        AsyncHttpClient client = getAsyncHttpClient(null);
        try {
            Future<Response> f = client.prepareGet("http://127.0.0.1:" + port1 + "/")//
                    .setRealm(new Realm.RealmBuilder().setPrincipal(USER).setPassword(ADMIN).setRealmName("MyRealm").setScheme(Realm.AuthScheme.DIGEST).build())//
                    .execute();
            Response resp = f.get(60, TimeUnit.SECONDS);
            assertNotNull(resp);
            assertEquals(resp.getStatusCode(), HttpServletResponse.SC_OK);
            assertNotNull(resp.getHeader("X-Auth"));
        } finally {
            client.close();
        }
    }
View Full Code Here

        AsyncHttpClient client = getAsyncHttpClient(null);
        try {
            Future<Response> f = client.prepareGet("http://127.0.0.1:" + port1 + "/")//
                    .setRealm(new Realm.RealmBuilder().setPrincipal(USER).setPassword(ADMIN).setRealmName("MyRealm").build())//
                    .execute();
            Response resp = f.get(60, TimeUnit.SECONDS);
            assertNotNull(resp);
            assertEquals(resp.getStatusCode(), HttpServletResponse.SC_OK);
            assertNotNull(resp.getHeader("X-Auth"));
        } finally {
            client.close();
        }
    }
View Full Code Here

        AsyncHttpClient client = getAsyncHttpClient(null);
        try {
            Future<Response> f = client.prepareGet("http://127.0.0.1:" + port1 + "/")//
                    .setRealm(new Realm.RealmBuilder().setPrincipal("fake").setPassword(ADMIN).setScheme(Realm.AuthScheme.DIGEST).build())//
                    .execute();
            Response resp = f.get(20, TimeUnit.SECONDS);
            assertNotNull(resp);
            assertEquals(resp.getStatusCode(), 401);
        } finally {
            client.close();
        }
    }
View Full Code Here

    @Test(groups = { "standalone", "default_provider" })
    public void testPutEmptyBody() throws Exception {
        AsyncHttpClient ahc = getAsyncHttpClient(null);
        try {
            Response response = ahc.preparePut(getTargetUrl()).setBody("String").execute().get();

            assertNotNull(response);
            assertEquals(response.getStatusCode(), 204);
            assertEquals(response.getResponseBody(), "");
            assertTrue(response.getResponseBodyAsStream() instanceof InputStream);
            assertEquals(response.getResponseBodyAsStream().read(), -1);
        } finally {
            ahc.close();
        }
    }
View Full Code Here

    public void mkcolWebDavTest1() throws InterruptedException, IOException, ExecutionException {

        AsyncHttpClient c = getAsyncHttpClient(null);
        try {
            Request mkcolRequest = new RequestBuilder("MKCOL").setUrl(getTargetUrl()).build();
            Response response = c.executeRequest(mkcolRequest).get();

            assertEquals(response.getStatusCode(), 201);
        } finally {
            c.close();
        }
    }
View Full Code Here

    public void mkcolWebDavTest2() throws InterruptedException, IOException, ExecutionException {

        AsyncHttpClient c = getAsyncHttpClient(null);
        try {
            Request mkcolRequest = new RequestBuilder("MKCOL").setUrl(getTargetUrl() + "/folder2").build();
            Response response = c.executeRequest(mkcolRequest).get();
            assertEquals(response.getStatusCode(), 409);
        } finally {
            c.close();
        }
    }
View Full Code Here

TOP

Related Classes of org.asynchttpclient.Response

Copyright © 2018 www.massapicom. 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.