test/java/time/tck/java/time/zone/TCKZoneOffsetTransition.java
Print this page
@@ -60,17 +60,18 @@
package tck.java.time.zone;
import static java.time.temporal.ChronoUnit.HOURS;
import static org.testng.Assert.assertEquals;
-import tck.java.time.AbstractTCKTest;
import java.time.Duration;
import java.time.LocalDateTime;
-import java.time.ZoneOffset;
import java.time.Year;
+import java.time.ZoneOffset;
import java.time.zone.ZoneOffsetTransition;
+
import org.testng.annotations.Test;
+import tck.java.time.AbstractTCKTest;
/**
* Test ZoneOffsetTransition.
*/
@Test
@@ -83,39 +84,39 @@
private static final ZoneOffset OFFSET_0400 = ZoneOffset.ofHours(4);
//-----------------------------------------------------------------------
// factory
//-----------------------------------------------------------------------
- @Test(expectedExceptions=NullPointerException.class, groups={"tck"})
+ @Test(expectedExceptions=NullPointerException.class)
public void test_factory_nullTransition() {
ZoneOffsetTransition.of(null, OFFSET_0100, OFFSET_0200);
}
- @Test(expectedExceptions=NullPointerException.class, groups={"tck"})
+ @Test(expectedExceptions=NullPointerException.class)
public void test_factory_nullOffsetBefore() {
ZoneOffsetTransition.of(LocalDateTime.of(2010, 12, 3, 11, 30), null, OFFSET_0200);
}
- @Test(expectedExceptions=NullPointerException.class, groups={"tck"})
+ @Test(expectedExceptions=NullPointerException.class)
public void test_factory_nullOffsetAfter() {
ZoneOffsetTransition.of(LocalDateTime.of(2010, 12, 3, 11, 30), OFFSET_0200, null);
}
- @Test(expectedExceptions=IllegalArgumentException.class, groups={"tck"})
+ @Test(expectedExceptions=IllegalArgumentException.class)
public void test_factory_sameOffset() {
ZoneOffsetTransition.of(LocalDateTime.of(2010, 12, 3, 11, 30), OFFSET_0200, OFFSET_0200);
}
- @Test(expectedExceptions=IllegalArgumentException.class, groups={"tck"})
+ @Test(expectedExceptions=IllegalArgumentException.class)
public void test_factory_noNanos() {
ZoneOffsetTransition.of(LocalDateTime.of(2010, 12, 3, 11, 30, 0, 500), OFFSET_0200, OFFSET_0300);
}
//-----------------------------------------------------------------------
// getters
//-----------------------------------------------------------------------
- @Test(groups={"tck"})
+ @Test
public void test_getters_gap() throws Exception {
LocalDateTime before = LocalDateTime.of(2010, 3, 31, 1, 0);
LocalDateTime after = LocalDateTime.of(2010, 3, 31, 2, 0);
ZoneOffsetTransition test = ZoneOffsetTransition.of(before, OFFSET_0200, OFFSET_0300);
assertEquals(test.isGap(), true);
@@ -127,11 +128,11 @@
assertEquals(test.getOffsetAfter(), OFFSET_0300);
assertEquals(test.getDuration(), Duration.of(1, HOURS));
assertSerializable(test);
}
- @Test(groups={"tck"})
+ @Test
public void test_getters_overlap() throws Exception {
LocalDateTime before = LocalDateTime.of(2010, 10, 31, 1, 0);
LocalDateTime after = LocalDateTime.of(2010, 10, 31, 0, 0);
ZoneOffsetTransition test = ZoneOffsetTransition.of(before, OFFSET_0300, OFFSET_0200);
assertEquals(test.isGap(), false);
@@ -161,22 +162,22 @@
}
//-----------------------------------------------------------------------
// isValidOffset()
//-----------------------------------------------------------------------
- @Test(groups={"tck"})
+ @Test
public void test_isValidOffset_gap() {
LocalDateTime ldt = LocalDateTime.of(2010, 3, 31, 1, 0);
ZoneOffsetTransition test = ZoneOffsetTransition.of(ldt, OFFSET_0200, OFFSET_0300);
assertEquals(test.isValidOffset(OFFSET_0100), false);
assertEquals(test.isValidOffset(OFFSET_0200), false);
assertEquals(test.isValidOffset(OFFSET_0230), false);
assertEquals(test.isValidOffset(OFFSET_0300), false);
assertEquals(test.isValidOffset(OFFSET_0400), false);
}
- @Test(groups={"tck"})
+ @Test
public void test_isValidOffset_overlap() {
LocalDateTime ldt = LocalDateTime.of(2010, 10, 31, 1, 0);
ZoneOffsetTransition test = ZoneOffsetTransition.of(ldt, OFFSET_0300, OFFSET_0200);
assertEquals(test.isValidOffset(OFFSET_0100), false);
assertEquals(test.isValidOffset(OFFSET_0200), true);
@@ -186,11 +187,11 @@
}
//-----------------------------------------------------------------------
// compareTo()
//-----------------------------------------------------------------------
- @Test(groups={"tck"})
+ @Test
public void test_compareTo() {
ZoneOffsetTransition a = ZoneOffsetTransition.of(
LocalDateTime.ofEpochSecond(23875287L - 1, 0, OFFSET_0200), OFFSET_0200, OFFSET_0300);
ZoneOffsetTransition b = ZoneOffsetTransition.of(
LocalDateTime.ofEpochSecond(23875287L, 0, OFFSET_0300), OFFSET_0300, OFFSET_0200);
@@ -208,11 +209,11 @@
assertEquals(c.compareTo(a) > 0, true);
assertEquals(c.compareTo(b) > 0, true);
assertEquals(c.compareTo(c) == 0, true);
}
- @Test(groups={"tck"})
+ @Test
public void test_compareTo_sameInstant() {
ZoneOffsetTransition a = ZoneOffsetTransition.of(
LocalDateTime.ofEpochSecond(23875287L, 0, OFFSET_0200), OFFSET_0200, OFFSET_0300);
ZoneOffsetTransition b = ZoneOffsetTransition.of(
LocalDateTime.ofEpochSecond(23875287L, 0, OFFSET_0300), OFFSET_0300, OFFSET_0200);
@@ -233,11 +234,11 @@
}
//-----------------------------------------------------------------------
// equals()
//-----------------------------------------------------------------------
- @Test(groups={"tck"})
+ @Test
public void test_equals() {
LocalDateTime ldtA = LocalDateTime.of(2010, 3, 31, 1, 0);
ZoneOffsetTransition a1 = ZoneOffsetTransition.of(ldtA, OFFSET_0200, OFFSET_0300);
ZoneOffsetTransition a2 = ZoneOffsetTransition.of(ldtA, OFFSET_0200, OFFSET_0300);
LocalDateTime ldtB = LocalDateTime.of(2010, 10, 31, 1, 0);
@@ -258,11 +259,11 @@
}
//-----------------------------------------------------------------------
// hashCode()
//-----------------------------------------------------------------------
- @Test(groups={"tck"})
+ @Test
public void test_hashCode_floatingWeek_gap_notEndOfDay() {
LocalDateTime ldtA = LocalDateTime.of(2010, 3, 31, 1, 0);
ZoneOffsetTransition a1 = ZoneOffsetTransition.of(ldtA, OFFSET_0200, OFFSET_0300);
ZoneOffsetTransition a2 = ZoneOffsetTransition.of(ldtA, OFFSET_0200, OFFSET_0300);
LocalDateTime ldtB = LocalDateTime.of(2010, 10, 31, 1, 0);
@@ -274,18 +275,18 @@
}
//-----------------------------------------------------------------------
// toString()
//-----------------------------------------------------------------------
- @Test(groups={"tck"})
+ @Test
public void test_toString_gap() {
LocalDateTime ldt = LocalDateTime.of(2010, 3, 31, 1, 0);
ZoneOffsetTransition test = ZoneOffsetTransition.of(ldt, OFFSET_0200, OFFSET_0300);
assertEquals(test.toString(), "Transition[Gap at 2010-03-31T01:00+02:00 to +03:00]");
}
- @Test(groups={"tck"})
+ @Test
public void test_toString_overlap() {
LocalDateTime ldt = LocalDateTime.of(2010, 10, 31, 1, 0);
ZoneOffsetTransition test = ZoneOffsetTransition.of(ldt, OFFSET_0300, OFFSET_0200);
assertEquals(test.toString(), "Transition[Overlap at 2010-10-31T01:00+03:00 to +02:00]");
}