Search in sources :

Example 11 with Document

use of org.apache.tapestry5.dom.Document in project tapestry-5 by apache.

the class ASOTest method submit_aso.

@Test
public void submit_aso() {
    tester = new PageTester(TestConstants.APP2_PACKAGE, TestConstants.APP2_NAME);
    Document doc = tester.renderPage("TestPageForASO");
    assertTrue(doc.toString().contains("bar"));
}
Also used : PageTester(org.apache.tapestry5.test.PageTester) Document(org.apache.tapestry5.dom.Document) Test(org.testng.annotations.Test)

Example 12 with Document

use of org.apache.tapestry5.dom.Document in project tapestry-5 by apache.

the class TestableResponseImplTest method http_headers.

@Test
public void http_headers() {
    Document document = tester.renderPage(TestPageForHttpHeaders.class.getSimpleName());
    assertTrue(document.toString().contains("Test page for HTTP headers"));
    TestableResponse response = tester.getService(TestableResponse.class);
    assertEquals(response.getHeader(TestPageForHttpHeaders.DATE_HEADER_NAME), 12345L);
    assertEquals(response.getHeader(TestPageForHttpHeaders.INT_HEADER_NAME), 6789);
    assertEquals(response.getHeader(TestPageForHttpHeaders.STRING_HEADER_NAME), "foo-bar-baz-barney");
}
Also used : TestPageForHttpHeaders(org.apache.tapestry5.integration.app2.pages.TestPageForHttpHeaders) Document(org.apache.tapestry5.dom.Document) Test(org.testng.annotations.Test)

Example 13 with Document

use of org.apache.tapestry5.dom.Document in project tapestry-5 by apache.

the class MarkupWriterImplTest method single_root_element_only.

/**
 * TAP5-349
 */
@Test
public void single_root_element_only() {
    MarkupWriter w = new MarkupWriterImpl(new XMLMarkupModel());
    w.element("root1");
    w.end();
    try {
        w.element("root2");
        unreachable();
    } catch (RuntimeException ex) {
        assertEquals(ex.getMessage(), "A document must have exactly one root element. Element <root1> is already the root element.");
    }
}
Also used : XMLMarkupModel(org.apache.tapestry5.dom.XMLMarkupModel) MarkupWriter(org.apache.tapestry5.MarkupWriter) Test(org.testng.annotations.Test)

Example 14 with Document

use of org.apache.tapestry5.dom.Document in project gwtproject by treblereel.

the class ScriptInjectorTest method findScriptUrl.

/**
 * Won't work for all urls, uses a regular expression match
 */
private JavaScriptObject findScriptUrl(JavaScriptObject wnd, String url) {
    Document document = getDocumentFromWindow(wnd);
    NodeList<Element> scripts = document.getElementsByTagName("script");
    for (int i = 0; i < scripts.getLength(); i++) {
        Element script = scripts.getAt(i);
        if (script.getAttribute("src").matches(url)) {
            return Js.cast(script);
        }
    }
    return null;
}
Also used : Element(elemental2.dom.Element) Document(elemental2.dom.Document)

Example 15 with Document

use of org.apache.tapestry5.dom.Document in project gwtproject by treblereel.

the class ScriptInjectorTest method findScriptText.

private JavaScriptObject findScriptText(JavaScriptObject wnd, String text) {
    Document document = getDocumentFromWindow(wnd);
    NodeList<Element> scripts = document.getElementsByTagName("script");
    for (int i = 0; i < scripts.getLength(); i++) {
        Element script = scripts.getAt(i);
        if (script.textContent.matches("^" + text)) {
            return Js.cast(script);
        }
    }
    return null;
}
Also used : Element(elemental2.dom.Element) Document(elemental2.dom.Document)

Aggregations

Document (org.apache.tapestry5.dom.Document)20 Test (org.testng.annotations.Test)19 PageTester (org.apache.tapestry5.test.PageTester)11 Element (org.apache.tapestry5.dom.Element)8 MarkupWriter (org.apache.tapestry5.MarkupWriter)4 Document (elemental2.dom.Document)2 Element (elemental2.dom.Element)2 XMLMarkupModel (org.apache.tapestry5.dom.XMLMarkupModel)2 IOException (java.io.IOException)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 XPathExpressionException (javax.xml.xpath.XPathExpressionException)1 TestPageForActionLinkWithStream (org.apache.tapestry5.integration.app2.pages.TestPageForActionLinkWithStream)1 TestPageForHttpHeaders (org.apache.tapestry5.integration.app2.pages.TestPageForHttpHeaders)1 Page (org.apache.tapestry5.internal.structure.Page)1 RenderCommand (org.apache.tapestry5.runtime.RenderCommand)1 ComponentLibraryInfo (org.apache.tapestry5.services.ComponentLibraryInfo)1 Test (org.junit.Test)1 Document (org.w3c.dom.Document)1