Search in sources :

Example 36 with RequestBuilder

use of org.asynchttpclient.RequestBuilder in project async-http-client by AsyncHttpClient.

the class WebdavTest method propFindWebDavTest.

@Test
public void propFindWebDavTest() throws InterruptedException, IOException, ExecutionException {
    try (AsyncHttpClient c = asyncHttpClient()) {
        Request mkcolRequest = new RequestBuilder("MKCOL").setUrl(getTargetUrl()).build();
        Response response = c.executeRequest(mkcolRequest).get();
        assertEquals(response.getStatusCode(), 201);
        Request putRequest = put(getTargetUrl() + "/Test.txt").setBody("this is a test").build();
        response = c.executeRequest(putRequest).get();
        assertEquals(response.getStatusCode(), 201);
        Request propFindRequest = new RequestBuilder("PROPFIND").setUrl(getTargetUrl() + "/Test.txt").build();
        response = c.executeRequest(propFindRequest).get();
        assertEquals(response.getStatusCode(), 207);
        assertTrue(response.getResponseBody().contains("HTTP/1.1 200 OK"), "Got " + response.getResponseBody());
    }
}
Also used : Response(org.asynchttpclient.Response) RequestBuilder(org.asynchttpclient.RequestBuilder) Request(org.asynchttpclient.Request) AsyncHttpClient(org.asynchttpclient.AsyncHttpClient) Test(org.testng.annotations.Test)

Example 37 with RequestBuilder

use of org.asynchttpclient.RequestBuilder in project async-http-client by AsyncHttpClient.

the class WebdavTest method mkcolWebDavTest1.

@Test
public void mkcolWebDavTest1() throws InterruptedException, IOException, ExecutionException {
    try (AsyncHttpClient c = asyncHttpClient()) {
        Request mkcolRequest = new RequestBuilder("MKCOL").setUrl(getTargetUrl()).build();
        Response response = c.executeRequest(mkcolRequest).get();
        assertEquals(response.getStatusCode(), 201);
    }
}
Also used : Response(org.asynchttpclient.Response) RequestBuilder(org.asynchttpclient.RequestBuilder) Request(org.asynchttpclient.Request) AsyncHttpClient(org.asynchttpclient.AsyncHttpClient) Test(org.testng.annotations.Test)

Example 38 with RequestBuilder

use of org.asynchttpclient.RequestBuilder in project async-http-client by AsyncHttpClient.

the class WebdavTest method basicPropFindWebDavTest.

@Test
public void basicPropFindWebDavTest() throws InterruptedException, IOException, ExecutionException {
    try (AsyncHttpClient c = asyncHttpClient()) {
        Request propFindRequest = new RequestBuilder("PROPFIND").setUrl(getTargetUrl()).build();
        Response response = c.executeRequest(propFindRequest).get();
        assertEquals(response.getStatusCode(), 404);
    }
}
Also used : Response(org.asynchttpclient.Response) RequestBuilder(org.asynchttpclient.RequestBuilder) Request(org.asynchttpclient.Request) AsyncHttpClient(org.asynchttpclient.AsyncHttpClient) Test(org.testng.annotations.Test)

Example 39 with RequestBuilder

use of org.asynchttpclient.RequestBuilder in project async-http-client by AsyncHttpClient.

the class WebdavTest method mkcolWebDavTest2.

@Test
public void mkcolWebDavTest2() throws InterruptedException, IOException, ExecutionException {
    try (AsyncHttpClient c = asyncHttpClient()) {
        Request mkcolRequest = new RequestBuilder("MKCOL").setUrl(getTargetUrl() + "/folder2").build();
        Response response = c.executeRequest(mkcolRequest).get();
        assertEquals(response.getStatusCode(), 409);
    }
}
Also used : Response(org.asynchttpclient.Response) RequestBuilder(org.asynchttpclient.RequestBuilder) Request(org.asynchttpclient.Request) AsyncHttpClient(org.asynchttpclient.AsyncHttpClient) Test(org.testng.annotations.Test)

Example 40 with RequestBuilder

use of org.asynchttpclient.RequestBuilder in project async-http-client by AsyncHttpClient.

the class WebdavTest method propFindCompletionHandlerWebDavTest.

@Test
public void propFindCompletionHandlerWebDavTest() throws InterruptedException, IOException, ExecutionException {
    try (AsyncHttpClient c = asyncHttpClient()) {
        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) {
                t.printStackTrace();
            }

            @Override
            public WebDavResponse onCompleted(WebDavResponse response) {
                return response;
            }
        }).get();
        assertEquals(webDavResponse.getStatusCode(), 207);
        assertTrue(webDavResponse.getResponseBody().contains("HTTP/1.1 200 OK"), "Got " + response.getResponseBody());
    }
}
Also used : Response(org.asynchttpclient.Response) RequestBuilder(org.asynchttpclient.RequestBuilder) Request(org.asynchttpclient.Request) AsyncHttpClient(org.asynchttpclient.AsyncHttpClient) Test(org.testng.annotations.Test)

Aggregations

RequestBuilder (org.asynchttpclient.RequestBuilder)44 Request (org.asynchttpclient.Request)18 AsyncHttpClient (org.asynchttpclient.AsyncHttpClient)17 Test (org.testng.annotations.Test)17 Response (org.asynchttpclient.Response)14 AbstractBasicTest (org.asynchttpclient.AbstractBasicTest)9 Realm (org.asynchttpclient.Realm)4 SpnegoEngineException (org.asynchttpclient.spnego.SpnegoEngineException)4 HttpHeaders (io.netty.handler.codec.http.HttpHeaders)3 Uri (org.asynchttpclient.uri.Uri)3 DefaultHttpHeaders (io.netty.handler.codec.http.DefaultHttpHeaders)2 HttpRequest (io.netty.handler.codec.http.HttpRequest)2 UUID (java.util.UUID)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Consumer (java.util.function.Consumer)2 Slf4j (lombok.extern.slf4j.Slf4j)2 lombok.val (lombok.val)2 Request (okhttp3.Request)2 Response (okhttp3.Response)2 REQUEST (org.asynchttpclient.extras.retrofit.AsyncHttpClientCallTest.REQUEST)2