01: package org.uispec4j.xml;
02:
03: import org.uispec4j.utils.UnitTestCase;
04:
05: import java.io.StringReader;
06: import java.io.StringWriter;
07:
08: public class XmlWriterTest extends UnitTestCase {
09: private StringWriter out = new StringWriter();
10:
11: public void testStartTag() throws Exception {
12: XmlWriter.startTag(out, "Root").addAttribute("toto", "titi")
13: .start("Toto").start("Titi").addAttribute("attr",
14: "value").addValue("bbb").end().start("A").end()
15: .start("B").start("C").end().end().end().end().end();
16:
17: SaxParser parser = new SaxParser();
18: parser.parse(SilentNode.INSTANCE, new StringReader(out
19: .toString()));
20: String expectedXmlString = "<Root toto=\"titi\"> <Toto> <Titi attr=\"value\">bbb</Titi> <A/> <B> <C/> </B> </Toto> </Root>";
21: XmlAssert.assertEquivalent(expectedXmlString, out.toString());
22: }
23: }
|