Search in sources :

Example 11 with WebClient

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

the class ProbeDefaultConfigurationPropertiesTest method testEmbededInfoSnippetAvailable.

@Test
public void testEmbededInfoSnippetAvailable() throws IOException {
    WebClient client = new WebClient();
    HtmlPage page = client.getPage(url.toString() + "test");
    assertTrue(page.getBody().asXml().toString().contains("Probe Development Tool"));
    assertTrue(page.getBody().asXml().toString().contains(TEST_ARCHIVE_NAME));
    assertTrue(page.getBody().asXml().toString().contains("The following snippet was automatically added by Weld"));
}
Also used : HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) WebClient(com.gargoylesoftware.htmlunit.WebClient) Test(org.junit.Test)

Example 12 with WebClient

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

the class ProbeDefaultConfigurationPropertiesTest method getChildInvocations.

private JsonArray getChildInvocations() throws IOException {
    WebClient webClient = invokeSimpleAction(url);
    JsonObject invocations = getPageAsJSONObject(INVOCATIONS_PATH, url, webClient);
    JsonArray invocationData = invocations.getJsonArray(DATA);
    int id = invocationData.getJsonObject(0).getInt(ID);
    JsonObject invocationTree = getPageAsJSONObject(INVOCATIONS_PATH + "/" + id, url, webClient);
    return invocationTree.getJsonArray(CHILDREN);
}
Also used : JsonArray(javax.json.JsonArray) JsonObject(javax.json.JsonObject) WebClient(com.gargoylesoftware.htmlunit.WebClient)

Example 13 with WebClient

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

the class ProbeEventsTest method testEventsEndpoint.

@Test
public void testEventsEndpoint() throws IOException {
    WebClient client = invokeSimpleAction(url);
    JsonObject events = getPageAsJSONObject(JSONTestUtil.EVENTS_PATH + "?filters=kind:\"APPLICATION\"", url, client);
    ReadContext ctx = JsonPath.parse(events.toString());
    List<String> eventInfos = ctx.read("$." + DATA + "[*]." + EVENT_INFO, List.class);
    List<String> qualifiers = ctx.read("$." + DATA + "[*]." + QUALIFIERS + "[*]", List.class);
    assertTrue("No events found !", eventInfos.size() > 0);
    // check events
    assertTrue(eventInfos.contains(SessionScopedBean.MESSAGE_A));
    assertTrue(eventInfos.contains(SessionScopedBean.MESSAGE_B));
    assertTrue(eventInfos.contains(SessionScopedBean.MESSAGE_AB));
    // check event qualifiers
    assertTrue(qualifiers.contains("@" + Collector.class.getName().concat("(value=\"B\")")));
    assertTrue(qualifiers.contains("@" + Collector.class.getName().concat("(value=\"A\")")));
}
Also used : ReadContext(com.jayway.jsonpath.ReadContext) JsonObject(javax.json.JsonObject) WebClient(com.gargoylesoftware.htmlunit.WebClient) Test(org.junit.Test)

Example 14 with WebClient

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

the class ProbeIntegrationTest method invokeSimpleAction.

protected WebClient invokeSimpleAction(URL url) throws IOException {
    WebClient client = new WebClient();
    client.getPage(url.toString() + "test");
    return client;
}
Also used : WebClient(com.gargoylesoftware.htmlunit.WebClient)

Example 15 with WebClient

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

the class EnhancedListenerShutdownTest method testEnhancedListenerNotDestroyingWeldIfListenerRegistered.

@Test
@InSequence(2)
public void testEnhancedListenerNotDestroyingWeldIfListenerRegistered(@ArquillianResource @OperateOnDeployment(TEST) URL testContext, @ArquillianResource @OperateOnDeployment(ASSERT) URL assertContext) throws IOException {
    // Init foo - set info archive deployment url
    WebClient webClient = new WebClient();
    webClient.setThrowExceptionOnFailingStatusCode(true);
    webClient.getPage(testContext + "init?url=" + URLEncoder.encode(assertContext.toExternalForm(), "UTF-8"));
    // Undeploy TEST
    deployer.undeploy(TEST);
    // Test that Foo is destroyed after TestListener is notified
    TextPage info = webClient.getPage(assertContext + "info?action=get");
    List<String> data = ActionSequence.buildFromCsvData(info.getContent()).getData();
    assertEquals(2, data.size());
    assertEquals(TestListener.class.getSimpleName(), data.get(0));
    assertEquals(Foo.class.getSimpleName(), data.get(1));
    // Undeploy ASSERT
    deployer.undeploy(ASSERT);
}
Also used : TextPage(com.gargoylesoftware.htmlunit.TextPage) WebClient(com.gargoylesoftware.htmlunit.WebClient) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

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