test/java/time/tck/java/time/TCKMonthDay.java

Print this page

        

@@ -82,11 +82,10 @@
 import java.time.chrono.IsoChronology;
 import java.time.format.DateTimeFormatter;
 import java.time.format.DateTimeParseException;
 import java.time.temporal.ChronoField;
 import java.time.temporal.JulianFields;
-import java.time.temporal.Queries;
 import java.time.temporal.TemporalAccessor;
 import java.time.temporal.TemporalField;
 import java.time.temporal.TemporalQuery;
 import java.util.ArrayList;
 import java.util.Arrays;

@@ -104,11 +103,11 @@
 @Test
 public class TCKMonthDay extends AbstractDateTimeTest {
 
     private MonthDay TEST_07_15;
 
-    @BeforeMethod(groups={"tck","implementation"})
+    @BeforeMethod
     public void setUp() {
         TEST_07_15 = MonthDay.of(7, 15);
     }
 
     //-----------------------------------------------------------------------

@@ -162,11 +161,11 @@
     }
 
     //-----------------------------------------------------------------------
     // now()
     //-----------------------------------------------------------------------
-    @Test(groups={"tck"})
+    @Test
     public void now() {
         MonthDay expected = MonthDay.now(Clock.systemDefaultZone());
         MonthDay test = MonthDay.now();
         for (int i = 0; i < 100; i++) {
             if (expected.equals(test)) {

@@ -179,16 +178,16 @@
     }
 
     //-----------------------------------------------------------------------
     // now(ZoneId)
     //-----------------------------------------------------------------------
-    @Test(expectedExceptions=NullPointerException.class, groups={"tck"})
+    @Test(expectedExceptions=NullPointerException.class)
     public void now_ZoneId_nullZoneId() {
         MonthDay.now((ZoneId) null);
     }
 
-    @Test(groups={"tck"})
+    @Test
     public void now_ZoneId() {
         ZoneId zone = ZoneId.of("UTC+01:02:03");
         MonthDay expected = MonthDay.now(Clock.system(zone));
         MonthDay test = MonthDay.now(zone);
         for (int i = 0; i < 100; i++) {

@@ -202,84 +201,84 @@
     }
 
     //-----------------------------------------------------------------------
     // now(Clock)
     //-----------------------------------------------------------------------
-    @Test(groups={"tck"})
+    @Test
     public void now_Clock() {
         Instant instant = LocalDateTime.of(2010, 12, 31, 0, 0).toInstant(ZoneOffset.UTC);
         Clock clock = Clock.fixed(instant, ZoneOffset.UTC);
         MonthDay test = MonthDay.now(clock);
         assertEquals(test.getMonth(), Month.DECEMBER);
         assertEquals(test.getDayOfMonth(), 31);
     }
 
-    @Test(expectedExceptions=NullPointerException.class, groups={"tck"})
+    @Test(expectedExceptions=NullPointerException.class)
     public void now_Clock_nullClock() {
         MonthDay.now((Clock) null);
     }
 
     //-----------------------------------------------------------------------
-    @Test(groups={"tck"})
+    @Test
     public void factory_intMonth() {
         assertEquals(TEST_07_15, MonthDay.of(Month.JULY, 15));
     }
 
-    @Test(expectedExceptions=DateTimeException.class, groups={"tck"})
+    @Test(expectedExceptions=DateTimeException.class)
     public void test_factory_intMonth_dayTooLow() {
         MonthDay.of(Month.JANUARY, 0);
     }
 
-    @Test(expectedExceptions=DateTimeException.class, groups={"tck"})
+    @Test(expectedExceptions=DateTimeException.class)
     public void test_factory_intMonth_dayTooHigh() {
         MonthDay.of(Month.JANUARY, 32);
     }
 
-    @Test(expectedExceptions=NullPointerException.class, groups={"tck"})
+    @Test(expectedExceptions=NullPointerException.class)
     public void factory_intMonth_nullMonth() {
         MonthDay.of(null, 15);
     }
 
     //-----------------------------------------------------------------------
-    @Test(groups={"tck"})
+    @Test
     public void factory_ints() {
         check(TEST_07_15, 7, 15);
     }
 
-    @Test(expectedExceptions=DateTimeException.class, groups={"tck"})
+    @Test(expectedExceptions=DateTimeException.class)
     public void test_factory_ints_dayTooLow() {
         MonthDay.of(1, 0);
     }
 
-    @Test(expectedExceptions=DateTimeException.class, groups={"tck"})
+    @Test(expectedExceptions=DateTimeException.class)
     public void test_factory_ints_dayTooHigh() {
         MonthDay.of(1, 32);
     }
 
 
-    @Test(expectedExceptions=DateTimeException.class, groups={"tck"})
+    @Test(expectedExceptions=DateTimeException.class)
     public void test_factory_ints_monthTooLow() {
         MonthDay.of(0, 1);
     }
 
-    @Test(expectedExceptions=DateTimeException.class, groups={"tck"})
+    @Test(expectedExceptions=DateTimeException.class)
     public void test_factory_ints_monthTooHigh() {
         MonthDay.of(13, 1);
     }
 
     //-----------------------------------------------------------------------
-    @Test(groups={"tck"})
+    @Test
     public void test_factory_CalendricalObject() {
         assertEquals(MonthDay.from(LocalDate.of(2007, 7, 15)), TEST_07_15);
     }
 
-    @Test(expectedExceptions=DateTimeException.class, groups={"tck"})
+    @Test(expectedExceptions=DateTimeException.class)
     public void test_factory_CalendricalObject_invalid_noDerive() {
         MonthDay.from(LocalTime.of(12, 30));
     }
 
-    @Test(expectedExceptions=NullPointerException.class, groups={"tck"})
+    @Test(expectedExceptions=NullPointerException.class)
     public void test_factory_CalendricalObject_null() {
         MonthDay.from((TemporalAccessor) null);
     }
 
     //-----------------------------------------------------------------------

@@ -313,11 +312,11 @@
                 {"--12-01", MonthDay.of(12, 1)},
                 {"--12-31", MonthDay.of(12, 31)},
         };
     }
 
-    @Test(dataProvider="goodParseData", groups={"tck"})
+    @Test(dataProvider="goodParseData")
     public void factory_parse_success(String text, MonthDay expected) {
         MonthDay monthDay = MonthDay.parse(text);
         assertEquals(monthDay, expected);
     }
 

@@ -331,11 +330,11 @@
                 {"--01-0", 5},
                 {"--01-3A", 5},
         };
     }
 
