/** Check that the equals() method distinguishes all fields. */ @Test public void testEquals() { XYAreaRenderer r1 = new XYAreaRenderer(); XYAreaRenderer r2 = new XYAreaRenderer(); assertEquals(r1, r2); r1 = new XYAreaRenderer(XYAreaRenderer.AREA_AND_SHAPES); assertFalse(r1.equals(r2)); r2 = new XYAreaRenderer(XYAreaRenderer.AREA_AND_SHAPES); assertTrue(r1.equals(r2)); r1 = new XYAreaRenderer(XYAreaRenderer.AREA); assertFalse(r1.equals(r2)); r2 = new XYAreaRenderer(XYAreaRenderer.AREA); assertTrue(r1.equals(r2)); r1 = new XYAreaRenderer(XYAreaRenderer.LINES); assertFalse(r1.equals(r2)); r2 = new XYAreaRenderer(XYAreaRenderer.LINES); assertTrue(r1.equals(r2)); r1 = new XYAreaRenderer(XYAreaRenderer.SHAPES); assertFalse(r1.equals(r2)); r2 = new XYAreaRenderer(XYAreaRenderer.SHAPES); assertTrue(r1.equals(r2)); r1 = new XYAreaRenderer(XYAreaRenderer.SHAPES_AND_LINES); assertFalse(r1.equals(r2)); r2 = new XYAreaRenderer(XYAreaRenderer.SHAPES_AND_LINES); assertTrue(r1.equals(r2)); r1.setOutline(true); assertFalse(r1.equals(r2)); r2.setOutline(true); assertTrue(r1.equals(r2)); r1.setLegendArea(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); assertFalse(r1.equals(r2)); r2.setLegendArea(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); assertTrue(r1.equals(r2)); r1.setUseFillPaint(true); assertFalse(r1.equals(r2)); r2.setUseFillPaint(true); assertTrue(r1.equals(r2)); r1.setGradientTransformer( new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_VERTICAL)); assertFalse(r1.equals(r2)); r2.setGradientTransformer( new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_VERTICAL)); assertTrue(r1.equals(r2)); }
/** Two objects that are equal are required to return the same hashCode. */ @Test public void testHashcode() { XYAreaRenderer r1 = new XYAreaRenderer(); XYAreaRenderer r2 = new XYAreaRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); r2.setUseFillPaint(true); assertFalse(r1.hashCode() == r2.hashCode()); }