use of org.apache.http.impl.client.CloseableHttpClient in project wildfly by wildfly.
the class WebModuleDeploymentTestCase method testSimpleBeanInjected.
@Test
public void testSimpleBeanInjected() throws Exception {
try (CloseableHttpClient httpclient = HttpClients.createDefault()) {
HttpGet httpget = new HttpGet(url.toExternalForm() + "/servlet");
HttpResponse response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
StatusLine statusLine = response.getStatusLine();
assertEquals(200, statusLine.getStatusCode());
String result = EntityUtils.toString(entity);
Assert.assertEquals(ModuleServlet.MODULE_SERVLET, result);
}
}
use of org.apache.http.impl.client.CloseableHttpClient in project wildfly by wildfly.
the class ExternalTagLibTestCase method testExternalTagLibOnly.
@Test
public void testExternalTagLibOnly() throws Exception {
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
HttpGet httpget = new HttpGet(external_dependency_only_url.toExternalForm() + TEST_JSP);
HttpResponse response = httpClient.execute(httpget);
HttpEntity entity = response.getEntity();
String result = EntityUtils.toString(entity);
Assert.assertTrue(result, result.contains("External Tag!"));
}
}
use of org.apache.http.impl.client.CloseableHttpClient in project wildfly by wildfly.
the class DefaultServletMultipartConfigTestCase method testMultipartRequestToDefaultServlet.
@Test
public void testMultipartRequestToDefaultServlet() throws Exception {
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
HttpPost post = new HttpPost(url.toExternalForm() + "/servlet");
post.setEntity(MultipartEntityBuilder.create().addTextBody("file", MESSAGE).build());
HttpResponse response = httpClient.execute(post);
HttpEntity entity = response.getEntity();
StatusLine statusLine = response.getStatusLine();
assertEquals(200, statusLine.getStatusCode());
String result = EntityUtils.toString(entity);
Assert.assertEquals(MESSAGE, result);
}
}
use of org.apache.http.impl.client.CloseableHttpClient in project wildfly by wildfly.
the class WebSecurityBASICTestCase method makeCall.
@Override
protected void makeCall(String user, String pass, int expectedStatusCode) throws Exception {
CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(new AuthScope(url.getHost(), url.getPort()), new UsernamePasswordCredentials(user, pass));
try (CloseableHttpClient httpclient = HttpClients.custom().setDefaultCredentialsProvider(credentialsProvider).build()) {
HttpGet httpget = new HttpGet(url.toExternalForm() + "secured/");
HttpResponse response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
StatusLine statusLine = response.getStatusLine();
if (entity != null) {
log.trace("Response content length: " + entity.getContentLength());
}
assertEquals(expectedStatusCode, statusLine.getStatusCode());
EntityUtils.consume(entity);
}
}
use of org.apache.http.impl.client.CloseableHttpClient in project wildfly by wildfly.
the class UndertowNonBlockingHandlerTestCase method testNonBlockingHandler.
@Test
public void testNonBlockingHandler() throws Exception {
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
HttpGet httpget = new HttpGet(url.toExternalForm());
HttpResponse response = httpClient.execute(httpget);
HttpEntity entity = response.getEntity();
StatusLine statusLine = response.getStatusLine();
assertEquals(200, statusLine.getStatusCode());
String result = EntityUtils.toString(entity);
Assert.assertEquals(SimpleUndertowExtension.THIS_IS_NOT_A_SERVLET, result);
}
}
Aggregations