Package com.gargoylesoftware.htmlunit

Examples of com.gargoylesoftware.htmlunit.WebClient$BinaryWebResponse


    }

    @Test(groups = { CONTEXTS, SERVLET })
    @SpecAssertion(section = "6.7.2", id = "aa")
    public void testSessionScopeActiveDuringServiceMethod() throws Exception {
        WebClient webClient = new WebClient();
        webClient.setThrowExceptionOnFailingStatusCode(true);
        webClient.getPage(contextPath + "serviceMethodTest");
    }
View Full Code Here


    }

    @Test(groups = { CONTEXTS, SERVLET })
    @SpecAssertion(section = "6.7.2", id = "ab")
    public void testSessionScopeActiveDuringDoFilterMethod() throws Exception {
        WebClient webClient = new WebClient();
        webClient.setThrowExceptionOnFailingStatusCode(true);
        webClient.getPage(contextPath + "SimplePage.html");
    }
View Full Code Here

    }

    @Test(groups = { CONTEXTS, SERVLET })
    @SpecAssertion(section = "6.7.2", id = "b")
    public void testSessionContextSharedBetweenServletRequestsInSameHttpSession() 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;
        // Make a second request and make sure the same context is used
        TextPage secondRequestResult = webClient.getPage(contextPath + "IntrospectSession");
        assert secondRequestResult.getContent() != null;
        assert Long.parseLong(secondRequestResult.getContent()) == Long.parseLong(firstRequestResult.getContent());
    }
View Full Code Here

    }

    @Test(groups = { CONTEXTS })
    @SpecAssertions({ @SpecAssertion(section = "6.7.4", id = "hb"), @SpecAssertion(section = "6.7.4", id = "o") })
    public void testConversationIdSetByContainerIsUnique() throws Exception {
        WebClient client = new WebClient();
        HtmlPage storm = client.getPage(getPath("storm.jsf"));
        HtmlSubmitInput beginConversationButton = getFirstMatchingElement(storm, HtmlSubmitInput.class,
                "beginConversationButton");
        storm = beginConversationButton.click();

        String c1 = getCid(storm);

        storm = client.getPage(getPath("storm.jsf"));
        beginConversationButton = getFirstMatchingElement(storm, HtmlSubmitInput.class, "beginConversationButton");
        storm = beginConversationButton.click();

        String c2 = getCid(storm);
View Full Code Here

    }

    @Test(groups = { CONTEXTS, SERVLET })
    @SpecAssertion(section = "6.7.2", id = "ca")
    public void testSessionContextDestroyedWhenHttpSessionInvalidated() 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");
        // 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(groups = { CONTEXTS })
    @SpecAssertion(section = "6.7.4", id = "j")
    public void testTransientConversationInstancesDestroyedAtRequestEnd() throws Exception {
        WebClient client = new WebClient();

        resetCloud(client);
        resetConversationContextObserver(client);

        HtmlPage page = client.getPage(getPath("cloud.jsf"));

        assertFalse(isLongRunning(page));
        assertTrue(isCloudDestroyed(client));
        assertTrue(isConversationContextDestroyed(client));
    }
View Full Code Here

    }

    @Test(groups = { CONTEXTS })
    @SpecAssertion(section = "6.7.4", id = "k")
    public void testLongRunningConversationInstancesNotDestroyedAtRequestEnd() throws Exception {
        WebClient client = new WebClient();
        HtmlPage storm = client.getPage(getPath("storm.jsf"));
        HtmlSubmitInput beginConversationButton = getFirstMatchingElement(storm, HtmlSubmitInput.class,
                "beginConversationButton");
        storm = beginConversationButton.click();

        resetCloud(client);

        client.getPage(getPath("cloud.jsf", getCid(storm)));
        assert !isCloudDestroyed(client);
    }
View Full Code Here

    }

    @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 = "5.5", id = "ef"), @SpecAssertion(section = "5.5.2", id = "ae"),
            @SpecAssertion(section = "5.5.2", id = "bn"), @SpecAssertion(section = "3.9", id = "b") })
    public void testInjectionIntoServlet() throws Exception {
        WebClient webClient = new WebClient();
        webClient.setThrowExceptionOnFailingStatusCode(true);
        webClient.getPage(contextPath + "Test/Servlet?test=injection");
    }
View Full Code Here

    }

    @Test(groups = { CONTEXTS })
    @SpecAssertion(section = "6.7.4", id = "p")
    public void testConversationsDontCrossSessionBoundary1() throws Exception {
        WebClient client = new WebClient();
        client.setThrowExceptionOnFailingStatusCode(false);
        // Load the page
        HtmlPage rain = client.getPage(getPath("rain.jsf"));

        // begin a conversation
        HtmlSubmitInput beginConversationButton = getFirstMatchingElement(rain, HtmlSubmitInput.class,
                "beginConversationButton");
        rain = beginConversationButton.click();
        String cid = getCid(rain);

        // Cause rain
        HtmlSubmitInput rainButton = getFirstMatchingElement(rain, HtmlSubmitInput.class, "rain");
        rain = rainButton.click();

        // Re-request the page, inside the conversation and check it has rained
        rain = client.getPage(getPath("rain.jsf", cid));
        assert hasRained(rain);

        // Invalidate the session, invalidate the conversation-scoped cloud
        invalidateSession(client);

        // Re-request the page, check it hasn't rained
        rain = client.getPage(getPath("rain.jsf", cid));
        assert !hasRained(rain);
    }
View Full Code Here

TOP

Related Classes of com.gargoylesoftware.htmlunit.WebClient$BinaryWebResponse

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.