|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| IndexOfTagHandlerT.java | - | 100% | 100% | 100% |
|
||||||||||||||
| 1 |
package junit.extensions.xml.elements;
|
|
| 2 |
|
|
| 3 |
import javax.swing.JTable;
|
|
| 4 |
import javax.swing.table.DefaultTableModel;
|
|
| 5 |
|
|
| 6 |
import org.w3c.dom.Element;
|
|
| 7 |
import junit.extensions.jfcunit.JFCTestCase;
|
|
| 8 |
import junit.extensions.xml.IXMLTestCase;
|
|
| 9 |
import junit.extensions.xml.XMLException;
|
|
| 10 |
import junit.extensions.xml.XMLTagResourceBundle;
|
|
| 11 |
|
|
| 12 |
/**
|
|
| 13 |
* <p>Title: test indexof tag handler.</p>
|
|
| 14 |
* <p>Description: Test IndexOfTagHandler</p>
|
|
| 15 |
* <p>Copyright: Copyright (c) 2003</p>
|
|
| 16 |
* <p>Company: JFCUnit OpenSource Project.</p>
|
|
| 17 |
* @author Kevin Wilson not attributable
|
|
| 18 |
* @version 1.0
|
|
| 19 |
*/
|
|
| 20 |
|
|
| 21 |
public class IndexOfTagHandlerT extends JFCTestCase { |
|
| 22 |
/**
|
|
| 23 |
* Test target.
|
|
| 24 |
*/
|
|
| 25 |
private IndexOfTagHandler m_tagHandler = null; |
|
| 26 |
|
|
| 27 |
/**
|
|
| 28 |
* Fixture for manipulating elements.
|
|
| 29 |
*/
|
|
| 30 |
private ElementFixture m_fixture;
|
|
| 31 |
|
|
| 32 |
/**
|
|
| 33 |
* Setup the test.
|
|
| 34 |
* @throws Exception may be thrown.
|
|
| 35 |
*/
|
|
| 36 | 2 |
protected void setUp() throws Exception { |
| 37 | 2 |
super.setUp();
|
| 38 | 2 |
m_fixture = new ElementFixture(this); |
| 39 | 2 |
m_fixture.setUp(); |
| 40 |
} |
|
| 41 |
|
|
| 42 |
/**
|
|
| 43 |
* Tear down the test case.
|
|
| 44 |
* @throws Exception may be thrown.
|
|
| 45 |
*/
|
|
| 46 | 2 |
protected void tearDown() throws Exception { |
| 47 | 2 |
m_tagHandler = null;
|
| 48 | 2 |
m_fixture.tearDown(); |
| 49 |
|
|
| 50 | 2 |
m_fixture = null;
|
| 51 | 2 |
super.tearDown();
|
| 52 |
} |
|
| 53 |
|
|
| 54 |
/**
|
|
| 55 |
* Test the process element.
|
|
| 56 |
* @throws XMLException may be thrown.
|
|
| 57 |
*/
|
|
| 58 | 1 |
public void testProcessElement() throws XMLException { |
| 59 |
|
|
| 60 | 1 |
IXMLTestCase tc = m_fixture.getTestCase(); |
| 61 | 1 |
Element indexer = m_fixture.newElement("indexof",
|
| 62 |
new String[] {
|
|
| 63 |
"refid", "table", |
|
| 64 |
"id", "loc", |
|
| 65 |
"type", "tablecell", |
|
| 66 |
"value", "testvalue" |
|
| 67 |
}); |
|
| 68 |
|
|
| 69 | 1 |
Object[][] data = new Object[][] {
|
| 70 |
{"test", "1", "2", null},
|
|
| 71 |
{"test", "1", "testvalue", null},
|
|
| 72 |
{"test", "1", "2", null},
|
|
| 73 |
{"test", "1", "2", null},
|
|
| 74 |
}; |
|
| 75 | 1 |
String[] heading = new String[] {"a", "b", "c", "d"}; |
| 76 | 1 |
DefaultTableModel model = new DefaultTableModel(data, heading);
|
| 77 | 1 |
JTable table = new JTable(model);
|
| 78 |
|
|
| 79 | 1 |
tc.addProperty("table", table);
|
| 80 |
|
|
| 81 | 1 |
m_tagHandler = new IndexOfTagHandler(indexer, tc);
|
| 82 | 1 |
m_tagHandler.processElement(); |
| 83 |
|
|
| 84 | 1 |
Integer row = (Integer) tc.getProperty("loc.row");
|
| 85 | 1 |
Integer col = (Integer) tc.getProperty("loc.column");
|
| 86 | 1 |
Object cell = tc.getProperty("loc");
|
| 87 |
|
|
| 88 | 1 |
assertEquals(1, row.intValue()); |
| 89 | 1 |
assertEquals(2, col.intValue()); |
| 90 | 1 |
assertEquals("testvalue", cell);
|
| 91 |
} |
|
| 92 |
|
|
| 93 |
/**
|
|
| 94 |
* Test process element.
|
|
| 95 |
* @throws XMLException may be thrown.
|
|
| 96 |
*/
|
|
| 97 | 1 |
public void testGetHandler() throws XMLException { |
| 98 |
|
|
| 99 | 1 |
IXMLTestCase tc = m_fixture.getTestCase(); |
| 100 | 1 |
Element indexer = m_fixture.newElement("indexof",
|
| 101 |
new String[] {
|
|
| 102 |
"refid", "table", |
|
| 103 |
"id", "loc", |
|
| 104 |
"type", "tablecell", |
|
| 105 |
"value", "testvalue" |
|
| 106 |
}); |
|
| 107 | 1 |
Object x = XMLTagResourceBundle.getTagHandler(indexer, tc, "indexof");
|
| 108 | 1 |
assertNotNull("Tag handler not found", x);
|
| 109 |
} |
|
| 110 |
|
|
| 111 |
} |
|
| 112 |
|
|
||||||||||