1 package net.sourceforge.selfesteem.test;
2
3 import junit.framework.TestCase;
4 import net.sourceforge.selfesteem.Serializer;
5 import org.jdom.Element;
6 import org.jdom.Document;
7 import org.jdom.JDOMException;
8
9 public class WriterTest extends TestCase {
10 public WriterTest(String s) {
11 super(s);
12 }
13
14 public void testGeneratingAnApplet() {
15 Serializer serializer = new Serializer();
16 serializer.addLine(0, "keep on rockin");
17 serializer.addLine(2, "in the free world");
18
19 assertEquals("lines='2'\n" +
20 " line1='keep on rockin'\n" +
21 " line2='--in the free world'\n",
22 serializer.toString());
23 }
24
25 public void testEscapingXMLCharacters() throws JDOMException {
26 String unescaped = "< > ' \" &";
27 String escaped = "< > ' " &";
28
29 Serializer serializer = new Serializer();
30 serializer.addLine(0, unescaped);
31
32 assertEquals("lines='1'\n" +
33 " line1='" + escaped + "'\n",
34 serializer.toString());
35
36 Element element = ParseStoriesTest.getDocument("<foo " + serializer.toString() + "/>").getRootElement();
37 assertEquals("< > ' \" &", element.getAttributeValue("line1"));
38 }
39 }
This page was automatically generated by Maven