Search in sources :

Example 51 with HtmlPage

use of com.gargoylesoftware.htmlunit.html.HtmlPage in project javaee7-samples by javaee-samples.

the class LoginServletTest method testUnauthenticatedRequest.

@Test
public void testUnauthenticatedRequest() throws IOException, SAXException {
    HtmlPage page = webClient.getPage(base + "/LoginServlet");
    String responseText = page.asText();
    System.out.println("testUnauthenticatedRequest:\n" + responseText + "\n");
    assertTrue(responseText.contains("isUserInRole?false"));
    assertTrue(responseText.contains("getRemoteUser?null"));
    assertTrue(responseText.contains("getUserPrincipal?null"));
    assertTrue(responseText.contains("getAuthType?null"));
}
Also used : HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) Test(org.junit.Test)

Example 52 with HtmlPage

use of com.gargoylesoftware.htmlunit.html.HtmlPage in project javaee7-samples by javaee-samples.

the class EventListenerTest method testRequestAttributeListener.

@Test
public void testRequestAttributeListener() throws IOException {
    HtmlPage page = webClient.getPage(base + "TestServlet");
    assertTrue(page.asText().contains("MyServletRequestAttributeListener.attributeAdded: attribute1"));
    assertTrue(page.asText().contains("MyServletRequestAttributeListener.attributeReplaced: attribute1"));
    assertTrue(page.asText().contains("MyServletRequestAttributeListener.attributeRemoved: attribute1"));
}
Also used : HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) Test(org.junit.Test)

Example 53 with HtmlPage

use of com.gargoylesoftware.htmlunit.html.HtmlPage in project javaee7-samples by javaee-samples.

the class EventListenerTest method testContextAttributeListener.

@Test
public void testContextAttributeListener() throws IOException {
    HtmlPage page = webClient.getPage(base + "TestServlet");
    System.out.println(page.asText());
    assertTrue(page.asText().contains("MyContextAttributeListener.attributeAdded: attribute1"));
    assertTrue(page.asText().contains("MyContextAttributeListener.attributeReplaced: attribute1"));
    assertTrue(page.asText().contains("MyContextAttributeListener.attributeRemoved: attribute1"));
}
Also used : HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) Test(org.junit.Test)

Example 54 with HtmlPage

use of com.gargoylesoftware.htmlunit.html.HtmlPage in project javaee7-samples by javaee-samples.

the class EventListenerTest method testSessionListener.

@Test
public void testSessionListener() throws IOException {
    HtmlPage page = webClient.getPage(base + "TestServlet");
    assertTrue(page.asText().contains("MySessionListener.sessionCreated:"));
    assertTrue(page.asText().contains("MySessionListener.sessionDestroyed:"));
}
Also used : HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) Test(org.junit.Test)

Example 55 with HtmlPage

use of com.gargoylesoftware.htmlunit.html.HtmlPage in project javaee7-samples by javaee-samples.

the class EventListenerTest method testSessionAttributeListener.

@Test
public void testSessionAttributeListener() throws IOException {
    HtmlPage page = webClient.getPage(base + "TestServlet");
    assertTrue(page.asText().contains("MyHttpSessionAttributeListener.attributeAdded: attribute1"));
    assertTrue(page.asText().contains("MyHttpSessionAttributeListener.attributeReplaced: attribute1"));
    assertTrue(page.asText().contains("MyHttpSessionAttributeListener.attributeRemoved: attribute1"));
}
Also used : HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) Test(org.junit.Test)

Aggregations

HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)159 Test (org.junit.Test)114 WebClient (com.gargoylesoftware.htmlunit.WebClient)51 HtmlSubmitInput (com.gargoylesoftware.htmlunit.html.HtmlSubmitInput)25 HtmlForm (com.gargoylesoftware.htmlunit.html.HtmlForm)23 HtmlSpan (com.gargoylesoftware.htmlunit.html.HtmlSpan)21 File (java.io.File)17 HtmlInput (com.gargoylesoftware.htmlunit.html.HtmlInput)15 Matchers.containsString (org.hamcrest.Matchers.containsString)13 IOException (java.io.IOException)11 JenkinsRule (org.jvnet.hudson.test.JenkinsRule)10 FreeStyleProject (hudson.model.FreeStyleProject)9 URL (java.net.URL)9 Page (com.gargoylesoftware.htmlunit.Page)8 HtmlTextInput (com.gargoylesoftware.htmlunit.html.HtmlTextInput)7 WebWindow (com.gargoylesoftware.htmlunit.WebWindow)6 DomElement (com.gargoylesoftware.htmlunit.html.DomElement)6 WebRequest (com.gargoylesoftware.htmlunit.WebRequest)5 HtmlButton (com.gargoylesoftware.htmlunit.html.HtmlButton)5 HtmlElement (com.gargoylesoftware.htmlunit.html.HtmlElement)5