1 39 package org.jfree.data.junit; 40 41 import junit.framework.Test; 42 import junit.framework.TestCase; 43 import junit.framework.TestSuite; 44 45 import org.jfree.data.DefaultTableXYDataset; 46 import org.jfree.data.XYSeries; 47 48 53 public class TableXYDatasetTests extends TestCase { 54 55 60 public static Test suite() { 61 return new TestSuite(TableXYDatasetTests.class); 62 } 63 64 69 public TableXYDatasetTests(String name) { 70 super(name); 71 } 72 73 76 public void testTableXYDataset() { 77 78 DefaultTableXYDataset tableXYDataSet = new DefaultTableXYDataset(); 79 XYSeries series1 = new XYSeries("Series 1", false); 80 series1.add(1, 1); 81 series1.add(2, 1); 82 series1.add(4, 1); 83 series1.add(5, 1); 84 85 XYSeries series2 = new XYSeries("Series 2", false); 86 series2.add(2, 2); 87 series2.add(3, 2); 88 series2.add(4, 2); 89 series2.add(5, 2); 90 series2.add(6, 2); 91 92 tableXYDataSet.addSeries(series1); 93 tableXYDataSet.addSeries(series2); 94 95 assertEquals(6, tableXYDataSet.getItemCount()); 97 assertEquals(6, tableXYDataSet.getXValue(0, 5).intValue()); 98 assertEquals(null, tableXYDataSet.getYValue(0, 5)); 99 assertEquals(6, tableXYDataSet.getXValue(1, 5).intValue()); 100 assertEquals(2, tableXYDataSet.getYValue(1, 5).intValue()); 101 102 series2.add(7, 2); 103 assertEquals(7, tableXYDataSet.getItemCount()); 105 assertEquals(null, tableXYDataSet.getYValue(0, 6)); 106 assertEquals(2, tableXYDataSet.getYValue(1, 6).intValue()); 107 108 tableXYDataSet.removeSeries(series1); 110 assertEquals(7, tableXYDataSet.getItemCount()); 112 113 tableXYDataSet.removeSeries(series2); 115 series1 = new XYSeries("Series 1", false); 116 series1.add(1, 1); 117 series1.add(2, 1); 118 series1.add(4, 1); 119 series1.add(5, 1); 120 tableXYDataSet.addSeries(series1); 121 122 assertEquals(4, tableXYDataSet.getItemCount()); 124 125 } 126 } 127 | Popular Tags |