jdk/test/java/time/test/java/time/chrono/TestUmmAlQuraChronology.java
changeset 28848 824124d1cba5
parent 20795 8ec9e5b79828
child 41600 5abb663b1ca4
equal deleted inserted replaced
28847:5667388e3a79 28848:824124d1cba5
    28 import static java.time.temporal.ChronoField.DAY_OF_MONTH;
    28 import static java.time.temporal.ChronoField.DAY_OF_MONTH;
    29 import static java.time.temporal.ChronoField.DAY_OF_YEAR;
    29 import static java.time.temporal.ChronoField.DAY_OF_YEAR;
    30 import static java.time.temporal.ChronoField.MONTH_OF_YEAR;
    30 import static java.time.temporal.ChronoField.MONTH_OF_YEAR;
    31 import static java.time.temporal.ChronoField.YEAR;
    31 import static java.time.temporal.ChronoField.YEAR;
    32 import static org.testng.Assert.assertEquals;
    32 import static org.testng.Assert.assertEquals;
       
    33 import static org.testng.Assert.assertFalse;
    33 import static org.testng.Assert.assertTrue;
    34 import static org.testng.Assert.assertTrue;
    34 import static org.testng.Assert.fail;
    35 import static org.testng.Assert.fail;
    35 
    36 
    36 import java.time.DateTimeException;
    37 import java.time.DateTimeException;
    37 import java.time.DayOfWeek;
    38 import java.time.DayOfWeek;
    69 import org.testng.annotations.Test;
    70 import org.testng.annotations.Test;
    70 
    71 
    71 /**
    72 /**
    72  * Tests for the Umm alQura chronology and data.
    73  * Tests for the Umm alQura chronology and data.
    73  * Note: The dates used for testing are just a sample of calendar data.
    74  * Note: The dates used for testing are just a sample of calendar data.
       
    75  * @bug 8067800
    74  */
    76  */
    75 @Test
    77 @Test
    76 public class TestUmmAlQuraChronology {
    78 public class TestUmmAlQuraChronology {
    77 
    79 
    78     private static final ZoneOffset OFFSET_PTWO = ZoneOffset.ofHours(2);
    80     private static final ZoneOffset OFFSET_PTWO = ZoneOffset.ofHours(2);
   527     @Test(dataProvider="leapYears")
   529     @Test(dataProvider="leapYears")
   528     public void test_leapYears(int y, boolean leapyear) {
   530     public void test_leapYears(int y, boolean leapyear) {
   529         HijrahDate date = HijrahDate.of(y, 1, 1);
   531         HijrahDate date = HijrahDate.of(y, 1, 1);
   530         assertEquals(date.isLeapYear(), leapyear);
   532         assertEquals(date.isLeapYear(), leapyear);
   531     }
   533     }
       
   534 
       
   535     // Data provider to verify that a given hijrah year is outside the range of supported years
       
   536     // The values are dependent on the currently configured UmmAlQura calendar data
       
   537     @DataProvider(name="OutOfRangeLeapYears")
       
   538     Object[][] data_invalid_leapyears() {
       
   539         return new Object[][] {
       
   540                 {1299},
       
   541                 {1601},
       
   542                 {Integer.MAX_VALUE},
       
   543                 {Integer.MIN_VALUE},
       
   544         };
       
   545     }
       
   546 
       
   547     @Test(dataProvider="OutOfRangeLeapYears")
       
   548     public void test_notLeapYears(int y) {
       
   549         assertFalse(HijrahChronology.INSTANCE.isLeapYear(y), "Out of range leap year");
       
   550     }
       
   551 
   532 
   552 
   533     // Date samples to convert HijrahDate to LocalDate and vice versa
   553     // Date samples to convert HijrahDate to LocalDate and vice versa
   534     @DataProvider(name="samples")
   554     @DataProvider(name="samples")
   535     Object[][] data_samples() {
   555     Object[][] data_samples() {
   536         return new Object[][] {
   556         return new Object[][] {