|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| LabeledComponentFinderTagHandlerT.java | - | 100% | 100% | 100% |
|
||||||||||||||
| 1 |
package junit.extensions.jfcunit.finder;
|
|
| 2 |
|
|
| 3 |
import javax.swing.BoxLayout;
|
|
| 4 |
import javax.swing.JFrame;
|
|
| 5 |
import javax.swing.JLabel;
|
|
| 6 |
import javax.swing.JTextField;
|
|
| 7 |
|
|
| 8 |
import org.w3c.dom.Element;
|
|
| 9 |
import junit.extensions.jfcunit.AbstractTestCase;
|
|
| 10 |
import junit.extensions.jfcunit.xml.JFCXMLTestCase;
|
|
| 11 |
import junit.extensions.xml.XMLException;
|
|
| 12 |
import junit.extensions.xml.XMLTagResourceBundle;
|
|
| 13 |
import junit.extensions.xml.elements.AbstractTagHandler;
|
|
| 14 |
import junit.extensions.xml.elements.ElementFixture;
|
|
| 15 |
|
|
| 16 |
/**
|
|
| 17 |
* Test LabeledComponentFinderTagHandler.
|
|
| 18 |
* @author Kevin Wilson not attributable
|
|
| 19 |
* @version 1.0
|
|
| 20 |
*/
|
|
| 21 |
public class LabeledComponentFinderTagHandlerT |
|
| 22 |
extends AbstractTestCase {
|
|
| 23 |
|
|
| 24 |
/**
|
|
| 25 |
* Test Fixture.
|
|
| 26 |
*/
|
|
| 27 |
private ElementFixture m_fixture;
|
|
| 28 |
|
|
| 29 |
/**
|
|
| 30 |
* Constructor.
|
|
| 31 |
* @param name Name of the test case.
|
|
| 32 |
*/
|
|
| 33 | 1 |
public LabeledComponentFinderTagHandlerT(final String name) {
|
| 34 | 1 |
super(name);
|
| 35 |
} |
|
| 36 |
|
|
| 37 |
/**
|
|
| 38 |
* Setup the test.
|
|
| 39 |
* @throws Exception may be thrown.
|
|
| 40 |
*/
|
|
| 41 | 1 |
protected void setUp() throws Exception { |
| 42 | 1 |
super.setUp();
|
| 43 | 1 |
m_fixture = new ElementFixture(this); |
| 44 | 1 |
m_fixture.setUp(); |
| 45 |
} |
|
| 46 |
|
|
| 47 |
/**
|
|
| 48 |
* Tear down the test.
|
|
| 49 |
* @throws Exception may be thrown.
|
|
| 50 |
*/
|
|
| 51 | 1 |
protected void tearDown() throws Exception { |
| 52 | 1 |
m_fixture.tearDown(); |
| 53 | 1 |
m_fixture = null;
|
| 54 | 1 |
super.tearDown();
|
| 55 |
} |
|
| 56 |
|
|
| 57 |
/**
|
|
| 58 |
* Test the process element.
|
|
| 59 |
* @throws XMLException may be thrown.
|
|
| 60 |
*/
|
|
| 61 | 1 |
public void testProcessElement() throws XMLException { |
| 62 | 1 |
JFCXMLTestCase tc = m_fixture.getJFCTestCase(); |
| 63 | 1 |
Element e = m_fixture.newElement("find", new String[] { |
| 64 |
"finder", "LabeledComponentFinder", |
|
| 65 |
"id", "component", |
|
| 66 |
"index", "0", |
|
| 67 |
"label", "test", |
|
| 68 |
"class", "javax.swing.JButton", |
|
| 69 |
"operation", "equals", |
|
| 70 |
"container", "frame" |
|
| 71 |
}); |
|
| 72 |
|
|
| 73 | 1 |
JFrame frame = this.createJFrame("TEST"); |
| 74 | 1 |
JLabel l1 = new JLabel("TEST"); |
| 75 | 1 |
JTextField tf1 = new JTextField();
|
| 76 | 1 |
l1.setLabelFor(tf1); |
| 77 | 1 |
tf1.setName("TF1");
|
| 78 |
|
|
| 79 | 1 |
JLabel l2 = new JLabel("test"); |
| 80 | 1 |
JTextField tf2 = new JTextField();
|
| 81 | 1 |
l2.setLabelFor(tf2); |
| 82 | 1 |
tf2.setName("TF2");
|
| 83 |
|
|
| 84 | 1 |
frame.getContentPane().setLayout(new BoxLayout(frame.getContentPane(),
|
| 85 |
BoxLayout.X_AXIS)); |
|
| 86 | 1 |
frame.getContentPane().add(l1); |
| 87 | 1 |
frame.getContentPane().add(tf1); |
| 88 | 1 |
frame.getContentPane().add(l2); |
| 89 | 1 |
frame.getContentPane().add(tf2); |
| 90 | 1 |
tc.addProperty("frame", frame);
|
| 91 | 1 |
packAndShow(frame); |
| 92 |
|
|
| 93 | 1 |
AbstractTagHandler handler = XMLTagResourceBundle.getTagHandler(e, tc, |
| 94 |
"find");
|
|
| 95 | 1 |
handler.processElement(); |
| 96 | 1 |
Object o = tc.getProperty("component");
|
| 97 | 1 |
assertSame("ComponentFound should be B2.", tf2, o);
|
| 98 |
} |
|
| 99 |
|
|
| 100 |
} |
|
| 101 |
|
|
||||||||||