use of com.gargoylesoftware.htmlunit.TextPage in project javaee7-samples by javaee-samples.
the class SecureServletTest method testPostWithIncorrectCredentials.
@Test
public void testPostWithIncorrectCredentials() throws Exception {
webClient.setCredentialsProvider(incorrectCreds);
WebRequest request = new WebRequest(new URL(base + "SecureServlet"), HttpMethod.POST);
TextPage page = webClient.getPage(request);
assertEquals("my POST", page.getContent());
}
use of com.gargoylesoftware.htmlunit.TextPage in project javaee7-samples by javaee-samples.
the class SecureServletTest method testGetWithCorrectCredentials.
// @Test
public void testGetWithCorrectCredentials() throws Exception {
webClient.setCredentialsProvider(correctCreds);
TextPage page = webClient.getPage(base + "/SecureServlet");
assertEquals("my GET", page.getContent());
}
use of com.gargoylesoftware.htmlunit.TextPage in project javaee7-samples by javaee-samples.
the class SecureServletTest method testPostWithCorrectCredentials.
@Test
public void testPostWithCorrectCredentials() throws Exception {
webClient.setCredentialsProvider(correctCreds);
WebRequest request = new WebRequest(new URL(base + "/SecureServlet"), HttpMethod.POST);
TextPage page = webClient.getPage(request);
assertEquals("my POST", page.getContent());
}
use of com.gargoylesoftware.htmlunit.TextPage in project javaee7-samples by javaee-samples.
the class SecureServletTest method testPostMethod.
@Test
public void testPostMethod() throws Exception {
webClient.setCredentialsProvider(correctCreds);
WebRequest request = new WebRequest(new URL(base + "SecureServlet"), HttpMethod.POST);
try {
TextPage p = webClient.getPage(request);
System.out.println(p.getContent());
} catch (FailingHttpStatusCodeException e) {
assertNotNull(e);
assertEquals(403, e.getStatusCode());
return;
}
fail("POST method could be called even with deny-unocvered-http-methods");
}
use of com.gargoylesoftware.htmlunit.TextPage in project sling by apache.
the class ITWebConsoleRemote method tailerGrep.
@Test
public void tailerGrep() throws Exception {
TextPage page = webClient.getPage(prepareUrl("slinglog/tailer.txt?name=FILE&tail=-1"));
String text = page.getContent();
assertThat(text, containsString(WebConsoleTestActivator.FOO_LOG));
assertThat(text, containsString(WebConsoleTestActivator.BAR_LOG));
page = webClient.getPage(prepareUrl("slinglog/tailer.txt?name=FILE&tail=1000&grep=" + WebConsoleTestActivator.FOO_LOG));
text = page.getContent();
//With grep pattern specified we should only see foo and not bar
assertThat(text, containsString(WebConsoleTestActivator.FOO_LOG));
assertThat(text, not(containsString(WebConsoleTestActivator.BAR_LOG)));
}
Aggregations