-    @Test(dataProvider="badParseData", expectedExceptions=DateTimeParseException.class, groups={"tck"})
+    @Test(dataProvider="badParseData", expectedExceptions=DateTimeParseException.class)
     public void factory_parse_fail(String text, int pos) {
         try {
             MonthDay.parse(text);
             fail(String.format("Parse should have failed for %s at position %d", text, pos));
         }

@@ -345,47 +344,47 @@
             throw ex;
         }
     }
 
     //-----------------------------------------------------------------------
-    @Test(expectedExceptions=DateTimeParseException.class, groups={"tck"})
+    @Test(expectedExceptions=DateTimeParseException.class)
     public void factory_parse_illegalValue_Day() {
         MonthDay.parse("--06-32");
     }
 
-    @Test(expectedExceptions=DateTimeParseException.class, groups={"tck"})
+    @Test(expectedExceptions=DateTimeParseException.class)
     public void factory_parse_invalidValue_Day() {
         MonthDay.parse("--06-31");
     }
 
-    @Test(expectedExceptions=DateTimeParseException.class, groups={"tck"})
+    @Test(expectedExceptions=DateTimeParseException.class)
     public void factory_parse_illegalValue_Month() {
         MonthDay.parse("--13-25");
     }
 
-    @Test(expectedExceptions=NullPointerException.class, groups={"tck"})
+    @Test(expectedExceptions=NullPointerException.class)
     public void factory_parse_nullText() {
         MonthDay.parse(null);
     }
 
     //-----------------------------------------------------------------------
     // parse(DateTimeFormatter)
     //-----------------------------------------------------------------------
-    @Test(groups={"tck"})
+    @Test
     public void factory_parse_formatter() {
         DateTimeFormatter f = DateTimeFormatter.ofPattern("M d");
         MonthDay test = MonthDay.parse("12 3", f);
         assertEquals(test, MonthDay.of(12, 3));
     }
 
-    @Test(expectedExceptions=NullPointerException.class, groups={"tck"})
+    @Test(expectedExceptions=NullPointerException.class)
     public void factory_parse_formatter_nullText() {
         DateTimeFormatter f = DateTimeFormatter.ofPattern("M d");
         MonthDay.parse((String) null, f);
     }
 
