use of com.gargoylesoftware.htmlunit.WebClient in project core by weld.
the class InvalidateConversationTest method testConversationDestroyedAfterRequestEnds.
@Test
public void testConversationDestroyedAfterRequestEnds() throws IOException {
WebClient client = new WebClient();
// reset ActionSequence on server
client.getPage(url + "resetSequence");
// trigger conversation
TextPage page = client.getPage(url + "begin");
String cid = page.getContent().trim();
// trigger session invalidation
page = client.getPage(url + "invalidate?cid=" + cid);
// invoke third request to get complete result of ActionSequence from server
page = client.getPage(url + "result");
String result = page.getContent();
// prepare expected result
ActionSequence.reset();
ActionSequence.addAction("conversationCreated");
ActionSequence.addAction("beforeInvalidate");
ActionSequence.addAction("afterInvalidate");
ActionSequence.addAction("conversationDestroyed");
assertEquals(ActionSequence.getSequence().dataToCsv(), result);
}
use of com.gargoylesoftware.htmlunit.WebClient in project core by weld.
the class InvalidateConversationTest method testAllLongRunningConversationsGetDestroyedAfterRequest.
@Test
public void testAllLongRunningConversationsGetDestroyedAfterRequest() throws IOException {
String firstCid;
String secondCid;
WebClient client = new WebClient();
// reset ActionSequence on server
client.getPage(url + "resetSequence");
// initiate conversations
TextPage page = client.getPage(url + "begin");
firstCid = page.getContent().trim();
page = client.getPage(url + "begin");
secondCid = page.getContent().trim();
assertFalse(firstCid.equals(secondCid));
// trigger session invalidation with one cid
page = client.getPage(url + "invalidate?cid=" + secondCid);
// invoke third request to get complete result of ActionSequence from server
page = client.getPage(url + "result");
String result = page.getContent();
// prepare expected result
ActionSequence.reset();
ActionSequence.addAction("conversationCreated");
ActionSequence.addAction("conversationCreated");
ActionSequence.addAction("beforeInvalidate");
ActionSequence.addAction("afterInvalidate");
ActionSequence.addAction("conversationDestroyed");
ActionSequence.addAction("conversationDestroyed");
assertEquals(ActionSequence.getSequence().dataToCsv(), result);
}
use of com.gargoylesoftware.htmlunit.WebClient in project core by weld.
the class ServletConversationTest method testPost.
@Test
public void testPost() 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);
// submit a form
{
HtmlPage form = client.getPage(url.toString() + "/message.html");
getFirstMatchingElement(form, HtmlTextInput.class, "message").setValueAttribute("Hola!");
getFirstMatchingElement(form, HtmlTextInput.class, "cid").setValueAttribute(cid);
TextPage page = getFirstMatchingElement(form, HtmlSubmitInput.class, "submit").click();
assertTrue(page.getContent().contains("message: Hola!"));
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: Hola!"));
assertTrue(page.getContent().contains("cid: [" + cid + "]"));
assertTrue(page.getContent().contains("transient: false"));
}
}
use of com.gargoylesoftware.htmlunit.WebClient in project core by weld.
the class Weld1262Test method startConversation.
public HtmlPage startConversation() throws Exception {
WebClient client = new WebClient();
HtmlPage main = client.getPage(url.toString().concat("crossroad.jsf"));
main = getFirstMatchingElement(main, HtmlSubmitInput.class, "begin").click();
String cid = getFirstMatchingElement(main, HtmlSpan.class, "cid").getTextContent();
assertTrue(Integer.valueOf(cid) > 0);
return main;
}
use of com.gargoylesoftware.htmlunit.WebClient in project core by weld.
the class RequestScopeEventTest method test.
@Test
public void test() throws Exception {
WebClient client = new WebClient();
TextPage page1 = client.getPage(url + "?foo=bar");
// the current request
assertTrue(page1.getContent().contains("Initialized requests:1"));
// not destroyed yet
assertTrue(page1.getContent().contains("Destroyed requests:0"));
TextPage page2 = client.getPage(url + "?foo=bar");
assertTrue(page2.getContent().contains("Initialized requests:2"));
assertTrue(page2.getContent().contains("Destroyed requests:1"));
}
Aggregations