Package com.gargoylesoftware.htmlunit

Examples of com.gargoylesoftware.htmlunit.TextPage


    @Test(groups = { CONTEXTS, SERVLET })
    @SpecAssertion(section = "6.7.2", id = "cb")
    public void testSessionContextDestroyedWhenHttpSessionTimesOut() throws Exception {
        WebClient webClient = new WebClient();
        webClient.setThrowExceptionOnFailingStatusCode(true);
        TextPage firstRequestResult = webClient.getPage(contextPath + "IntrospectSession");
        assert firstRequestResult.getContent() != null;
        assert Long.parseLong(firstRequestResult.getContent()) != 0;
        webClient.getPage(contextPath + "InvalidateSession?timeout=1");

        Timer.startNew(DEFAULT_SLEEP_INTERVAL);

        // Make a second request and make sure the same context is not there
        TextPage secondRequestResult = webClient.getPage(contextPath + "IntrospectSession");
        assert secondRequestResult.getContent() != null;
        assert Long.parseLong(secondRequestResult.getContent()) != Long.parseLong(firstRequestResult.getContent());

        // As final confirmation that the context was destroyed, check that its beans
        // were also destroyed.
        TextPage beanDestructionResult = webClient.getPage(contextPath + "InvalidateSession?isBeanDestroyed");
        assert Boolean.parseBoolean(beanDestructionResult.getContent());
    }
View Full Code Here


    @Test
    @SpecAssertions({ @SpecAssertion(section = "6.7.4", id = "ba"), @SpecAssertion(section = "6.7.4", id = "bb") })
    public void testLifecycleEventFiredForTransientConversation() throws Exception {
        WebClient client = new WebClient();

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

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

    @Test
    @SpecAssertions({ @SpecAssertion(section = "6.7.4", id = "ba"), @SpecAssertion(section = "6.7.4", id = "bb") })
    public void testLifecycleEventFiredForLongRunningConversation() throws Exception {
        WebClient client = new WebClient();

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

        page = client.getPage(contextPath + "/display?cid=org.jboss.weld");
        assertTrue(page.getContent().contains("Initialized conversations:1"));
        assertTrue(page.getContent().contains("Destroyed conversations:0"));

        page = client.getPage(contextPath + "/display?cid=org.jboss.weld");
        assertTrue(page.getContent().contains("Initialized conversations:1"));
        assertTrue(page.getContent().contains("Destroyed conversations:0"));

        page = client.getPage(contextPath + "/end?cid=org.jboss.weld");
        assertTrue(page.getContent().contains("Initialized conversations:1"));
        assertTrue(page.getContent().contains("Destroyed conversations:0"));

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

            @SpecAssertion(section = "3.7", id = "dc") })
    public void testBuiltinBeansFromClient(@ArquillianResource URL contextPath) throws Exception {

        WebClient client = new WebClient();

        TextPage requestPage = client.getPage(contextPath + "/convert-request?text=BaR");
        assertEquals(requestPage.getContent(), "bar");

        TextPage sessionPage = client.getPage(contextPath + "/convert-session");
        assertEquals(sessionPage.getContent(), "session");

        TextPage contextPage = client.getPage(contextPath + "/convert-context");
        assertEquals(contextPage.getContent(), "servletcontext");
    }
View Full Code Here

        WebClient webClient = new WebClient();
        webClient.setThrowExceptionOnFailingStatusCode(true);

        // New instance of Foo is created for each request
        TextPage resource01 = webClient.getPage(contextPath + "resources/foo");
        Long id01 = Long.valueOf(resource01.getContent());
        TextPage resource02 = webClient.getPage(contextPath + "resources/foo");
        Long id02 = Long.valueOf(resource02.getContent());
        assertNotEquals(id01, id02);

        // At the time the info servlet is generating response, 3 requests were initialized and 2 destroyed
        TextPage resource03 = webClient.getPage(contextPath + "info");
        assertTrue(resource03.getContent().contains("Initialized requests:3"));
        assertTrue(resource03.getContent().contains("Destroyed requests:2"));

        assertTrue(resource03.getContent().contains("Foo destroyed:2"));
    }
