test/java/time/tck/java/time/TestIsoChronology.java

Print this page

        

@@ -55,51 +55,51 @@
  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-package tck.java.time.temporal;
+package tck.java.time;
 
+import static java.time.chrono.IsoChronology.ERA_BCE;
+import static java.time.chrono.IsoChronology.ERA_CE;
 import static java.time.temporal.ChronoField.ERA;
 import static java.time.temporal.ChronoField.YEAR;
 import static java.time.temporal.ChronoField.YEAR_OF_ERA;
-import static java.time.temporal.ISOChrono.ERA_BCE;
-import static java.time.temporal.ISOChrono.ERA_CE;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertFalse;
 import static org.testng.Assert.assertNotNull;
 import static org.testng.Assert.assertTrue;
 
 import java.time.DateTimeException;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.Month;
-import java.time.temporal.Chrono;
-import java.time.temporal.ChronoField;
-import java.time.temporal.ChronoLocalDate;
 import java.time.temporal.Adjusters;
-import java.time.calendar.HijrahChrono;
-import java.time.temporal.Era;
-import java.time.temporal.ISOChrono;
+import java.time.temporal.ChronoField;
+import java.time.chrono.HijrahChronology;
+import java.time.chrono.Chronology;
+import java.time.chrono.ChronoLocalDate;
+import java.time.chrono.Era;
+import java.time.chrono.IsoChronology;
 
 import org.testng.Assert;
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
 /**
  * Test.
  */
 @Test
