use of com.gargoylesoftware.htmlunit.html.HtmlPage in project core by weld.
the class ErrorPageTest method testActionMethodExceptionDoesNotDestroyContext.
@Test
public void testActionMethodExceptionDoesNotDestroyContext() throws Exception {
WebClient client = new WebClient();
client.setThrowExceptionOnFailingStatusCode(false);
HtmlPage page = client.getPage(getPath("/storm.jsf"));
HtmlSubmitInput disasterButton = getFirstMatchingElement(page, HtmlSubmitInput.class, "disasterButton");
HtmlTextInput strength = getFirstMatchingElement(page, HtmlTextInput.class, "stormStrength");
strength.setValueAttribute("10");
page = disasterButton.click();
Assert.assertEquals("Application Error", page.getTitleText());
HtmlDivision conversationValue = getFirstMatchingElement(page, HtmlDivision.class, "conversation");
Assert.assertEquals("10", conversationValue.asText());
HtmlDivision requestValue = getFirstMatchingElement(page, HtmlDivision.class, "request");
Assert.assertEquals("medium", requestValue.asText());
}
use of com.gargoylesoftware.htmlunit.html.HtmlPage in project core by weld.
the class ClientConversationContextTest method testInvalidateCallsPreDestroy.
@Test
public void testInvalidateCallsPreDestroy() throws Exception {
WebClient client = new WebClient();
// Now start a conversation
HtmlPage cloud = client.getPage(getPath("/cloud.jsf"));
cloud = getFirstMatchingElement(cloud, HtmlSubmitInput.class, "hurricane").click();
// Invalidate the session
cloud = getFirstMatchingElement(cloud, HtmlSubmitInput.class, "invalidateSession").click();
String cloudDestroyed = getFirstMatchingElement(cloud, HtmlSpan.class, "cloudDestroyed").getTextContent();
assertEquals("true", cloudDestroyed);
}
use of com.gargoylesoftware.htmlunit.html.HtmlPage in project core by weld.
the class ClientConversationContextTest method testExceptionInPreDestroy.
@Test
public void testExceptionInPreDestroy() throws Exception {
WebClient client = new WebClient();
// 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 and access the page that throws an exception
// again
HtmlPage thunderstorm = getFirstMatchingElement(cloud, HtmlSubmitInput.class, "beginConversation").click();
String thunderstormName = getFirstMatchingElement(thunderstorm, HtmlSpan.class, "thunderstormName").getTextContent();
assertEquals(Thunderstorm.NAME, thunderstormName);
cloud = getFirstMatchingElement(thunderstorm, HtmlSubmitInput.class, "cloud").click();
// And navigate to another page, checking the conversation exists by
// verifying that state is maintained
cloudName = getFirstMatchingElement(cloud, HtmlSpan.class, "cloudName").getTextContent();
assertEquals("bob", cloudName);
}
use of com.gargoylesoftware.htmlunit.html.HtmlPage in project core by weld.
the class ClientConversationContextTest method testInvalidateThenRedirect.
@Test
public void testInvalidateThenRedirect() throws Exception {
WebClient client = new WebClient();
// Now start a conversation
HtmlPage cloud = client.getPage(getPath("/cloud.jsf"));
cloud = getFirstMatchingElement(cloud, HtmlSubmitInput.class, "hurricane").click();
// Now invalidate the session and redirect
cloud = getFirstMatchingElement(cloud, HtmlSubmitInput.class, "sleet").click();
// Check that we are still working by verifying the page rendered
String cloudName = getFirstMatchingElement(cloud, HtmlSpan.class, "cloudName").getTextContent();
assertEquals(Cloud.NAME, cloudName);
}
use of com.gargoylesoftware.htmlunit.html.HtmlPage in project core by weld.
the class ClientConversationContextTest method testExceptionInPostConstruct.
@Test
public void testExceptionInPostConstruct() throws Exception {
WebClient client = new WebClient();
// First, try a transient conversation
client.setThrowExceptionOnFailingStatusCode(false);
// Access a page that throws an exception
client.getPage(getPath("/hailstorm.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 and access the page that throws an exception
// again
Page hailstorm = getFirstMatchingElement(cloud, HtmlSubmitInput.class, "hail").click();
String cid = getCid(hailstorm);
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