View Full Code Here

    @Test(groups = { CONTEXTS })
    @SpecAssertion(section = "6.7.3", id = "e")
    public void testApplicationContextSharedBetweenServletRequests() throws Exception {
        WebClient webClient = new WebClient();
        webClient.setThrowExceptionOnFailingStatusCode(true);
        TextPage firstRequestResult = webClient.getPage(contextPath + "IntrospectApplication");
        assertNotNull(firstRequestResult.getContent());
        assertTrue(Double.parseDouble(firstRequestResult.getContent()) != 0);
        // Make a second request and make sure the same context is used
        TextPage secondRequestResult = webClient.getPage(contextPath + "IntrospectApplication");
        assertNotNull(secondRequestResult.getContent());
        // should be same random number
        assertEquals(Double.parseDouble(secondRequestResult.getContent()), Double.parseDouble(firstRequestResult.getContent()));
    }
View Full Code Here

    @Test(groups = { CONTEXTS })
    @SpecAssertion(section = "6.7.3", id = "e")
    public void testApplicationContextSharedBetweenJaxRsRequests() throws Exception {
        WebClient webClient = new WebClient();
        webClient.setThrowExceptionOnFailingStatusCode(true);
        TextPage firstRequestResult = webClient.getPage(contextPath + "jaxrs/application-id");
        assertNotNull(firstRequestResult.getContent());
        assertTrue(Double.parseDouble(firstRequestResult.getContent()) != 0);
        // Make a second request and make sure the same context is used
        TextPage secondRequestResult = webClient.getPage(contextPath + "jaxrs/application-id");
        assertNotNull(secondRequestResult.getContent());
        // should be same random number
        assertEquals(Double.parseDouble(secondRequestResult.getContent()), Double.parseDouble(firstRequestResult.getContent()));
    }
View Full Code Here

        WebClient webClient = new WebClient();
        webClient.setThrowExceptionOnFailingStatusCode(true);

        // First request - response content contains SimpleRequestBean id
        TextPage firstRequestResult = webClient.getPage(contextPath + "introspectRequest");
        assertNotNull(firstRequestResult.getContent());
        assertNotEquals(Double.parseDouble(firstRequestResult.getContent()), 0);
        // Make a second request and make sure the same context is not there (compare SimpleRequestBean ids)
        TextPage secondRequestResult = webClient.getPage(contextPath + "introspectRequest");
        assertNotNull(secondRequestResult.getContent());
        assertNotEquals(Double.parseDouble(secondRequestResult.getContent()),
                Double.parseDouble(firstRequestResult.getContent()));

        // Make sure request context is destroyed after service(), doFilter(), requestDestroyed()
        webClient.getPage(contextPath + "introspectRequest?guard=collect");
        TextPage destroyRequestResult = webClient.getPage(contextPath + "introspectRequest?guard=verify");
        assertNotNull(destroyRequestResult.getContent());
        assertEquals(destroyRequestResult.getContent(), "true");
    }
View Full Code Here

    @Test
    @SpecAssertion(section = "6.7.3", id = "ae")
    public void testApplicationContextActiveOnComplete() throws Exception {
        WebClient webClient = new WebClient();
        webClient.setThrowExceptionOnFailingStatusCode(true);
        TextPage page = webClient.getPage(getPage(AsyncServlet.TEST_COMPLETE));
        assertTrue(page.getContent().contains("onTimeout: null"));
        assertTrue(page.getContent().contains("onError: null"));
        assertFalse(page.getContent().contains("onComplete: null"));
    }
View Full Code Here

    @Test
    @SpecAssertion(section = "6.7.3", id = "ae")
    public void testApplicationContextActiveOnTimeout() throws Exception {
        WebClient webClient = new WebClient();
        webClient.setThrowExceptionOnFailingStatusCode(true);
        TextPage page = webClient.getPage(getPage(AsyncServlet.TEST_TIMEOUT));
        assertFalse(page.getContent().contains("onTimeout: null"));
    }
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.