1 /*
   2  * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * This file is available under and governed by the GNU General Public
  26  * License version 2 only, as published by the Free Software Foundation.
  27  * However, the following notice accompanied the original version of this
  28  * file:
  29  *
  30  * Copyright (c) 2010-2012, Stephen Colebourne & Michael Nascimento Santos
  31  *
  32  * All rights reserved.
  33  *
  34  * Redistribution and use in source and binary forms, with or without
  35  * modification, are permitted provided that the following conditions are met:
  36  *
  37  *  * Redistributions of source code must retain the above copyright notice,
  38  *    this list of conditions and the following disclaimer.
  39  *
  40  *  * Redistributions in binary form must reproduce the above copyright notice,
  41  *    this list of conditions and the following disclaimer in the documentation
  42  *    and/or other materials provided with the distribution.
  43  *
  44  *  * Neither the name of JSR-310 nor the names of its contributors
  45  *    may be used to endorse or promote products derived from this software
  46  *    without specific prior written permission.
  47  *
  48  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  49  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  50  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  51  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  52  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  53  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  54  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  55  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  56  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  57  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  58  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  59  */
  60 package tck.java.time.zone;
  61 
  62 import java.time.ZoneId;
  63 import java.time.zone.*;
  64 import test.java.time.zone.*;
  65 
  66 import static org.testng.Assert.assertEquals;
  67 
  68 import java.io.ByteArrayOutputStream;
  69 import java.io.DataOutputStream;
  70 import java.io.IOException;
  71 
  72 import tck.java.time.AbstractTCKTest;
  73 import java.time.DayOfWeek;
  74 import java.time.LocalDateTime;
  75 import java.time.LocalTime;
  76 import java.time.Month;
  77 import java.time.ZoneOffset;
  78 import java.time.zone.ZoneOffsetTransitionRule.TimeDefinition;
  79 
  80 import org.testng.annotations.Test;
  81 
  82 /**
  83  * Test ZoneOffsetTransitionRule.
  84  */
  85 @Test
  86 public class TCKZoneOffsetTransitionRule extends AbstractTCKTest {
  87 
  88     private static final LocalTime TIME_0100 = LocalTime.of(1, 0);
  89     private static final ZoneOffset OFFSET_0200 = ZoneOffset.ofHours(2);
  90     private static final ZoneOffset OFFSET_0300 = ZoneOffset.ofHours(3);
  91 
  92     //-----------------------------------------------------------------------
  93     // factory
  94     //-----------------------------------------------------------------------
  95     @Test(expectedExceptions=NullPointerException.class, groups={"tck"})
  96     public void test_factory_nullMonth() {
  97         ZoneOffsetTransitionRule.of(
  98                 null, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
  99                 OFFSET_0200, OFFSET_0200, OFFSET_0300);
 100     }
 101 
 102     @Test(expectedExceptions=NullPointerException.class, groups={"tck"})
 103     public void test_factory_nullTime() {
 104         ZoneOffsetTransitionRule.of(
 105                 Month.MARCH, 20, DayOfWeek.SUNDAY, null, false, TimeDefinition.WALL,
 106                 OFFSET_0200, OFFSET_0200, OFFSET_0300);
 107     }
 108 
 109     @Test(expectedExceptions=NullPointerException.class, groups={"tck"})
 110     public void test_factory_nullTimeDefinition() {
 111         ZoneOffsetTransitionRule.of(
 112                 Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, null,
 113                 OFFSET_0200, OFFSET_0200, OFFSET_0300);
 114     }
 115 
 116     @Test(expectedExceptions=NullPointerException.class, groups={"tck"})
 117     public void test_factory_nullStandardOffset() {
 118         ZoneOffsetTransitionRule.of(
 119                 Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
 120                 null, OFFSET_0200, OFFSET_0300);
 121     }
 122 
 123     @Test(expectedExceptions=NullPointerException.class, groups={"tck"})
 124     public void test_factory_nullOffsetBefore() {
 125         ZoneOffsetTransitionRule.of(
 126                 Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
 127                 OFFSET_0200, null, OFFSET_0300);
 128     }
 129 
 130     @Test(expectedExceptions=NullPointerException.class, groups={"tck"})
 131     public void test_factory_nullOffsetAfter() {
 132         ZoneOffsetTransitionRule.of(
 133                 Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
 134                 OFFSET_0200, OFFSET_0200, null);
 135     }
 136 
 137     @Test(expectedExceptions=IllegalArgumentException.class, groups={"tck"})
 138     public void test_factory_invalidDayOfMonthIndicator_tooSmall() {
 139         ZoneOffsetTransitionRule.of(
 140                 Month.MARCH, -29, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
 141                 OFFSET_0200, OFFSET_0200, OFFSET_0300);
 142     }
 143 
 144     @Test(expectedExceptions=IllegalArgumentException.class, groups={"tck"})
 145     public void test_factory_invalidDayOfMonthIndicator_zero() {
 146         ZoneOffsetTransitionRule.of(
 147                 Month.MARCH, 0, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
 148                 OFFSET_0200, OFFSET_0200, OFFSET_0300);
 149     }
 150 
 151     @Test(expectedExceptions=IllegalArgumentException.class, groups={"tck"})
 152     public void test_factory_invalidDayOfMonthIndicator_tooLarge() {
 153         ZoneOffsetTransitionRule.of(
 154                 Month.MARCH, 32, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
 155                 OFFSET_0200, OFFSET_0200, OFFSET_0300);
 156     }
 157 
 158     @Test(expectedExceptions=IllegalArgumentException.class, groups={"tck"})
 159     public void test_factory_invalidMidnightFlag() {
 160         ZoneOffsetTransitionRule.of(
 161                 Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, true, TimeDefinition.WALL,
 162                 OFFSET_0200, OFFSET_0200, OFFSET_0300);
 163     }
 164 
 165     //-----------------------------------------------------------------------
 166     // getters
 167     //-----------------------------------------------------------------------
 168     @Test
 169     public void test_getters_floatingWeek() throws Exception {
 170         ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(
 171                 Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
 172                 OFFSET_0200, OFFSET_0200, OFFSET_0300);
 173         assertEquals(test.getMonth(), Month.MARCH);
 174         assertEquals(test.getDayOfMonthIndicator(), 20);
 175         assertEquals(test.getDayOfWeek(), DayOfWeek.SUNDAY);
 176         assertEquals(test.getLocalTime(), TIME_0100);
 177         assertEquals(test.isMidnightEndOfDay(), false);
 178         assertEquals(test.getTimeDefinition(), TimeDefinition.WALL);
 179         assertEquals(test.getStandardOffset(), OFFSET_0200);
 180         assertEquals(test.getOffsetBefore(), OFFSET_0200);
 181         assertEquals(test.getOffsetAfter(), OFFSET_0300);
 182         assertSerializable(test);
 183     }
 184 
 185     @Test
 186     public void test_getters_floatingWeekBackwards() throws Exception {
 187         ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(
 188                 Month.MARCH, -1, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
 189                 OFFSET_0200, OFFSET_0200, OFFSET_0300);
 190         assertEquals(test.getMonth(), Month.MARCH);
 191         assertEquals(test.getDayOfMonthIndicator(), -1);
 192         assertEquals(test.getDayOfWeek(), DayOfWeek.SUNDAY);
 193         assertEquals(test.getLocalTime(), TIME_0100);
 194         assertEquals(test.isMidnightEndOfDay(), false);
 195         assertEquals(test.getTimeDefinition(), TimeDefinition.WALL);
 196         assertEquals(test.getStandardOffset(), OFFSET_0200);
 197         assertEquals(test.getOffsetBefore(), OFFSET_0200);
 198         assertEquals(test.getOffsetAfter(), OFFSET_0300);
 199         assertSerializable(test);
 200     }
 201 
 202     @Test
 203     public void test_getters_fixedDate() throws Exception {
 204         ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(
 205                 Month.MARCH, 20, null, TIME_0100, false, TimeDefinition.WALL,
 206                 OFFSET_0200, OFFSET_0200, OFFSET_0300);
 207         assertEquals(test.getMonth(), Month.MARCH);
 208         assertEquals(test.getDayOfMonthIndicator(), 20);
 209         assertEquals(test.getDayOfWeek(), null);
 210         assertEquals(test.getLocalTime(), TIME_0100);
 211         assertEquals(test.isMidnightEndOfDay(), false);
 212         assertEquals(test.getTimeDefinition(), TimeDefinition.WALL);
 213         assertEquals(test.getStandardOffset(), OFFSET_0200);
 214         assertEquals(test.getOffsetBefore(), OFFSET_0200);
 215         assertEquals(test.getOffsetAfter(), OFFSET_0300);
 216         assertSerializable(test);
 217     }
 218 
 219     @Test
 220     public void test_serialization_unusualOffsets() throws Exception {
 221         ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(
 222                 Month.MARCH, 20, null, TIME_0100, false, TimeDefinition.STANDARD,
 223                 ZoneOffset.ofHoursMinutesSeconds(-12, -20, -50),
 224                 ZoneOffset.ofHoursMinutesSeconds(-4, -10, -34),
 225                 ZoneOffset.ofHours(-18));
 226         assertSerializable(test);
 227     }
 228 
 229     @Test
 230     public void test_serialization_endOfDay() throws Exception {
 231         ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(
 232                 Month.MARCH, 20, DayOfWeek.FRIDAY, LocalTime.MIDNIGHT, true, TimeDefinition.UTC,
 233                 OFFSET_0200, OFFSET_0200, OFFSET_0300);
 234         assertSerializable(test);
 235     }
 236 
 237     @Test
 238     public void test_serialization_unusualTime() throws Exception {
 239         ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(
 240                 Month.MARCH, 20, DayOfWeek.WEDNESDAY, LocalTime.of(13, 34, 56), false, TimeDefinition.STANDARD,
 241                 OFFSET_0200, OFFSET_0200, OFFSET_0300);
 242         assertSerializable(test);
 243     }
 244 
 245     //-----------------------------------------------------------------------
 246     // createTransition()
 247     //-----------------------------------------------------------------------
 248     @Test(groups={"tck"})
 249     public void test_createTransition_floatingWeek_gap_notEndOfDay() {
 250         ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(
 251                 Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
 252                 OFFSET_0200, OFFSET_0200, OFFSET_0300);
 253         ZoneOffsetTransition trans = ZoneOffsetTransition.of(
 254                 LocalDateTime.of(2000, Month.MARCH, 26, 1, 0), OFFSET_0200, OFFSET_0300);
 255         assertEquals(test.createTransition(2000), trans);
 256     }
 257 
 258     @Test(groups={"tck"})
 259     public void test_createTransition_floatingWeek_overlap_endOfDay() {
 260         ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(
 261                 Month.MARCH, 20, DayOfWeek.SUNDAY, LocalTime.MIDNIGHT, true, TimeDefinition.WALL,
 262                 OFFSET_0200, OFFSET_0300, OFFSET_0200);
 263         ZoneOffsetTransition trans = ZoneOffsetTransition.of(
 264                 LocalDateTime.of(2000, Month.MARCH, 27, 0, 0), OFFSET_0300, OFFSET_0200);
 265         assertEquals(test.createTransition(2000), trans);
 266     }
 267 
 268     @Test(groups={"tck"})
 269     public void test_createTransition_floatingWeekBackwards_last() {
 270         ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(
 271                 Month.MARCH, -1, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
 272                 OFFSET_0200, OFFSET_0200, OFFSET_0300);
 273         ZoneOffsetTransition trans = ZoneOffsetTransition.of(
 274                 LocalDateTime.of(2000, Month.MARCH, 26, 1, 0), OFFSET_0200, OFFSET_0300);
 275         assertEquals(test.createTransition(2000), trans);
 276     }
 277 
 278     @Test(groups={"tck"})
 279     public void test_createTransition_floatingWeekBackwards_seventhLast() {
 280         ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(
 281                 Month.MARCH, -7, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
 282                 OFFSET_0200, OFFSET_0200, OFFSET_0300);
 283         ZoneOffsetTransition trans = ZoneOffsetTransition.of(
 284                 LocalDateTime.of(2000, Month.MARCH, 19, 1, 0), OFFSET_0200, OFFSET_0300);
 285         assertEquals(test.createTransition(2000), trans);
 286     }
 287 
 288     @Test(groups={"tck"})
 289     public void test_createTransition_floatingWeekBackwards_secondLast() {
 290         ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(
 291                 Month.MARCH, -2, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
 292                 OFFSET_0200, OFFSET_0200, OFFSET_0300);
 293         ZoneOffsetTransition trans = ZoneOffsetTransition.of(
 294                 LocalDateTime.of(2000, Month.MARCH, 26, 1, 0), OFFSET_0200, OFFSET_0300);
 295         assertEquals(test.createTransition(2000), trans);
 296     }
 297 
 298     @Test(groups={"tck"})
 299     public void test_createTransition_fixedDate() {
 300         ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(
 301                 Month.MARCH, 20, null, TIME_0100, false, TimeDefinition.STANDARD,
 302                 OFFSET_0200, OFFSET_0200, OFFSET_0300);
 303         ZoneOffsetTransition trans = ZoneOffsetTransition.of(
 304                 LocalDateTime.of(2000, Month.MARCH, 20, 1, 0), OFFSET_0200, OFFSET_0300);
 305         assertEquals(test.createTransition(2000), trans);
 306     }
 307 
 308     //-----------------------------------------------------------------------
 309     // equals()
 310     //-----------------------------------------------------------------------
 311     @Test(groups={"tck"})
 312     public void test_equals_monthDifferent() {
 313         ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of(
 314                 Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
 315                 OFFSET_0200, OFFSET_0200, OFFSET_0300);
 316         ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of(
 317                 Month.APRIL, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
 318                 OFFSET_0200, OFFSET_0200, OFFSET_0300);
 319         assertEquals(a.equals(a), true);
 320         assertEquals(a.equals(b), false);
 321         assertEquals(b.equals(a), false);
 322         assertEquals(b.equals(b), true);
 323     }
 324 
 325     @Test(groups={"tck"})
 326     public void test_equals_dayOfMonthDifferent() {
 327         ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of(
 328                 Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
 329                 OFFSET_0200, OFFSET_0200, OFFSET_0300);
 330         ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of(
 331                 Month.MARCH, 21, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
 332                 OFFSET_0200, OFFSET_0200, OFFSET_0300);
 333         assertEquals(a.equals(a), true);
 334         assertEquals(a.equals(b), false);
 335         assertEquals(b.equals(a), false);
 336         assertEquals(b.equals(b), true);
 337     }
 338 
 339     @Test(groups={"tck"})
 340     public void test_equals_dayOfWeekDifferent() {
 341         ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of(
 342                 Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
 343                 OFFSET_0200, OFFSET_0200, OFFSET_0300);
 344         ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of(
 345                 Month.MARCH, 20, DayOfWeek.SATURDAY, TIME_0100, false, TimeDefinition.WALL,
 346                 OFFSET_0200, OFFSET_0200, OFFSET_0300);
 347         assertEquals(a.equals(a), true);
 348         assertEquals(a.equals(b), false);
 349         assertEquals(b.equals(a), false);
 350         assertEquals(b.equals(b), true);
 351     }
 352 
 353     @Test(groups={"tck"})
 354     public void test_equals_dayOfWeekDifferentNull() {
 355         ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of(
 356                 Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
 357                 OFFSET_0200, OFFSET_0200, OFFSET_0300);
 358         ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of(
 359                 Month.MARCH, 20, null, TIME_0100, false, TimeDefinition.WALL,
 360                 OFFSET_0200, OFFSET_0200, OFFSET_0300);
 361         assertEquals(a.equals(a), true);
 362         assertEquals(a.equals(b), false);
 363         assertEquals(b.equals(a), false);
 364         assertEquals(b.equals(b), true);
 365     }
 366 
 367     @Test(groups={"tck"})
 368     public void test_equals_localTimeDifferent() {
 369         ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of(
 370                 Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
 371                 OFFSET_0200, OFFSET_0200, OFFSET_0300);
 372         ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of(
 373                 Month.MARCH, 20, DayOfWeek.SUNDAY, LocalTime.MIDNIGHT, false, TimeDefinition.WALL,
 374                 OFFSET_0200, OFFSET_0200, OFFSET_0300);
 375         assertEquals(a.equals(a), true);
 376         assertEquals(a.equals(b), false);
 377         assertEquals(b.equals(a), false);
 378         assertEquals(b.equals(b), true);
 379     }
 380 
 381     @Test(groups={"tck"})
 382     public void test_equals_endOfDayDifferent() {
 383         ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of(
 384                 Month.MARCH, 20, DayOfWeek.SUNDAY, LocalTime.MIDNIGHT, false, TimeDefinition.WALL,
 385                 OFFSET_0200, OFFSET_0200, OFFSET_0300);
 386         ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of(
 387                 Month.MARCH, 20, DayOfWeek.SUNDAY, LocalTime.MIDNIGHT, true, TimeDefinition.WALL,
 388                 OFFSET_0200, OFFSET_0200, OFFSET_0300);
 389         assertEquals(a.equals(a), true);
 390         assertEquals(a.equals(b), false);
 391         assertEquals(b.equals(a), false);
 392         assertEquals(b.equals(b), true);
 393     }
 394 
 395     @Test(groups={"tck"})
 396     public void test_equals_timeDefinitionDifferent() {
 397         ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of(
 398                 Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
 399                 OFFSET_0200, OFFSET_0200, OFFSET_0300);
 400         ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of(
 401                 Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.STANDARD,
 402                 OFFSET_0200, OFFSET_0200, OFFSET_0300);
 403         assertEquals(a.equals(a), true);
 404         assertEquals(a.equals(b), false);
 405         assertEquals(b.equals(a), false);
 406         assertEquals(b.equals(b), true);
 407     }
 408 
 409     @Test(groups={"tck"})
 410     public void test_equals_standardOffsetDifferent() {
 411         ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of(
 412                 Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
 413                 OFFSET_0200, OFFSET_0200, OFFSET_0300);
 414         ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of(
 415                 Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
 416                 OFFSET_0300, OFFSET_0200, OFFSET_0300);
 417         assertEquals(a.equals(a), true);
 418         assertEquals(a.equals(b), false);
 419         assertEquals(b.equals(a), false);
 420         assertEquals(b.equals(b), true);
 421     }
 422 
 423     @Test(groups={"tck"})
 424     public void test_equals_offsetBeforeDifferent() {
 425         ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of(
 426                 Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
 427                 OFFSET_0200, OFFSET_0200, OFFSET_0300);
 428         ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of(
 429                 Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
 430                 OFFSET_0200, OFFSET_0300, OFFSET_0300);
 431         assertEquals(a.equals(a), true);
 432         assertEquals(a.equals(b), false);
 433         assertEquals(b.equals(a), false);
 434         assertEquals(b.equals(b), true);
 435     }
 436 
 437     @Test(groups={"tck"})
 438     public void test_equals_offsetAfterDifferent() {
 439         ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of(
 440                 Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
 441                 OFFSET_0200, OFFSET_0200, OFFSET_0300);
 442         ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of(
 443                 Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
 444                 OFFSET_0200, OFFSET_0200, OFFSET_0200);
 445         assertEquals(a.equals(a), true);
 446         assertEquals(a.equals(b), false);
 447         assertEquals(b.equals(a), false);
 448         assertEquals(b.equals(b), true);
 449     }
 450 
 451     @Test(groups={"tck"})
 452     public void test_equals_string_false() {
 453         ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of(
 454                 Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
 455                 OFFSET_0200, OFFSET_0200, OFFSET_0300);
 456         assertEquals(a.equals("TZDB"), false);
 457     }
 458 
 459     @Test(groups={"tck"})
 460     public void test_equals_null_false() {
 461         ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of(
 462                 Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
 463                 OFFSET_0200, OFFSET_0200, OFFSET_0300);
 464         assertEquals(a.equals(null), false);
 465     }
 466 
 467     //-----------------------------------------------------------------------
 468     // hashCode()
 469     //-----------------------------------------------------------------------
 470     @Test(groups={"tck"})
 471     public void test_hashCode_floatingWeek_gap_notEndOfDay() {
 472         ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of(
 473                 Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
 474                 OFFSET_0200, OFFSET_0200, OFFSET_0300);
 475         ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of(
 476                 Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
 477                 OFFSET_0200, OFFSET_0200, OFFSET_0300);
 478         assertEquals(a.hashCode(), b.hashCode());
 479     }
 480 
 481     @Test(groups={"tck"})
 482     public void test_hashCode_floatingWeek_overlap_endOfDay_nullDayOfWeek() {
 483         ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of(
 484                 Month.OCTOBER, 20, null, LocalTime.MIDNIGHT, true, TimeDefinition.WALL,
 485                 OFFSET_0200, OFFSET_0300, OFFSET_0200);
 486         ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of(
 487                 Month.OCTOBER, 20, null, LocalTime.MIDNIGHT, true, TimeDefinition.WALL,
 488                 OFFSET_0200, OFFSET_0300, OFFSET_0200);
 489         assertEquals(a.hashCode(), b.hashCode());
 490     }
 491 
 492     @Test(groups={"tck"})
 493     public void test_hashCode_floatingWeekBackwards() {
 494         ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of(
 495                 Month.MARCH, -1, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
 496                 OFFSET_0200, OFFSET_0200, OFFSET_0300);
 497         ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of(
 498                 Month.MARCH, -1, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
 499                 OFFSET_0200, OFFSET_0200, OFFSET_0300);
 500         assertEquals(a.hashCode(), b.hashCode());
 501     }
 502 
 503     @Test(groups={"tck"})
 504     public void test_hashCode_fixedDate() {
 505         ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of(
 506                 Month.MARCH, 20, null, TIME_0100, false, TimeDefinition.STANDARD,
 507                 OFFSET_0200, OFFSET_0200, OFFSET_0300);
 508         ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of(
 509                 Month.MARCH, 20, null, TIME_0100, false, TimeDefinition.STANDARD,
 510                 OFFSET_0200, OFFSET_0200, OFFSET_0300);
 511         assertEquals(a.hashCode(), b.hashCode());
 512     }
 513 
 514     //-----------------------------------------------------------------------
 515     // toString()
 516     //-----------------------------------------------------------------------
 517     @Test(groups={"tck"})
 518     public void test_toString_floatingWeek_gap_notEndOfDay() {
 519         ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(
 520                 Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
 521                 OFFSET_0200, OFFSET_0200, OFFSET_0300);
 522         assertEquals(test.toString(), "TransitionRule[Gap +02:00 to +03:00, SUNDAY on or after MARCH 20 at 01:00 WALL, standard offset +02:00]");
 523     }
 524 
 525     @Test(groups={"tck"})
 526     public void test_toString_floatingWeek_overlap_endOfDay() {
 527         ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(
 528                 Month.OCTOBER, 20, DayOfWeek.SUNDAY, LocalTime.MIDNIGHT, true, TimeDefinition.WALL,
 529                 OFFSET_0200, OFFSET_0300, OFFSET_0200);
 530         assertEquals(test.toString(), "TransitionRule[Overlap +03:00 to +02:00, SUNDAY on or after OCTOBER 20 at 24:00 WALL, standard offset +02:00]");
 531     }
 532 
 533     @Test(groups={"tck"})
 534     public void test_toString_floatingWeekBackwards_last() {
 535         ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(
 536                 Month.MARCH, -1, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
 537                 OFFSET_0200, OFFSET_0200, OFFSET_0300);
 538         assertEquals(test.toString(), "TransitionRule[Gap +02:00 to +03:00, SUNDAY on or before last day of MARCH at 01:00 WALL, standard offset +02:00]");
 539     }
 540 
 541     @Test(groups={"tck"})
 542     public void test_toString_floatingWeekBackwards_secondLast() {
 543         ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(
 544                 Month.MARCH, -2, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
 545                 OFFSET_0200, OFFSET_0200, OFFSET_0300);
 546         assertEquals(test.toString(), "TransitionRule[Gap +02:00 to +03:00, SUNDAY on or before last day minus 1 of MARCH at 01:00 WALL, standard offset +02:00]");
 547     }
 548 
 549     @Test(groups={"tck"})
 550     public void test_toString_fixedDate() {
 551         ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(
 552                 Month.MARCH, 20, null, TIME_0100, false, TimeDefinition.STANDARD,
 553                 OFFSET_0200, OFFSET_0200, OFFSET_0300);
 554         assertEquals(test.toString(), "TransitionRule[Gap +02:00 to +03:00, MARCH 20 at 01:00 STANDARD, standard offset +02:00]");
 555     }
 556 
 557 }