-    @Test(expectedExceptions=NullPointerException.class, groups={"tck"})
+    @Test(expectedExceptions=NullPointerException.class)
     public void factory_parse_formatter_nullFormatter() {
         MonthDay.parse("ANY", null);
     }
 
     //-----------------------------------------------------------------------

@@ -407,17 +406,17 @@
     // query(TemporalQuery)
     //-----------------------------------------------------------------------
     @DataProvider(name="query")
     Object[][] data_query() {
         return new Object[][] {
-                {TEST_07_15, Queries.chronology(), IsoChronology.INSTANCE},
-                {TEST_07_15, Queries.zoneId(), null},
-                {TEST_07_15, Queries.precision(), null},
-                {TEST_07_15, Queries.zone(), null},
-                {TEST_07_15, Queries.offset(), null},
-                {TEST_07_15, Queries.localDate(), null},
-                {TEST_07_15, Queries.localTime(), null},
+                {TEST_07_15, TemporalQuery.chronology(), IsoChronology.INSTANCE},
+                {TEST_07_15, TemporalQuery.zoneId(), null},
+                {TEST_07_15, TemporalQuery.precision(), null},
+                {TEST_07_15, TemporalQuery.zone(), null},
+                {TEST_07_15, TemporalQuery.offset(), null},
+                {TEST_07_15, TemporalQuery.localDate(), null},
+                {TEST_07_15, TemporalQuery.localTime(), null},
         };
     }
 
     @Test(dataProvider="query")
     public <T> void test_query(TemporalAccessor temporal, TemporalQuery<T> query, T expected) {

@@ -459,179 +458,194 @@
     }
 
     //-----------------------------------------------------------------------
     // with(Month)
     //-----------------------------------------------------------------------
-    @Test(groups={"tck"})
+    @Test
     public void test_with_Month() {
         assertEquals(MonthDay.of(6, 30).with(Month.JANUARY), MonthDay.of(1, 30));
     }
 
-    @Test(groups={"tck"})
+    @Test
     public void test_with_Month_adjustToValid() {
         assertEquals(MonthDay.of(7, 31).with(Month.JUNE), MonthDay.of(6, 30));
     }
 
-    @Test(groups={"tck"})
+    @Test
     public void test_with_Month_adjustToValidFeb() {
         assertEquals(MonthDay.of(7, 31).with(Month.FEBRUARY), MonthDay.of(2, 29));
     }
 
-    @Test(groups={"tck"})
+    @Test
     public void test_with_Month_noChangeEqual() {
         MonthDay test = MonthDay.of(6, 30);
         assertEquals(test.with(Month.JUNE), test);
     }
 
-    @Test(expectedExceptions=NullPointerException.class, groups={"tck"})
+    @Test(expectedExceptions=NullPointerException.class)
     public void test_with_Month_null() {
         MonthDay.of(6, 30).with((Month) null);
     }
 
     //-----------------------------------------------------------------------
     // withMonth()
     //-----------------------------------------------------------------------
-    @Test(groups={"tck"})
+    @Test
     public void test_withMonth() {
         assertEquals(MonthDay.of(6, 30).withMonth(1), MonthDay.of(1, 30));
     }
 
-    @Test(groups={"tck"})
+    @Test
     public void test_withMonth_adjustToValid() {
         assertEquals(MonthDay.of(7, 31).withMonth(6), MonthDay.of(6, 30));
     }
 
-    @Test(groups={"tck"})
+    @Test
     public void test_withMonth_adjustToValidFeb() {
         assertEquals(MonthDay.of(7, 31).withMonth(2), MonthDay.of(2, 29));
     }
 
-    @Test(groups={"tck"})
+    @Test
     public void test_withMonth_int_noChangeEqual() {
         MonthDay test = MonthDay.of(6, 30);
         assertEquals(test.withMonth(6), test);
     }
 
-    @Test(expectedExceptions=DateTimeException.class, groups={"tck"})
+    @Test(expectedExceptions=DateTimeException.class)
     public void test_withMonth_tooLow() {
         MonthDay.of(6, 30).withMonth(0);
     }
 
-    @Test(expectedExceptions=DateTimeException.class, groups={"tck"})
+    @Test(expectedExceptions=DateTimeException.class)
     public void test_withMonth_tooHigh() {
         MonthDay.of(6, 30).withMonth(13);
     }
 
     //-----------------------------------------------------------------------
     // withDayOfMonth()
     //-----------------------------------------------------------------------
-    @Test(groups={"tck"})
+    @Test
     public void test_withDayOfMonth() {
         assertEquals(MonthDay.of(6, 30).withDayOfMonth(1), MonthDay.of(6, 1));
     }
 
