Package org.apache.tapestry5

Examples of org.apache.tapestry5.MarkupWriter


    }

    @Test
    public void element_with_attributes()
    {
        MarkupWriter w = new MarkupWriterImpl();

        w.element("img", "src", "foo.png", "width", 20, "height", 20);
        w.end();

        // img is a tag with an end tag style of omit, so no close tag is written.

        assertEquals(w.toString(), "<img height=\"20\" width=\"20\" src=\"foo.png\"/>");
    }
View Full Code Here


    }

    @Test
    public void attributes()
    {
        MarkupWriter w = new MarkupWriterImpl();

        w.element("root");

        w.attributes("foo", "bar", "gnip", "gnop");

        assertEquals(w.toString(), "<root gnip=\"gnop\" foo=\"bar\"></root>");
    }
View Full Code Here

    }

    @Test
    public void attributes_odd_number()
    {
        MarkupWriter w = new MarkupWriterImpl();

        w.element("img");

        try
        {
            w.attributes("src", "foo.png", "width", 20, 30);
            unreachable();
        }
        catch (RuntimeException ex)
        {
            assertMessageContains(ex, "Writing attributes of the element 'img' failed.",
View Full Code Here

    }

    @Test
    public void comment()
    {
        MarkupWriter w = new MarkupWriterImpl();

        w.element("root");
        w.comment(" A comment ");
        w.end();

        assertEquals(w.toString(), "<root><!-- A comment --></root>");
    }
View Full Code Here

    }

    @Test
    public void entities_inside_comment_not_converted()
    {
        MarkupWriter w = new MarkupWriterImpl();

        w.element("root");
        w.comment(" <&> ");
        w.end();

        assertEquals(w.toString(), "<root><!-- <&> --></root>");
    }
View Full Code Here

    }

    @Test
    public void new_text_node_after_comment_node()
    {
        MarkupWriter w = new MarkupWriterImpl();

        w.element("root");
        w.write("before");
        w.comment(" A comment ");
        w.write("after");
        w.end();

        assertEquals(w.toString(), "<root>before<!-- A comment -->after</root>");
    }
View Full Code Here

    }

    @Test
    public void null_write_is_ok()
    {
        MarkupWriter w = new MarkupWriterImpl();

        w.element("root");
        w.write(null);
        w.end();

        assertEquals(w.toString(), "<root></root>");
    }
View Full Code Here

    }

    @Test
    public void writef()
    {
        MarkupWriter w = new MarkupWriterImpl();

        w.element("root");
        w.writef("Test name: %s", "writef");

        assertEquals(w.toString(), "<root>Test name: writef</root>");
    }
View Full Code Here

    }

    @Test
    public void write_raw()
    {
        MarkupWriter w = new MarkupWriterImpl();

        w.element("root");
        w.write("<");
        w.writeRaw("&nbsp;");
        w.write(">");
        w.end();

        assertEquals(w.toString(), "<root>&lt;&nbsp;&gt;</root>");
    }
View Full Code Here

    }

    @Test
    public void remove_while_rendering()
    {
        MarkupWriter writer = new MarkupWriterImpl(new XMLMarkupModel());

        writer.element("ul");

        for (int i = 0; i < 4; i++)
        {
            Element e = writer.element("li");

            if (i != 2)
            {
                writer.write(String.valueOf(i));
            }

            writer.end();

            if (e.getChildren().isEmpty())
            {
                e.remove();
            }
        }

        writer.end();

        assertEquals(writer.toString(), "<?xml version=\"1.0\"?>\n" +
                "<ul><li>0</li><li>1</li><li>3</li></ul>");
    }
View Full Code Here

TOP

Related Classes of org.apache.tapestry5.MarkupWriter

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.