< prev index next >

test/jdk/java/text/Collator/G7Test.java

Print this page
@@ -1,7 +1,7 @@
  /*
-  * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+  * Copyright (c) 1997, 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,10 +24,11 @@
  /*
   * @test
   * @library /java/text/testlib
   * @summary test G7 Collation
   * @modules jdk.localedata
+  * @run junit G7Test
   */
  /*
   *
   *
   * (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved

@@ -52,17 +53,17 @@
  
  import java.text.Collator;
  import java.text.RuleBasedCollator;
  import java.util.Locale;
  
- // G7 test program for printing out test results
+ import org.junit.jupiter.api.Test;
  
- public class G7Test extends CollatorTest {
+ import static org.junit.jupiter.api.Assertions.fail;
  
-     public static void main(String[] args) throws Exception {
-         new G7Test().run(args);
-     }
+ // G7 test program for printing out test results
+ 
+ public class G7Test {
  
      private static final String testCases[] = {
          "black-birds",              // 0
          "Pat",                      // 1
          "p\u00E9ch\u00E9",          // 2

@@ -156,37 +157,39 @@
          19, 22, 21, 23, 24, 25, 12, 13,  9,  0,
          17, 16, 26, 27, 28, 15, 18, 14,  1, 11,
           2,  3,  4,  5, 20,  6,  8, 10,  7, 29
      };
  
+     @Test
      public void TestG7Data() {
          for (int i = 0; i < locales.length; i++) {
              Collator myCollation= null;
              RuleBasedCollator tblColl1 = null;
  
              try {
                  myCollation = Collator.getInstance(locales[i]);
                  tblColl1 = new RuleBasedCollator(((RuleBasedCollator)myCollation).getRules());
              } catch (Exception foo) {
-                 errln("Exception: " + foo.getMessage() +
+                 fail("Exception: " + foo.getMessage() +
                        " Locale : " + locales[i].getDisplayName() +
                        " getRules failed\n");
                  continue;
              }
              for (int j = 0; j < FIXEDTESTSET; j++) {
                  for (int n = j+1; n < FIXEDTESTSET; n++) {
-                     doTest(tblColl1, testCases[G7Results[i][j]],
+                     TestUtils.doCollatorTest(tblColl1, testCases[G7Results[i][j]],
                             testCases[G7Results[i][n]], -1);
                  }
              }
              myCollation = null;
          }
      }
  
      /*
       * Demo Test 1 : Create a new table collation with rules "& Z < p, P"
       */
+     @Test
      public void TestDemoTest1() {
          int j = 0;
          final Collator myCollation = Collator.getInstance(Locale.US);
          final String defRules = ((RuleBasedCollator)myCollation).getRules();
          RuleBasedCollator tblColl = null;

@@ -194,88 +197,91 @@
  
          try {
              tblColl = new RuleBasedCollator(newRules);
              for (j = 0; j < FIXEDTESTSET; j++) {
                  for (int n = j+1; n < FIXEDTESTSET; n++) {
-                     doTest(tblColl, testCases[Test1Results[j]],
+                     TestUtils.doCollatorTest(tblColl, testCases[Test1Results[j]],
                             testCases[Test1Results[n]], -1);
                  }
              }
              tblColl = null;
          } catch (Exception foo) {
-             errln("Exception: " + foo.getMessage() +
+             fail("Exception: " + foo.getMessage() +
                    "\nDemo Test 1 Table Collation object creation failed.");
          }
      }
  
      /*
       * Demo Test 2 : Create a new table collation with rules
       *     "& C < ch , cH, Ch, CH"
       */
+     @Test
      public void TestDemoTest2() {
          final Collator myCollation = Collator.getInstance(Locale.US);
          final String defRules = ((RuleBasedCollator)myCollation).getRules();
          String newRules = defRules + "& C < ch , cH, Ch, CH";
  
          try {
              RuleBasedCollator tblColl = new RuleBasedCollator(newRules);
              for (int j = 0; j < TOTALTESTSET; j++) {
                  for (int n = j+1; n < TOTALTESTSET; n++) {
-                     doTest(tblColl, testCases[Test2Results[j]],
+                     TestUtils.doCollatorTest(tblColl, testCases[Test2Results[j]],
                             testCases[Test2Results[n]], -1);
                  }
              }
          } catch (Exception foo) {
-             errln("Exception: " + foo.getMessage() +
+             fail("Exception: " + foo.getMessage() +
                    "\nDemo Test 2 Table Collation object creation failed.\n");
          }
      }
  
      /*
       * Demo Test 3 : Create a new table collation with rules
       *     "& Question'-'mark ; '?' & Hash'-'mark ; '#' & Ampersand ; '&'"
       */
+     @Test
      public void TestDemoTest3() {
          final Collator myCollation = Collator.getInstance(Locale.US);
          final String defRules = ((RuleBasedCollator)myCollation).getRules();
          RuleBasedCollator tblColl = null;
          String newRules = defRules + "& Question'-'mark ; '?' & Hash'-'mark ; '#' & Ampersand ; '&";
  
          try {
              tblColl = new RuleBasedCollator(newRules);
              for (int j = 0; j < TOTALTESTSET; j++) {
                  for (int n = j+1; n < TOTALTESTSET; n++) {
-                     doTest(tblColl, testCases[Test3Results[j]],
+                     TestUtils.doCollatorTest(tblColl, testCases[Test3Results[j]],
                             testCases[Test3Results[n]], -1);
                  }
              }
          } catch (Exception foo) {
-             errln("Exception: " + foo.getMessage() +
+             fail("Exception: " + foo.getMessage() +
                    "\nDemo Test 3 Table Collation object creation failed.");
          }
      }
  
      /*
       * Demo Test 4 : Create a new table collation with rules
       *     " & aa ; a'-' & ee ; e'-' & ii ; i'-' & oo ; o'-' & uu ; u'-' "
       */
+     @Test
      public void TestDemoTest4() {
          final Collator myCollation = Collator.getInstance(Locale.US);
          final String defRules = ((RuleBasedCollator)myCollation).getRules();
          RuleBasedCollator tblColl = null;
          String newRules = defRules + " & aa ; a'-' & ee ; e'-' & ii ; i'-' & oo ; o'-' & uu ; u'-' ";
  
          try {
              tblColl = new RuleBasedCollator(newRules);
              for (int j = 0; j < TOTALTESTSET; j++) {
                  for (int n = j+1; n < TOTALTESTSET; n++) {
-                     doTest(tblColl, testCases[Test4Results[j]],
+                     TestUtils.doCollatorTest(tblColl, testCases[Test4Results[j]],
                             testCases[Test4Results[n]], -1);
                  }
              }
          } catch (Exception foo) {
-             errln("Exception: " + foo.getMessage() +
+             fail("Exception: " + foo.getMessage() +
                    "\nDemo Test 4 Table Collation object creation failed.");
          }
          tblColl = null;
      }
  
< prev index next >