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());
}
}
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);
}
}
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);
}
}
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);
}
}
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());
}
}
Aggregations