|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| PropertyTagHandlerT.java | - | 100% | 100% | 100% |
|
||||||||||||||
| 1 |
package junit.extensions.xml.elements;
|
|
| 2 |
|
|
| 3 |
import org.w3c.dom.Element;
|
|
| 4 |
import junit.extensions.xml.IXMLTestCase;
|
|
| 5 |
import junit.extensions.xml.IXMLTestSuite;
|
|
| 6 |
import junit.extensions.xml.XMLException;
|
|
| 7 |
import junit.framework.TestCase;
|
|
| 8 |
import junit.extensions.xml.XMLTagResourceBundle;
|
|
| 9 |
|
|
| 10 |
/**
|
|
| 11 |
* <p>Title: PropertyTagHandler Test Case.</p>
|
|
| 12 |
* <p>Copyright: Copyright (c) 2004</p>
|
|
| 13 |
* <p>Company: JFCUnit OpenSource Project</p>
|
|
| 14 |
* @author Kevin Wilson
|
|
| 15 |
* @version 1.0
|
|
| 16 |
*/
|
|
| 17 |
public class PropertyTagHandlerT |
|
| 18 |
extends TestCase {
|
|
| 19 |
|
|
| 20 |
/**
|
|
| 21 |
* Test tag handler.
|
|
| 22 |
*/
|
|
| 23 |
private PropertyTagHandler m_tagHandler = null; |
|
| 24 |
|
|
| 25 |
/**
|
|
| 26 |
* Test fixture.
|
|
| 27 |
*/
|
|
| 28 |
private ElementFixture m_fixture;
|
|
| 29 |
|
|
| 30 |
/**
|
|
| 31 |
* Setup the test.
|
|
| 32 |
* @throws Exception may be thrown.
|
|
| 33 |
*/
|
|
| 34 | 5 |
protected void setUp() throws Exception { |
| 35 | 5 |
super.setUp();
|
| 36 | 5 |
m_fixture = new ElementFixture(this); |
| 37 | 5 |
m_fixture.setUp(); |
| 38 |
} |
|
| 39 |
|
|
| 40 |
/**
|
|
| 41 |
* Tear down the test.
|
|
| 42 |
* @throws Exception may be thrown.
|
|
| 43 |
*/
|
|
| 44 | 5 |
protected void tearDown() throws Exception { |
| 45 | 5 |
m_tagHandler = null;
|
| 46 | 5 |
m_fixture.tearDown(); |
| 47 |
|
|
| 48 | 5 |
m_fixture = null;
|
| 49 | 5 |
super.tearDown();
|
| 50 |
} |
|
| 51 |
|
|
| 52 |
/**
|
|
| 53 |
* TestCase Constructor.
|
|
| 54 |
*/
|
|
| 55 | 1 |
public void testPropertyTagHandler() { |
| 56 | 1 |
Element element = m_fixture.newElement("property",
|
| 57 |
new String[] {
|
|
| 58 |
"name", "pname", |
|
| 59 |
"value", "val" |
|
| 60 |
}); |
|
| 61 | 1 |
IXMLTestCase testcase = m_fixture.getTestCase(); |
| 62 | 1 |
m_tagHandler = new PropertyTagHandler(element, testcase);
|
| 63 |
} |
|
| 64 |
|
|
| 65 |
/**
|
|
| 66 |
* Test Suite constructor.
|
|
| 67 |
*/
|
|
| 68 | 1 |
public void testPropertyTagHandler1() { |
| 69 | 1 |
Element element = m_fixture.newElement("property",
|
| 70 |
new String[] {
|
|
| 71 |
"name", "pname", |
|
| 72 |
"value", "val" |
|
| 73 |
}); |
|
| 74 | 1 |
IXMLTestSuite suite = m_fixture.getTestSuite(); |
| 75 | 1 |
m_tagHandler = new PropertyTagHandler(element, suite);
|
| 76 |
} |
|
| 77 |
|
|
| 78 |
/**
|
|
| 79 |
* test Property element in test case.
|
|
| 80 |
* @throws XMLException may be thrown.
|
|
| 81 |
*/
|
|
| 82 | 1 |
public void testProcessElement() throws XMLException { |
| 83 | 1 |
Element element = m_fixture.newElement("property",
|
| 84 |
new String[] {
|
|
| 85 |
"name", "pname", |
|
| 86 |
"value", "val" |
|
| 87 |
}); |
|
| 88 | 1 |
IXMLTestCase testcase = m_fixture.getTestCase(); |
| 89 | 1 |
m_tagHandler = new PropertyTagHandler(element, testcase);
|
| 90 | 1 |
m_tagHandler.processElement(); |
| 91 |
|
|
| 92 | 1 |
Object value = testcase.getProperty("pname");
|
| 93 | 1 |
assertEquals("val", value);
|
| 94 |
} |
|
| 95 |
|
|
| 96 |
/**
|
|
| 97 |
* Test Property element in suite.
|
|
| 98 |
* @throws XMLException may be thrown.
|
|
| 99 |
*/
|
|
| 100 | 1 |
public void testProcessElementInSuite() throws XMLException { |
| 101 | 1 |
Element element = m_fixture.newElement("property",
|
| 102 |
new String[] {
|
|
| 103 |
"name", "pname", |
|
| 104 |
"value", "val" |
|
| 105 |
}); |
|
| 106 | 1 |
IXMLTestSuite testcase = m_fixture.getTestSuite(); |
| 107 | 1 |
m_tagHandler = new PropertyTagHandler(element, testcase);
|
| 108 | 1 |
m_tagHandler.processElement(); |
| 109 |
|
|
| 110 | 1 |
Object value = testcase.getProperty("pname");
|
| 111 | 1 |
assertEquals("val", value);
|
| 112 |
} |
|
| 113 |
|
|
| 114 |
/**
|
|
| 115 |
* Test the Tag lookup.
|
|
| 116 |
*/
|
|
| 117 | 1 |
public void testLookup() { |
| 118 | 1 |
Element element = m_fixture.newElement("property",
|
| 119 |
new String[] {
|
|
| 120 |
"name", "pname", |
|
| 121 |
"value", "val" |
|
| 122 |
}); |
|
| 123 | 1 |
IXMLTestSuite testcase = m_fixture.getTestSuite(); |
| 124 | 1 |
Object o = XMLTagResourceBundle.getTagHandler(element, testcase, "property");
|
| 125 | 1 |
assertNotNull(o); |
| 126 |
} |
|
| 127 |
|
|
| 128 |
} |
|
| 129 |
|
|
||||||||||