|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| AssertTableContainsTagHandlerT.java | - | 100% | 100% | 100% |
|
||||||||||||||
| 1 |
package junit.extensions.xml.elements;
|
|
| 2 |
|
|
| 3 |
import javax.swing.JLabel;
|
|
| 4 |
import javax.swing.JTable;
|
|
| 5 |
import javax.swing.table.DefaultTableModel;
|
|
| 6 |
|
|
| 7 |
import org.w3c.dom.Element;
|
|
| 8 |
import junit.extensions.xml.IXMLTestCase;
|
|
| 9 |
import junit.extensions.xml.XMLException;
|
|
| 10 |
import junit.framework.TestCase;
|
|
| 11 |
import junit.extensions.xml.XMLTagResourceBundle;
|
|
| 12 |
|
|
| 13 |
/**
|
|
| 14 |
* <p>Title: Test AssertTableContainsTagHandler.</p>
|
|
| 15 |
* <p>Copyright: Copyright (c) 2003</p>
|
|
| 16 |
* <p>Company: JFCUnit OpenSource Project</p>
|
|
| 17 |
* @author Kevin Wilson
|
|
| 18 |
* @version 1.0
|
|
| 19 |
*/
|
|
| 20 |
public class AssertTableContainsTagHandlerT |
|
| 21 |
extends TestCase {
|
|
| 22 |
|
|
| 23 |
/**
|
|
| 24 |
* Assert Tag Handler to be tested.
|
|
| 25 |
*/
|
|
| 26 |
private AssertTableContainsTagHandler m_assertTagHandler = null; |
|
| 27 |
|
|
| 28 |
/**
|
|
| 29 |
* Test fixture.
|
|
| 30 |
*/
|
|
| 31 |
private ElementFixture m_fixture;
|
|
| 32 |
|
|
| 33 |
/**
|
|
| 34 |
* Setup the test.
|
|
| 35 |
* @throws Exception may be thrown.
|
|
| 36 |
*/
|
|
| 37 | 6 |
protected void setUp() throws Exception { |
| 38 | 6 |
super.setUp();
|
| 39 | 6 |
m_fixture = new ElementFixture(this); |
| 40 |
|
|
| 41 | 6 |
m_fixture.setUp(); |
| 42 |
} |
|
| 43 |
|
|
| 44 |
/**
|
|
| 45 |
* Tear down the test.
|
|
| 46 |
* @throws Exception may be thrown.
|
|
| 47 |
*/
|
|
| 48 | 6 |
protected void tearDown() throws Exception { |
| 49 | 6 |
m_assertTagHandler = null;
|
| 50 | 6 |
m_fixture.tearDown(); |
| 51 |
|
|
| 52 | 6 |
m_fixture = null;
|
| 53 | 6 |
super.tearDown();
|
| 54 |
} |
|
| 55 |
|
|
| 56 |
/**
|
|
| 57 |
* Test process element success.
|
|
| 58 |
* @throws XMLException may be thrown.
|
|
| 59 |
*/
|
|
| 60 | 1 |
public void testProcessElement() throws XMLException { |
| 61 | 1 |
JTable tbl = new JTable(new DefaultTableModel(new Object[][] { |
| 62 |
{"abc", "def", "ghi"},
|
|
| 63 |
{"abc", "successful", "ghi"},
|
|
| 64 |
{"abc", "def", "ghi"},
|
|
| 65 |
}, new String[] {
|
|
| 66 |
"ABC", "DEF", "GHI" |
|
| 67 |
})); |
|
| 68 |
|
|
| 69 | 1 |
IXMLTestCase tc = m_fixture.getTestCase(); |
| 70 | 1 |
tc.addProperty("comp", tbl);
|
| 71 | 1 |
Element asrt = m_fixture.newElement("asserttablecontains",
|
| 72 |
new String[] {
|
|
| 73 |
"id", "comp", |
|
| 74 |
"value", "successful", |
|
| 75 |
"row", "1", |
|
| 76 |
"column", "1", |
|
| 77 |
"useRE", "false" |
|
| 78 |
}); |
|
| 79 | 1 |
m_assertTagHandler = new AssertTableContainsTagHandler(asrt, tc);
|
| 80 | 1 |
m_assertTagHandler.processElement(); |
| 81 |
} |
|
| 82 |
|
|
| 83 |
/**
|
|
| 84 |
* Test success with useRE.
|
|
| 85 |
* @throws XMLException may be thrown.
|
|
| 86 |
*/
|
|
| 87 | 1 |
public void testProcessUseRE() throws XMLException { |
| 88 | 1 |
JTable tbl = new JTable(new DefaultTableModel(new Object[][] { |
| 89 |
{"abc", "def", "ghi"},
|
|
| 90 |
{"abc", "successful", "ghi"},
|
|
| 91 |
{"abc", "def", "ghi"},
|
|
| 92 |
}, new String[] {
|
|
| 93 |
"ABC", "DEF", "GHI" |
|
| 94 |
})); |
|
| 95 |
|
|
| 96 | 1 |
IXMLTestCase tc = m_fixture.getTestCase(); |
| 97 | 1 |
tc.addProperty("comp", tbl);
|
| 98 | 1 |
Element asrt = m_fixture.newElement("asserttablecontains",
|
| 99 |
new String[] {
|
|
| 100 |
"id", "comp", |
|
| 101 |
"value", "succ", |
|
| 102 |
"row", "1", |
|
| 103 |
"column", "1", |
|
| 104 |
"useRE", "true" |
|
| 105 |
}); |
|
| 106 | 1 |
m_assertTagHandler = new AssertTableContainsTagHandler(asrt, tc);
|
| 107 | 1 |
m_assertTagHandler.processElement(); |
| 108 |
} |
|
| 109 |
|
|
| 110 |
/**
|
|
| 111 |
* Test fail without useRE.
|
|
| 112 |
* @throws XMLException may be thrown.
|
|
| 113 |
*/
|
|
| 114 | 1 |
public void testProcessFail() throws XMLException { |
| 115 | 1 |
JTable tbl = new JTable(new DefaultTableModel(new Object[][] { |
| 116 |
{"abc", "def", "ghi"},
|
|
| 117 |
{"abc", "successful", "ghi"},
|
|
| 118 |
{"abc", "def", "ghi"},
|
|
| 119 |
}, new String[] {
|
|
| 120 |
"ABC", "DEF", "GHI" |
|
| 121 |
})); |
|
| 122 |
|
|
| 123 | 1 |
IXMLTestCase tc = m_fixture.getTestCase(); |
| 124 | 1 |
tc.addProperty("comp", tbl);
|
| 125 | 1 |
Element asrt = m_fixture.newElement("asserttablecontains",
|
| 126 |
new String[] {
|
|
| 127 |
"id", "comp", |
|
| 128 |
"value", "successful", |
|
| 129 |
"row", "0", |
|
| 130 |
"column", "1", |
|
| 131 |
"useRE", "false" |
|
| 132 |
}); |
|
| 133 | 1 |
m_assertTagHandler = new AssertTableContainsTagHandler(asrt, tc);
|
| 134 | 1 |
Error er = null;
|
| 135 | 1 |
try {
|
| 136 | 1 |
m_assertTagHandler.processElement(); |
| 137 |
} catch (Error e) {
|
|
| 138 | 1 |
er = e; |
| 139 |
} |
|
| 140 | 1 |
assertNotNull("Exception expected:", er);
|
| 141 |
} |
|
| 142 |
|
|
| 143 |
/**
|
|
| 144 |
* Test fail with useRE.
|
|
| 145 |
* @throws XMLException may be thrown.
|
|
| 146 |
*/
|
|
| 147 | 1 |
public void testProcessFailUseRE() throws XMLException { |
| 148 | 1 |
JTable tbl = new JTable(new DefaultTableModel(new Object[][] { |
| 149 |
{"abc", "def", "ghi"},
|
|
| 150 |
{"abc", "successful", "ghi"},
|
|
| 151 |
{"abc", "def", "ghi"},
|
|
| 152 |
}, new String[] {
|
|
| 153 |
"ABC", "DEF", "GHI" |
|
| 154 |
})); |
|
| 155 |
|
|
| 156 | 1 |
IXMLTestCase tc = m_fixture.getTestCase(); |
| 157 | 1 |
tc.addProperty("comp", tbl);
|
| 158 | 1 |
Element asrt = m_fixture.newElement("asserttablecontains",
|
| 159 |
new String[] {
|
|
| 160 |
"id", "comp", |
|
| 161 |
"value", "successful", |
|
| 162 |
"row", "0", |
|
| 163 |
"column", "1", |
|
| 164 |
"useRE", "true" |
|
| 165 |
}); |
|
| 166 | 1 |
m_assertTagHandler = new AssertTableContainsTagHandler(asrt, tc);
|
| 167 | 1 |
Error er = null;
|
| 168 | 1 |
try {
|
| 169 | 1 |
m_assertTagHandler.processElement(); |
| 170 |
} catch (Error e) {
|
|
| 171 | 1 |
er = e; |
| 172 |
} |
|
| 173 | 1 |
assertNotNull("Exception expected:", er);
|
| 174 |
} |
|
| 175 |
|
|
| 176 |
/**
|
|
| 177 |
* Test process invalid component.
|
|
| 178 |
* @throws XMLException may be thrown.
|
|
| 179 |
*/
|
|
| 180 | 1 |
public void testProcessInvalidComp() throws XMLException { |
| 181 | 1 |
JLabel tbl = new JLabel();
|
| 182 |
|
|
| 183 | 1 |
IXMLTestCase tc = m_fixture.getTestCase(); |
| 184 | 1 |
tc.addProperty("comp", tbl);
|
| 185 | 1 |
Element asrt = m_fixture.newElement("asserttablecontains",
|
| 186 |
new String[] {
|
|
| 187 |
"id", "comp", |
|
| 188 |
"value", "successful", |
|
| 189 |
"row", "1", |
|
| 190 |
"column", "1", |
|
| 191 |
"useRE", "false" |
|
| 192 |
}); |
|
| 193 | 1 |
m_assertTagHandler = new AssertTableContainsTagHandler(asrt, tc);
|
| 194 | 1 |
m_assertTagHandler.processElement(); |
| 195 |
} |
|
| 196 |
|
|
| 197 |
/**
|
|
| 198 |
* Test the Lookup.
|
|
| 199 |
*/
|
|
| 200 | 1 |
public void testLookup() { |
| 201 | 1 |
Element element = m_fixture.newElement("asserttablecontains", new String[] { |
| 202 |
"actualrefid", "data1", |
|
| 203 |
"expectedrefid", "data2"}); |
|
| 204 | 1 |
IXMLTestCase testCase = m_fixture.getTestCase(); |
| 205 | 1 |
Object o = XMLTagResourceBundle.getTagHandler(element, testCase, |
| 206 |
"asserttablecontains");
|
|
| 207 | 1 |
assertNotNull(o); |
| 208 |
} |
|
| 209 |
|
|
| 210 |
} |
|
| 211 |
|
|
||||||||||