1 7 8 package org.jdesktop.jdnc.markup; 9 10 import java.net.URL ; 11 import java.net.MalformedURLException ; 12 13 import javax.swing.SwingConstants ; 14 15 import junit.framework.TestCase; 16 17 import net.openmarkup.ObjectRealizer; 18 19 import org.jdesktop.jdnc.markup.ElementTypes; 20 21 import org.jdesktop.jdnc.JNTable; 22 23 26 public class TableTest extends TestCase { 27 28 private ObjectRealizer realizer; 29 30 protected void setUp() { 31 realizer = RealizerUnitTest.createObjectRealizer(); 32 realizer.add(ElementTypes.get()); 33 } 34 35 protected void tearDown() { 36 realizer = null; 37 } 38 39 42 private JNTable getTable(String resource) throws Exception { 43 URL url = RealizerUnitTest.class.getResource(resource); 44 assertNotNull(url); 45 46 Object obj = realizer.getObject(url); 47 assertNotNull(obj); 48 assertTrue(obj.getClass().toString() + " is not a JNTable", 49 obj instanceof JNTable); 50 51 return (JNTable) obj; 52 } 53 54 58 public void testTable() throws Exception { 59 getTable("resources/table1.xml"); 60 getTable("resources/table2.xml"); 61 getTable("resources/table2-1.xml"); 62 getTable("resources/table2-2.xml"); 63 getTable("resources/table2.xml"); 64 getTable("resources/table3.xml"); 65 getTable("resources/table4.xml"); 66 getTable("resources/table4-1.xml"); 67 getTable("resources/table5.xml"); 68 } 69 70 public void testTableData() throws Exception { 71 JNTable table = getTable("resources/table2.xml"); 72 73 } 76 77 80 public void testDataDelimeter() throws Exception { 81 JNTable table = getTable("resources/table2-1.xml"); 82 83 87 } 88 89 public void testTableDataMetaData() throws Exception { 90 JNTable table = getTable("resources/table2-2.xml"); 91 } 92 93 97 public void testTableColumnAlignment() throws Exception { 98 JNTable table = getTable("resources/table4-1.xml"); 99 assertEquals(SwingConstants.RIGHT, table.getColumnHorizontalAlignment("synopsis")); 100 assertEquals(SwingConstants.TRAILING, table.getColumnHorizontalAlignment("state")); 101 assertEquals(SwingConstants.TRAILING, table.getColumnHorizontalAlignment("bugid")); 102 assertEquals(SwingConstants.CENTER, table.getColumnHorizontalAlignment("priority")); 103 assertEquals(SwingConstants.LEFT, table.getColumnHorizontalAlignment("severity")); 104 assertEquals(-1, table.getColumnHorizontalAlignment("jdcvotes")); 110 } 111 } | Popular Tags |