1 42 43 package org.jfree.chart.renderer.category.junit; 44 45 import junit.framework.Test; 46 import junit.framework.TestCase; 47 import junit.framework.TestSuite; 48 49 import org.jfree.chart.labels.IntervalCategoryItemLabelGenerator; 50 import org.jfree.chart.labels.StandardCategoryItemLabelGenerator; 51 import org.jfree.chart.renderer.category.AbstractCategoryItemRenderer; 52 import org.jfree.chart.renderer.category.BarRenderer; 53 54 58 public class AbstractCategoryItemRendererTests extends TestCase { 59 60 65 public static Test suite() { 66 return new TestSuite(AbstractCategoryItemRendererTests.class); 67 } 68 69 72 public void testCloning1() { 73 74 AbstractCategoryItemRenderer r1 = new BarRenderer(); 75 r1.setItemLabelGenerator(new StandardCategoryItemLabelGenerator()); 76 AbstractCategoryItemRenderer r2 = null; 77 try { 78 r2 = (BarRenderer) r1.clone(); 79 } 80 catch (CloneNotSupportedException e) { 81 System.err.println("Failed to clone."); 82 } 83 assertTrue(r1 != r2); 84 assertTrue(r1.getClass() == r2.getClass()); 85 assertTrue(r1.equals(r2)); 86 87 r1 = new BarRenderer(); 88 r1.setSeriesItemLabelGenerator( 89 0, new StandardCategoryItemLabelGenerator() 90 ); 91 r2 = null; 92 try { 93 r2 = (BarRenderer) r1.clone(); 94 } 95 catch (CloneNotSupportedException e) { 96 System.err.println("Failed to clone."); 97 } 98 assertTrue(r1 != r2); 99 assertTrue(r1.getClass() == r2.getClass()); 100 assertTrue(r1.equals(r2)); 101 102 r1 = new BarRenderer(); 103 r1.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); 104 r2 = null; 105 try { 106 r2 = (BarRenderer) r1.clone(); 107 } 108 catch (CloneNotSupportedException e) { 109 System.err.println("Failed to clone."); 110 } 111 assertTrue(r1 != r2); 112 assertTrue(r1.getClass() == r2.getClass()); 113 assertTrue(r1.equals(r2)); 114 } 115 116 119 public void testCloning2() { 120 121 BarRenderer r1 = new BarRenderer(); 122 r1.setItemLabelGenerator(new IntervalCategoryItemLabelGenerator()); 123 BarRenderer r2 = null; 124 try { 125 r2 = (BarRenderer) r1.clone(); 126 } 127 catch (CloneNotSupportedException e) { 128 System.err.println("Failed to clone."); 129 } 130 assertTrue(r1 != r2); 131 assertTrue(r1.getClass() == r2.getClass()); 132 assertTrue(r1.equals(r2)); 133 134 r1 = new BarRenderer(); 135 r1.setSeriesItemLabelGenerator( 136 0, new IntervalCategoryItemLabelGenerator() 137 ); 138 r2 = null; 139 try { 140 r2 = (BarRenderer) r1.clone(); 141 } 142 catch (CloneNotSupportedException e) { 143 System.err.println("Failed to clone."); 144 } 145 assertTrue(r1 != r2); 146 assertTrue(r1.getClass() == r2.getClass()); 147 assertTrue(r1.equals(r2)); 148 149 r1 = new BarRenderer(); 150 r1.setBaseItemLabelGenerator(new IntervalCategoryItemLabelGenerator()); 151 r2 = null; 152 try { 153 r2 = (BarRenderer) r1.clone(); 154 } 155 catch (CloneNotSupportedException e) { 156 System.err.println("Failed to clone."); 157 } 158 assertTrue(r1 != r2); 159 assertTrue(r1.getClass() == r2.getClass()); 160 assertTrue(r1.equals(r2)); 161 } 162 163 } 164 165 | Popular Tags |