Package com.gargoylesoftware.htmlunit

Examples of com.gargoylesoftware.htmlunit.WebClient$CurrentWindowTracker


    protected WebClient _webClient;
    protected URL _url;

    protected void setUp() throws Exception {
        //New HTMLunit web client
        _webClient = new WebClient();
        _webClient.setRedirectEnabled(true);

        // Going to have the WebClient connect to this URL
        _url = new URL(testUrl);
View Full Code Here


     */
    @Override
    //@Before
    public void before()
    {
        webClient = new WebClient(getBrowserVersion());
        webClient.setAjaxController(new NicelyResynchronizingAjaxController());
    }
View Full Code Here

    //@Before
    public void before()
    {
        super.before();

        webClient = new WebClient(getBrowserVersion());
        webClient.setAjaxController(new NicelyResynchronizingAjaxController());
    }
View Full Code Here

     * The request scope is active during the service() method of any Servlet in the web application.
     */
    @Test(groups = { CONTEXTS, SERVLET })
    @SpecAssertions({ @SpecAssertion(section = "6.7.1", id = "aa"), @SpecAssertion(section = "6.7.1", id = "ac") })
    public void testRequestScopeActiveDuringServiceMethod() throws Exception {
        WebClient webClient = new WebClient();
        webClient.setThrowExceptionOnFailingStatusCode(true);
        webClient.getPage(contextPath + "serviceMethodTest");
    }
View Full Code Here

     * The request scope is active during the doFilter() method of any Filter in the web application.
     */
    @Test(groups = { CONTEXTS, SERVLET })
    @SpecAssertions({ @SpecAssertion(section = "6.7.1", id = "ab"), @SpecAssertion(section = "6.7.1", id = "ac") })
    public void testRequestScopeActiveDuringServletFilter() throws Exception {
        WebClient webClient = new WebClient();
        webClient.setThrowExceptionOnFailingStatusCode(true);
        webClient.getPage(contextPath + "SimplePage.html");
    }
View Full Code Here

            @SpecAssertion(section = "6.7.3", id = "ga"), @SpecAssertion(section = "11.5.4", id = "a") })
    public void testShutdown(@ArquillianResource @OperateOnDeployment(FOO) URL fooContext,
            @ArquillianResource @OperateOnDeployment(INFO) URL infoContext) throws Exception {

        // Init foo - set info archive deployment url
        WebClient webClient = new WebClient();
        webClient.setThrowExceptionOnFailingStatusCode(true);
        webClient.getPage(fooContext + "init?url=" + URLEncoder.encode(infoContext.toExternalForm(), "UTF-8"));

        // Undeploy foo
        deployer.undeploy(FOO);

        // 1. Destroy contexts
        // 2. Destroy dependent objects injected into enums
        // 3. BeforeShutdown event
        ActionSequence correctSequence = new ActionSequence().add(RequestScoped.class.getName())
                .add(ApplicationScoped.class.getName()).add(Foo.class.getName()).add(BeforeShutdown.class.getName());
        TextPage info = webClient.getPage(infoContext + "info?action=get");
        assertEquals(info.getContent(), correctSequence.toString());

        // Undeploy info
        deployer.undeploy(INFO);
    }
View Full Code Here

    @Test(groups = { CONTEXTS, SERVLET })
    @SpecAssertions({ @SpecAssertion(section = "6.7.1", id = "ba"), @SpecAssertion(section = "6.7.1", id = "bb"),
            @SpecAssertion(section = "6.7.1", id = "bc") })
    public void testRequestScopeIsDestroyedAfterServletRequest() throws Exception {

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

        // First request - response content contains SimpleRequestBean id
        TextPage firstRequestResult = webClient.getPage(contextPath + "introspectRequest");
        assertNotNull(firstRequestResult.getContent());
        // 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(secondRequestResult.getContent().trim(), firstRequestResult.getContent().trim());

        // Make sure request context is destroyed after service(), doFilter(), requestDestroyed()
        webClient.getPage(contextPath + "introspectRequest?mode=collect");
        ActionSequence correctSequence = new ActionSequence().add(IntrospectServlet.class.getName())
                .add(IntrospectTestFilter.class.getName()).add(TestServletRequestListener.class.getName())
                .add(ContextDestructionObserver.class.getName());
        TextPage destroyRequestResult = webClient.getPage(contextPath + "introspectRequest?mode=verify");
        assertNotNull(destroyRequestResult.getContent());
        assertEquals(destroyRequestResult.getContent(), correctSequence.toString());
    }
View Full Code Here

    @Test
    @SpecAssertions({ @SpecAssertion(section = "6.7.1", id = "jd") })
    public void testEventsFired() throws Exception {

        WebClient client = new WebClient();

        TextPage page = client.getPage(contextPath + "info");
        String content = page.getContent();

        checkContent(content, "(Initialized:)(\\w+)", "true");
        // Timeout request only
        checkContent(content, "(Destroyed:)(\\w+)", "true");
View Full Code Here

    @Test
    @SpecAssertions({ @SpecAssertion(section = "6.7.1", id = "je") })
    public void testEventsFired() throws Exception {

        WebClient client = new WebClient();

        TextPage page = client.getPage(contextPath + "info");
        String content = page.getContent();

        // Test request and timeout request
        checkContent(content, "(Initialized:)(\\w+)", "true");
        // Timeout request only
View Full Code Here

    @Test(groups = { CONTEXTS })
    @SpecAssertions({ @SpecAssertion(section = "6.7.1", id = "c"), @SpecAssertion(section = "6.7.1", id = "d"),
            @SpecAssertion(section = "6.7.1", id = "jb") })
    public void testRequestScopeActiveDuringWebServiceInvocation() throws Exception {

        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

TOP

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

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.