test/java/time/tck/java/time/chrono/TestJapaneseChronology.java

Print this page




  37  *  * Redistributions in binary form must reproduce the above copyright notice,
  38  *    this list of conditions and the following disclaimer in the documentation
  39  *    and/or other materials provided with the distribution.
  40  *
  41  *  * Neither the name of JSR-310 nor the names of its contributors
  42  *    may be used to endorse or promote products derived from this software
  43  *    without specific prior written permission.
  44  *
  45  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  46  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  47  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  48  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  49  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  50  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  51  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  52  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  53  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  54  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  55  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  56  */
  57 package tck.java.time.calendar;
  58 
  59 import static org.testng.Assert.assertEquals;
  60 import static org.testng.Assert.assertFalse;
  61 import static org.testng.Assert.assertTrue;
  62 import static org.testng.Assert.fail;
  63 
  64 import java.util.List;
  65 
  66 import java.time.DateTimeException;
  67 import java.time.LocalDate;
  68 import java.time.LocalDateTime;
  69 import java.time.Month;
  70 import java.time.calendar.JapaneseChrono;





  71 import java.time.temporal.Adjusters;
  72 import java.time.temporal.Chrono;
  73 import java.time.temporal.ChronoLocalDate;
  74 import java.time.temporal.Era;
  75 import java.time.temporal.ISOChrono;
  76 
  77 import org.testng.Assert;
  78 import org.testng.annotations.DataProvider;
  79 import org.testng.annotations.Test;
  80 
  81 /**
  82  * Test.
  83  */
  84 @Test
  85 public class TestJapaneseChrono {




  86 
  87     //-----------------------------------------------------------------------
  88     // Chrono.ofName("Japanese")  Lookup by name
  89     //-----------------------------------------------------------------------
  90     @Test(groups={"tck"})
  91     public void test_chrono_byName() {
  92         Chrono<JapaneseChrono> c = JapaneseChrono.INSTANCE;
  93         Chrono<?> test = Chrono.of("Japanese");
  94         Assert.assertNotNull(test, "The Japanese calendar could not be found byName");
  95         Assert.assertEquals(test.getId(), "Japanese", "ID mismatch");
  96         Assert.assertEquals(test.getCalendarType(), "japanese", "Type mismatch");
  97         Assert.assertEquals(test, c);
  98     }
  99 
 100     //-----------------------------------------------------------------------






































 101     // creation, toLocalDate()
 102     //-----------------------------------------------------------------------
 103     @DataProvider(name="samples")
 104     Object[][] data_samples() {
 105         return new Object[][] {
 106             {JapaneseChrono.INSTANCE.date(1, 1, 1), LocalDate.of(1, 1, 1)},
 107             {JapaneseChrono.INSTANCE.date(1, 1, 2), LocalDate.of(1, 1, 2)},
 108             {JapaneseChrono.INSTANCE.date(1, 1, 3), LocalDate.of(1, 1, 3)},
 109 
 110             {JapaneseChrono.INSTANCE.date(2, 1, 1), LocalDate.of(2, 1, 1)},
 111             {JapaneseChrono.INSTANCE.date(3, 1, 1), LocalDate.of(3, 1, 1)},
 112             {JapaneseChrono.INSTANCE.date(3, 12, 6), LocalDate.of(3, 12, 6)},
 113             {JapaneseChrono.INSTANCE.date(4, 1, 1), LocalDate.of(4, 1, 1)},
 114             {JapaneseChrono.INSTANCE.date(4, 7, 3), LocalDate.of(4, 7, 3)},
 115             {JapaneseChrono.INSTANCE.date(4, 7, 4), LocalDate.of(4, 7, 4)},
 116             {JapaneseChrono.INSTANCE.date(5, 1, 1), LocalDate.of(5, 1, 1)},
 117             {JapaneseChrono.INSTANCE.date(1662, 3, 3), LocalDate.of(1662, 3, 3)},
 118             {JapaneseChrono.INSTANCE.date(1728, 10, 28), LocalDate.of(1728, 10, 28)},
 119             {JapaneseChrono.INSTANCE.date(1728, 10, 29), LocalDate.of(1728, 10, 29)},











 120         };
 121     }
 122 
 123     @Test(dataProvider="samples", groups={"tck"})
 124     public void test_toLocalDate(ChronoLocalDate<JapaneseChrono> jdate, LocalDate iso) {
 125         assertEquals(LocalDate.from(jdate), iso);
 126     }
 127 
 128     @Test(dataProvider="samples", groups={"tck"})
 129     public void test_fromCalendrical(ChronoLocalDate<JapaneseChrono> jdate, LocalDate iso) {
 130         assertEquals(JapaneseChrono.INSTANCE.date(iso), jdate);
 131     }
 132 
 133     @DataProvider(name="badDates")
 134     Object[][] data_badDates() {
 135         return new Object[][] {
 136             {1728, 0, 0},
 137 
 138             {1728, -1, 1},
 139             {1728, 0, 1},
 140             {1728, 14, 1},
 141             {1728, 15, 1},
 142 
 143             {1728, 1, -1},
 144             {1728, 1, 0},
 145             {1728, 1, 32},
 146 
 147             {1728, 12, -1},
 148             {1728, 12, 0},
 149             {1728, 12, 32},




 150         };
 151     }
 152 
 153     @Test(dataProvider="badDates", groups={"tck"}, expectedExceptions=DateTimeException.class)
 154     public void test_badDates(int year, int month, int dom) {
 155         JapaneseChrono.INSTANCE.date(year, month, dom);







































 156     }
 157 
 158     //-----------------------------------------------------------------------
 159     // with(WithAdjuster)
 160     //-----------------------------------------------------------------------
 161     @Test(groups={"tck"})
 162     public void test_adjust1() {
 163         ChronoLocalDate<JapaneseChrono> base = JapaneseChrono.INSTANCE.date(1728, 10, 29);
 164         ChronoLocalDate<JapaneseChrono> test = base.with(Adjusters.lastDayOfMonth());
 165         assertEquals(test, JapaneseChrono.INSTANCE.date(1728, 10, 31));
 166     }
 167 
 168     @Test(groups={"tck"})
 169     public void test_adjust2() {
 170         ChronoLocalDate<JapaneseChrono> base = JapaneseChrono.INSTANCE.date(1728, 12, 2);
 171         ChronoLocalDate<JapaneseChrono> test = base.with(Adjusters.lastDayOfMonth());
 172         assertEquals(test, JapaneseChrono.INSTANCE.date(1728, 12, 31));
 173     }
 174 
 175     //-----------------------------------------------------------------------
 176     // JapaneseDate.with(Local*)
 177     //-----------------------------------------------------------------------
 178     @Test(groups={"tck"})
 179     public void test_adjust_toLocalDate() {
 180         ChronoLocalDate<JapaneseChrono> jdate = JapaneseChrono.INSTANCE.date(1726, 1, 4);
 181         ChronoLocalDate<JapaneseChrono> test = jdate.with(LocalDate.of(2012, 7, 6));
 182         assertEquals(test, JapaneseChrono.INSTANCE.date(2012, 7, 6));
 183     }
 184 
 185     @Test(groups={"tck"}, expectedExceptions=DateTimeException.class)
 186     public void test_adjust_toMonth() {
 187         ChronoLocalDate<?> jdate = JapaneseChrono.INSTANCE.date(1726, 1, 4);
 188         jdate.with(Month.APRIL);
 189     }
 190 
 191     //-----------------------------------------------------------------------
 192     // LocalDate.with(JapaneseDate)
 193     //-----------------------------------------------------------------------
 194     @Test(groups={"tck"})
 195     public void test_LocalDate_adjustToJapaneseDate() {
 196         ChronoLocalDate<JapaneseChrono> jdate = JapaneseChrono.INSTANCE.date(1728, 10, 29);
 197         LocalDate test = LocalDate.MIN.with(jdate);
 198         assertEquals(test, LocalDate.of(1728, 10, 29));
 199     }
 200 
 201     @Test(groups={"tck"})
 202     public void test_LocalDateTime_adjustToJapaneseDate() {
 203         ChronoLocalDate<JapaneseChrono> jdate = JapaneseChrono.INSTANCE.date(1728, 10, 29);
 204         LocalDateTime test = LocalDateTime.MIN.with(jdate);
 205         assertEquals(test, LocalDateTime.of(1728, 10, 29, 0, 0));
 206     }
 207 
 208     //-----------------------------------------------------------------------
 209     // Check Japanese Eras
 210     //-----------------------------------------------------------------------
 211     @DataProvider(name="japaneseEras")
 212     Object[][] data_japanseseEras() {
 213         return new Object[][] {
 214             { JapaneseChrono.ERA_SEIREKI, -999, "Seireki"},
 215             { JapaneseChrono.ERA_MEIJI, -1, "Meiji"},
 216             { JapaneseChrono.ERA_TAISHO, 0, "Taisho"},
 217             { JapaneseChrono.ERA_SHOWA, 1, "Showa"},
 218             { JapaneseChrono.ERA_HEISEI, 2, "Heisei"},
 219         };
 220     }
 221 
 222     @Test(groups={"tck"}, dataProvider="japaneseEras")
 223     public void test_Japanese_Eras(Era era, int eraValue, String name) {
 224         assertEquals(era.getValue(), eraValue, "EraValue");
 225         assertEquals(era.toString(), name, "Era Name");
 226         assertEquals(era, JapaneseChrono.INSTANCE.eraOf(eraValue), "JapaneseChrono.eraOf()");
 227         List<Era<JapaneseChrono>> eras = JapaneseChrono.INSTANCE.eras();
 228         assertTrue(eras.contains(era), "Era is not present in JapaneseChrono.INSTANCE.eras()");
 229     }
 230 
 231     @Test(groups="tck")
 232     public void test_Japanese_badEras() {
 233         int badEras[] = {-1000, -998, -997, -2, 3, 4, 1000};
 234         for (int badEra : badEras) {
 235             try {
 236                 Era<JapaneseChrono> era = JapaneseChrono.INSTANCE.eraOf(badEra);
 237                 fail("JapaneseChrono.eraOf returned " + era + " + for invalid eraValue " + badEra);
 238             } catch (DateTimeException ex) {
 239                 // ignore expected exception
 240             }
 241         }
 242     }
 243 
 244     //-----------------------------------------------------------------------
 245     // toString()
 246     //-----------------------------------------------------------------------
 247     @DataProvider(name="toString")
 248     Object[][] data_toString() {
 249         return new Object[][] {
 250             {JapaneseChrono.INSTANCE.date(0001,  1,  1), "Japanese 0001-01-01"},
 251             {JapaneseChrono.INSTANCE.date(1728, 10, 28), "Japanese 1728-10-28"},
 252             {JapaneseChrono.INSTANCE.date(1728, 10, 29), "Japanese 1728-10-29"},
 253             {JapaneseChrono.INSTANCE.date(1727, 12,  5), "Japanese 1727-12-05"},
 254             {JapaneseChrono.INSTANCE.date(1727, 12,  6), "Japanese 1727-12-06"},
 255             {JapaneseChrono.INSTANCE.date(1868,  9,  8), "Japanese Meiji 1-09-08"},
 256             {JapaneseChrono.INSTANCE.date(1912,  7, 29), "Japanese Meiji 45-07-29"},
 257             {JapaneseChrono.INSTANCE.date(1912,  7, 30), "Japanese Taisho 1-07-30"},
 258             {JapaneseChrono.INSTANCE.date(1926, 12, 24), "Japanese Taisho 15-12-24"},
 259             {JapaneseChrono.INSTANCE.date(1926, 12, 25), "Japanese Showa 1-12-25"},
 260             {JapaneseChrono.INSTANCE.date(1989,  1,  7), "Japanese Showa 64-01-07"},
 261             {JapaneseChrono.INSTANCE.date(1989,  1,  8), "Japanese Heisei 1-01-08"},
 262             {JapaneseChrono.INSTANCE.date(2012, 12,  6), "Japanese Heisei 24-12-06"},
 263         };
 264     }
 265 
 266     @Test(dataProvider="toString", groups={"tck"})
 267     public void test_toString(ChronoLocalDate<JapaneseChrono> jdate, String expected) {
 268         assertEquals(jdate.toString(), expected);
 269     }
 270 
 271     //-----------------------------------------------------------------------
 272     // equals()
 273     //-----------------------------------------------------------------------
 274     @Test(groups="tck")
 275     public void test_equals_true() {
 276         assertTrue(JapaneseChrono.INSTANCE.equals(JapaneseChrono.INSTANCE));
 277     }
 278 
 279     @Test(groups="tck")
 280     public void test_equals_false() {
 281         assertFalse(JapaneseChrono.INSTANCE.equals(ISOChrono.INSTANCE));
 282     }
 283 
 284 }


  37  *  * Redistributions in binary form must reproduce the above copyright notice,
  38  *    this list of conditions and the following disclaimer in the documentation
  39  *    and/or other materials provided with the distribution.
  40  *
  41  *  * Neither the name of JSR-310 nor the names of its contributors
  42  *    may be used to endorse or promote products derived from this software
  43  *    without specific prior written permission.
  44  *
  45  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  46  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  47  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  48  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  49  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  50  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  51  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  52  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  53  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  54  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  55  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  56  */
  57 package tck.java.time.chrono;
  58 
  59 import static org.testng.Assert.assertEquals;
  60 import static org.testng.Assert.assertFalse;
  61 import static org.testng.Assert.assertTrue;
  62 import static org.testng.Assert.fail;
  63 
  64 import java.util.List;
  65 
  66 import java.time.DateTimeException;
  67 import java.time.LocalDate;
  68 import java.time.LocalDateTime;
  69 import java.time.Month;
  70 import java.time.Year;
  71 import java.time.chrono.JapaneseChronology;
  72 import java.time.chrono.JapaneseDate;
  73 import java.time.chrono.Chronology;
  74 import java.time.chrono.Era;
  75 import java.time.chrono.IsoChronology;
  76 import java.time.temporal.Adjusters;
  77 import java.util.Locale;



  78 
  79 import org.testng.Assert;
  80 import org.testng.annotations.DataProvider;
  81 import org.testng.annotations.Test;
  82 
  83 /**
  84  * Test.
  85  */
  86 @Test
  87 public class TestJapaneseChronology {
  88     private static int YDIFF_HEISEI = 1988;
  89     private static int YDIFF_MEIJI = 1867;
  90     private static int YDIFF_SHOWA = 1925;
  91     private static int YDIFF_TAISHO = 1911;
  92 
  93     //-----------------------------------------------------------------------
  94     // Chronology.of(String)
  95     //-----------------------------------------------------------------------
  96     @Test
  97     public void test_chrono_byName() {
  98         Chronology c = JapaneseChronology.INSTANCE;
  99         Chronology test = Chronology.of("Japanese");
 100         Assert.assertNotNull(test, "The Japanese calendar could not be found byName");
 101         Assert.assertEquals(test.getId(), "Japanese", "ID mismatch");
 102         Assert.assertEquals(test.getCalendarType(), "japanese", "Type mismatch");
 103         Assert.assertEquals(test, c);
 104     }
 105 
 106     //-----------------------------------------------------------------------
 107     // Chronology.ofLocale(Locale)
 108     //-----------------------------------------------------------------------
 109     @Test
 110     public void test_chrono_byLocale_fullTag_japaneseCalendarFromJapan() {
 111         Chronology test = Chronology.ofLocale(Locale.forLanguageTag("ja-JP-u-ca-japanese"));
 112         Assert.assertEquals(test.getId(), "Japanese");
 113         Assert.assertEquals(test, JapaneseChronology.INSTANCE);
 114     }
 115 
 116     @Test
 117     public void test_chrono_byLocale_fullTag_japaneseCalendarFromElsewhere() {
 118         Chronology test = Chronology.ofLocale(Locale.forLanguageTag("en-US-u-ca-japanese"));
 119         Assert.assertEquals(test.getId(), "Japanese");
 120         Assert.assertEquals(test, JapaneseChronology.INSTANCE);
 121     }
 122 
 123     @Test
 124     public void test_chrono_byLocale_oldJP_noVariant() {
 125         Chronology test = Chronology.ofLocale(new Locale("ja", "JP"));
 126         Assert.assertEquals(test.getId(), "ISO");
 127         Assert.assertEquals(test, IsoChronology.INSTANCE);
 128     }
 129 
 130     @Test
 131     public void test_chrono_byLocale_oldJP_variant() {
 132         Chronology test = Chronology.ofLocale(new Locale("ja", "JP", "JP"));
 133         Assert.assertEquals(test.getId(), "Japanese");
 134         Assert.assertEquals(test, JapaneseChronology.INSTANCE);
 135     }
 136 
 137     @Test
 138     public void test_chrono_byLocale_iso() {
 139         Assert.assertEquals(Chronology.ofLocale(new Locale("ja", "JP")).getId(), "ISO");
 140         Assert.assertEquals(Chronology.ofLocale(Locale.forLanguageTag("ja-JP")).getId(), "ISO");
 141         Assert.assertEquals(Chronology.ofLocale(Locale.forLanguageTag("ja-JP-JP")).getId(), "ISO");
 142     }
 143 
 144     //-----------------------------------------------------------------------
 145     // creation, toLocalDate()
 146     //-----------------------------------------------------------------------
 147     @DataProvider(name="samples")
 148     Object[][] data_samples() {
 149         return new Object[][] {
 150             {JapaneseChronology.INSTANCE.date(1, 1, 1), LocalDate.of(1, 1, 1)},
 151             {JapaneseChronology.INSTANCE.date(1, 1, 2), LocalDate.of(1, 1, 2)},
 152             {JapaneseChronology.INSTANCE.date(1, 1, 3), LocalDate.of(1, 1, 3)},
 153 
 154             {JapaneseChronology.INSTANCE.date(2, 1, 1), LocalDate.of(2, 1, 1)},
 155             {JapaneseChronology.INSTANCE.date(3, 1, 1), LocalDate.of(3, 1, 1)},
 156             {JapaneseChronology.INSTANCE.date(3, 12, 6), LocalDate.of(3, 12, 6)},
 157             {JapaneseChronology.INSTANCE.date(4, 1, 1), LocalDate.of(4, 1, 1)},
 158             {JapaneseChronology.INSTANCE.date(4, 7, 3), LocalDate.of(4, 7, 3)},
 159             {JapaneseChronology.INSTANCE.date(4, 7, 4), LocalDate.of(4, 7, 4)},
 160             {JapaneseChronology.INSTANCE.date(5, 1, 1), LocalDate.of(5, 1, 1)},
 161             {JapaneseChronology.INSTANCE.date(1662, 3, 3), LocalDate.of(1662, 3, 3)},
 162             {JapaneseChronology.INSTANCE.date(1728, 10, 28), LocalDate.of(1728, 10, 28)},
 163             {JapaneseChronology.INSTANCE.date(1728, 10, 29), LocalDate.of(1728, 10, 29)},
 164 
 165             {JapaneseChronology.INSTANCE.date(JapaneseChronology.ERA_HEISEI, 1996 - YDIFF_HEISEI, 2, 29), LocalDate.of(1996, 2, 29)},
 166             {JapaneseChronology.INSTANCE.date(JapaneseChronology.ERA_HEISEI, 2000 - YDIFF_HEISEI, 2, 29), LocalDate.of(2000, 2, 29)},
 167             {JapaneseChronology.INSTANCE.date(JapaneseChronology.ERA_MEIJI, 1868 - YDIFF_MEIJI, 2, 29), LocalDate.of(1868, 2, 29)},
 168             {JapaneseChronology.INSTANCE.date(JapaneseChronology.ERA_SHOWA, 1928 - YDIFF_SHOWA, 2, 29), LocalDate.of(1928, 2, 29)},
 169             {JapaneseChronology.INSTANCE.date(JapaneseChronology.ERA_TAISHO, 1912 - YDIFF_TAISHO, 2, 29), LocalDate.of(1912, 2, 29)},
 170 
 171             {JapaneseChronology.INSTANCE.dateYearDay(1996, 60), LocalDate.of(1996, 2, 29)},
 172             {JapaneseChronology.INSTANCE.dateYearDay(1868, 60), LocalDate.of(1868, 2, 29)},
 173             {JapaneseChronology.INSTANCE.dateYearDay(1928, 60), LocalDate.of(1928, 2, 29)},
 174             {JapaneseChronology.INSTANCE.dateYearDay(1912, 60), LocalDate.of(1912, 2, 29)},
 175         };
 176     }
 177 
 178     @Test(dataProvider="samples", groups={"tck"})
 179     public void test_toLocalDate(JapaneseDate jdate, LocalDate iso) {
 180         assertEquals(LocalDate.from(jdate), iso);
 181     }
 182 
 183     @Test(dataProvider="samples", groups={"tck"})
 184     public void test_fromCalendrical(JapaneseDate jdate, LocalDate iso) {
 185         assertEquals(JapaneseChronology.INSTANCE.date(iso), jdate);
 186     }
 187 
 188     @DataProvider(name="badDates")
 189     Object[][] data_badDates() {
 190         return new Object[][] {
 191             {1728, 0, 0},
 192 
 193             {1728, -1, 1},
 194             {1728, 0, 1},
 195             {1728, 14, 1},
 196             {1728, 15, 1},
 197 
 198             {1728, 1, -1},
 199             {1728, 1, 0},
 200             {1728, 1, 32},
 201 
 202             {1728, 12, -1},
 203             {1728, 12, 0},
 204             {1728, 12, 32},
 205 
 206             {1725, 2, 29},
 207             {500, 2, 29},
 208             {2100, 2, 29},
 209         };
 210     }
 211 
 212     @Test(dataProvider="badDates", groups={"tck"}, expectedExceptions=DateTimeException.class)
 213     public void test_badDates(int year, int month, int dom) {
 214         JapaneseChronology.INSTANCE.date(year, month, dom);
 215     }
 216 
 217     //-----------------------------------------------------------------------
 218     // prolepticYear() and is LeapYear()
 219     //-----------------------------------------------------------------------
 220     @DataProvider(name="prolepticYear")
 221     Object[][] data_prolepticYear() {
 222         return new Object[][] {
 223             {2, JapaneseChronology.ERA_HEISEI, 1, 1 + YDIFF_HEISEI, false},
 224             {2, JapaneseChronology.ERA_HEISEI, 100, 100 + YDIFF_HEISEI, true},
 225             {2, JapaneseChronology.ERA_HEISEI, 0, YDIFF_HEISEI, true},
 226             {2, JapaneseChronology.ERA_HEISEI, -10, -10 + YDIFF_HEISEI, false},
 227 
 228             {-1, JapaneseChronology.ERA_MEIJI, 1, 1 + YDIFF_MEIJI, true},
 229             {-1, JapaneseChronology.ERA_MEIJI, 100, 100 + YDIFF_MEIJI, false},
 230             {-1, JapaneseChronology.ERA_MEIJI, 0, YDIFF_MEIJI, false},
 231             {-1, JapaneseChronology.ERA_MEIJI, -10, -10 + YDIFF_MEIJI, false},
 232 
 233             {1, JapaneseChronology.ERA_SHOWA, 1, 1 + YDIFF_SHOWA, false},
 234             {1, JapaneseChronology.ERA_SHOWA, 100, 100 + YDIFF_SHOWA, false},
 235             {1, JapaneseChronology.ERA_SHOWA, 0, YDIFF_SHOWA, false},
 236             {1, JapaneseChronology.ERA_SHOWA, -5, -5 + YDIFF_SHOWA, true},
 237 
 238             {0, JapaneseChronology.ERA_TAISHO, 1, 1 + YDIFF_TAISHO, true},
 239             {0, JapaneseChronology.ERA_TAISHO, 100, 100 + YDIFF_TAISHO, false},
 240             {0, JapaneseChronology.ERA_TAISHO, 0, YDIFF_TAISHO, false},
 241             {0, JapaneseChronology.ERA_TAISHO, -10, -10 + YDIFF_TAISHO, false},
 242 
 243         };
 244     }
 245 
 246     @Test(dataProvider="prolepticYear", groups={"tck"})
 247     public void test_prolepticYear(int eraValue, Era  era, int yearOfEra, int expectedProlepticYear, boolean isLeapYear) {
 248         Era eraObj = JapaneseChronology.INSTANCE.eraOf(eraValue) ;
 249         assertTrue(JapaneseChronology.INSTANCE.eras().contains(eraObj));
 250         assertEquals(eraObj, era);
 251         assertEquals(JapaneseChronology.INSTANCE.prolepticYear(era, yearOfEra), expectedProlepticYear);
 252         assertEquals(JapaneseChronology.INSTANCE.isLeapYear(expectedProlepticYear), isLeapYear) ;
 253         assertEquals(JapaneseChronology.INSTANCE.isLeapYear(expectedProlepticYear), Year.of(expectedProlepticYear).isLeap()) ;
 254     }
 255 
 256     //-----------------------------------------------------------------------
 257     // with(WithAdjuster)
 258     //-----------------------------------------------------------------------
 259     @Test(groups={"tck"})
 260     public void test_adjust1() {
 261         JapaneseDate base = JapaneseChronology.INSTANCE.date(1728, 10, 29);
 262         JapaneseDate test = base.with(Adjusters.lastDayOfMonth());
 263         assertEquals(test, JapaneseChronology.INSTANCE.date(1728, 10, 31));
 264     }
 265 
 266     @Test(groups={"tck"})
 267     public void test_adjust2() {
 268         JapaneseDate base = JapaneseChronology.INSTANCE.date(1728, 12, 2);
 269         JapaneseDate test = base.with(Adjusters.lastDayOfMonth());
 270         assertEquals(test, JapaneseChronology.INSTANCE.date(1728, 12, 31));
 271     }
 272 
 273     //-----------------------------------------------------------------------
 274     // JapaneseDate.with(Local*)
 275     //-----------------------------------------------------------------------
 276     @Test(groups={"tck"})
 277     public void test_adjust_toLocalDate() {
 278         JapaneseDate jdate = JapaneseChronology.INSTANCE.date(1726, 1, 4);
 279         JapaneseDate test = jdate.with(LocalDate.of(2012, 7, 6));
 280         assertEquals(test, JapaneseChronology.INSTANCE.date(2012, 7, 6));
 281     }
 282 
 283     @Test(groups={"tck"}, expectedExceptions=DateTimeException.class)
 284     public void test_adjust_toMonth() {
 285         JapaneseDate jdate = JapaneseChronology.INSTANCE.date(1726, 1, 4);
 286         jdate.with(Month.APRIL);
 287     }
 288 
 289     //-----------------------------------------------------------------------
 290     // LocalDate.with(JapaneseDate)
 291     //-----------------------------------------------------------------------
 292     @Test(groups={"tck"})
 293     public void test_LocalDate_adjustToJapaneseDate() {
 294         JapaneseDate jdate = JapaneseChronology.INSTANCE.date(1728, 10, 29);
 295         LocalDate test = LocalDate.MIN.with(jdate);
 296         assertEquals(test, LocalDate.of(1728, 10, 29));
 297     }
 298 
 299     @Test(groups={"tck"})
 300     public void test_LocalDateTime_adjustToJapaneseDate() {
 301         JapaneseDate jdate = JapaneseChronology.INSTANCE.date(1728, 10, 29);
 302         LocalDateTime test = LocalDateTime.MIN.with(jdate);
 303         assertEquals(test, LocalDateTime.of(1728, 10, 29, 0, 0));
 304     }
 305 
 306     //-----------------------------------------------------------------------
 307     // Check Japanese Eras
 308     //-----------------------------------------------------------------------
 309     @DataProvider(name="japaneseEras")
 310     Object[][] data_japanseseEras() {
 311         return new Object[][] {
 312             { JapaneseChronology.ERA_SEIREKI, -999, "Seireki"},
 313             { JapaneseChronology.ERA_MEIJI, -1, "Meiji"},
 314             { JapaneseChronology.ERA_TAISHO, 0, "Taisho"},
 315             { JapaneseChronology.ERA_SHOWA, 1, "Showa"},
 316             { JapaneseChronology.ERA_HEISEI, 2, "Heisei"},
 317         };
 318     }
 319 
 320     @Test(groups={"tck"}, dataProvider="japaneseEras")
 321     public void test_Japanese_Eras(Era era, int eraValue, String name) {
 322         assertEquals(era.getValue(), eraValue, "EraValue");
 323         assertEquals(era.toString(), name, "Era Name");
 324         assertEquals(era, JapaneseChronology.INSTANCE.eraOf(eraValue), "JapaneseChronology.eraOf()");
 325         List<Era> eras = JapaneseChronology.INSTANCE.eras();
 326         assertTrue(eras.contains(era), "Era is not present in JapaneseChronology.INSTANCE.eras()");
 327     }
 328 
 329     @Test(groups="tck")
 330     public void test_Japanese_badEras() {
 331         int badEras[] = {-1000, -998, -997, -2, 3, 4, 1000};
 332         for (int badEra : badEras) {
 333             try {
 334                 Era era = JapaneseChronology.INSTANCE.eraOf(badEra);
 335                 fail("JapaneseChronology.eraOf returned " + era + " + for invalid eraValue " + badEra);
 336             } catch (DateTimeException ex) {
 337                 // ignore expected exception
 338             }
 339         }
 340     }
 341 
 342     //-----------------------------------------------------------------------
 343     // toString()
 344     //-----------------------------------------------------------------------
 345     @DataProvider(name="toString")
 346     Object[][] data_toString() {
 347         return new Object[][] {
 348             {JapaneseChronology.INSTANCE.date(0001,  1,  1), "Japanese 0001-01-01"},
 349             {JapaneseChronology.INSTANCE.date(1728, 10, 28), "Japanese 1728-10-28"},
 350             {JapaneseChronology.INSTANCE.date(1728, 10, 29), "Japanese 1728-10-29"},
 351             {JapaneseChronology.INSTANCE.date(1727, 12,  5), "Japanese 1727-12-05"},
 352             {JapaneseChronology.INSTANCE.date(1727, 12,  6), "Japanese 1727-12-06"},
 353             {JapaneseChronology.INSTANCE.date(1868,  9,  8), "Japanese Meiji 1-09-08"},
 354             {JapaneseChronology.INSTANCE.date(1912,  7, 29), "Japanese Meiji 45-07-29"},
 355             {JapaneseChronology.INSTANCE.date(1912,  7, 30), "Japanese Taisho 1-07-30"},
 356             {JapaneseChronology.INSTANCE.date(1926, 12, 24), "Japanese Taisho 15-12-24"},
 357             {JapaneseChronology.INSTANCE.date(1926, 12, 25), "Japanese Showa 1-12-25"},
 358             {JapaneseChronology.INSTANCE.date(1989,  1,  7), "Japanese Showa 64-01-07"},
 359             {JapaneseChronology.INSTANCE.date(1989,  1,  8), "Japanese Heisei 1-01-08"},
 360             {JapaneseChronology.INSTANCE.date(2012, 12,  6), "Japanese Heisei 24-12-06"},
 361         };
 362     }
 363 
 364     @Test(dataProvider="toString", groups={"tck"})
 365     public void test_toString(JapaneseDate jdate, String expected) {
 366         assertEquals(jdate.toString(), expected);
 367     }
 368 
 369     //-----------------------------------------------------------------------
 370     // equals()
 371     //-----------------------------------------------------------------------
 372     @Test(groups="tck")
 373     public void test_equals_true() {
 374         assertTrue(JapaneseChronology.INSTANCE.equals(JapaneseChronology.INSTANCE));
 375     }
 376 
 377     @Test(groups="tck")
 378     public void test_equals_false() {
 379         assertFalse(JapaneseChronology.INSTANCE.equals(IsoChronology.INSTANCE));
 380     }
 381 
 382 }