|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
AssertNullTagHandlerT.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.XMLException;
|
|
6 |
import junit.framework.AssertionFailedError;
|
|
7 |
import junit.framework.TestCase;
|
|
8 |
import junit.extensions.xml.XMLTagResourceBundle;
|
|
9 |
|
|
10 |
/**
|
|
11 |
* <p>Title: Test AssertNullTagHandler.</p>
|
|
12 |
* <p>Copyright: Copyright (c) 2003</p>
|
|
13 |
* <p>Company: JFCUnit OpenSource Project</p>
|
|
14 |
* @author Kevin Wilson
|
|
15 |
* @version 1.0
|
|
16 |
*/
|
|
17 |
|
|
18 |
public class AssertNullTagHandlerT |
|
19 |
extends TestCase {
|
|
20 |
|
|
21 |
/**
|
|
22 |
* Test tag handler.
|
|
23 |
*/
|
|
24 |
private AssertNullTagHandler m_tagHandler = null; |
|
25 |
|
|
26 |
/**
|
|
27 |
* Test fixture.
|
|
28 |
*/
|
|
29 |
private ElementFixture m_fixture;
|
|
30 |
|
|
31 |
/**
|
|
32 |
* Setup the test.
|
|
33 |
* @throws Exception may be thrown.
|
|
34 |
*/
|
|
35 | 4 |
protected void setUp() throws Exception { |
36 | 4 |
super.setUp();
|
37 | 4 |
m_fixture = new ElementFixture(this); |
38 | 4 |
m_fixture.setUp(); |
39 |
} |
|
40 |
|
|
41 |
/**
|
|
42 |
* Tear down the test.
|
|
43 |
* @throws Exception may be thrown.
|
|
44 |
*/
|
|
45 | 4 |
protected void tearDown() throws Exception { |
46 | 4 |
m_tagHandler = null;
|
47 | 4 |
m_fixture.tearDown(); |
48 |
|
|
49 | 4 |
m_fixture = null;
|
50 | 4 |
super.tearDown();
|
51 |
} |
|
52 |
|
|
53 |
/**
|
|
54 |
* Test the constructor.
|
|
55 |
*/
|
|
56 | 1 |
public void testAssertNullTagHandler() { |
57 | 1 |
Element element = m_fixture.newElement("assertnull",
|
58 |
new String[] {
|
|
59 |
"actualrefid", "data"}); |
|
60 | 1 |
IXMLTestCase testCase = m_fixture.getTestCase(); |
61 | 1 |
m_tagHandler = new AssertNullTagHandler(element, testCase);
|
62 |
} |
|
63 |
|
|
64 |
/**
|
|
65 |
* Null value with refid.
|
|
66 |
* @throws XMLException may be thrown.
|
|
67 |
*/
|
|
68 | 1 |
public void testProcessElement() throws XMLException { |
69 | 1 |
Element element = m_fixture.newElement("assertnull",
|
70 |
new String[] {
|
|
71 |
"actualrefid", "data"}); |
|
72 | 1 |
IXMLTestCase testCase = m_fixture.getTestCase(); |
73 | 1 |
testCase.addProperty("data", null); |
74 | 1 |
m_tagHandler = new AssertNullTagHandler(element, testCase);
|
75 |
|
|
76 | 1 |
m_tagHandler.processElement(); |
77 |
} |
|
78 |
|
|
79 |
/**
|
|
80 |
* String value with refid.
|
|
81 |
* @throws XMLException may be thrown.
|
|
82 |
*/
|
|
83 | 1 |
public void testProcessElement2() throws XMLException { |
84 | 1 |
Element element = m_fixture.newElement("assertnotnull",
|
85 |
new String[] {
|
|
86 |
"actualrefid", "data"}); |
|
87 | 1 |
IXMLTestCase testCase = m_fixture.getTestCase(); |
88 | 1 |
testCase.addProperty("data", "AVXC"); |
89 | 1 |
m_tagHandler = new AssertNullTagHandler(element, testCase);
|
90 | 1 |
AssertionFailedError err = null;
|
91 | 1 |
try {
|
92 | 1 |
m_tagHandler.processElement(); |
93 |
} catch (AssertionFailedError afe) {
|
|
94 | 1 |
err = afe; |
95 |
} |
|
96 | 1 |
assertNotNull("Exception not thrown.", err);
|
97 | 1 |
String exp = "junit.framework.AssertionFailedError";
|
98 | 1 |
assertEquals(exp, err.toString()); |
99 |
} |
|
100 |
|
|
101 |
/**
|
|
102 |
* Test the Lookup.
|
|
103 |
*/
|
|
104 | 1 |
public void testLookup() { |
105 | 1 |
Element element = m_fixture.newElement("assertnull", new String[] { |
106 |
"actualrefid", "data1", |
|
107 |
"expectedrefid", "data2"}); |
|
108 | 1 |
IXMLTestCase testCase = m_fixture.getTestCase(); |
109 | 1 |
Object o = XMLTagResourceBundle.getTagHandler(element, testCase, |
110 |
"assertnull");
|
|
111 | 1 |
assertNotNull(o); |
112 |
} |
|
113 |
|
|
114 |
} |
|
115 |
|
|