Package org.apache.tapestry.dom

Examples of org.apache.tapestry.dom.Document


    public void submit_form()
    {
        String appPackage = "org.apache.tapestry.integration.app2";
        String appName = "";
        _tester = new PageTester(appPackage, appName);
        Document doc = _tester.renderPage("TestPageForForm");
        Element form = doc.getElementById("form1");
        Map<String, String> fieldValues = CollectionFactory.newMap();
        fieldValues.put("t1", "hello");
        doc = _tester.submitForm(form, fieldValues);
        assertTrue(doc.toString().contains("You entered: hello"));
    }
View Full Code Here


    public void render()
    {
        String appPackage = "org.apache.tapestry.integration.app2";
        String appName = "";
        _tester = new PageTester(appPackage, appName);
        Document doc = _tester.renderPage("TestPageForIf");
        assertNotNull(doc.getElementById("1"));
        assertNotNull(doc.getElementById("3"));
        assertNull(doc.getElementById("2"));
        assertNull(doc.getElementById("4"));
    }
View Full Code Here

public class InjectStandardStylesheetCommandTest extends InternalBaseTestCase
{
    @Test
    public void no_head_element()
    {
        Document d = new Document();
        Environment env = newEnvironment();
        Asset asset = newAsset();

        d.newRootElement("foo");
        String initial = d.toString();

        train_peek(env, Document.class, d);

        replay();

        new InjectStandardStylesheetCommand(asset).cleanup(env);

        assertEquals(d.toString(), initial, "Document structure should not change.");

        verify();
    }
View Full Code Here

    }

    @Test
    public void head_element_found()
    {
        Document d = new Document();
        Environment env = newEnvironment();
        Asset asset = newAsset();

        d.newRootElement("html").element("head");

        train_peek(env, Document.class, d);

        toClientURL(asset, "{clientURL}");

        replay();

        new InjectStandardStylesheetCommand(asset).cleanup(env);

        verify();

        assertEquals(
                d.toString(),
                "<html><head><link href=\"{clientURL}\" rel=\"stylesheet\" type=\"text/css\"></head></html>");
    }
View Full Code Here

public class DocumentScriptBuilderImplTest extends InternalBaseTestCase
{
    @Test
    public void do_nothing_if_no_body()
    {
        Document document = new Document();

        document.newRootElement("not-html").text("not an HTML document");

        DocumentScriptBuilder builder = new DocumentScriptBuilderImpl();

        builder.addScript("foo.js");
        builder.addScript("doSomething();");

        builder.updateDocument(document);

        assertEquals(document.toString(), "<not-html>not an HTML document</not-html>");
    }
View Full Code Here

    }

    @Test
    public void add_script_links() throws Exception
    {
        Document document = new Document(new XMLMarkupModel());

        document.newRootElement("html").element("body").element("p").text(
                "Ready to be updated with scripts.");

        DocumentScriptBuilder builder = new DocumentScriptBuilderImpl();

        builder.addScriptLink("foo.js");
        builder.addScriptLink("bar/baz.js");

        builder.updateDocument(document);

        assertEquals(document.toString(), readFile("add_script_links.txt", true));
    }
View Full Code Here

    }

    @Test
    public void duplicate_script_links_ignored() throws Exception
    {
        Document document = new Document();

        document.newRootElement("html").element("body").element("p").text(
                "Ready to be updated with scripts.");

        DocumentScriptBuilder builder = new DocumentScriptBuilderImpl();

        for (int i = 0; i < 3; i++)
        {
            builder.addScriptLink("foo.js");
            builder.addScriptLink("bar/baz.js");
            builder.addScriptLink("biff.js");
        }

        builder.updateDocument(document);

        assertEquals(document.toString(), readFile("duplicate_script_links_ignored.txt", true));
    }
View Full Code Here

    }

    @Test
    public void add_script() throws Exception
    {
        Document document = new Document();

        document.newRootElement("html").element("body").element("p").text(
                "Ready to be updated with scripts.");

        DocumentScriptBuilder builder = new DocumentScriptBuilderImpl();

        builder.addScript("doSomething();");
        builder.addScript("doSomethingElse();");

        builder.updateDocument(document);

        assertEquals(document.toString(), readFile("add_script.txt", false).trim());
    }
View Full Code Here

        {
            public void cleanup(Environment environment)
            {
                environment.pop(PageRenderSupport.class);

                Document document = environment.peek(Document.class);

                DocumentHeadBuilder builder = environment.pop(DocumentHeadBuilder.class);

                builder.updateDocument(document);
            }
View Full Code Here

        {
            public void cleanup(Environment environment)
            {
                environment.pop(PageRenderSupport.class);

                Document document = environment.peek(Document.class);

                DocumentScriptBuilder builder = environment.pop(DocumentScriptBuilder.class);

                builder.updateDocument(document);
            }
View Full Code Here

TOP

Related Classes of org.apache.tapestry.dom.Document

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.