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