예제 #1
0
 @Test(dataProvider = "calendarNameAndType")
 public void test_required_calendars(String chronoId, String calendarSystemType) {
   Chronology chrono = Chronology.of(chronoId);
   assertNotNull(chrono, "Required calendar not found by ID: " + chronoId);
   chrono = Chronology.of(calendarSystemType);
   assertNotNull(chrono, "Required calendar not found by type: " + chronoId);
   Set<Chronology> cals = Chronology.getAvailableChronologies();
   assertTrue(cals.contains(chrono), "Required calendar not found in set of available calendars");
 }
예제 #2
0
 @Test(dataProvider = "calendarNameAndType")
 public void test_getters(String chronoId, String calendarSystemType) {
   Chronology chrono = Chronology.of(chronoId);
   assertNotNull(chrono, "Required calendar not found by ID: " + chronoId);
   assertEquals(chrono.getId(), chronoId);
   assertEquals(chrono.getCalendarType(), calendarSystemType);
 }
예제 #3
0
 @Test
 public void test_ThaiBuddhistChronology_dateYearDay() {
   Chronology chrono = Chronology.of("ThaiBuddhist");
   ChronoLocalDate date1 = chrono.dateYearDay(ThaiBuddhistEra.BE, 2459, 60);
   ChronoLocalDate date2 = chrono.date(ThaiBuddhistEra.BE, 2459, 2, 29);
   assertEquals(date1, ThaiBuddhistChronology.INSTANCE.dateYearDay(ThaiBuddhistEra.BE, 2459, 60));
   assertEquals(date2, ThaiBuddhistChronology.INSTANCE.dateYearDay(ThaiBuddhistEra.BE, 2459, 60));
 }
예제 #4
0
 @Test
 public void test_JapaneseChronology_dateYearDay() {
   Chronology chrono = Chronology.of("Japanese");
   ChronoLocalDate date1 = chrono.dateYearDay(JapaneseEra.HEISEI, 8, 60);
   ChronoLocalDate date2 = chrono.date(JapaneseEra.HEISEI, 8, 2, 29);
   assertEquals(date1, JapaneseChronology.INSTANCE.dateYearDay(JapaneseEra.HEISEI, 8, 60));
   assertEquals(date2, JapaneseChronology.INSTANCE.dateYearDay(JapaneseEra.HEISEI, 8, 60));
 }
예제 #5
0
 @Test
 public void test_IsoChronology_dateYearDay() {
   Chronology chrono = Chronology.of("ISO");
   ChronoLocalDate date1 = chrono.dateYearDay(IsoEra.CE, 5, 60);
   ChronoLocalDate date2 = chrono.date(IsoEra.CE, 5, 3, 1);
   assertEquals(date1, IsoChronology.INSTANCE.dateYearDay(IsoEra.CE, 5, 60));
   assertEquals(date2, IsoChronology.INSTANCE.dateYearDay(IsoEra.CE, 5, 60));
 }
예제 #6
0
 @Test
 public void test_MinguoChronology_dateYearDay() {
   Chronology chrono = Chronology.of("Minguo");
   ChronoLocalDate date1 = chrono.dateYearDay(MinguoEra.ROC, 5, 60);
   ChronoLocalDate date2 = chrono.date(MinguoEra.ROC, 5, 2, 29);
   assertEquals(date1, MinguoChronology.INSTANCE.dateYearDay(MinguoEra.ROC, 5, 60));
   assertEquals(date2, MinguoChronology.INSTANCE.dateYearDay(MinguoEra.ROC, 5, 60));
 }
예제 #7
0
 // -----------------------------------------------------------------------
 // dateYearDay() and date()
 // -----------------------------------------------------------------------
 @Test
 public void test_HijrahChronology_dateYearDay() {
   Chronology chrono = Chronology.of("Hijrah");
   ChronoLocalDate date1 = chrono.dateYearDay(HijrahEra.AH, 1434, 178);
   ChronoLocalDate date2 = chrono.date(HijrahEra.AH, 1434, 7, 1);
   assertEquals(date1, HijrahChronology.INSTANCE.dateYearDay(HijrahEra.AH, 1434, 178));
   assertEquals(date2, HijrahChronology.INSTANCE.dateYearDay(HijrahEra.AH, 1434, 178));
 }
