|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| ComponentFinderTagHandler.java | - | 100% | 100% | 100% |
|
||||||||||||||
| 1 |
package junit.extensions.jfcunit.finder;
|
|
| 2 |
|
|
| 3 |
import junit.extensions.xml.IXMLTestCase;
|
|
| 4 |
import junit.extensions.xml.XMLException;
|
|
| 5 |
|
|
| 6 |
import org.w3c.dom.Element;
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
/**
|
|
| 10 |
* This is a extension of the findTagHandler element. Where the
|
|
| 11 |
* finder specified is ComponentFinder.
|
|
| 12 |
*
|
|
| 13 |
* <h3>Description</h3>
|
|
| 14 |
* <p>
|
|
| 15 |
* This creates a ComponentFinder and executes the find.
|
|
| 16 |
* </p>
|
|
| 17 |
* <h3>Finder tag name</h3>
|
|
| 18 |
* <p>
|
|
| 19 |
* ComponentFinder
|
|
| 20 |
* </p>
|
|
| 21 |
* <h3>Parameters</h3>
|
|
| 22 |
* <table border="1" cellpadding="2" cellspacing="0">
|
|
| 23 |
* <tr>
|
|
| 24 |
* <td valign="top"><b>Attribute</b></td>
|
|
| 25 |
* <td valign="top"><b>Description</b></td>
|
|
| 26 |
* <td align="center" valign="top"><b>Required</b></td>
|
|
| 27 |
* <td valign="top"><b>Default</b></td>
|
|
| 28 |
* <td valign="top"><b>Values</b></td>
|
|
| 29 |
* </tr>
|
|
| 30 |
* <tr>
|
|
| 31 |
* <td valign="top">finder</td>
|
|
| 32 |
* <td valign="top">For this element the type must be set to ComponentFinder</td>
|
|
| 33 |
* <td valign="top" align="center">Yes</td>
|
|
| 34 |
* <td valign="top">N/A</td>
|
|
| 35 |
* <td valign="top">N/A</td>
|
|
| 36 |
* </tr>
|
|
| 37 |
* <tr>
|
|
| 38 |
* <td valign="top">refid</td>
|
|
| 39 |
* <td valign="top">Id for the object found.</td>
|
|
| 40 |
* <td valign="top" align="center">No</td>
|
|
| 41 |
* <td valign="top">Search in all windows</td>
|
|
| 42 |
* <td valign="top">Panel to be searched</td>
|
|
| 43 |
* </tr>
|
|
| 44 |
* <tr>
|
|
| 45 |
* <td valign="top">id</td>
|
|
| 46 |
* <td valign="top">Id for the object found.</td>
|
|
| 47 |
* <td valign="top" align="center">Yes</td>
|
|
| 48 |
* <td valign="top">N/A</td>
|
|
| 49 |
* <td valign="top">String</td>
|
|
| 50 |
* </tr>
|
|
| 51 |
* <tr>
|
|
| 52 |
* <td valign="top">index</td>
|
|
| 53 |
* <td valign="top">The index of the element to select from the combo box.</td>
|
|
| 54 |
* <td valign="top" align="center">Yes</td>
|
|
| 55 |
* <td valign="top">N/A</td>
|
|
| 56 |
* <td valign="top">Zero based index of list items.</td>
|
|
| 57 |
* </tr>
|
|
| 58 |
* <tr>
|
|
| 59 |
* <td valign="top">class</td>
|
|
| 60 |
* <td valign="top">The label of the button to be found.</td>
|
|
| 61 |
* <td valign="top" align="center">Yes</td>
|
|
| 62 |
* <td valign="top">None</td>
|
|
| 63 |
* <td valign="top">Class name of the component</td>
|
|
| 64 |
* </tr>
|
|
| 65 |
* </table>
|
|
| 66 |
* <h3>Example</h3>
|
|
| 67 |
* <blockquote><pre>
|
|
| 68 |
* <find
|
|
| 69 |
* finder="ComponentFinder"
|
|
| 70 |
* id="MyTable"
|
|
| 71 |
* refid="MyPanel"
|
|
| 72 |
* index="0"
|
|
| 73 |
* class="javax.swing.JTable"
|
|
| 74 |
* />
|
|
| 75 |
* </pre></blockquote>
|
|
| 76 |
* <p>
|
|
| 77 |
* The above finds the first occurance of a JTable within the panel
|
|
| 78 |
* previously identified by MyPanel.
|
|
| 79 |
* </p>
|
|
| 80 |
* @see junit.extensions.jfcunit.finder.ComponentFinder
|
|
| 81 |
* @author Kevin Wilson
|
|
| 82 |
* @author <a href="mailto:vraravam@thoughtworks.com">Vijay Aravamudhan : ThoughtWorks Inc.</a>
|
|
| 83 |
*/
|
|
| 84 |
public class ComponentFinderTagHandler extends BaseFindTagHandler { |
|
| 85 |
/**
|
|
| 86 |
* Constructor for ComponentFinderTagHandler.
|
|
| 87 |
*
|
|
| 88 |
* @param element The element to be processed
|
|
| 89 |
* @param testCase The IXMLTestCase that uses this element
|
|
| 90 |
*/
|
|
| 91 | 131 |
public ComponentFinderTagHandler(final Element element,
|
| 92 |
final IXMLTestCase testCase) {
|
|
| 93 | 131 |
super(element, testCase);
|
| 94 |
} |
|
| 95 |
|
|
| 96 |
/**
|
|
| 97 |
* @see junit.extensions.xml.elements.AbstractTagHandler#processElement()
|
|
| 98 |
*/
|
|
| 99 | 131 |
public void processElement() throws XMLException { |
| 100 | 131 |
validateElement(); |
| 101 |
|
|
| 102 | 131 |
String clazzName = getClassName(); |
| 103 | 131 |
Class clazz = null;
|
| 104 |
|
|
| 105 | 131 |
try {
|
| 106 | 131 |
clazz = Class.forName(clazzName); |
| 107 |
} catch (ClassNotFoundException ex) {
|
|
| 108 | 1 |
throw new XMLException("Could not find class:" + clazzName, ex, |
| 109 |
getElement(), |
|
| 110 |
getXMLTestCase().getPropertyCache()); |
|
| 111 |
} |
|
| 112 |
|
|
| 113 | 130 |
find(new ComponentFinder(clazz));
|
| 114 |
} |
|
| 115 |
|
|
| 116 |
/**
|
|
| 117 |
* @see junit.extensions.xml.elements.AbstractTagHandler#validateElement()
|
|
| 118 |
*/
|
|
| 119 | 131 |
public void validateElement() throws XMLException { |
| 120 |
// do the default validations from the super class
|
|
| 121 | 131 |
super.validateElement();
|
| 122 |
|
|
| 123 |
// reqd attribute: class
|
|
| 124 | 131 |
checkRequiredAttribute(CLASS); |
| 125 |
} |
|
| 126 |
} |
|
| 127 |
|
|
||||||||||