예제 #1
0
  /**
   * A test for bug report 1472942. The DateFormat.equals() method is not checking the range
   * attribute.
   */
  @Test
  public void test1472942() {
    DateAxis a1 = new DateAxis("Test");
    DateAxis a2 = new DateAxis("Test");
    assertTrue(a1.equals(a2));

    // range
    a1.setRange(new Date(1L), new Date(2L));
    assertFalse(a1.equals(a2));
    a2.setRange(new Date(1L), new Date(2L));
    assertTrue(a1.equals(a2));
  }
예제 #2
0
 /** Confirm that cloning works. */
 @Test
 public void testCloning() throws CloneNotSupportedException {
   DateAxis a1 = new DateAxis("Test");
   DateAxis a2 = (DateAxis) a1.clone();
   assertTrue(a1 != a2);
   assertTrue(a1.getClass() == a2.getClass());
   assertTrue(a1.equals(a2));
 }
예제 #3
0
 /** Two objects that are equal are required to return the same hashCode. */
 @Test
 public void testHashCode() {
   DateAxis a1 = new DateAxis("Test");
   DateAxis a2 = new DateAxis("Test");
   assertTrue(a1.equals(a2));
   int h1 = a1.hashCode();
   int h2 = a2.hashCode();
   assertEquals(h1, h2);
 }
예제 #4
0
  /** 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));
  }