@Test(dataProvider = "calendars") public void test_badDateTimeFieldChrono(Chronology chrono) { LocalDate refDate = LocalDate.of(1900, 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 FixedDateTimeField(cdt2); if (chrono != chrono2) { try { cdt.with(adjuster, 1); Assert.fail( "DateTimeField doSet 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, "DateTimeField doSet failed to replace date"); } } }