tests/libjava-mauve/src/gnu/testlet/java/util/SimpleTimeZone/check14.java
branchjk_new_structure
changeset 1541 75c2e24dea9a
parent 1540 92ac284961c1
child 1542 be11db817bcf
equal deleted inserted replaced
1540:92ac284961c1 1541:75c2e24dea9a
     1 // Test SimpleTimeZone.check14().
       
     2 
       
     3 // Written by Jerry Quinn <jlquinn@optonline.net>
       
     4 
       
     5 // This file is part of Mauve.
       
     6 
       
     7 // Mauve is free software; you can redistribute it and/or modify
       
     8 // it under the terms of the GNU General Public License as published by
       
     9 // the Free Software Foundation; either version 2, or (at your option)
       
    10 // any later version.
       
    11 
       
    12 // Mauve is distributed in the hope that it will be useful,
       
    13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    15 // GNU General Public License for more details.
       
    16 
       
    17 // You should have received a copy of the GNU General Public License
       
    18 // along with Mauve; see the file COPYING.  If not, write to
       
    19 // the Free Software Foundation, 59 Temple Place - Suite 330,
       
    20 // Boston, MA 02111-1307, USA.
       
    21 
       
    22 // Tags: JDK1.4
       
    23 
       
    24 // Verify the constructors added in JDK 1.4
       
    25 
       
    26 package gnu.testlet.java.util.SimpleTimeZone;
       
    27 
       
    28 import gnu.testlet.Testlet;
       
    29 import gnu.testlet.TestHarness;
       
    30 import java.util.*;
       
    31 
       
    32 public class check14 implements Testlet
       
    33 {
       
    34   public void test (TestHarness harness)
       
    35   {
       
    36     int rawOff = -18000000;	// 5 hours
       
    37     int dstOff = 3600000;	// 1 hour
       
    38 
       
    39     // Create a timezone for UTC-5 with daylight savings starting on
       
    40     // April 10 at 12 noon, ending September 10, 12 noon in daylight
       
    41     // savings, 1 hour shift.
       
    42 
       
    43     // All three should represent the same period
       
    44     SimpleTimeZone tzwall =
       
    45       new SimpleTimeZone(rawOff, "Z1",
       
    46 			 4, 10, 0, 43200000, SimpleTimeZone.WALL_TIME,
       
    47 			 9, 10, 0, 43200000, SimpleTimeZone.WALL_TIME,
       
    48 			 dstOff);
       
    49 
       
    50     // Start time is same between WALL_TIME and STANDARD_TIME.  End
       
    51     // time is in STANDARD_TIME, not DST.  So ending at the same time
       
    52     // really means ending earlier in standard time.
       
    53     SimpleTimeZone tzstd =
       
    54       new SimpleTimeZone(rawOff, "Z2",
       
    55 			 Calendar.MAY, 10, 0, 43200000, SimpleTimeZone.STANDARD_TIME,
       
    56 			 Calendar.OCTOBER, 10, 0, 39600000, SimpleTimeZone.STANDARD_TIME,
       
    57 			 dstOff);
       
    58 
       
    59     // Times are UTC, so later than 
       
    60     SimpleTimeZone tzutc =
       
    61       new SimpleTimeZone(rawOff, "Z3",
       
    62 			 Calendar.MAY, 10, 0, 61200000, SimpleTimeZone.UTC_TIME,
       
    63 			 Calendar.OCTOBER, 10, 0, 57600000, SimpleTimeZone.UTC_TIME,
       
    64 			 dstOff);
       
    65 
       
    66     int wall;
       
    67     int std;
       
    68     int utc;
       
    69 
       
    70     // test 1/2 hour before dst
       
    71     wall = tzwall.getOffset(GregorianCalendar.AD, 2000, Calendar.MAY, 10, Calendar.WEDNESDAY, 41400000);
       
    72     std = tzstd.getOffset(GregorianCalendar.AD, 2000, Calendar.MAY, 10, Calendar.WEDNESDAY, 41400000);
       
    73     utc = tzutc.getOffset(GregorianCalendar.AD, 2000, Calendar.MAY, 10, Calendar.WEDNESDAY, 41400000);
       
    74 
       
    75     harness.check(wall, rawOff);  // check 1
       
    76     harness.check(std, rawOff);   // check 2
       
    77     harness.check(utc, rawOff);   // check 3
       
    78     
       
    79     // test 1/2 hour into dst
       
    80     wall = tzwall.getOffset(GregorianCalendar.AD, 2000, Calendar.MAY, 10, Calendar.WEDNESDAY, 45000000);
       
    81     std = tzstd.getOffset(GregorianCalendar.AD, 2000, Calendar.MAY, 10, Calendar.WEDNESDAY, 45000000);
       
    82     utc = tzutc.getOffset(GregorianCalendar.AD, 2000, Calendar.MAY, 10, Calendar.WEDNESDAY, 45000000);
       
    83 
       
    84     harness.check(wall, rawOff + dstOff);  // check 4
       
    85     harness.check(std, rawOff + dstOff);   // check 5
       
    86     harness.check(utc, rawOff + dstOff);   // check 6
       
    87     
       
    88     // test 1/2 hour before fall back to standard time
       
    89     wall = tzwall.getOffset(GregorianCalendar.AD, 2000, Calendar.OCTOBER, 10, Calendar.TUESDAY, 41400000 - dstOff);
       
    90     std = tzstd.getOffset(GregorianCalendar.AD, 2000, Calendar.OCTOBER, 10, Calendar.TUESDAY, 41400000 - dstOff);
       
    91     utc = tzutc.getOffset(GregorianCalendar.AD, 2000, Calendar.OCTOBER, 10, Calendar.TUESDAY, 41400000 - dstOff);
       
    92 
       
    93     harness.check(wall, rawOff + dstOff);  // check 7
       
    94     harness.check(std, rawOff + dstOff);   // check 8
       
    95     harness.check(utc, rawOff + dstOff);   // check 9
       
    96     
       
    97     // test 1/2 hour after fall back to standard time
       
    98     wall = tzwall.getOffset(GregorianCalendar.AD, 2000, Calendar.OCTOBER, 10, Calendar.TUESDAY, 45000000 - dstOff);
       
    99     std = tzstd.getOffset(GregorianCalendar.AD, 2000, Calendar.OCTOBER, 10, Calendar.TUESDAY, 45000000 - dstOff);
       
   100     utc = tzutc.getOffset(GregorianCalendar.AD, 2000, Calendar.OCTOBER, 10, Calendar.TUESDAY, 45000000 - dstOff);
       
   101 
       
   102     harness.check(wall, rawOff);           // check 10
       
   103     harness.check(std, rawOff);            // check 11
       
   104     harness.check(utc, rawOff);            // check 12
       
   105 
       
   106   }
       
   107 }