1 package de.fu_berlin.ties.xml;
2
3 import junit.framework.TestCase;
4
5
6
7 /***
8 * Generated by JUnitDoclet, a tool provided by
9 * ObjectFab GmbH under LGPL.
10 * Please see www.junitdoclet.org, www.gnu.org
11 * and www.objectfab.de for informations about
12 * the tool, the licence and the authors.
13 */
14
15
16 public class XMLConstituentTest
17
18 extends TestCase
19
20 {
21
22 final short type[] = {
23 OtherConstituent.COMMENT,
24 OtherConstituent.TEXT
25 };
26 final String[] rep = {
27 "<!-- this is a comment -->",
28 "Some text."
29 };
30 XMLConstituent[] xmlConsts = new XMLConstituent[type.length];
31
32
33 public XMLConstituentTest(String name) {
34
35 super(name);
36
37 }
38
39 public de.fu_berlin.ties.xml.XMLConstituent createInstance() throws Exception {
40
41
42 return new OtherConstituent(type[0], rep[0]);
43
44 }
45
46 protected void setUp() throws Exception {
47
48 super.setUp();
49 for (int i = 0; i < xmlConsts.length; i++) {
50 xmlConsts[i] = new OtherConstituent(type[i], rep[i]);
51 if (i > 0) {
52 xmlConsts[i-1].insertAfter(xmlConsts[i]);
53 }
54 }
55
56 }
57
58 protected void tearDown() throws Exception {
59
60 for (int i = 0; i < xmlConsts.length; i++) {
61 xmlConsts[i] = null;
62 }
63 super.tearDown();
64
65 }
66
67 public void testSetGetRepresentantion() throws Exception {
68
69 final String newRep = "new representation";
70 for (int i = 0; i < xmlConsts.length; i++) {
71 assertEquals(xmlConsts[i].getRepresentantion(), rep[i]);
72 xmlConsts[i].setRepresentantion(newRep);
73 assertEquals(xmlConsts[i].getRepresentantion(), newRep);
74 xmlConsts[i].setRepresentantion("");
75 assertEquals(xmlConsts[i].getRepresentantion(), "");
76 xmlConsts[i].setRepresentantion(null);
77 assertNull(xmlConsts[i].getRepresentantion());
78 }
79
80 }
81
82 public void testGetType() throws Exception {
83
84 for (int i = 0; i < xmlConsts.length; i++) {
85 assertEquals(xmlConsts[i].getType(), type[i]);
86 }
87
88 }
89
90 public void testNextConstituent() throws Exception {
91
92 for (int i = 0; i < xmlConsts.length-1; i++) {
93 assertSame(xmlConsts[i].nextConstituent(), xmlConsts[i].next());
94 assertSame(xmlConsts[i].nextConstituent(), xmlConsts[i+1]);
95 }
96 assertNull(xmlConsts[xmlConsts.length-1].nextConstituent());
97
98 }
99
100 public void testPreviousConstituent() throws Exception {
101
102 for (int i = 1; i < xmlConsts.length; i++) {
103 assertSame(xmlConsts[i].previousConstituent(), xmlConsts[i].previous());
104 assertSame(xmlConsts[i].previousConstituent(), xmlConsts[i-1]);
105 }
106 assertNull(xmlConsts[0].previousConstituent());
107
108 }
109
110
111
112 /***
113 * JUnitDoclet moves marker to this method, if there is not match
114 * for them in the regenerated code and if the marker is not empty.
115 * This way, no test gets lost when regenerating after renaming.
116 * Method testVault is supposed to be empty.
117 */
118 public void testVault() throws Exception {
119
120
121 }
122
123 public static void main(String[] args) {
124
125 junit.textui.TestRunner.run(XMLConstituentTest.class);
126
127 }
128 }