Examples of MarkupWriter


Examples of org.apache.tapestry5.MarkupWriter

     * 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(),
View Full Code Here

Examples of org.apache.tapestry5.MarkupWriter

    }

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

        w.write("  ");

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

        assertEquals(w.toString(), "<?xml version=\"1.0\"?>\n" +
                "  <root/>");
    }
View Full Code Here

Examples of org.apache.tapestry5.MarkupWriter

    }

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

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

        w.write("  ");

        assertEquals(w.toString(), "<?xml version=\"1.0\"?>\n  <root/>");
    }
View Full Code Here

Examples of org.apache.tapestry5.MarkupWriter

    }

    @Test()
    public void preamble_content() throws Exception
    {
        MarkupWriter w = new MarkupWriterImpl(new XMLMarkupModel());

        w.comment("preamble start");
        w.write("preamble text");
        w.cdata("CDATA content");
        w.writeRaw("&nbsp;");
        w.element("root");
        w.end();
        // You really shouldn't have any text after the close tag of the document, so it
        // gets moved to the top, to the "preamble", before the first element.
        w.comment("content after root element in preamble");

        assertEquals(w.getDocument().toString(), readFile("preamble_content.txt"));
    }
View Full Code Here

Examples of org.apache.tapestry5.MarkupWriter

    }

    @Test(expectedExceptions = IllegalStateException.class)
    public void attribute_ns_with_no_current_element()
    {
        MarkupWriter w = new MarkupWriterImpl();

        w.attributeNS("foo", "bar", "baz");
    }
View Full Code Here

Examples of org.apache.tapestry5.MarkupWriter

    }

    @Test(expectedExceptions = IllegalStateException.class)
    public void define_namespace_with_no_current_element()
    {
        MarkupWriter w = new MarkupWriterImpl();

        w.defineNamespace("foo", "bar");
    }
View Full Code Here

Examples of org.apache.tapestry5.MarkupWriter

    }

    @Test(expectedExceptions = IllegalStateException.class)
    public void end_with_no_current_element()
    {
        MarkupWriter w = new MarkupWriterImpl();

        w.end();
    }
View Full Code Here

Examples of org.apache.tapestry5.MarkupWriter

    }

    @Test(expectedExceptions = IllegalStateException.class)
    public void attributes_with_no_current_element()
    {
        MarkupWriter w = new MarkupWriterImpl();

        w.attributes("fail", "now");
    }
View Full Code Here

Examples of org.apache.tapestry5.MarkupWriter

    }

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

        w.element("root");

        assertNull(w.end());
    }
View Full Code Here

Examples of org.apache.tapestry5.MarkupWriter

    }

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

        Element root = w.element("root");

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

        w.write("before child");

        assertNotSame(w.element("nested"), root);

        w.write("inner text");

        assertSame(w.end(), root);

        w.write("after child");

        root.attribute("gnip", "gnop");

        assertEquals(w.toString(),
                     "<root foo=\"bar\" gnip=\"gnop\">before child<nested>inner text</nested>after child</root>");
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.