-    @Test(expectedExceptions=DateTimeException.class, groups={"tck"})
+    @Test(expectedExceptions=DateTimeException.class)
     public void test_withDayOfMonth_invalid() {
         MonthDay.of(6, 30).withDayOfMonth(31);
     }
 
-    @Test(groups={"tck"})
+    @Test
     public void test_withDayOfMonth_adjustToValidFeb() {
         assertEquals(MonthDay.of(2, 1).withDayOfMonth(29), MonthDay.of(2, 29));
     }
 
-    @Test(groups={"tck"})
+    @Test
     public void test_withDayOfMonth_noChangeEqual() {
         MonthDay test = MonthDay.of(6, 30);
         assertEquals(test.withDayOfMonth(30), test);
     }
 
-    @Test(expectedExceptions=DateTimeException.class, groups={"tck"})
+    @Test(expectedExceptions=DateTimeException.class)
     public void test_withDayOfMonth_tooLow() {
         MonthDay.of(6, 30).withDayOfMonth(0);
     }
 
-    @Test(expectedExceptions=DateTimeException.class, groups={"tck"})
+    @Test(expectedExceptions=DateTimeException.class)
     public void test_withDayOfMonth_tooHigh() {
         MonthDay.of(6, 30).withDayOfMonth(32);
     }
 
     //-----------------------------------------------------------------------
     // adjustInto()
     //-----------------------------------------------------------------------
-    @Test(groups={"tck"})
+    @Test
     public void test_adjustDate() {
         MonthDay test = MonthDay.of(6, 30);
         LocalDate date = LocalDate.of(2007, 1, 1);
         assertEquals(test.adjustInto(date), LocalDate.of(2007, 6, 30));
     }
 
-    @Test(groups={"tck"})
+    @Test
     public void test_adjustDate_resolve() {
         MonthDay test = MonthDay.of(2, 29);
         LocalDate date = LocalDate.of(2007, 6, 30);
         assertEquals(test.adjustInto(date), LocalDate.of(2007, 2, 28));
     }
 
-    @Test(groups={"tck"})
+    @Test
     public void test_adjustDate_equal() {
         MonthDay test = MonthDay.of(6, 30);
         LocalDate date = LocalDate.of(2007, 6, 30);
         assertEquals(test.adjustInto(date), date);
     }
 
-    @Test(expectedExceptions=NullPointerException.class, groups={"tck"})
+    @Test(expectedExceptions=NullPointerException.class)
     public void test_adjustDate_null() {
         TEST_07_15.adjustInto((LocalDate) null);
     }
 
     //-----------------------------------------------------------------------
     // isValidYear(int)
     //-----------------------------------------------------------------------
-    @Test(groups={"tck"})
+    @Test
     public void test_isValidYear_june() {
         MonthDay test = MonthDay.of(6, 30);
         assertEquals(test.isValidYear(2007), true);
     }
 
-    @Test(groups={"tck"})
+    @Test
     public void test_isValidYear_febNonLeap() {
         MonthDay test = MonthDay.of(2, 29);
         assertEquals(test.isValidYear(2007), false);
     }
 
-    @Test(groups={"tck"})
+    @Test
     public void test_isValidYear_febLeap() {
         MonthDay test = MonthDay.of(2, 29);
         assertEquals(test.isValidYear(2008), true);
     }
 
     //-----------------------------------------------------------------------
+    // format(DateTimeFormatter)
+    //-----------------------------------------------------------------------
+    @Test
+    public void test_format_formatter() {
+        DateTimeFormatter f = DateTimeFormatter.ofPattern("M d");
+        String t = MonthDay.of(12, 3).format(f);
+        assertEquals(t, "12 3");
+    }
+
+    @Test(expectedExceptions=NullPointerException.class)
+    public void test_format_formatter_null() {
+        MonthDay.of(12, 3).format(null);
+    }
+
+    //-----------------------------------------------------------------------
     // atYear(int)
     //-----------------------------------------------------------------------
-    @Test(groups={"tck"})
+    @Test
     public void test_atYear_int() {
         MonthDay test = MonthDay.of(6, 30);
         assertEquals(test.atYear(2008), LocalDate.of(2008, 6, 30));
     }
 
-    @Test(groups={"tck"})
+    @Test
     public void test_atYear_int_leapYearAdjust() {
         MonthDay test = MonthDay.of(2, 29);
         assertEquals(test.atYear(2005), LocalDate.of(2005, 2, 28));
     }
 
