Package com.gargoylesoftware.htmlunit

Examples of com.gargoylesoftware.htmlunit.TextPage


    @Test
    public void testShiroWithSomeOtherUser() throws Exception {

        WebClient client = new WebClient();

        TextPage beforeLogin = client.getPage(url + "features");
        assertTrue(beforeLogin.getContent().contains("DISABLED = false"));
        assertTrue(beforeLogin.getContent().contains("ENABLED_FOR_ALL = true"));
        assertTrue(beforeLogin.getContent().contains("ENABLED_FOR_CK = false"));

        TextPage loginPage = client.getPage(url + "login?user=somebody");
        assertTrue(loginPage.getContent().contains("SUCCESS"));

        TextPage afterLogin = client.getPage(url + "features");
        assertTrue(afterLogin.getContent().contains("DISABLED = false"));
        assertTrue(afterLogin.getContent().contains("ENABLED_FOR_ALL = true"));
        assertTrue(afterLogin.getContent().contains("ENABLED_FOR_CK = false"));

        TextPage logoutPage = client.getPage(url + "logout");
        assertTrue(logoutPage.getContent().contains("SUCCESS"));

        TextPage afterLogout = client.getPage(url + "features");
        assertTrue(afterLogout.getContent().contains("DISABLED = false"));
        assertTrue(afterLogout.getContent().contains("ENABLED_FOR_ALL = true"));
        assertTrue(afterLogout.getContent().contains("ENABLED_FOR_CK = false"));

    }
View Full Code Here


*/
public class HelloworldTestCase {

    @Test
    public void testA() throws FailingHttpStatusCodeException, MalformedURLException, IOException {
        TextPage page = (TextPage)new WebClient().getPage("http://localhost:8085/helloworld-jaxrs/rest/world");
        assertEquals("Hello World", page.getContent());
    }
View Full Code Here

        // make sure we see the annotation
        HtmlPage rsp = createWebClient().getPage(b, "console");
        assertEquals(1,rsp.selectNodes("//B[@class='demo']").size());

        // make sure raw console output doesn't include the garbage
        TextPage raw = (TextPage)createWebClient().goTo(b.getUrl()+"consoleText","text/plain");
        System.out.println(raw.getContent());
        String nl = System.getProperty("line.separator");
        assertTrue(raw.getContent().contains(nl+"---"+nl+"ooo"+nl+"ooo"+nl));

        // there should be two 'ooo's
        assertEquals(3,rsp.asXml().split("ooo").length);
    }
View Full Code Here

        // make sure we see the annotation
        HtmlPage rsp = createWebClient().getPage(b, "console");
        assertEquals(1,rsp.selectNodes("//A[@href='http://infradna.com/']").size());

        // make sure raw console output doesn't include the garbage
        TextPage raw = (TextPage)createWebClient().goTo(b.getUrl()+"consoleText","text/plain");
        System.out.println(raw.getContent());
        assertTrue(raw.getContent().contains("\nabc\ndef\n"));
    }
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());
        // 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

        // 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

    @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

    @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
        checkContent(content, "(Destroyed:)(\\w+)", "true");
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

    @SpecAssertions({ @SpecAssertion(section = "6.7.1", id = "e"), @SpecAssertion(section = "6.7.1", id = "f") })
    public void testSimplePostConstructCallback() throws Exception {

        WebClient client = new WebClient();

        TextPage page = client.getPage(contextPath + "simple");
        // Context was active
        assertTrue(page.getContent().contains("Active:true"));
        // Not destroyed yet
        assertTrue(page.getContent().contains("Destroyed requests:0"));
    }
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.