use of org.apache.http.impl.client.CloseableHttpClient in project wildfly by wildfly.
the class UndertowHandlersConfigTestCase method testRewrite.
@Test
public void testRewrite() throws Exception {
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
HttpGet httpget = new HttpGet(url.toExternalForm() + "rewritea");
HttpResponse response = httpClient.execute(httpget);
HttpEntity entity = response.getEntity();
StatusLine statusLine = response.getStatusLine();
assertEquals(200, statusLine.getStatusCode());
String result = EntityUtils.toString(entity);
Assert.assertEquals("A file", result);
Header[] headers = response.getHeaders("MyHeader");
Assert.assertEquals(1, headers.length);
Assert.assertEquals("MyValue", headers[0].getValue());
}
}
use of org.apache.http.impl.client.CloseableHttpClient in project wildfly by wildfly.
the class JspMappingTestCase method testFalseCss.
@Test
public void testFalseCss() throws Exception {
log.trace("False CSS");
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
HttpResponse response = httpClient.execute(new HttpGet(webappUrl.toURI() + "test.css"));
try (InputStream in = response.getEntity().getContent()) {
String content = getContent(in);
assertThat(content, containsString("1 + 1 = 2"));
}
}
}
use of org.apache.http.impl.client.CloseableHttpClient in project wildfly by wildfly.
the class JspMappingTestCase method testTrueHtmlPage.
@Test
public void testTrueHtmlPage() throws Exception {
log.trace("True HTML");
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
HttpResponse response = httpClient.execute(new HttpGet(webappUrl.toURI() + "index.html"));
try (InputStream in = response.getEntity().getContent()) {
String content = getContent(in);
assertThat(content, not(containsString("1 + 1 = 2")));
}
}
}
use of org.apache.http.impl.client.CloseableHttpClient in project wildfly by wildfly.
the class JspMappingTestCase method testFalseHtmlPage.
@Test
public void testFalseHtmlPage() throws Exception {
log.trace("False HTML");
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
HttpResponse response = httpClient.execute(new HttpGet(webappUrl.toURI() + "test.html"));
try (InputStream in = response.getEntity().getContent()) {
String content = getContent(in);
assertThat(content, containsString("1 + 1 = 2"));
}
}
}
use of org.apache.http.impl.client.CloseableHttpClient in project wildfly by wildfly.
the class JspMappingTestCase method testSimpleJSP.
@Test
public void testSimpleJSP() throws Exception {
log.trace("Simple JSP");
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
HttpResponse response = httpClient.execute(new HttpGet(webappUrl.toURI() + "index.jsp"));
try (InputStream in = response.getEntity().getContent()) {
String content = getContent(in);
assertThat(content, containsString("1 + 1 = 2"));
}
}
}
Aggregations