< prev index next >

test/jdk/java/util/Calendar/bug4409072.java

Print this page
@@ -1,7 +1,7 @@
  /*
-  * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
+  * Copyright (c) 2001, 2023, 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.

@@ -24,29 +24,30 @@
  /*
   * @test
   * @bug 4409072
   * @summary tests for set(), add(), and roll() with various week parameters.
   * @library /java/text/testlib
-  * @run main bug4409072
+  * @run junit bug4409072
   */
  
  import  java.util.*;
  import static java.util.Calendar.*;
  
- public class bug4409072 extends IntlTest {
+ import org.junit.jupiter.api.Test;
  
-     public static void main(String[] args) throws Exception {
-         new bug4409072().run(args);
-     }
+ import static org.junit.jupiter.api.Assertions.fail;
+ 
+ public class bug4409072 {
  
      /* Confirm some public methods' behavior in Calendar.
       * (e.g. add(), roll(), set())
       */
+     @Test
      public void Test4409072() {
          Locale locale = Locale.getDefault();
          if (!TestUtils.usesGregorianCalendar(locale)) {
-             logln("Skipping this test because locale is " + locale);
+             System.out.println("Skipping this test because locale is " + locale);
              return;
          }
  
          Locale savedLocale = Locale.getDefault();
          TimeZone savedTZ = TimeZone.getDefault();

@@ -409,20 +410,20 @@
                  int month = cal.get(MONTH);
                  int date = cal.get(DATE);
  
                  if (cal.get(WEEK_OF_YEAR) != 22) {
                      noerror = false;
-                     errln("Failed : set(WEEK_OF_YEAR=22)" +
+                     fail("Failed : set(WEEK_OF_YEAR=22)" +
                            " *** get(WEEK_OF_YEAR=" +
                            cal.get(WEEK_OF_YEAR) + ")" +
                            ", got " + (month+1)+"/"+date+"/"+year +
                            ", expected " + (m+1)+"/"+d+"/"+2005 +
                            ", MinFirstDOW=" + minDow +
                            ", FirstDOW=" + dow);
                  } else if ((year != y) || (month != m) || (date != d)) {
                      noerror = false;
-                     errln("Failed : set(WEEK_OF_YEAR=22)" +
+                     fail("Failed : set(WEEK_OF_YEAR=22)" +
                            " got " + (month+1)+"/"+date+"/"+year +
                            ", expected " + (m+1)+"/"+d+"/"+y +
                            ", MinFirstDOW=" + minDow +
                            ", FirstDOW=" + dow);
                  }

@@ -444,11 +445,11 @@
                      month = cal.get(MONTH);
                      date = cal.get(DATE);
  
                      if ((year != y) || (month != m) || (date != d)) {
                          noerror = false;
-                         errln("Failed : set(WEEK_OF_MONTH=1)" +
+                         fail("Failed : set(WEEK_OF_MONTH=1)" +
                                " got " + (month+1)+"/"+date+"/"+year +
                                ", expected " + (m+1)+"/"+d+"/"+y +
                                ", MinFirstDOW=" + minDow +
                                ", FirstDOW=" + dow);
                      }

@@ -468,31 +469,31 @@
                      month = cal.get(MONTH);
                      date = cal.get(DATE);
  
                      if (cal.get(WEEK_OF_YEAR) != 1) {
                          noerror = false;
-                         errln("Failed : set(WEEK_OF_YEAR=1)" +
+                         fail("Failed : set(WEEK_OF_YEAR=1)" +
                                " *** get(WEEK_OF_YEAR=" +
                                cal.get(WEEK_OF_YEAR) + ")" +
                                ", got " + (month+1)+"/"+date+"/"+year +
                                ", expected " + (m+1)+"/"+d+"/"+y +
                                ", MinFirstDOW=" + minDow +
                                ", FirstDOW=" + dow);
                      } else if ((year != y) || (month != m) || (date != d)) {
                          noerror = false;
-                         errln("Failed : set(WEEK_OF_YEAR=1)" +
+                         fail("Failed : set(WEEK_OF_YEAR=1)" +
                                " got " + (month+1)+"/"+date+"/"+year +
                                ", expected " + (m+1)+"/"+d+"/"+y +
                                ", MinFirstDOW=" + minDow +
                                ", FirstDOW=" + dow);
                      }
                  }
              }
          }
  
          if (noerror) {
-             logln("Passed : set() test");
+             System.out.println("Passed : set() test");
          }
      }
  
      /**
       * Test for add()

@@ -523,11 +524,11 @@
                  int month = cal.get(MONTH);
                  int date = cal.get(DATE);
  
                  if ((year != 2006) || (month != 0) || (date != 25)) {
                      noerror = false;
-                     errln("Failed : add(WEEK_OF_YEAR+1)" +
+                     fail("Failed : add(WEEK_OF_YEAR+1)" +
                            " got " + (month+1)+"/"+date+"/"+year +
                            ", expected 1/25/2006" +
                            ", MinFirstDOW=" + minDow +
                            ", FirstDOW=" + dow);
                  }

@@ -540,29 +541,29 @@
                  year = cal.get(YEAR);
                  month = cal.get(MONTH);
                  date = cal.get(DATE);
  
                  if ((oldWOY - newWOY) != 3) {
-                     errln("Failed : add(WEEK_OF_YEAR-1)" +
+                     fail("Failed : add(WEEK_OF_YEAR-1)" +
                            " got " + (month+1)+"/"+date+"/"+year +
                            ", expected 11/16/2005" +
                            ", MinFirstDOW=" + minDow +
                            ", FirstDOW=" + dow +
                            ", WEEK_OF_YEAR=" + newWOY +
                            " should be " + (oldWOY-3));
                  } else if ((year != 2005) || (month != 10) || (date != 16)) {
-                     errln("Failed : add(-1)" +
+                     fail("Failed : add(-1)" +
                            " got " + (month+1)+"/"+date+"/"+year +
                            ", expected 11/16/2005" +
                            ", MinFirstDOW=" + minDow +
                            ", FirstDOW=" + dow);
                  }
              }
          }
  
          if (noerror) {
-             logln("Passed : add() test");
+             System.out.println("Passed : add() test");
          }
      }
  
      /*
       * Golden data for roll() test

@@ -620,11 +621,11 @@
                  int month = cal.get(MONTH);
                  int date = cal.get(DATE);
  
                  if ((year != y) || (month != m) || (date != d)) {
                      noerror = false;
-                     errln("Failed : roll(WEEK_OF_MONTH-1)" +
+                     fail("Failed : roll(WEEK_OF_MONTH-1)" +
                            " got " + (month+1) + "/" + date + "/" + year +
                            ", expected " + (m+1) + "/" + d + "/" + y +
                            ", MinFirstDOW=" + minDow +
                            ", FirstDOW=" + dow);
                  }

@@ -647,11 +648,11 @@
                  month = cal.get(MONTH);
                  date = cal.get(DATE);
  
                  if ((year != y) || (month != m) || (date != d)) {
                      noerror = false;
-                     errln("Failed : roll(WEEK_OF_YEAR+1)" +
+                     fail("Failed : roll(WEEK_OF_YEAR+1)" +
                            " got " + (month+1) + "/" + date + "/" + year +
                            ", expected " + (m+1) + "/" + d + "/" + y +
                            ", MinFirstDOW=" + minDow +
                            ", FirstDOW=" + dow);
                  }

@@ -668,19 +669,19 @@
                  month = cal.get(MONTH);
                  date = cal.get(DATE);
  
                  if ((year != y) || (month != m) || (date != d)) {
                      noerror = false;
-                     errln("Failed : roll(WEEK_OF_YEAR-1)" +
+                     fail("Failed : roll(WEEK_OF_YEAR-1)" +
                            " got " + (month+1)+"/"+date+"/"+year +
                            ", expected " + (m+1)+"/"+d+"/"+y +
                            ", MinFirstDOW=" + minDow +
                            ", FirstDOW=" + dow);
                  }
              }
          }
  
          if (noerror) {
-             logln("Passed : roll() test");
+             System.out.println("Passed : roll() test");
          }
      }
  }
< prev index next >