use of com.gargoylesoftware.htmlunit.Page in project core by weld.
the class ServletConversationTest method testLongRunningConversation.
@Test
public void testLongRunningConversation() throws Exception {
WebClient client = new WebClient();
// begin conversation
TextPage initialPage = client.getPage(getPath("/begin", null));
String content = initialPage.getContent();
assertTrue(content.contains("message: Hello"));
assertTrue(content.contains("transient: false"));
String cid = getCid(content);
// verify conversation is not transient
{
TextPage page = client.getPage(getPath("/display", cid));
assertTrue(page.getContent().contains("message: Hello"));
assertTrue(page.getContent().contains("cid: [" + cid + "]"));
assertTrue(page.getContent().contains("transient: false"));
}
// modify conversation state
{
TextPage page = client.getPage(getPath("/set", cid) + "&message=Hi");
assertTrue(page.getContent().contains("message: Hi"));
assertTrue(page.getContent().contains("cid: [" + cid + "]"));
assertTrue(page.getContent().contains("transient: false"));
}
// verify conversation state
{
TextPage page = client.getPage(getPath("/display", cid));
assertTrue(page.getContent().contains("message: Hi"));
assertTrue(page.getContent().contains("cid: [" + cid + "]"));
assertTrue(page.getContent().contains("transient: false"));
}
// end conversation
{
TextPage page = client.getPage(getPath("/end", cid));
assertTrue(page.getContent().contains("message: Hi"));
assertTrue(page.getContent().contains("transient: true"));
}
// verify that the conversation can no longer be restored
{
client.setThrowExceptionOnFailingStatusCode(false);
Page page = client.getPage(getPath("/display", cid));
assertEquals(500, page.getWebResponse().getStatusCode());
}
}
use of com.gargoylesoftware.htmlunit.Page in project core by weld.
the class ServletConversationTest method testInvalidatingSessionDestroysConversation.
@Test
public void testInvalidatingSessionDestroysConversation() throws Exception {
WebClient client = new WebClient();
// begin conversation 1
TextPage initialPage1 = client.getPage(getPath("/begin", null));
String content = initialPage1.getContent();
assertTrue(content.contains("message: Hello"));
assertTrue(content.contains("transient: false"));
String cid1 = getCid(content);
// begin conversation 1
TextPage initialPage2 = client.getPage(getPath("/begin", null));
String content2 = initialPage2.getContent();
assertTrue(content2.contains("message: Hello"));
assertTrue(content2.contains("transient: false"));
String cid2 = getCid(content2);
assertFalse(cid1.equals(cid2));
/*
* Invalidate the session. This should destroy the currently associated conversation (with cid1) as well as the
* not-currently-associated conversation (with cid2).
*/
{
client.getPage(getPath("/invalidateSession", cid1));
}
// verify destroyed conversations
{
TextPage page = client.getPage(getPath("/listDestroyedMessages", null));
assertTrue(page.getContent().contains("DestroyedMessages:"));
assertTrue(page.getContent().contains("<M:" + cid1 + ">"));
assertTrue(page.getContent().contains("<M:" + cid2 + ">"));
}
{
TextPage page = client.getPage(getPath("/listConversationsDestroyedWhileBeingAssociated", null));
assertTrue(page.getContent().contains("ConversationsDestroyedWhileBeingAssociated:"));
assertTrue(page.getContent().contains("<" + cid1 + ">"));
}
{
TextPage page = client.getPage(getPath("/listConversationsDestroyedWhileBeingDisassociated", null));
assertTrue(page.getContent().contains("ConversationsDestroyedWhileBeingDisassociated:"));
assertTrue(page.getContent().contains("<" + cid2 + ">"));
}
// Verify that the conversation 1 cannot be associated
{
client.setThrowExceptionOnFailingStatusCode(false);
Page page = client.getPage(getPath("/display", cid1));
assertEquals(500, page.getWebResponse().getStatusCode());
}
// Verify that the conversation 2 cannot be associated
{
client.setThrowExceptionOnFailingStatusCode(false);
Page page = client.getPage(getPath("/display", cid2));
assertEquals(500, page.getWebResponse().getStatusCode());
}
}
use of com.gargoylesoftware.htmlunit.Page in project core by weld.
the class EagerHttpSessionTest method testHttpSession.
@Test
public void testHttpSession() throws Exception {
WebClient client = new WebClient();
client.setThrowExceptionOnFailingStatusCode(true);
Page page = client.getPage(url + "/test");
String id = page.getWebResponse().getContentAsString();
assertFalse(id.isEmpty());
}
use of com.gargoylesoftware.htmlunit.Page in project core by weld.
the class EnterpriseBeanLifecycleRemoteTest method testDestroyRemovesSFSB.
@Test
public void testDestroyRemovesSFSB() throws Exception {
WebClient client = new WebClient();
Page page = client.getPage(getPath("request1"));
assertEquals(page.getWebResponse().getStatusCode(), HttpServletResponse.SC_OK);
page = client.getPage(getPath("request2"));
assertEquals(page.getWebResponse().getStatusCode(), HttpServletResponse.SC_OK);
}
use of com.gargoylesoftware.htmlunit.Page in project core by weld.
the class JspTest method testConversationPropagationToNonExistentConversationLeadsException.
@Test
public void testConversationPropagationToNonExistentConversationLeadsException() throws Exception {
WebClient client = new WebClient();
client.setThrowExceptionOnFailingStatusCode(false);
Page page = client.getPage(getPath("/index.jsp"));
Assert.assertEquals(200, page.getWebResponse().getStatusCode());
Assert.assertTrue(page.getUrl().toString().contains("home.jsf"));
}
Aggregations