/** Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { DateAxis a1 = new DateAxis("Test"); DateAxis a2 = new DateAxis("Test"); assertTrue(a1.equals(a2)); assertFalse(a1.equals(null)); assertFalse(a1.equals("Some non-DateAxis object")); a1 = new DateAxis("Test", TimeZone.getTimeZone("PST"), Locale.US); assertFalse(a1.equals(a2)); a2 = new DateAxis("Test", TimeZone.getTimeZone("PST"), Locale.US); assertTrue(a1.equals(a2)); a1 = new DateAxis("Test", TimeZone.getTimeZone("PST"), Locale.FRANCE); assertFalse(a1.equals(a2)); a2 = new DateAxis("Test", TimeZone.getTimeZone("PST"), Locale.FRANCE); assertTrue(a1.equals(a2)); // tickUnit a1.setTickUnit(new DateTickUnit(DateTickUnit.DAY, 7)); assertFalse(a1.equals(a2)); a2.setTickUnit(new DateTickUnit(DateTickUnit.DAY, 7)); assertTrue(a1.equals(a2)); // dateFormatOverride a1.setDateFormatOverride(new SimpleDateFormat("yyyy")); assertFalse(a1.equals(a2)); a2.setDateFormatOverride(new SimpleDateFormat("yyyy")); assertTrue(a1.equals(a2)); // tickMarkPosition a1.setTickMarkPosition(DateTickMarkPosition.END); assertFalse(a1.equals(a2)); a2.setTickMarkPosition(DateTickMarkPosition.END); assertTrue(a1.equals(a2)); // timeline a1.setTimeline(SegmentedTimeline.newMondayThroughFridayTimeline()); assertFalse(a1.equals(a2)); a2.setTimeline(SegmentedTimeline.newMondayThroughFridayTimeline()); assertTrue(a1.equals(a2)); }
@Test public void testBug3484403() { final long[] dates = { 1304892000000L, 1304632800000L, 1304546400000L, 1304460000000L, 1304373600000L, 1304287200000L, 1320015600000L, 1309384800000L, 1319752800000L, 1319666400000L, 1319580000000L, 1319493600000L }; Arrays.sort(dates); DateAxis axis = new DateAxis("Date"); // set start and end date Date start = new Date(dates[0]); Date end = new Date(dates[dates.length - 1]); axis.setMinimumDate(start); axis.setMaximumDate(end); SegmentedTimeline timeline = SegmentedTimeline.newMondayThroughFridayTimeline(); timeline.setStartTime(start.getTime()); axis.setTimeline(timeline); BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = image.createGraphics(); Rectangle2D area = new Rectangle2D.Double(0.0, 0.0, 500, 200); // if the bug is still present, this leads to an endless loop axis.refreshTicks(g2, new AxisState(), area, RectangleEdge.BOTTOM); }