use of java.time.chrono.Chronology in project jdk8u_jdk by JetBrains.
the class TCKChronology method test_MinguoChronology_dateYearDay.
@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));
}
use of java.time.chrono.Chronology in project jdk8u_jdk by JetBrains.
the class TCKChronology method test_calendar_list.
@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);
}
use of java.time.chrono.Chronology in project jdk8u_jdk by JetBrains.
the class TCKChronology method test_getters.
@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);
}
use of java.time.chrono.Chronology in project jdk8u_jdk by JetBrains.
the class TCKChronoLocalDateTime method test_badPlusAdjusterChrono.
@Test(dataProvider = "calendars")
public void test_badPlusAdjusterChrono(Chronology chrono) {
LocalDate refDate = LocalDate.of(2013, 1, 1);
ChronoLocalDateTime<?> cdt = chrono.date(refDate).atTime(LocalTime.NOON);
for (Chronology[] clist : data_of_calendars()) {
Chronology chrono2 = clist[0];
ChronoLocalDateTime<?> cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON);
TemporalAmount adjuster = new FixedAdjuster(cdt2);
if (chrono != chrono2) {
try {
cdt.plus(adjuster);
Assert.fail("WithAdjuster should have thrown a ClassCastException, " + "required: " + cdt + ", supplied: " + cdt2);
} catch (ClassCastException cce) {
// Expected exception; not an error
}
} else {
// Same chronology,
ChronoLocalDateTime<?> result = cdt.plus(adjuster);
assertEquals(result, cdt2, "WithAdjuster failed to replace date time");
}
}
}
use of java.time.chrono.Chronology in project jdk8u_jdk by JetBrains.
the class TCKChronoLocalDateTime method test_badTemporalFieldChrono.
@Test(dataProvider = "calendars")
public void test_badTemporalFieldChrono(Chronology chrono) {
LocalDate refDate = LocalDate.of(2013, 1, 1);
ChronoLocalDateTime<?> cdt = chrono.date(refDate).atTime(LocalTime.NOON);
for (Chronology[] clist : data_of_calendars()) {
Chronology chrono2 = clist[0];
ChronoLocalDateTime<?> cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON);
TemporalField adjuster = new FixedTemporalField(cdt2);
if (chrono != chrono2) {
try {
cdt.with(adjuster, 1);
Assert.fail("TemporalField doWith() should have thrown a ClassCastException" + cdt.getClass() + ", can not be cast to " + cdt2.getClass());
} catch (ClassCastException cce) {
// Expected exception; not an error
}
} else {
// Same chronology,
ChronoLocalDateTime<?> result = cdt.with(adjuster, 1);
assertEquals(result, cdt2, "TemporalField doWith() failed to replace date");
}
}
}
Aggregations