use of java.time.chrono.Chronology in project jdk8u_jdk by JetBrains.
the class TCKMinguoChronology method test_InvalidEras.
//-----------------------------------------------------------------------
// Bad Era for Chronology.date(era,...) and Chronology.prolepticYear(Era,...)
//-----------------------------------------------------------------------
@Test
public void test_InvalidEras() {
// Verify that the eras from every other Chronology are invalid
for (Chronology chrono : Chronology.getAvailableChronologies()) {
if (chrono instanceof MinguoChronology) {
continue;
}
List<Era> eras = chrono.eras();
for (Era era : eras) {
try {
ChronoLocalDate date = MinguoChronology.INSTANCE.date(era, 1, 1, 1);
fail("MinguoChronology.date did not throw ClassCastException for Era: " + era);
} catch (ClassCastException cex) {
// ignore expected exception
;
}
try {
@SuppressWarnings("unused") int year = MinguoChronology.INSTANCE.prolepticYear(era, 1);
fail("MinguoChronology.prolepticYear did not throw ClassCastException for Era: " + era);
} catch (ClassCastException cex) {
// ignore expected exception
;
}
}
}
}
use of java.time.chrono.Chronology in project jdk8u_jdk by JetBrains.
the class TCKMinguoChronology method test_chrono_byName.
//-----------------------------------------------------------------------
// Chronology.ofName("Minguo") Lookup by name
//-----------------------------------------------------------------------
@Test
public void test_chrono_byName() {
Chronology c = MinguoChronology.INSTANCE;
Chronology test = Chronology.of("Minguo");
Assert.assertNotNull(test, "The Minguo calendar could not be found byName");
Assert.assertEquals(test.getId(), "Minguo", "ID mismatch");
Assert.assertEquals(test.getCalendarType(), "roc", "Type mismatch");
Assert.assertEquals(test, c);
}
use of java.time.chrono.Chronology in project jdk8u_jdk by JetBrains.
the class TCKJapaneseChronology method test_chrono_byLocale_oldJP_noVariant.
@Test
public void test_chrono_byLocale_oldJP_noVariant() {
Chronology test = Chronology.ofLocale(new Locale("ja", "JP"));
Assert.assertEquals(test.getId(), "ISO");
Assert.assertEquals(test, IsoChronology.INSTANCE);
}
use of java.time.chrono.Chronology in project jdk8u_jdk by JetBrains.
the class TCKJapaneseChronology method test_chrono_byLocale_fullTag_japaneseCalendarFromElsewhere.
@Test
public void test_chrono_byLocale_fullTag_japaneseCalendarFromElsewhere() {
Chronology test = Chronology.ofLocale(Locale.forLanguageTag("en-US-u-ca-japanese"));
Assert.assertEquals(test.getId(), "Japanese");
Assert.assertEquals(test, JapaneseChronology.INSTANCE);
}
use of java.time.chrono.Chronology in project jdk8u_jdk by JetBrains.
the class TCKJapaneseChronology method test_InvalidEras.
//-----------------------------------------------------------------------
// Bad Era for Chronology.date(era,...) and Chronology.prolepticYear(Era,...)
//-----------------------------------------------------------------------
@Test
public void test_InvalidEras() {
// Verify that the eras from every other Chronology are invalid
for (Chronology chrono : Chronology.getAvailableChronologies()) {
if (chrono instanceof JapaneseChronology) {
continue;
}
List<Era> eras = chrono.eras();
for (Era era : eras) {
try {
ChronoLocalDate date = JapaneseChronology.INSTANCE.date(era, 1, 1, 1);
fail("JapaneseChronology.date did not throw ClassCastException for Era: " + era);
} catch (ClassCastException cex) {
// ignore expected exception
;
}
try {
@SuppressWarnings("unused") int year = JapaneseChronology.INSTANCE.prolepticYear(era, 1);
fail("JapaneseChronology.prolepticYear did not throw ClassCastException for Era: " + era);
} catch (ClassCastException cex) {
// ignore expected exception
;
}
}
}
}
Aggregations