Search in sources :

Example 21 with WebClient

use of com.gargoylesoftware.htmlunit.WebClient in project core by weld.

the class SimpleAsyncListenerTest method testOnTimeoutCalledSuccesfully.

@Test
public void testOnTimeoutCalledSuccesfully() throws Exception {
    WebClient webClient = new WebClient();
    webClient.setThrowExceptionOnFailingStatusCode(false);
    webClient.getPage(getPath(AsyncServlet.TEST_TIMEOUT));
    Page results = webClient.getPage(contextPath + "Status");
    assertTrue(results.getWebResponse().getContentAsString().contains("onTimeout: true"));
}
Also used : Page(com.gargoylesoftware.htmlunit.Page) WebClient(com.gargoylesoftware.htmlunit.WebClient) Test(org.junit.Test)

Example 22 with WebClient

use of com.gargoylesoftware.htmlunit.WebClient in project core by weld.

the class EMFFactoryTest method testStaticManagedBeanEMFProducerField.

/*
    * description = "WELD-632"
    */
@Test
public void testStaticManagedBeanEMFProducerField() throws Exception {
    WebClient client = new WebClient();
    client.setThrowExceptionOnFailingStatusCode(false);
    Page page = client.getPage(getPath("emfconsumer3"));
    assertEquals(200, page.getWebResponse().getStatusCode());
}
Also used : Page(com.gargoylesoftware.htmlunit.Page) WebClient(com.gargoylesoftware.htmlunit.WebClient) Test(org.junit.Test)

Example 23 with WebClient

use of com.gargoylesoftware.htmlunit.WebClient in project core by weld.

the class EMFFactoryTest method testStaticEJBEMFProducerField.

/*
    * description = "WELD-632"
    */
@Test
public void testStaticEJBEMFProducerField() throws Exception {
    WebClient client = new WebClient();
    client.setThrowExceptionOnFailingStatusCode(false);
    Page page = client.getPage(getPath("emfconsumer1"));
    assertEquals(200, page.getWebResponse().getStatusCode());
}
Also used : Page(com.gargoylesoftware.htmlunit.Page) WebClient(com.gargoylesoftware.htmlunit.WebClient) Test(org.junit.Test)

Example 24 with WebClient

use of com.gargoylesoftware.htmlunit.WebClient in project core by weld.

the class RequestScopedCacheLeakTest method test.

@Test
public void test() throws Exception {
    WebClient webClient = new WebClient();
    webClient.setThrowExceptionOnFailingStatusCode(false);
    for (int i = 0; i < 100; i++) {
        // first, send out a hundred of poisoning requests
        // each of these should leave a thread in a broken state
        sendRequest(webClient, i, true);
    }
    for (int i = 0; i < 100; i++) {
        // now send out normal requests to see if they are affected by the thread's broken state
        String result = sendRequest(webClient, i, false);
        Assert.assertFalse("Invalid state detected after " + (i + 1) + " requests", result.startsWith("bar"));
    }
}
Also used : WebClient(com.gargoylesoftware.htmlunit.WebClient) Test(org.junit.Test)

Example 25 with WebClient

use of com.gargoylesoftware.htmlunit.WebClient in project core by weld.

the class ClientConversationContextTest method testRedirectToConversation.

@Test
public void testRedirectToConversation() throws Exception {
    WebClient client = new WebClient();
    HtmlPage page = client.getPage(getPath("/cloud.jsf"));
    HtmlPage snowstorm = getFirstMatchingElement(page, HtmlSubmitInput.class, "snow").click();
    String name = getFirstMatchingElement(snowstorm, HtmlSpan.class, "snowstormName").getTextContent();
    assertEquals(Snowstorm.NAME, name);
    snowstorm = getFirstMatchingElement(snowstorm, HtmlSubmitInput.class, "go").click();
    name = getFirstMatchingElement(snowstorm, HtmlSpan.class, "snowstormName").getTextContent();
    assertEquals(Snowstorm.NAME, name);
}
Also used : HtmlSpan(com.gargoylesoftware.htmlunit.html.HtmlSpan) HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) HtmlSubmitInput(com.gargoylesoftware.htmlunit.html.HtmlSubmitInput) WebClient(com.gargoylesoftware.htmlunit.WebClient) Test(org.junit.Test)

Aggregations

WebClient (com.gargoylesoftware.htmlunit.WebClient)182 Test (org.junit.Test)110 HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)55 Page (com.gargoylesoftware.htmlunit.Page)33 TextPage (com.gargoylesoftware.htmlunit.TextPage)21 Before (org.junit.Before)20 HtmlSubmitInput (com.gargoylesoftware.htmlunit.html.HtmlSubmitInput)17 URL (java.net.URL)14 JsonObject (javax.json.JsonObject)13 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)13 WebResponse (com.gargoylesoftware.htmlunit.WebResponse)12 SpecAssertion (org.jboss.test.audit.annotations.SpecAssertion)11 HtmlSpan (com.gargoylesoftware.htmlunit.html.HtmlSpan)10 ReadContext (com.jayway.jsonpath.ReadContext)10 File (java.io.File)9 IOException (java.io.IOException)8 NicelyResynchronizingAjaxController (com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController)7 Test (org.junit.jupiter.api.Test)7 HtmlForm (com.gargoylesoftware.htmlunit.html.HtmlForm)6 DefaultCredentialsProvider (com.gargoylesoftware.htmlunit.DefaultCredentialsProvider)5