Package com.gargoylesoftware.htmlunit

Examples of com.gargoylesoftware.htmlunit.WebClient$BinaryWebResponse


        this.oAuthParams = oAuthParams;
        this.oAuthToken = null;

        // create HtmlUnit client
        webClient = new WebClient(BrowserVersion.FIREFOX_24);
        final WebClientOptions options = webClient.getOptions();
        options.setRedirectEnabled(true);
        options.setJavaScriptEnabled(false);
        options.setThrowExceptionOnFailingStatusCode(true);
        options.setThrowExceptionOnScriptError(true);
View Full Code Here


    @Inject
    private Instance<TestClass> testClass;

    public void checkComponentSource(URL pageName, String xmlunitPage, By pageElementToTest) throws IOException, SAXException {
        WebClient client = new WebClient();
        client.getOptions().setJavaScriptEnabled(false);

        HtmlPage page = client.getPage(pageName);
        DomElement element;

        String locator = pageElementToTest.toString();
        locator = locator.substring(locator.indexOf(':') + 1).trim();
View Full Code Here

    @Test(groups = {INTEGRATION, ASYNC_SERVLET})
    @SpecAssertions({ @SpecAssertion(section = SESSION_CONTEXT, id = "ad") })
    public void testSessionContextActiveOnComplete() throws Exception {

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

        TextPage page01 = webClient.getPage(getPath(AsyncServlet.TEST_COMPLETE));
        assertTrue(page01.getContent().contains("onTimeout: null"));
        assertTrue(page01.getContent().contains("onError: null"));
        assertFalse(page01.getContent().contains("onComplete: null"));
        String id = extractSimpleSessionBeanId(page01.getContent());
        assertNotNull(id);
View Full Code Here

    }

    @Test(groups = {INTEGRATION, ASYNC_SERVLET})
    @SpecAssertions({ @SpecAssertion(section = SESSION_CONTEXT, id = "ad") })
    public void testSessionContextActiveOnTimeout() throws Exception {
        WebClient webClient = new WebClient();
        webClient.setThrowExceptionOnFailingStatusCode(false);
        TextPage page = webClient.getPage(getPath(AsyncServlet.TEST_TIMEOUT));
        assertTrue(page.getContent().contains("onTimeout:"));
        assertFalse(page.getContent().contains("onTimeout: null"));
    }
View Full Code Here

    }

    @Test(groups = {INTEGRATION, ASYNC_SERVLET})
    @SpecAssertions({ @SpecAssertion(section = SESSION_CONTEXT, id = "ad") })
    public void testSessionContextActiveOnError() throws Exception {
        WebClient webClient = new WebClient();
        webClient.setThrowExceptionOnFailingStatusCode(false);
        TextPage page = webClient.getPage(getPath(AsyncServlet.TEST_ERROR));
        assertTrue(page.getContent().contains("onError:"));
        assertFalse(page.getContent().contains("onError: null"));
    }
View Full Code Here

    }

    @Test(groups = {INTEGRATION, ASYNC_SERVLET})
    @SpecAssertions({ @SpecAssertion(section = SESSION_CONTEXT, id = "ad") })
    public void testSessionContextActiveOnStartAsync() throws Exception {
        WebClient webClient = new WebClient();
        webClient.setThrowExceptionOnFailingStatusCode(true);
        TextPage page = webClient.getPage(getPath(AsyncServlet.TEST_LOOP));
        assertFalse(page.getContent().contains("onStartAsync: null"));
        assertFalse(page.getContent().contains("onComplete: null"));
    }
View Full Code Here

        // New instance of Foo is created for each WS request
        String id01 = translator.translate();
        String id02 = translator.translate();
        assertNotEquals(id01, id02);

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

        TextPage info = webClient.getPage(contextPath + "info");

        Matcher matcher = Pattern.compile("(Foo destroyed:)(\\w+)").matcher(info.getContent());
        if (matcher.find()) {
            String value = matcher.group(2);
            assertEquals(value, "2");
View Full Code Here

    @Test(groups = {INTEGRATION, ASYNC_SERVLET})
    @SpecAssertions({ @SpecAssertion(section = REQUEST_CONTEXT, id = "ad"), @SpecAssertion(section = REQUEST_CONTEXT, id = "bd") })
    public void testRequestContextActiveOnComplete() throws Exception {

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

        TextPage page01 = webClient.getPage(getPath(AsyncServlet.TEST_COMPLETE));
        assertTrue(page01.getContent().contains("onTimeout: null"));
        assertTrue(page01.getContent().contains("onError: null"));
        assertFalse(page01.getContent().contains("onComplete: null"));

        // Indirectly test request context is destroyed after onComplete()
        TextPage page02 = webClient.getPage(getPath(AsyncServlet.TEST_COMPLETE));
        assertNotEquals(extractSimpleRequestBeanIdString(page01.getContent()),
                extractSimpleRequestBeanIdString(page02.getContent()));
    }
View Full Code Here

    }

    @Test(groups = {INTEGRATION, ASYNC_SERVLET})
    @SpecAssertion(section = REQUEST_CONTEXT, id = "ad")
    public void testRequestContextActiveOnTimeout() throws Exception {
        WebClient webClient = new WebClient();
        webClient.setThrowExceptionOnFailingStatusCode(false);
        TextPage page = webClient.getPage(getPath(AsyncServlet.TEST_TIMEOUT));
        assertTrue(page.getContent().contains("onTimeout:"));
        assertFalse(page.getContent().contains("onTimeout: null"));
    }
View Full Code Here

    }

    @Test(groups = {INTEGRATION, ASYNC_SERVLET})
    @SpecAssertion(section = REQUEST_CONTEXT, id = "ad")
    public void testRequestContextActiveOnError() throws Exception {
        WebClient webClient = new WebClient();
        webClient.setThrowExceptionOnFailingStatusCode(false);
        TextPage page = webClient.getPage(getPath(AsyncServlet.TEST_ERROR));
        assertTrue(page.getContent().contains("onError:"));
        assertFalse(page.getContent().contains("onError: null"));
    }
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.