|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
SuiteTagHandler.java | - | 100% | 100% | 100% |
|
1 |
package junit.extensions.xml.elements;
|
|
2 |
|
|
3 |
import junit.extensions.xml.IXMLTestSuite;
|
|
4 |
import junit.extensions.xml.XMLException;
|
|
5 |
import junit.extensions.xml.XMLTestSuite;
|
|
6 |
|
|
7 |
import org.w3c.dom.Element;
|
|
8 |
|
|
9 |
|
|
10 |
/**
|
|
11 |
* This class will handle the processing of <suite> nodes.
|
|
12 |
* These nodes may contain taghandlers, procedures, property, test and file
|
|
13 |
* elements.<p>
|
|
14 |
*
|
|
15 |
* Procedures defined at the test suite level are visible to all
|
|
16 |
* children test cases. Children may define procedures of the same
|
|
17 |
* name. Access to the higher level procedure is then done via
|
|
18 |
* explicit reference to the parent with "../".<p>
|
|
19 |
*
|
|
20 |
* <H3>Required Attributes</H3>
|
|
21 |
* name - The test suite name.
|
|
22 |
*
|
|
23 |
* <H3>Children</H3>
|
|
24 |
* <pre>
|
|
25 |
* file - see FileTagHander
|
|
26 |
* taghandlers - see TagHandlersTagHander
|
|
27 |
* suite - recursive reference.
|
|
28 |
* test - see TestTagHandler
|
|
29 |
* procedure - see ProcedureTagHandler
|
|
30 |
* property - see PropertyTagHandler
|
|
31 |
* </pre>
|
|
32 |
* @author <a href="mailto:vraravam@thoughtworks.com">Vijay Aravamudhan : ThoughtWorks Inc.</a>
|
|
33 |
*/
|
|
34 |
public class SuiteTagHandler extends AbstractTagHandler { |
|
35 |
/**
|
|
36 |
* Default constructor.
|
|
37 |
*
|
|
38 |
* @param element The element to be processed
|
|
39 |
* @param testSuite The XMLTestSuite that uses this element
|
|
40 |
*/
|
|
41 | 330 |
public SuiteTagHandler(final Element element, final IXMLTestSuite testSuite) {
|
42 | 330 |
super(element, testSuite);
|
43 | 330 |
validateElement(); |
44 | 330 |
addTestSuite(); |
45 |
} |
|
46 |
|
|
47 |
/**
|
|
48 |
* Process the children of the suite.
|
|
49 |
* @throws XMLException is thrown if the element cannot be understood.
|
|
50 |
*/
|
|
51 | 20 |
public void processElement() throws XMLException { |
52 |
} |
|
53 |
|
|
54 |
/**
|
|
55 |
* Validate that the tag name is suite.
|
|
56 |
* @throws XMLException if this is used against a
|
|
57 |
* different tag.
|
|
58 |
*/
|
|
59 | 330 |
public void validateElement() throws XMLException { |
60 |
// do the default validations from the super class
|
|
61 | 330 |
super.validateElement();
|
62 |
|
|
63 |
// check the element tag name
|
|
64 | 330 |
checkElementTagName(SUITE); |
65 | 330 |
checkRequiredAttribute(NAME); |
66 |
} |
|
67 |
|
|
68 |
/**
|
|
69 |
* Get the value of the name attribute.
|
|
70 |
* @return String value of the name attribute.
|
|
71 |
*/
|
|
72 | 330 |
protected final String getName() {
|
73 | 330 |
return getString(NAME);
|
74 |
} |
|
75 |
|
|
76 |
/**
|
|
77 |
* Add the test suite to the parent XMLTestSuite.
|
|
78 |
*/
|
|
79 | 330 |
protected void addTestSuite() { |
80 | 330 |
IXMLTestSuite parent = getXMLTestSuite(); |
81 | 330 |
parent.addTest(createSuite( |
82 |
getName(), |
|
83 |
getElement())); |
|
84 |
} |
|
85 |
|
|
86 |
/**
|
|
87 |
* Creates a XMLTestSuite implementation.
|
|
88 |
* @param file file to be processed.
|
|
89 |
* @param element element to be processed.
|
|
90 |
* @return IXMLTestSuite Impementation.
|
|
91 |
*/
|
|
92 | 330 |
protected IXMLTestSuite createSuite(final String file, final Element element) {
|
93 | 330 |
return new XMLTestSuite(file, element); |
94 |
} |
|
95 |
} |
|
96 |
|
|