use of com.gargoylesoftware.htmlunit.WebClient in project core by weld.
the class ServletBeansTest method testServletContext.
@Test
public void testServletContext() throws Exception {
WebClient client = new WebClient();
client.getPage(url + "/context");
}
use of com.gargoylesoftware.htmlunit.WebClient in project core by weld.
the class UnavailableInterceptedBeanMetadataTest method testMetadataIsNotAvailable.
@Test
public void testMetadataIsNotAvailable() throws FailingHttpStatusCodeException, MalformedURLException, IOException {
WebClient webClient = new WebClient();
webClient.setThrowExceptionOnFailingStatusCode(true);
Page page = webClient.getPage(contextPath + "FooServlet");
assertEquals("OK", page.getWebResponse().getContentAsString().trim());
}
use of com.gargoylesoftware.htmlunit.WebClient in project core by weld.
the class AsyncServletTest method test.
@Test
public void test() throws FailingHttpStatusCodeException, MalformedURLException, IOException {
WebClient client = new WebClient();
Page page = client.getPage(url.toString() + "/foo");
String content = page.getWebResponse().getContentAsString();
assertTrue("Unexpected response, was: " + content, content.contains("BMX"));
}
use of com.gargoylesoftware.htmlunit.WebClient in project core by weld.
the class EmptyCidConversationRestorationTest method testEmptyCidDoesNotTriggerConversationRestoration.
@Test
public void testEmptyCidDoesNotTriggerConversationRestoration() throws FailingHttpStatusCodeException, MalformedURLException, IOException {
WebClient webClient = new WebClient();
webClient.setThrowExceptionOnFailingStatusCode(true);
TextPage page = webClient.getPage(contextPath + "echo?say=Hello&cid=");
assertEquals("Hello", page.getContent());
}
use of com.gargoylesoftware.htmlunit.WebClient in project core by weld.
the class ClientConversationContextTest method testExceptionPhaseListener.
@Test
public void testExceptionPhaseListener() throws Exception {
WebClient client = new WebClient();
client.setThrowExceptionOnFailingStatusCode(false);
// First, try a transient conversation
// Access a page that throws an exception
client.getPage(getPath("/thunderstorm.jsf"));
// Then access another page that doesn't and check the contexts are ok
HtmlPage cloud = client.getPage(getPath("/cloud.jsf"));
String cloudName = getFirstMatchingElement(cloud, HtmlSpan.class, "cloudName").getTextContent();
assertEquals(Cloud.NAME, cloudName);
// Now start a conversation
HtmlPage thunderstorm = getFirstMatchingElement(cloud, HtmlSubmitInput.class, "beginConversation").click();
String cid = getCid(thunderstorm);
// and access the page that throws an exception again
getFirstMatchingElement(cloud, HtmlSubmitInput.class, "thunderstorm").click();
cloud = client.getPage(getPath("/cloud.jsf", cid));
// And navigate to another page, checking the conversation exists by verifying that state is maintained
cloudName = getFirstMatchingElement(cloud, HtmlSpan.class, "cloudName").getTextContent();
assertEquals("gavin", cloudName);
}
Aggregations