1   package de.fu_berlin.ties.xml;
2   
3   import junit.framework.TestCase;
4   // JUnitDoclet begin import
5   // JUnitDoclet end import
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  // JUnitDoclet begin extends_implements
18  extends TestCase
19  // JUnitDoclet end extends_implements
20  {
21    // JUnitDoclet begin class
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    // JUnitDoclet end class
32    
33    public XMLConstituentTest(String name) {
34      // JUnitDoclet begin method XMLConstituentTest
35      super(name);
36      // JUnitDoclet end method XMLConstituentTest
37    }
38    
39    public de.fu_berlin.ties.xml.XMLConstituent createInstance() throws Exception {
40      // JUnitDoclet begin method testcase.createInstance
41      // instantiate subclass because this class is abstract
42      return new OtherConstituent(type[0], rep[0]);
43      // JUnitDoclet end method testcase.createInstance
44    }
45    
46    protected void setUp() throws Exception {
47      // JUnitDoclet begin method testcase.setUp
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      // JUnitDoclet end method testcase.setUp
56    }
57    
58    protected void tearDown() throws Exception {
59      // JUnitDoclet begin method testcase.tearDown
60      for (int i = 0; i < xmlConsts.length; i++) {
61          xmlConsts[i] = null;
62      }
63      super.tearDown();
64      // JUnitDoclet end method testcase.tearDown
65    }
66    
67    public void testSetGetRepresentantion() throws Exception {
68      // JUnitDoclet begin method setRepresentantion getRepresentantion
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      // JUnitDoclet end method setRepresentantion getRepresentantion
80    }
81    
82    public void testGetType() throws Exception {
83      // JUnitDoclet begin method getType
84      for (int i = 0; i < xmlConsts.length; i++) {
85          assertEquals(xmlConsts[i].getType(), type[i]);
86      }
87      // JUnitDoclet end method getType
88    }
89    
90    public void testNextConstituent() throws Exception {
91      // JUnitDoclet begin method nextConstituent
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      // JUnitDoclet end method nextConstituent
98    }
99    
100   public void testPreviousConstituent() throws Exception {
101     // JUnitDoclet begin method previousConstituent
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     // JUnitDoclet end method previousConstituent
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     // JUnitDoclet begin method testcase.testVault
120     // JUnitDoclet end method testcase.testVault
121   }
122   
123   public static void main(String[] args) {
124     // JUnitDoclet begin method testcase.main
125     junit.textui.TestRunner.run(XMLConstituentTest.class);
126     // JUnitDoclet end method testcase.main
127   }
128 }