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