< prev index next >

test/jdk/java/util/TimeZone/Bug4322313.java

Print this page
*** 1,7 ***
  /*
!  * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.
--- 1,7 ---
  /*
!  * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.

*** 25,18 ***
   * @test
   * @bug 4322313
   * @summary Make sure that new implementation of custom time zone
   * support for TimeZone.getTimeZone() works correctly and the
   * getDisplayName() methods are locale independent.
!  * @library /java/text/testlib
   */
  
! import java.io.*;
! import java.text.*;
- import java.util.*;
  
! public class Bug4322313 extends IntlTest {
      private static final int MPM = 60 * 1000;    /* Milliseconds per minute */
      private static final Object[][] VALIDS = {
          /* given ID    rawOffset   normalized ID */
          {"GMT+00:00",  0,          "GMT+00:00"},
          {"GMT+3:04",   184 * MPM,  "GMT+03:04"},
--- 25,21 ---
   * @test
   * @bug 4322313
   * @summary Make sure that new implementation of custom time zone
   * support for TimeZone.getTimeZone() works correctly and the
   * getDisplayName() methods are locale independent.
!  * @run junit Bug4322313
   */
  
! import java.util.Locale;
! import java.util.TimeZone;
  
! import org.junit.jupiter.api.Test;
+ 
+ import static org.junit.jupiter.api.Assertions.fail;
+ 
+ public class Bug4322313 {
      private static final int MPM = 60 * 1000;    /* Milliseconds per minute */
      private static final Object[][] VALIDS = {
          /* given ID    rawOffset   normalized ID */
          {"GMT+00:00",  0,          "GMT+00:00"},
          {"GMT+3:04",   184 * MPM,  "GMT+03:04"},

*** 78,10 ***
--- 81,11 ---
          "GMT-a",      "GMT-24",      "GMT-060",    "GMT-2403",
          "GMT-42195",  "GMT-+1",      "GMT-+15",    "G M T",
          "GMT+09:00 ",
      };
  
+     @Test
      void Test4322313() {
          Locale savedLocale = Locale.getDefault();
          TimeZone savedTimeZone = TimeZone.getDefault();
          boolean err = false;
  

*** 104,11 ***
                          System.err.println("\tFailed [Locale=" +
                                             locale + ", \"" + VALIDS[k][0] +
                                             "\"] Invalid TimeZone ID, expected:" +
                                             VALIDS[k][2] + ", got:" + tz.getID() + ", " + tz);
                      } else {
!                         logln("\tPassed [Locale=" +
                                locale + ", \"" + VALIDS[k][0] +
                                "\"] Valid TimeZone ID, got:" + VALIDS[k][2]);
                      }
  
                      offset = tz.getRawOffset();
--- 108,11 ---
                          System.err.println("\tFailed [Locale=" +
                                             locale + ", \"" + VALIDS[k][0] +
                                             "\"] Invalid TimeZone ID, expected:" +
                                             VALIDS[k][2] + ", got:" + tz.getID() + ", " + tz);
                      } else {
!                         System.out.println("\tPassed [Locale=" +
                                locale + ", \"" + VALIDS[k][0] +
                                "\"] Valid TimeZone ID, got:" + VALIDS[k][2]);
                      }
  
                      offset = tz.getRawOffset();

*** 117,11 ***
                          System.err.println("\tFailed [Locale=" +
                                             locale + ", \"" + VALIDS[k][0] +
                                             "\"] Invalid RawOffset, expected:" + VALIDS[k][1] +
                                             ", got:" + offset + ", " + tz);
                      } else {
!                         logln("\tPassed [Locale=" +
                                locale + ", \"" + VALIDS[k][0] +
                                "\"] Vaild RawOffset, got:" + offset);
                      }
  
                      offset = tz.getDSTSavings();
--- 121,11 ---
                          System.err.println("\tFailed [Locale=" +
                                             locale + ", \"" + VALIDS[k][0] +
                                             "\"] Invalid RawOffset, expected:" + VALIDS[k][1] +
                                             ", got:" + offset + ", " + tz);
                      } else {
!                         System.out.println("\tPassed [Locale=" +
                                locale + ", \"" + VALIDS[k][0] +
                                "\"] Vaild RawOffset, got:" + offset);
                      }
  
                      offset = tz.getDSTSavings();