-    @Test(expectedExceptions=DateTimeException.class, groups={"tck"})
+    @Test(expectedExceptions=DateTimeException.class)
     public void test_atYear_int_invalidYear() {
         MonthDay test = MonthDay.of(6, 30);
         test.atYear(Integer.MIN_VALUE);
     }
 
     //-----------------------------------------------------------------------
     // compareTo()
     //-----------------------------------------------------------------------
-    @Test(groups={"tck"})
+    @Test
     public void test_comparisons() {
         doTest_comparisons_MonthDay(
             MonthDay.of(1, 1),
             MonthDay.of(1, 31),
             MonthDay.of(2, 1),

@@ -664,29 +678,29 @@
                 }
             }
         }
     }
 
-    @Test(expectedExceptions=NullPointerException.class, groups={"tck"})
+    @Test(expectedExceptions=NullPointerException.class)
     public void test_compareTo_ObjectNull() {
         TEST_07_15.compareTo(null);
     }
 
-    @Test(expectedExceptions=NullPointerException.class, groups={"tck"})
+    @Test(expectedExceptions=NullPointerException.class)
     public void test_isBefore_ObjectNull() {
         TEST_07_15.isBefore(null);
     }
 
-    @Test(expectedExceptions=NullPointerException.class, groups={"tck"})
+    @Test(expectedExceptions=NullPointerException.class)
     public void test_isAfter_ObjectNull() {
         TEST_07_15.isAfter(null);
     }
 
     //-----------------------------------------------------------------------
     // equals()
     //-----------------------------------------------------------------------
-    @Test(groups={"tck"})
+    @Test
     public void test_equals() {
         MonthDay a = MonthDay.of(1, 1);
         MonthDay b = MonthDay.of(1, 1);
         MonthDay c = MonthDay.of(2, 1);
         MonthDay d = MonthDay.of(1, 2);

@@ -710,37 +724,37 @@
         assertEquals(d.equals(b), false);
         assertEquals(d.equals(c), false);
         assertEquals(d.equals(d), true);
     }
 
-    @Test(groups={"tck"})
+    @Test
     public void test_equals_itself_true() {
         assertEquals(TEST_07_15.equals(TEST_07_15), true);
     }
 
-    @Test(groups={"tck"})
+    @Test
     public void test_equals_string_false() {
         assertEquals(TEST_07_15.equals("2007-07-15"), false);
     }
 
-    @Test(groups={"tck"})
+    @Test
     public void test_equals_null_false() {
         assertEquals(TEST_07_15.equals(null), false);
     }
 
     //-----------------------------------------------------------------------
     // hashCode()
     //-----------------------------------------------------------------------
-    @Test(dataProvider="sampleDates", groups={"tck"})
+    @Test(dataProvider="sampleDates")
     public void test_hashCode(int m, int d) {
         MonthDay a = MonthDay.of(m, d);
         assertEquals(a.hashCode(), a.hashCode());
         MonthDay b = MonthDay.of(m, d);
         assertEquals(a.hashCode(), b.hashCode());
     }
 
-    @Test(groups={"tck"})
+    @Test
     public void test_hashCode_unique() {
         int leapYear = 2008;
         Set<Integer> uniques = new HashSet<Integer>(366);
         for (int i = 1; i <= 12; i++) {
             for (int j = 1; j <= 31; j++) {

@@ -761,28 +775,13 @@
             {12, 31, "--12-31"},
             {1, 2, "--01-02"},
         };
     }
 
-    @Test(dataProvider="sampleToString", groups={"tck"})
+    @Test(dataProvider="sampleToString")
     public void test_toString(int m, int d, String expected) {
         MonthDay test = MonthDay.of(m, d);
         String str = test.toString();
         assertEquals(str, expected);
     }
 
-    //-----------------------------------------------------------------------
-    // toString(DateTimeFormatter)
-    //-----------------------------------------------------------------------
-    @Test(groups={"tck"})
-    public void test_toString_formatter() {
-        DateTimeFormatter f = DateTimeFormatter.ofPattern("M d");
-        String t = MonthDay.of(12, 3).toString(f);
-        assertEquals(t, "12 3");
-    }
-
-    @Test(expectedExceptions=NullPointerException.class, groups={"tck"})
-    public void test_toString_formatter_null() {
-        MonthDay.of(12, 3).toString(null);
-    }
-
 }