1   package de.fu_berlin.ties.xml;
2   
3   import junit.framework.TestCase;
4   // JUnitDoclet begin import
5   import de.fu_berlin.ties.xml.TagConstituent;
6   // JUnitDoclet end import
7   
8   /***
9   * Generated by JUnitDoclet, a tool provided by
10  * ObjectFab GmbH under LGPL.
11  * Please see www.junitdoclet.org, www.gnu.org
12  * and www.objectfab.de for informations about
13  * the tool, the licence and the authors.
14  */
15  
16  
17  public class TagConstituentTest
18  // JUnitDoclet begin extends_implements
19  extends TestCase
20  // JUnitDoclet end extends_implements
21  {
22    // JUnitDoclet begin class
23    final short type[] = { 
24      TagConstituent.START_TAG,
25      TagConstituent.END_TAG,
26    };
27    final String[] name = {
28        "body",
29        "html"
30    };
31    final String[] rep = {
32      "<body bgcolor='red'>",
33      "</html>"
34    };
35    final int[] markupSeries = {
36        0,
37        7
38    };
39    TagConstituent[] tagConsts = new TagConstituent[type.length];
40    // JUnitDoclet end class
41    
42    public TagConstituentTest(String name) {
43      // JUnitDoclet begin method TagConstituentTest
44      super(name);
45      // JUnitDoclet end method TagConstituentTest
46    }
47    
48    public de.fu_berlin.ties.xml.TagConstituent createInstance() throws Exception {
49      // JUnitDoclet begin method testcase.createInstance
50      // these calls should NOT work
51      TagConstituent tagConst = null;
52      try {
53          tagConst = new TagConstituent(OtherConstituent.DOCTYPE, "noname",
54              "<no rep>", 3);
55          fail("Constructor should have thrown exception");
56      } catch (IllegalArgumentException iae) {
57          // that's what we expect
58      }
59  
60      try {
61          tagConst = new TagConstituent((short)-1, "noname", "<no rep>", 3);
62          fail("Constructor should have thrown exception");
63      } catch (IllegalArgumentException iae) {
64          // that's what we expect
65      }
66  
67      return tagConst;
68      // JUnitDoclet end method testcase.createInstance
69    }
70    
71    protected void setUp() throws Exception {
72      // JUnitDoclet begin method testcase.setUp
73      super.setUp();
74      createInstance();
75      for (int i = 0; i < tagConsts.length; i++) {
76          tagConsts[i] = new 
77              TagConstituent(type[i], name[i], rep[i], markupSeries[i]);
78          if (i > 0) {
79              tagConsts[i-1].insertAfter(tagConsts[i]);
80          }
81      }
82      // JUnitDoclet end method testcase.setUp
83    }
84    
85    protected void tearDown() throws Exception {
86      // JUnitDoclet begin method testcase.tearDown
87      for (int i = 0; i < tagConsts.length; i++) {
88          tagConsts[i] = null;
89      }
90      super.tearDown();
91      // JUnitDoclet end method testcase.tearDown
92    }
93    
94    public void testGetName() throws Exception {
95      // JUnitDoclet begin method getName
96      for (int i = 0; i < tagConsts.length; i++) {
97          assertEquals(tagConsts[i].getName(), name[i]);
98      }
99      // JUnitDoclet end method getName
100   }
101   
102   public void testSetGetMarkupSeriesNo() throws Exception {
103     // JUnitDoclet begin method setMarkupSeriesNo getMarkupSeriesNo
104     final int newNo = 17;
105     for (int i = 0; i < tagConsts.length; i++) {
106         assertEquals(tagConsts[i].getMarkupSeriesNo(), markupSeries[i]);   
107         tagConsts[i].setMarkupSeriesNo(newNo);
108         assertEquals(tagConsts[i].getMarkupSeriesNo(), newNo);
109         tagConsts[i].setMarkupSeriesNo(-1);
110         assertEquals(tagConsts[i].getMarkupSeriesNo(), -1);
111     }
112     // JUnitDoclet end method setMarkupSeriesNo getMarkupSeriesNo
113   }
114   
115   public void testSetGetVariety() throws Exception {
116     // JUnitDoclet begin method setVariety getVariety
117     de.fu_berlin.ties.xml.TagVariety[] tests = {TagVariety.REGULAR,
118         TagVariety.TENTATIVE, null};
119     
120     for (int i = 0; i < tests.length; i++) {
121       tagConsts[0].setVariety(tests[i]);
122       assertEquals(tests[i], tagConsts[0].getVariety());
123     }
124     // JUnitDoclet end method setVariety getVariety
125   }
126   
127   public void testToString() throws Exception {
128     // JUnitDoclet begin method toString
129     // no need to test toString()
130     // JUnitDoclet end method toString
131   }
132   
133   
134   
135   /***
136   * JUnitDoclet moves marker to this method, if there is not match
137   * for them in the regenerated code and if the marker is not empty.
138   * This way, no test gets lost when regenerating after renaming.
139   * Method testVault is supposed to be empty.
140   */
141   public void testVault() throws Exception {
142     // JUnitDoclet begin method testcase.testVault
143     // JUnitDoclet end method testcase.testVault
144   }
145   
146   public static void main(String[] args) {
147     // JUnitDoclet begin method testcase.main
148     junit.textui.TestRunner.run(TagConstituentTest.class);
149     // JUnitDoclet end method testcase.main
150   }
151 }