/** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { ExtendedCategoryAxis a1 = new ExtendedCategoryAxis("Test"); ExtendedCategoryAxis a2 = new ExtendedCategoryAxis("Test"); assertTrue(a1.equals(a2)); a1.addSubLabel("C1", "C1-sublabel"); assertFalse(a1.equals(a2)); a2.addSubLabel("C1", "C1-sublabel"); assertTrue(a1.equals(a2)); a1.setSubLabelFont(new Font("Dialog", Font.BOLD, 8)); assertFalse(a1.equals(a2)); a2.setSubLabelFont(new Font("Dialog", Font.BOLD, 8)); assertTrue(a1.equals(a2)); a1.setSubLabelPaint(Color.red); assertFalse(a1.equals(a2)); a2.setSubLabelPaint(Color.red); assertTrue(a1.equals(a2)); }
/** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { ExtendedCategoryAxis a1 = new ExtendedCategoryAxis("Test"); ExtendedCategoryAxis a2 = new ExtendedCategoryAxis("Test"); assertTrue(a1.equals(a2)); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); }