Search in sources :

Example 1 with Year

use of java.time.Year in project jdk8u_jdk by JetBrains.

the class TCKYear method test_minus_long_TemporalUnit.

@Test(dataProvider = "minus_long_TemporalUnit")
public void test_minus_long_TemporalUnit(Year base, long amount, TemporalUnit unit, Year expectedYear, Class<?> expectedEx) {
    if (expectedEx == null) {
        assertEquals(base.minus(amount, unit), expectedYear);
    } else {
        try {
            Year result = base.minus(amount, unit);
            fail();
        } catch (Exception ex) {
            assertTrue(expectedEx.isInstance(ex));
        }
    }
}
Also used : Year(java.time.Year) DateTimeException(java.time.DateTimeException) DateTimeParseException(java.time.format.DateTimeParseException) UnsupportedTemporalTypeException(java.time.temporal.UnsupportedTemporalTypeException) Test(org.testng.annotations.Test)

Example 2 with Year

use of java.time.Year in project jdk8u_jdk by JetBrains.

the class TCKYear method test_with_BadTemporalAdjuster.

@Test(expectedExceptions = DateTimeException.class)
public void test_with_BadTemporalAdjuster() {
    Year test = Year.of(1);
    test.with(LocalTime.of(18, 1, 2));
}
Also used : Year(java.time.Year) Test(org.testng.annotations.Test)

Example 3 with Year

use of java.time.Year in project jdk8u_jdk by JetBrains.

the class TCKYear method test_equals_nullYear.

@Test
public void test_equals_nullYear() {
    Year doy = null;
    Year test = Year.of(1);
    assertEquals(test.equals(doy), false);
}
Also used : Year(java.time.Year) Test(org.testng.annotations.Test)

Example 4 with Year

use of java.time.Year in project jdk8u_jdk by JetBrains.

the class TCKYear method test_atDay_leapYear.

@Test
public void test_atDay_leapYear() {
    Year test = Year.of(2008);
    LocalDate expected = LocalDate.of(2008, 1, 1);
    for (int i = 1; i <= 366; i++) {
        assertEquals(test.atDay(i), expected);
        expected = expected.plusDays(1);
    }
}
Also used : Year(java.time.Year) LocalDate(java.time.LocalDate) Test(org.testng.annotations.Test)

Example 5 with Year

use of java.time.Year in project jdk8u_jdk by JetBrains.

the class TCKYear method factory_parse_success.

@Test(dataProvider = "goodParseData")
public void factory_parse_success(String text, Year expected) {
    Year year = Year.parse(text);
    assertEquals(year, expected);
}
Also used : Year(java.time.Year) Test(org.testng.annotations.Test)

Aggregations

Year (java.time.Year)72 Test (org.junit.Test)35 Test (org.testng.annotations.Test)33 LocalDate (java.time.LocalDate)7 YearMonth (java.time.YearMonth)3 ZoneId (java.time.ZoneId)3 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)2 Clock (java.time.Clock)2 DateTimeException (java.time.DateTimeException)2 Instant (java.time.Instant)2 DateTimeFormatter (java.time.format.DateTimeFormatter)2 DateTimeParseException (java.time.format.DateTimeParseException)2 Temporal (java.time.temporal.Temporal)2 UnsupportedTemporalTypeException (java.time.temporal.UnsupportedTemporalTypeException)2 Test (org.junit.jupiter.api.Test)2 LocalDateTime (java.time.LocalDateTime)1 ZonedDateTime (java.time.ZonedDateTime)1 TemporalAccessor (java.time.temporal.TemporalAccessor)1 Date (java.util.Date)1