use of com.gargoylesoftware.htmlunit.WebRequest 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"), POST);
HtmlPage page = webClient.getPage(request);
assertEquals("Servlet Security Annotated - Basic Auth with File-base Realm", page.getTitleText());
}
use of com.gargoylesoftware.htmlunit.WebRequest in project javaee7-samples by javaee-samples.
the class SecureServletTest method testPutMethod.
@Test
public void testPutMethod() throws Exception {
webClient.setCredentialsProvider(correctCreds);
WebRequest request = new WebRequest(new URL(base + "SecureServlet"), PUT);
TextPage page = null;
try {
page = webClient.getPage(request);
System.out.println(page.getContent());
} catch (FailingHttpStatusCodeException e) {
assertNotEquals("PUT denied, but should be allowed", 403, e.getStatusCode());
throw e;
}
}
use of com.gargoylesoftware.htmlunit.WebRequest 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"), POST);
TextPage page = null;
try {
page = webClient.getPage(request);
System.out.println(page.getContent());
assertTrue("POST method could not be called even without deny-uncovered-http-methods", page.getContent().contains("my POST"));
} catch (FailingHttpStatusCodeException e) {
assertNotEquals("Post denied, but should be allowed", 403, e.getStatusCode());
throw e;
}
}
use of com.gargoylesoftware.htmlunit.WebRequest in project javaee7-samples by javaee-samples.
the class SimpleServletTest method testPost.
@Test
public void testPost() throws IOException, SAXException {
WebRequest request = new WebRequest(new URL(base + "SimpleServlet"), HttpMethod.POST);
TextPage page = webClient.getPage(request);
assertEquals("my POST", page.getContent());
}
use of com.gargoylesoftware.htmlunit.WebRequest in project javaee7-samples by javaee-samples.
the class TestServletTest method testPost.
@Test
public void testPost() throws IOException, SAXException {
WebRequest request = new WebRequest(new URL(base + "TestServlet"), HttpMethod.POST);
TextPage page = webClient.getPage(request);
assertEquals("my POST", page.getContent());
}
Aggregations