1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.castor.xmlctf;
19
20 import junit.framework.Test;
21 import junit.framework.TestSuite;
22
23 import org.exolab.castor.tests.framework.testDescriptor.OnlySourceGenerationTest;
24 import org.exolab.castor.tests.framework.testDescriptor.UnitTestCase;
25 import org.exolab.castor.xml.XMLContext;
26
27
28
29
30
31
32
33
34
35
36
37 public class OnlySourceGenerationTestCase extends XMLTestCase {
38
39
40 private static final String ONLY_GENERATION = "_OnlySourceGeneration";
41
42
43 private final TestSourceGenerator _sourceGenerator;
44
45
46
47
48
49
50
51
52
53
54
55 public OnlySourceGenerationTestCase(final CastorTestCase test, final UnitTestCase unit,
56 final OnlySourceGenerationTest sourceGen) {
57 super(test, unit);
58 _sourceGenerator = new TestSourceGenerator(test, unit, sourceGen);
59 }
60
61
62
63
64
65 public OnlySourceGenerationTestCase(final String name) {
66 super(name);
67 _sourceGenerator = null;
68 }
69
70
71
72
73
74 public Test suite() {
75 TestSuite suite = new TestSuite(_name);
76
77 String name = getTestSuiteName();
78 name = (name != null) ? name + "#" + _name : _name;
79 this.setName(name + ONLY_GENERATION);
80
81 suite.addTest(this);
82 return suite;
83 }
84
85
86
87
88
89 protected void setUp() throws java.lang.Exception {
90 verbose("\n================================================");
91 verbose("Test suite '"+_test.getName()+"': setting up test '" + _name+"'");
92 verbose("================================================\n");
93 if (getXMLContext() == null) {
94
95 setXMLContext(new XMLContext());
96 }
97 _sourceGenerator.setXMLContext(getXMLContext());
98 _sourceGenerator.setUp();
99 }
100
101 public void runTest() {
102 _sourceGenerator.runTest();
103 verbose("-->Done");
104 }
105
106
107
108
109
110 protected void tearDown() throws java.lang.Exception {
111 verbose("\n================================================");
112 verbose("Test suite '"+_test.getName()+"': test '" + _name+"' complete.");
113 verbose("================================================\n");
114 _sourceGenerator.tearDown();
115 }
116
117 }