use of org.asynchttpclient.AsyncHttpClient in project async-http-client by AsyncHttpClient.
the class AbstractAsyncHttpClientFactoryTest method testFactoryWithNonExistentAsyncHttpClient.
// ===================================================================================================================================
/*
* If the system property exists instantiate the class else if the class is not found throw an AsyncHttpClientException.
*/
@Test(groups = "standalone", expectedExceptions = AsyncHttpClientImplException.class)
public void testFactoryWithNonExistentAsyncHttpClient() throws IOException {
System.setProperty(AsyncImplHelper.ASYNC_HTTP_CLIENT_IMPL_SYSTEM_PROPERTY, NON_EXISTENT_CLIENT_CLASS_NAME);
AsyncHttpClientConfigHelper.reloadProperties();
try (AsyncHttpClient ahc = AsyncHttpClientFactory.getAsyncHttpClient()) {
//
}
Assert.fail("AsyncHttpClientImplException should have been thrown before this point");
}
use of org.asynchttpclient.AsyncHttpClient in project async-http-client by AsyncHttpClient.
the class AbstractAsyncHttpClientFactoryTest method testGetAsyncHttpClientConfigWithBadAsyncHttpClient.
@Test(groups = "standalone")
public void testGetAsyncHttpClientConfigWithBadAsyncHttpClient() throws IOException {
System.setProperty(AsyncImplHelper.ASYNC_HTTP_CLIENT_IMPL_SYSTEM_PROPERTY, BAD_CLIENT_CLASS_NAME);
AsyncHttpClientConfigHelper.reloadProperties();
try (AsyncHttpClient ahc = AsyncHttpClientFactory.getAsyncHttpClient()) {
//
} catch (AsyncHttpClientImplException e) {
assertException(e);
}
// Assert.fail("AsyncHttpClientImplException should have been thrown before this point");
}
use of org.asynchttpclient.AsyncHttpClient in project async-http-client by AsyncHttpClient.
the class AsyncHttpClientRegistryTest method testDeRegister.
@Test(groups = "standalone")
public void testDeRegister() throws IOException {
try (AsyncHttpClient ahc = AsyncHttpClientFactory.getAsyncHttpClient()) {
Assert.assertFalse(AsyncHttpClientRegistryImpl.getInstance().unregister(TEST_AHC));
Assert.assertNull(AsyncHttpClientRegistryImpl.getInstance().addOrReplace(TEST_AHC, ahc));
Assert.assertTrue(AsyncHttpClientRegistryImpl.getInstance().unregister(TEST_AHC));
Assert.assertNull(AsyncHttpClientRegistryImpl.getInstance().get(TEST_AHC));
}
}
use of org.asynchttpclient.AsyncHttpClient in project async-http-client by AsyncHttpClient.
the class WebDavBasicTest method propFindWebDavTest.
@Test(groups = "standalone")
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(String.format("http://localhost:%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://localhost:%s/folder1/Test.txt", port1)).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.AsyncHttpClient in project async-http-client by AsyncHttpClient.
the class WebDavBasicTest method propFindCompletionHandlerWebDavTest.
@Test(groups = "standalone")
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) throws Exception {
return response;
}
}).get();
assertEquals(webDavResponse.getStatusCode(), 207);
assertTrue(webDavResponse.getResponseBody().contains("HTTP/1.1 200 OK"), "Got " + response.getResponseBody());
}
}
Aggregations