Package com.gargoylesoftware.htmlunit

Examples of com.gargoylesoftware.htmlunit.TextPage


    @SpecAssertions({ @SpecAssertion(section = "11.3.1", id = "e") })
    public void testCorrectBeanManagerAvailable() throws Exception {

        WebClient client = new WebClient();

        TextPage page1 = client.getPage(urlAlpha);
        assertEquals(page1.getContent(), "foo,foo");

        TextPage page2 = client.getPage(urlBravo);
        assertEquals(page2.getContent(), "bar,bar");
    }
View Full Code Here


    @Test
    public void test() throws Exception {
        WebClient client = new WebClient();

        {
            TextPage page = client.getPage(url);
            assertTrue(page.getContent().contains("Initialized sessions:1")); // the current session
            assertTrue(page.getContent().contains("Destroyed sessions:0")); // not destroyed yet
        }

        {
            // nothing should change
            TextPage page = client.getPage(url);
            assertTrue(page.getContent().contains("Initialized sessions:1"));
            assertTrue(page.getContent().contains("Destroyed sessions:0"));
        }
        {
            // invalidate the session
            TextPage page = client.getPage(url + "/invalidate");
            assertTrue(page.getContent().contains("Initialized sessions:1"));
            // the context is destroyed after the response is sent
            // verify in the next request
            assertTrue(page.getContent().contains("Destroyed sessions:0"));
        }
        {
            TextPage page = client.getPage(url);
            // new session context was initialized
            assertTrue(page.getContent().contains("Initialized sessions:2"));
            // the previous one was destroyed
            assertTrue(page.getContent().contains("Destroyed sessions:1"));
        }
    }
View Full Code Here

    }

    @Test
    public void testFirstArchive() throws Exception {
        WebClient client = new WebClient();
        TextPage page = client.getPage(fooUrl);
        Assert.assertEquals("/foo;/foo", page.getContent());
    }
View Full Code Here

    }

    @Test
    public void testSecondArchive() throws Exception {
        WebClient client = new WebClient();
        TextPage page = client.getPage(barUrl);
        Assert.assertEquals("/bar;/bar", page.getContent());
    }
View Full Code Here

    @Test
    public void test() throws Exception {
        WebClient client = new WebClient();

        TextPage page1 = client.getPage(url + "?foo=bar");
        assertTrue(page1.getContent().contains("Initialized requests:1")); // the current request
        assertTrue(page1.getContent().contains("Destroyed requests:0")); // not destroyed yet

        TextPage page2 = client.getPage(url + "?foo=bar");
        assertTrue(page2.getContent().contains("Initialized requests:2"));
        assertTrue(page2.getContent().contains("Destroyed requests:1"));
    }
View Full Code Here

    @RunAsClient
    public void testConversationTimesout() throws Exception {
        WebClient client = new WebClient();
        client.setThrowExceptionOnFailingStatusCode(false);
       
        TextPage page = client.getPage(url + "/servlet/beginConversation");
        String cid = page.getContent();

        Thread.sleep(1000); // wait for conversation to time out

        page = client.getPage(url + "/servlet/testConversation?cid=" + cid);
        assertEquals(TimeoutFilter.NON_EXISTENT_CONVERSATION, page.getContent());
    }
View Full Code Here

    @Test
    @RunAsClient
    public void testConversationDoesNotTimeoutOnRedirect() throws Exception {
        WebClient client = new WebClient();

        TextPage page = client.getPage(url + "/servlet/beginConversation");
        String cid = page.getContent();

        // Conversation will expire in middle of request but should not timeout
        page = client.getPage(url + "/servlet/makeLongRequest?cid=" + cid);
        assertEquals(cid, page.getContent());

        // Simulate redirect
        page = client.getPage(url + "/servlet/testConversation?cid=" + cid);
        assertEquals(cid, page.getContent());
    }
View Full Code Here

    @Test
    public void testLifecycleEventFiredForTransientConversation() throws Exception {
        WebClient client = new WebClient();

        {
            TextPage page = client.getPage(url + "/display");
            assertTrue(page.getContent(), page.getContent().contains("Initialized conversations:1")); // the current transient conversation
            assertTrue(page.getContent(), page.getContent().contains("Destroyed conversations:0")); // not destroyed yet
        }

        {
            TextPage page = client.getPage(url + "/display");
            assertTrue(page.getContent().contains("Initialized conversations:2"));
            assertTrue(page.getContent(), page.getContent().contains("Destroyed conversations:1"));
        }
    }
View Full Code Here

    @Test
    public void testLifecycleEventFiredForLongRunningConversation() throws Exception {
        WebClient client = new WebClient();

        {
            TextPage page = client.getPage(url + "/begin");
            assertTrue(page.getContent(), page.getContent().contains("Initialized conversations:1")); // the current transient conversation
            assertTrue(page.getContent(), page.getContent().contains("Destroyed conversations:0")); // not destroyed yet
        }
       
        {
            TextPage page = client.getPage(url + "/display?cid=org.jboss.weld");
            assertTrue(page.getContent(), page.getContent().contains("Initialized conversations:1"));
            assertTrue(page.getContent(), page.getContent().contains("Destroyed conversations:0"));
        }
       
        {
            TextPage page = client.getPage(url + "/display?cid=org.jboss.weld");
            assertTrue(page.getContent(), page.getContent().contains("Initialized conversations:1"));
            assertTrue(page.getContent(), page.getContent().contains("Destroyed conversations:0"));
        }
       
        {
            TextPage page = client.getPage(url + "/end?cid=org.jboss.weld");
            assertTrue(page.getContent(), page.getContent().contains("Initialized conversations:1"));
            assertTrue(page.getContent(), page.getContent().contains("Destroyed conversations:0"));
        }
       
        {
            TextPage page = client.getPage(url + "/display");
            assertTrue(page.getContent(), page.getContent().contains("Initialized conversations:2"));
            assertTrue(page.getContent(), page.getContent().contains("Destroyed conversations:1"));
        }
    }
View Full Code Here

    }

    @Test
    public void testTransientConversation() throws Exception {
        WebClient client = new WebClient();
        TextPage page = client.getPage(getPath("/display", null));
        assertTrue(page.getContent().contains("message: Hello"));
        assertTrue(page.getContent().contains("cid: [null]"));
        assertTrue(page.getContent().contains("transient: true"));
    }
View Full Code Here

TOP

Related Classes of com.gargoylesoftware.htmlunit.TextPage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.