예제 #8
0
 @Test(dataProvider = "calendarNameAndType")
 public void test_dateEpochDay(String name, String alias) {
   Chronology chrono = Chronology.of(name);
   ChronoLocalDate date = chrono.dateNow();
   long epochDay = date.getLong(ChronoField.EPOCH_DAY);
   ChronoLocalDate test = chrono.dateEpochDay(epochDay);
   assertEquals(test, date);
 }
예제 #9
0
 // -----------------------------------------------------------------------
 // Chronology.of(String)
 // -----------------------------------------------------------------------
 @Test
 public void test_chrono_byName() {
   Chronology c = JapaneseChronology.INSTANCE;
   Chronology test = Chronology.of("Japanese");
   Assert.assertNotNull(test, "The Japanese calendar could not be found byName");
   Assert.assertEquals(test.getId(), "Japanese", "ID mismatch");
   Assert.assertEquals(test.getCalendarType(), "japanese", "Type mismatch");
   Assert.assertEquals(test, c);
 }
예제 #10
0
  @Test
  public void test_JapaneseChronology_dateNow() {
    ZoneId zoneId_paris = ZoneId.of("Europe/Paris");
    Clock clock = Clock.system(zoneId_paris);

    Chronology chrono = Chronology.of("Japanese");
    assertEquals(chrono.dateNow(), JapaneseChronology.INSTANCE.dateNow());
    assertEquals(chrono.dateNow(zoneId_paris), JapaneseChronology.INSTANCE.dateNow(zoneId_paris));
    assertEquals(chrono.dateNow(clock), JapaneseChronology.INSTANCE.dateNow(clock));
  }
예제 #11
0
 /** Compute the number of days from the Epoch and compute the date from the number of days. */
 @Test(dataProvider = "calendarNameAndType")
 public void test_epoch(String name, String alias) {
   Chronology chrono = Chronology.of(name); // a chronology. In practice this is rarely hardcoded
   ChronoLocalDate date1 = chrono.dateNow();
   long epoch1 = date1.getLong(ChronoField.EPOCH_DAY);
   ChronoLocalDate date2 = date1.with(ChronoField.EPOCH_DAY, epoch1);
   assertEquals(date1, date2, "Date from epoch day is not same date: " + date1 + " != " + date2);
   long epoch2 = date1.getLong(ChronoField.EPOCH_DAY);
   assertEquals(epoch1, epoch2, "Epoch day not the same: " + epoch1 + " != " + epoch2);
 }
예제 #12
0
 // -----------------------------------------------------------------------
 // serialization; serialize and check each calendar system
 // -----------------------------------------------------------------------
 @Test(dataProvider = "calendarNameAndType")
 public void test_chronoSerializationSingleton(String id, String _calendarType) throws Exception {
   Chronology original = Chronology.of(id);
   ByteArrayOutputStream baos = new ByteArrayOutputStream();
   ObjectOutputStream out = new ObjectOutputStream(baos);
   out.writeObject(original);
   out.close();
   ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
   ObjectInputStream in = new ObjectInputStream(bais);
   Chronology ser = (Chronology) in.readObject();
   assertEquals(ser, original, "Deserialized Chronology is not correct");
 }
예제 #13
0
 @Test
 public void test_calendar_list() {
   Set<Chronology> chronos = Chronology.getAvailableChronologies();
   assertNotNull(chronos, "Required list of calendars must be non-null");
   for (Chronology chrono : chronos) {
     Chronology lookup = Chronology.of(chrono.getId());
     assertNotNull(lookup, "Required calendar not found: " + chrono);
   }
   assertEquals(
       chronos.size() >= data_of_calendars().length,
       true,
       "Chronology.getAvailableChronologies().size = "
           + chronos.size()
           + ", expected >= "
           + data_of_calendars().length);
 }
예제 #14
0
 @Test(expectedExceptions = DateTimeException.class)
 public void test_noChrono() {
   Chronology chrono = Chronology.of("FooFoo");
 }
예제 #15
0
 @Test(dataProvider = "calendarDisplayName")
 public void test_getDisplayName(String chronoId, String calendarDisplayName) {
   Chronology chrono = Chronology.of(chronoId);
   assertEquals(chrono.getDisplayName(TextStyle.FULL, Locale.ENGLISH), calendarDisplayName);
 }