-public class TestISOChrono {
+public class TestIsoChronology {
 
     //-----------------------------------------------------------------------
-    // Chrono.ofName("ISO")  Lookup by name
+    // Chronology.ofName("ISO")  Lookup by name
     //-----------------------------------------------------------------------
     @Test(groups={"tck"})
     public void test_chrono_byName() {
-        Chrono<ISOChrono> c = ISOChrono.INSTANCE;
-        Chrono<?> test = Chrono.of("ISO");
+        Chronology c = IsoChronology.INSTANCE;
+        Chronology test = Chronology.of("ISO");
         Assert.assertNotNull(test, "The ISO calendar could not be found byName");
         Assert.assertEquals(test.getId(), "ISO", "ID mismatch");
         Assert.assertEquals(test.getCalendarType(), "iso8601", "Type mismatch");
         Assert.assertEquals(test, c);
     }

@@ -107,53 +107,53 @@
     //-----------------------------------------------------------------------
     // Lookup by Singleton
     //-----------------------------------------------------------------------
     @Test(groups="tck")
     public void instanceNotNull() {
-        assertNotNull(ISOChrono.INSTANCE);
+        assertNotNull(IsoChronology.INSTANCE);
     }
 
     //-----------------------------------------------------------------------
     // Era creation
     //-----------------------------------------------------------------------
     @Test(groups="tck")
     public void test_eraOf() {
-        assertEquals(ISOChrono.INSTANCE.eraOf(0), ERA_BCE);
-        assertEquals(ISOChrono.INSTANCE.eraOf(1), ERA_CE);
+        assertEquals(IsoChronology.INSTANCE.eraOf(0), ERA_BCE);
+        assertEquals(IsoChronology.INSTANCE.eraOf(1), ERA_CE);
     }
 
     //-----------------------------------------------------------------------
     // creation, toLocalDate()
     //-----------------------------------------------------------------------
     @DataProvider(name="samples")
     Object[][] data_samples() {
         return new Object[][] {
-            {ISOChrono.INSTANCE.date(1, 7, 8), LocalDate.of(1, 7, 8)},
-            {ISOChrono.INSTANCE.date(1, 7, 20), LocalDate.of(1, 7, 20)},
-            {ISOChrono.INSTANCE.date(1, 7, 21), LocalDate.of(1, 7, 21)},
-
-            {ISOChrono.INSTANCE.date(2, 7, 8), LocalDate.of(2, 7, 8)},
-            {ISOChrono.INSTANCE.date(3, 6, 27), LocalDate.of(3, 6, 27)},
-            {ISOChrono.INSTANCE.date(3, 5, 23), LocalDate.of(3, 5, 23)},
-            {ISOChrono.INSTANCE.date(4, 6, 16), LocalDate.of(4, 6, 16)},
-            {ISOChrono.INSTANCE.date(4, 7, 3), LocalDate.of(4, 7, 3)},
-            {ISOChrono.INSTANCE.date(4, 7, 4), LocalDate.of(4, 7, 4)},
-            {ISOChrono.INSTANCE.date(5, 1, 1), LocalDate.of(5, 1, 1)},
-            {ISOChrono.INSTANCE.date(1727, 3, 3), LocalDate.of(1727, 3, 3)},
-            {ISOChrono.INSTANCE.date(1728, 10, 28), LocalDate.of(1728, 10, 28)},
-            {ISOChrono.INSTANCE.date(2012, 10, 29), LocalDate.of(2012, 10, 29)},
+            {IsoChronology.INSTANCE.date(1, 7, 8), LocalDate.of(1, 7, 8)},
+            {IsoChronology.INSTANCE.date(1, 7, 20), LocalDate.of(1, 7, 20)},
+            {IsoChronology.INSTANCE.date(1, 7, 21), LocalDate.of(1, 7, 21)},
+
+            {IsoChronology.INSTANCE.date(2, 7, 8), LocalDate.of(2, 7, 8)},
+            {IsoChronology.INSTANCE.date(3, 6, 27), LocalDate.of(3, 6, 27)},
+            {IsoChronology.INSTANCE.date(3, 5, 23), LocalDate.of(3, 5, 23)},
+            {IsoChronology.INSTANCE.date(4, 6, 16), LocalDate.of(4, 6, 16)},
+            {IsoChronology.INSTANCE.date(4, 7, 3), LocalDate.of(4, 7, 3)},
+            {IsoChronology.INSTANCE.date(4, 7, 4), LocalDate.of(4, 7, 4)},
+            {IsoChronology.INSTANCE.date(5, 1, 1), LocalDate.of(5, 1, 1)},
+            {IsoChronology.INSTANCE.date(1727, 3, 3), LocalDate.of(1727, 3, 3)},
+            {IsoChronology.INSTANCE.date(1728, 10, 28), LocalDate.of(1728, 10, 28)},
+            {IsoChronology.INSTANCE.date(2012, 10, 29), LocalDate.of(2012, 10, 29)},
         };
     }
 
     @Test(dataProvider="samples", groups={"tck"})
-    public void test_toLocalDate(ChronoLocalDate<ISOChrono> isoDate, LocalDate iso) {
+    public void test_toLocalDate(LocalDate isoDate, LocalDate iso) {
         assertEquals(LocalDate.from(isoDate), iso);
     }
 
     @Test(dataProvider="samples", groups={"tck"})
-    public void test_fromCalendrical(ChronoLocalDate<ISOChrono> isoDate, LocalDate iso) {
-        assertEquals(ISOChrono.INSTANCE.date(iso), isoDate);
+    public void test_fromCalendrical(LocalDate isoDate, LocalDate iso) {
+        assertEquals(IsoChronology.INSTANCE.date(iso), isoDate);
     }
 
     @DataProvider(name="badDates")
     Object[][] data_badDates() {
         return new Object[][] {

@@ -174,19 +174,19 @@
         };
     }
 
     @Test(dataProvider="badDates", groups={"tck"}, expectedExceptions=DateTimeException.class)
     public void test_badDates(int year, int month, int dom) {
-        ISOChrono.INSTANCE.date(year, month, dom);
+        IsoChronology.INSTANCE.date(year, month, dom);
     }
 
     @Test(groups="tck")
     public void test_date_withEra() {
         int year = 5;
         int month = 5;
         int dayOfMonth = 5;
-        ChronoLocalDate<ISOChrono> test = ISOChrono.INSTANCE.date(ERA_BCE, year, month, dayOfMonth);
+        LocalDate test = IsoChronology.INSTANCE.date(ERA_BCE, year, month, dayOfMonth);
         assertEquals(test.getEra(), ERA_BCE);
         assertEquals(test.get(ChronoField.YEAR_OF_ERA), year);
         assertEquals(test.get(ChronoField.MONTH_OF_YEAR), month);
         assertEquals(test.get(ChronoField.DAY_OF_MONTH), dayOfMonth);
 

@@ -196,59 +196,59 @@
     }
 
     @SuppressWarnings({ "unchecked", "rawtypes" })
     @Test(expectedExceptions=DateTimeException.class, groups="tck")
     public void test_date_withEra_withWrongEra() {
-        ISOChrono.INSTANCE.date((Era) HijrahChrono.ERA_AH, 1, 1, 1);
+        IsoChronology.INSTANCE.date((Era) HijrahChronology.ERA_AH, 1, 1, 1);
     }
 
     //-----------------------------------------------------------------------
     // with(DateTimeAdjuster)
     //-----------------------------------------------------------------------
     @Test(groups={"tck"})
     public void test_adjust1() {
-        ChronoLocalDate<ISOChrono> base = ISOChrono.INSTANCE.date(1728, 10, 28);
-        ChronoLocalDate<ISOChrono> test = base.with(Adjusters.lastDayOfMonth());
-        assertEquals(test, ISOChrono.INSTANCE.date(1728, 10, 31));
+        LocalDate base = IsoChronology.INSTANCE.date(1728, 10, 28);
+        LocalDate test = base.with(Adjusters.lastDayOfMonth());
+        assertEquals(test, IsoChronology.INSTANCE.date(1728, 10, 31));
     }
 
     @Test(groups={"tck"})
     public void test_adjust2() {
-        ChronoLocalDate<ISOChrono> base = ISOChrono.INSTANCE.date(1728, 12, 2);
-        ChronoLocalDate<ISOChrono> test = base.with(Adjusters.lastDayOfMonth());
-        assertEquals(test, ISOChrono.INSTANCE.date(1728, 12, 31));
+        LocalDate base = IsoChronology.INSTANCE.date(1728, 12, 2);
+        LocalDate test = base.with(Adjusters.lastDayOfMonth());
+        assertEquals(test, IsoChronology.INSTANCE.date(1728, 12, 31));
     }
 
     //-----------------------------------------------------------------------
     // ISODate.with(Local*)
     //-----------------------------------------------------------------------
     @Test(groups={"tck"})
     public void test_adjust_toLocalDate() {
-        ChronoLocalDate<ISOChrono> isoDate = ISOChrono.INSTANCE.date(1726, 1, 4);
-        ChronoLocalDate<ISOChrono> test = isoDate.with(LocalDate.of(2012, 7, 6));
-        assertEquals(test, ISOChrono.INSTANCE.date(2012, 7, 6));
+        LocalDate isoDate = IsoChronology.INSTANCE.date(1726, 1, 4);
+        LocalDate test = isoDate.with(LocalDate.of(2012, 7, 6));
+        assertEquals(test, IsoChronology.INSTANCE.date(2012, 7, 6));
     }
 
     @Test(groups={"tck"})
     public void test_adjust_toMonth() {
-        ChronoLocalDate<ISOChrono> isoDate = ISOChrono.INSTANCE.date(1726, 1, 4);
-        assertEquals(ISOChrono.INSTANCE.date(1726, 4, 4), isoDate.with(Month.APRIL));
+        LocalDate isoDate = IsoChronology.INSTANCE.date(1726, 1, 4);
+        assertEquals(IsoChronology.INSTANCE.date(1726, 4, 4), isoDate.with(Month.APRIL));
     }
 
     //-----------------------------------------------------------------------
     // LocalDate.with(ISODate)
     //-----------------------------------------------------------------------
     @Test(groups={"tck"})
     public void test_LocalDate_adjustToISODate() {
-        ChronoLocalDate<ISOChrono> isoDate = ISOChrono.INSTANCE.date(1728, 10, 29);
+        LocalDate isoDate = IsoChronology.INSTANCE.date(1728, 10, 29);
         LocalDate test = LocalDate.MIN.with(isoDate);
         assertEquals(test, LocalDate.of(1728, 10, 29));
     }
 
     @Test(groups={"tck"})
     public void test_LocalDateTime_adjustToISODate() {
-        ChronoLocalDate<ISOChrono> isoDate = ISOChrono.INSTANCE.date(1728, 10, 29);
+        LocalDate isoDate = IsoChronology.INSTANCE.date(1728, 10, 29);
         LocalDateTime test = LocalDateTime.MIN.with(isoDate);
         assertEquals(test, LocalDateTime.of(1728, 10, 29, 0, 0));
     }
 
     //-----------------------------------------------------------------------

@@ -266,49 +266,49 @@
         };
     }
 
     @Test(dataProvider="leapYears", groups="tck")
     public void test_isLeapYear(int year, boolean isLeapYear) {
-        assertEquals(ISOChrono.INSTANCE.isLeapYear(year), isLeapYear);
+        assertEquals(IsoChronology.INSTANCE.isLeapYear(year), isLeapYear);
     }
 
     //-----------------------------------------------------------------------
     // toString()
     //-----------------------------------------------------------------------
     @Test(groups="tck")
     public void test_now() {
-        assertEquals(LocalDate.from(ISOChrono.INSTANCE.dateNow()), LocalDate.now());
+        assertEquals(LocalDate.from(IsoChronology.INSTANCE.dateNow()), LocalDate.now());
     }
 
     //-----------------------------------------------------------------------
     // toString()
     //-----------------------------------------------------------------------
     @DataProvider(name="toString")
     Object[][] data_toString() {
         return new Object[][] {
-            {ISOChrono.INSTANCE.date(1, 1, 1), "0001-01-01"},
-            {ISOChrono.INSTANCE.date(1728, 10, 28), "1728-10-28"},
-            {ISOChrono.INSTANCE.date(1728, 10, 29), "1728-10-29"},
-            {ISOChrono.INSTANCE.date(1727, 12, 5), "1727-12-05"},
-            {ISOChrono.INSTANCE.date(1727, 12, 6), "1727-12-06"},
+            {IsoChronology.INSTANCE.date(1, 1, 1), "0001-01-01"},
+            {IsoChronology.INSTANCE.date(1728, 10, 28), "1728-10-28"},
+            {IsoChronology.INSTANCE.date(1728, 10, 29), "1728-10-29"},
+            {IsoChronology.INSTANCE.date(1727, 12, 5), "1727-12-05"},
+            {IsoChronology.INSTANCE.date(1727, 12, 6), "1727-12-06"},
         };
     }
 
     @Test(dataProvider="toString", groups={"tck"})
-    public void test_toString(ChronoLocalDate<ISOChrono> isoDate, String expected) {
+    public void test_toString(LocalDate isoDate, String expected) {
         assertEquals(isoDate.toString(), expected);
     }
 
     //-----------------------------------------------------------------------
     // equals()
     //-----------------------------------------------------------------------
     @Test(groups="tck")
     public void test_equals_true() {
-        assertTrue(ISOChrono.INSTANCE.equals(ISOChrono.INSTANCE));
+        assertTrue(IsoChronology.INSTANCE.equals(IsoChronology.INSTANCE));
     }
 
     @Test(groups="tck")
     public void test_equals_false() {
-        assertFalse(ISOChrono.INSTANCE.equals(HijrahChrono.INSTANCE));
+        assertFalse(IsoChronology.INSTANCE.equals(HijrahChronology.INSTANCE));
     }
 
 }