*** 130,11 ***
                          System.err.println("\tFailed [Locale=" +
                                             locale + ", \"" + VALIDS[k][0] +
                                             "\"] DSTSavings should be zero, got:" + offset +
                                             ", " + tz);
                      } else {
!                         logln("\tPassed [Locale=" +
                                locale + ", \"" + VALIDS[k][0] +
                                "\"] DSTSavings is zero.");
                      }
                  }
  
--- 134,11 ---
                          System.err.println("\tFailed [Locale=" +
                                             locale + ", \"" + VALIDS[k][0] +
                                             "\"] DSTSavings should be zero, got:" + offset +
                                             ", " + tz);
                      } else {
!                         System.out.println("\tPassed [Locale=" +
                                locale + ", \"" + VALIDS[k][0] +
                                "\"] DSTSavings is zero.");
                      }
                  }
  

*** 148,11 ***
                          System.err.println("\tFailed [Locale=" +
                                             locale + ", \"" + INVALIDS[k] +
                                             "\"] Invalid TimeZone ID, expected:GMT, got:" +
                                             tz.getID() + ", " + tz);
                      } else {
!                         logln("\tPassed [Locale=" +
                                locale + ", \"" + INVALIDS[k] +
                                "\"] Valid TimeZone ID, got:" + tz.getID());
                      }
  
                      offset = tz.getRawOffset();
--- 152,11 ---
                          System.err.println("\tFailed [Locale=" +
                                             locale + ", \"" + INVALIDS[k] +
                                             "\"] Invalid TimeZone ID, expected:GMT, got:" +
                                             tz.getID() + ", " + tz);
                      } else {
!                         System.out.println("\tPassed [Locale=" +
                                locale + ", \"" + INVALIDS[k] +
                                "\"] Valid TimeZone ID, got:" + tz.getID());
                      }
  
                      offset = tz.getRawOffset();

*** 161,11 ***
                          System.err.println("\tFailed [Locale=" +
                                             locale + ", \"" + INVALIDS[k] +
                                             "\"] RawOffset should be zero, got:" + offset +
                                             ", " + tz);
                      } else {
!                         logln("\tPassed [Locale=" +
                                locale + ", \"" + INVALIDS[k] +
                                "\"] RawOffset is zero.");
                      }
  
                      offset = tz.getDSTSavings();
--- 165,11 ---
                          System.err.println("\tFailed [Locale=" +
                                             locale + ", \"" + INVALIDS[k] +
                                             "\"] RawOffset should be zero, got:" + offset +
                                             ", " + tz);
                      } else {
!                         System.out.println("\tPassed [Locale=" +
                                locale + ", \"" + INVALIDS[k] +
                                "\"] RawOffset is zero.");
                      }
  
                      offset = tz.getDSTSavings();

*** 174,11 ***
                          System.err.println("\tFailed [Locale=" +
                                             locale + ", \"" + INVALIDS[k] +
                                             "\"] DSTSavings should be zero, got:" + offset +
                                             ", " + tz);
                      } else {
!                         logln("\tPassed [Locale=" +
                                locale + ", \"" + INVALIDS[k] +
                                "\"] DSTSavings is zero.");
                      }
                  }
  
--- 178,11 ---
                          System.err.println("\tFailed [Locale=" +
                                             locale + ", \"" + INVALIDS[k] +
                                             "\"] DSTSavings should be zero, got:" + offset +
                                             ", " + tz);
                      } else {
!                         System.out.println("\tPassed [Locale=" +
                                locale + ", \"" + INVALIDS[k] +
                                "\"] DSTSavings is zero.");
                      }
                  }
  

*** 216,15 ***
          } finally {
              Locale.setDefault(savedLocale);
              TimeZone.setDefault(savedTimeZone);
          }
          if (err) {
!             errln("TimeZone.getTimeZone() test failed");
          } else {
!             logln("TimeZone.getTimeZone() test passed");
          }
      }
- 
-     public static void main (String[] args) throws Exception {
-         new Bug4322313().run(args);
-     }
  }
--- 220,11 ---
          } finally {
              Locale.setDefault(savedLocale);
              TimeZone.setDefault(savedTimeZone);
          }
          if (err) {
!             fail("TimeZone.getTimeZone() test failed");
          } else {
!             System.out.println("TimeZone.getTimeZone() test passed");
          }
      }
  }
< prev index next >