Package org.asynchttpclient

Examples of org.asynchttpclient.AsyncHttpClient.executeRequest()


    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

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

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

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

    public void propFindWebDavTest() 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);

            Request putRequest = new RequestBuilder("PUT").setUrl(String.format("http://127.0.0.1:%s/folder1/Test.txt", port1)).setBody("this is a test").build();
            response = c.executeRequest(putRequest).get();
            assertEquals(response.getStatusCode(), 201);
View Full Code Here

            Request mkcolRequest = new RequestBuilder("MKCOL").setUrl(getTargetUrl()).build();
            Response response = c.executeRequest(mkcolRequest).get();
            assertEquals(response.getStatusCode(), 201);

            Request putRequest = new RequestBuilder("PUT").setUrl(String.format("http://127.0.0.1:%s/folder1/Test.txt", port1)).setBody("this is a test").build();
            response = c.executeRequest(putRequest).get();
            assertEquals(response.getStatusCode(), 201);

            Request propFindRequest = new RequestBuilder("PROPFIND").setUrl(String.format("http://127.0.0.1:%s/folder1/Test.txt", port1)).build();
            response = c.executeRequest(propFindRequest).get();
View Full Code Here

            Request putRequest = new RequestBuilder("PUT").setUrl(String.format("http://127.0.0.1:%s/folder1/Test.txt", port1)).setBody("this is a test").build();
            response = c.executeRequest(putRequest).get();
            assertEquals(response.getStatusCode(), 201);

            Request propFindRequest = new RequestBuilder("PROPFIND").setUrl(String.format("http://127.0.0.1:%s/folder1/Test.txt", port1)).build();
            response = c.executeRequest(propFindRequest).get();

            assertEquals(response.getStatusCode(), 207);
            assertTrue(response.getResponseBody().contains("<status>HTTP/1.1 200 OK</status>"));
        } finally {
            c.close();
View Full Code Here

    public void propFindCompletionHandlerWebDavTest() 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);

            Request propFindRequest = new RequestBuilder("PROPFIND").setUrl(getTargetUrl()).build();
            WebDavResponse webDavResponse = c.executeRequest(propFindRequest, new WebDavCompletionHandlerBase<WebDavResponse>() {
                /**
 
View Full Code Here

            Request mkcolRequest = new RequestBuilder("MKCOL").setUrl(getTargetUrl()).build();
            Response response = c.executeRequest(mkcolRequest).get();
            assertEquals(response.getStatusCode(), 201);

            Request propFindRequest = new RequestBuilder("PROPFIND").setUrl(getTargetUrl()).build();
            WebDavResponse webDavResponse = c.executeRequest(propFindRequest, new WebDavCompletionHandlerBase<WebDavResponse>() {
                /**
                 * {@inheritDoc}
                 */
                @Override
                public void onThrowable(Throwable t) {
View Full Code Here

    @Test(groups = { "standalone", "default_provider" })
    public void testMaxRetry() throws Exception {
        AsyncHttpClient ahc = getAsyncHttpClient(new AsyncHttpClientConfig.Builder().setMaxRequestRetry(0).build());
        try {
            ahc.executeRequest(ahc.prepareGet(getTargetUrl()).build()).get();
            fail();
        } catch (Exception t) {
            assertNotNull(t.getCause());
            assertEquals(t.getCause().getClass(), IOException.class);
            if (t.getCause() != AsyncHttpProviderUtils.REMOTELY_CLOSED_EXCEPTION) {
View Full Code Here

                .setAsyncHttpClientProviderConfig(nettyConfig).build());

        try {
            final CountDownLatch l = new CountDownLatch(1);
            Request request = new RequestBuilder("GET").setUrl(getTargetUrl()).build();
            p.executeRequest(request, new AsyncCompletionHandlerAdapter() {
                @Override
                public Response onCompleted(Response response) throws Exception {
                    try {
                        assertEquals(response.getStatusCode(), 200);
                        assertEquals(response.getHeader("X-Original-Content-Encoding"), "<original encoding>");
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.