< prev index next >

test/jdk/java/util/Locale/LocaleEnhanceTest.java

Print this page
*** 1,7 ***
  /*
!  * Copyright (c) 2010, 2022, 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) 2010, 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.

*** 39,28 ***
  import java.util.List;
  import java.util.Locale;
  import java.util.Locale.Builder;
  import java.util.Set;
  
  /**
   * @test
   * @bug 6875847 6992272 7002320 7015500 7023613 7032820 7033504 7004603
   *    7044019 8008577 8176853 8255086 8263202 8287868
   * @summary test API changes to Locale
-  * @library /java/text/testlib
   * @modules jdk.localedata
   * @compile LocaleEnhanceTest.java
!  * @run main/othervm -Djava.locale.providers=JRE,SPI -esa LocaleEnhanceTest
   */
! public class LocaleEnhanceTest extends IntlTest {
- 
-     public static void main(String[] args) throws Exception {
-         List<String> argList = new ArrayList<String>();
-         argList.addAll(Arrays.asList(args));
-         argList.add("-nothrow");
-         new LocaleEnhanceTest().run(argList.toArray(new String[argList.size()]));
-     }
  
      public LocaleEnhanceTest() {
      }
  
      ///
--- 39,24 ---
  import java.util.List;
  import java.util.Locale;
  import java.util.Locale.Builder;
  import java.util.Set;
  
+ import org.junit.jupiter.api.Test;
+ 
+ import static org.junit.jupiter.api.Assertions.fail;
+ 
  /**
   * @test
   * @bug 6875847 6992272 7002320 7015500 7023613 7032820 7033504 7004603
   *    7044019 8008577 8176853 8255086 8263202 8287868
   * @summary test API changes to Locale
   * @modules jdk.localedata
   * @compile LocaleEnhanceTest.java
!  * @run junit/othervm -Djava.locale.providers=JRE,SPI -esa LocaleEnhanceTest
   */
! public class LocaleEnhanceTest {
  
      public LocaleEnhanceTest() {
      }
  
      ///

*** 81,10 ***
--- 77,11 ---
  
      /**
       * Ensure that Builder builds locales that have the expected
       * tag and java6 ID.  Note the odd cases for the ID.
       */
+     @Test
      public void testCreateLocaleCanonicalValid() {
          String[] valids = {
              "en-Latn-US-NewYork", "en_US_NewYork_#Latn",
              "en-Latn-US", "en_US_#Latn",
              "en-Latn-NewYork", "en__NewYork_#Latn", // double underscore

*** 129,11 ***
                  assertEquals(msg + "variant", idv, l.getVariant());
                  assertEquals(msg + "tag", tag, l.toLanguageTag());
                  assertEquals(msg + "id", id, l.toString());
              }
              catch (IllegalArgumentException e) {
!                 errln(msg + e.getMessage());
              }
          }
      }
  
      /**
--- 126,11 ---
                  assertEquals(msg + "variant", idv, l.getVariant());
                  assertEquals(msg + "tag", tag, l.toLanguageTag());
                  assertEquals(msg + "id", id, l.toString());
              }
              catch (IllegalArgumentException e) {
!                 fail(msg + e.getMessage());
              }
          }
      }
  
      /**

*** 144,10 ***
--- 141,11 ---
       * subtag by omitting empty subtags and joining the remainer
       * with underscores.  So the resulting variant tag is "Newer_Yorker".
       * Note that 'New' and 'York' are invalid BCP47 variant subtags
       * because they are too short.
       */
+     @Test
      public void testCreateLocaleMultipleVariants() {
  
          String[] valids = {
              "en-Latn-US-Newer-Yorker",  "en_US_Newer_Yorker_#Latn",
              "en-Latn-Newer-Yorker",     "en__Newer_Yorker_#Latn",

*** 186,19 ***
  
                  assertEquals(msg + "tag", tag, l.toLanguageTag());
                  assertEquals(msg + "id", id, l.toString());
              }
              catch (IllegalArgumentException e) {
!                 errln(msg + e.getMessage());
              }
          }
      }
  
      /**
       * Ensure that all these invalid formats are not recognized by
       * forLanguageTag.
       */
      public void testCreateLocaleCanonicalInvalidSeparator() {
          String[] invalids = {
              // trailing separator
              "en_Latn_US_NewYork_",
              "en_Latn_US_",
--- 184,20 ---
  
                  assertEquals(msg + "tag", tag, l.toLanguageTag());
                  assertEquals(msg + "id", id, l.toString());
              }
              catch (IllegalArgumentException e) {
!                 fail(msg + e.getMessage());
              }
          }
      }
  
      /**
       * Ensure that all these invalid formats are not recognized by
       * forLanguageTag.
       */
+     @Test
      public void testCreateLocaleCanonicalInvalidSeparator() {
          String[] invalids = {
              // trailing separator
              "en_Latn_US_NewYork_",
              "en_Latn_US_",

*** 238,10 ***
--- 237,11 ---
  
      /**
       * Ensure that all current locale ids parse.  Use DateFormat as a proxy
       * for all current locale ids.
       */
+     @Test
      public void testCurrentLocales() {
          Locale[] locales = java.text.DateFormat.getAvailableLocales();
          Builder builder = new Builder();
  
          for (Locale target : locales) {

*** 264,10 ***
--- 264,11 ---
      }
  
      /**
       * Ensure that all icu locale ids parse.
       */
+     @Test
      public void testIcuLocales() throws Exception {
          BufferedReader br = new BufferedReader(
              new InputStreamReader(
                  LocaleEnhanceTest.class.getResourceAsStream("icuLocales.txt"),
                  "UTF-8"));

*** 280,10 ***
--- 281,11 ---
  
      ///
      /// Compatibility tests
      ///
  
+     @Test
      public void testConstructor() {
          // all the old weirdness still holds, no new weirdness
          String[][] tests = {
              // language to lower case, region to upper, variant unchanged
              // short

*** 318,10 ***
--- 320,11 ---
  
      ///
      /// Locale API tests.
      ///
  
+     @Test
      public void testGetScript() {
          // forLanguageTag normalizes case
          Locale locale = Locale.forLanguageTag("und-latn");
          assertEquals("forLanguageTag", "Latn", locale.getScript());
  

*** 332,10 ***
--- 335,11 ---
          // empty string is returned, not null, if there is no script
          locale = Locale.forLanguageTag("und");
          assertEquals("script is empty string", "", locale.getScript());
      }
  
+     @Test
      public void testGetExtension() {
          // forLanguageTag does NOT normalize to hyphen
          Locale locale = Locale.forLanguageTag("und-a-some_ex-tension");
          assertEquals("some_ex-tension", null, locale.getExtension('a'));
  

*** 352,30 ***
          // 'x' is not an extension, it's a private use tag, but it's accessed through this API
          locale = Locale.forLanguageTag("x-y-z-blork");
          assertEquals("x", "y-z-blork", locale.getExtension('x'));
      }
  
      public void testGetExtensionKeys() {
          Locale locale = Locale.forLanguageTag("und-a-xx-yy-b-zz-ww");
          Set<Character> result = locale.getExtensionKeys();
          assertEquals("result size", 2, result.size());
          assertTrue("'a','b'", result.contains('a') && result.contains('b'));
  
          // result is not mutable
          try {
              result.add('x');
!             errln("expected exception on add to extension key set");
          }
          catch (UnsupportedOperationException e) {
              // ok
          }
  
          // returns empty set if no extensions
          locale = Locale.forLanguageTag("und");
          assertTrue("empty result", locale.getExtensionKeys().isEmpty());
      }
  
      public void testGetUnicodeLocaleAttributes() {
          Locale locale = Locale.forLanguageTag("en-US-u-abc-def");
          Set<String> attributes = locale.getUnicodeLocaleAttributes();
          assertEquals("number of attributes", 2, attributes.size());
          assertTrue("attribute abc", attributes.contains("abc"));
--- 356,32 ---
          // 'x' is not an extension, it's a private use tag, but it's accessed through this API
          locale = Locale.forLanguageTag("x-y-z-blork");
          assertEquals("x", "y-z-blork", locale.getExtension('x'));
      }
  
+     @Test
      public void testGetExtensionKeys() {
          Locale locale = Locale.forLanguageTag("und-a-xx-yy-b-zz-ww");
          Set<Character> result = locale.getExtensionKeys();
          assertEquals("result size", 2, result.size());
          assertTrue("'a','b'", result.contains('a') && result.contains('b'));
  
          // result is not mutable
          try {
              result.add('x');
!             fail("expected exception on add to extension key set");
          }
          catch (UnsupportedOperationException e) {
              // ok
          }
  
          // returns empty set if no extensions
          locale = Locale.forLanguageTag("und");
          assertTrue("empty result", locale.getExtensionKeys().isEmpty());
      }
  
+     @Test
      public void testGetUnicodeLocaleAttributes() {
          Locale locale = Locale.forLanguageTag("en-US-u-abc-def");
          Set<String> attributes = locale.getUnicodeLocaleAttributes();
          assertEquals("number of attributes", 2, attributes.size());
          assertTrue("attribute abc", attributes.contains("abc"));

*** 384,10 ***
--- 390,11 ---
          locale = Locale.forLanguageTag("en-US-u-ca-gregory");
          attributes = locale.getUnicodeLocaleAttributes();
          assertTrue("empty attributes", attributes.isEmpty());
      }
  
+     @Test
      public void testGetUnicodeLocaleType() {
          Locale locale = Locale.forLanguageTag("und-u-co-japanese-nu-thai");
          assertEquals("collation", "japanese", locale.getUnicodeLocaleType("co"));
          assertEquals("numbers", "thai", locale.getUnicodeLocaleType("nu"));
  

*** 411,34 ***
  
          // null argument throws exception
          new ExpectNPE() { public void call() { Locale.forLanguageTag("").getUnicodeLocaleType(null); }};
      }
  
      public void testGetUnicodeLocaleKeys() {
          Locale locale = Locale.forLanguageTag("und-u-co-japanese-nu-thai");
          Set<String> result = locale.getUnicodeLocaleKeys();
          assertEquals("two keys", 2, result.size());
          assertTrue("co and nu", result.contains("co") && result.contains("nu"));
  
          // result is not modifiable
          try {
              result.add("frobozz");
!             errln("expected exception when add to locale key set");
          }
          catch (UnsupportedOperationException e) {
              // ok
          }
      }
  
      public void testPrivateUseExtension() {
          Locale locale = Locale.forLanguageTag("x-y-x-blork-");
          assertEquals("blork", "y-x-blork", locale.getExtension(Locale.PRIVATE_USE_EXTENSION));
  
          locale = Locale.forLanguageTag("und");
          assertEquals("no privateuse", null, locale.getExtension(Locale.PRIVATE_USE_EXTENSION));
      }
  
      public void testToLanguageTag() {
          // lots of normalization to test here
          // test locales created using the constructor
          String[][] tests = {
              // empty locale canonicalizes to 'und'
--- 418,37 ---
  
          // null argument throws exception
          new ExpectNPE() { public void call() { Locale.forLanguageTag("").getUnicodeLocaleType(null); }};
      }
  
+     @Test
      public void testGetUnicodeLocaleKeys() {
          Locale locale = Locale.forLanguageTag("und-u-co-japanese-nu-thai");
          Set<String> result = locale.getUnicodeLocaleKeys();
          assertEquals("two keys", 2, result.size());
          assertTrue("co and nu", result.contains("co") && result.contains("nu"));
  
          // result is not modifiable
          try {
              result.add("frobozz");
!             fail("expected exception when add to locale key set");
          }
          catch (UnsupportedOperationException e) {
              // ok
          }
      }
  
+     @Test
      public void testPrivateUseExtension() {
          Locale locale = Locale.forLanguageTag("x-y-x-blork-");
          assertEquals("blork", "y-x-blork", locale.getExtension(Locale.PRIVATE_USE_EXTENSION));
  
          locale = Locale.forLanguageTag("und");
          assertEquals("no privateuse", null, locale.getExtension(Locale.PRIVATE_USE_EXTENSION));
      }
  
+     @Test
      public void testToLanguageTag() {
          // lots of normalization to test here
          // test locales created using the constructor
          String[][] tests = {
              // empty locale canonicalizes to 'und'

*** 500,10 ***
--- 510,11 ---
              assertEquals("case " + test[0], test[1], locale.toLanguageTag());
          }
  
      }
  
+     @Test
      public void testForLanguageTag() {
          // forLanguageTag implements the 'Language-Tag' production of
          // BCP47, so it handles private use and legacy language tags,
          // unlike locale builder.  Tags listed below (except for the
          // sample private use tags) come from 4646bis Feb 29, 2009.

*** 587,11 ***
              try {
                  Locale locale = Locale.forLanguageTag(test[1]);
                  assertEquals(msg, test[2], locale.toLanguageTag());
              }
              catch (IllegalArgumentException e) {
!                 errln(msg + " caught exception: " + e);
              }
          }
  
          // duplicated extension are just ignored
          Locale locale = Locale.forLanguageTag("und-d-aa-00-bb-01-D-AA-10-cc-11-c-1234");
--- 598,11 ---
              try {
                  Locale locale = Locale.forLanguageTag(test[1]);
                  assertEquals(msg, test[2], locale.toLanguageTag());
              }
              catch (IllegalArgumentException e) {
!                 fail(msg + " caught exception: " + e);
              }
          }
  
          // duplicated extension are just ignored
          Locale locale = Locale.forLanguageTag("und-d-aa-00-bb-01-D-AA-10-cc-11-c-1234");

*** 605,10 ***
--- 616,11 ---
          locale = Locale.forLanguageTag("und-u-aa-000-bb-001-bB-002-cc-003-c-1234");
          assertEquals("Unicode keywords", "aa-000-bb-001-cc-003", locale.getExtension(Locale.UNICODE_LOCALE_EXTENSION));
          assertEquals("Duplicated Unicode locake key followed by an extension", "1234", locale.getExtension('c'));
      }
  
+     @Test
      public void testGetDisplayScript() {
          Locale latnLocale = Locale.forLanguageTag("und-latn");
          Locale hansLocale = Locale.forLanguageTag("und-hans");
  
          Locale oldLocale = Locale.getDefault();

*** 622,10 ***
--- 634,11 ---
          assertEquals("hans DE", "Vereinfacht", hansLocale.getDisplayScript());
  
          Locale.setDefault(oldLocale);
      }
  
+     @Test
      public void testGetDisplayScriptWithLocale() {
          Locale latnLocale = Locale.forLanguageTag("und-latn");
          Locale hansLocale = Locale.forLanguageTag("und-hans");
  
          assertEquals("latn US", "Latin", latnLocale.getDisplayScript(Locale.US));

*** 633,10 ***
--- 646,11 ---
  
          assertEquals("latn DE", "Lateinisch", latnLocale.getDisplayScript(Locale.GERMANY));
          assertEquals("hans DE", "Vereinfacht", hansLocale.getDisplayScript(Locale.GERMANY));
      }
  
+     @Test
      public void testGetDisplayName() {
          final Locale[] testLocales = {
                  Locale.ROOT,
                  Locale.ENGLISH,
                  Locale.US,

*** 686,10 ***
--- 700,11 ---
  
      ///
      /// Builder tests
      ///
  
+     @Test
      public void testBuilderSetLocale() {
          Builder builder = new Builder();
          Builder lenientBuilder = new Builder();
  
          String languageTag = "en-Latn-US-NewYork-a-bb-ccc-u-co-japanese-x-y-z";

*** 728,10 ***
--- 743,11 ---
                  b.setLocale(Locale.of("123", "4567", "89"));
              }
          };
      }
  
+     @Test
      public void testBuilderSetLanguageTag() {
          String source = "eN-LaTn-Us-NewYork-A-Xx-B-Yy-X-1-2-3";
          String target = "en-Latn-US-NewYork-a-xx-b-yy-x-1-2-3";
          Builder builder = new Builder();
          String result = builder

*** 745,10 ***
--- 761,11 ---
  
          // redundant Unicode locale extension keys within an Unicode locale extension cause a failure
          new BuilderILE() { public void call() { b.setLanguageTag("und-u-nu-thai-NU-chinese-xx-1234"); }};
      }
  
+     @Test
      public void testBuilderSetLanguage() {
          // language is normalized to lower case
          String source = "eN";
          String target = "en";
          String defaulted = "";

*** 790,10 ***
--- 807,11 ---
              .build()
              .getLanguage();
          assertEquals("eng", "eng", result);
      }
  
+     @Test
      public void testBuilderSetScript() {
          // script is normalized to title case
          String source = "lAtN";
          String target = "Latn";
          String defaulted = "";

*** 826,10 ***
--- 844,11 ---
  
          // script code validation is NOT performed, any 4-alpha passes
          assertEquals("4alpha", "Wxyz", builder.setScript("wxyz").build().getScript());
      }
  
+     @Test
      public void testBuilderSetRegion() {
          // region is normalized to upper case
          String source = "uS";
          String target = "US";
          String defaulted = "";

*** 863,10 ***
--- 882,11 ---
          // region code validation is NOT performed, any 2-alpha or 3-digit passes
          assertEquals("2alpha", "ZZ", builder.setRegion("ZZ").build().getCountry());
          assertEquals("3digit", "000", builder.setRegion("000").build().getCountry());
      }
  
+     @Test
      public void testBuilderSetVariant() {
          // Variant case is not normalized in lenient variant mode
          String source = "NewYork";
          String target = source;
          String defaulted = "";

*** 915,10 ***
--- 935,11 ---
  
          // all subfields must conform
          new BuilderILE("abcde-fg") { public void call() { b.setVariant(arg); }};
      }
  
+     @Test
      public void testBuilderSetExtension() {
          // upper case characters are normalized to lower case
          final char sourceKey = 'a';
          final String sourceValue = "aB-aBcdefgh-12-12345678";
          String target = "ab-abcdefgh-12-12345678";

*** 1005,10 ***
--- 1026,11 ---
              .build()
              .toLanguageTag();
          assertEquals("duplicate keys", "und-u-nu-thai-xx-1234", result);
      }
  
+     @Test
      public void testBuilderAddUnicodeLocaleAttribute() {
          Builder builder = new Builder();
          Locale locale = builder
              .addUnicodeLocaleAttribute("def")
              .addUnicodeLocaleAttribute("abc")

*** 1036,10 ***
--- 1058,11 ---
  
          // illformed attribute throws IllformedLocaleException
          new BuilderILE("invalid attribute") { public void call() { b.addUnicodeLocaleAttribute("ca"); }};
      }
  
+     @Test
      public void testBuildersetUnicodeLocaleKeyword() {
          // Note: most behavior is tested in testBuilderSetExtension
          Builder builder = new Builder();
          Locale locale = builder
              .setUnicodeLocaleKeyword("co", "japanese")

*** 1079,10 ***
--- 1102,11 ---
  
          // well-formed values are 3-8 alphanum
          new BuilderILE("ab", "abcdefghi") { public void call() { b.setUnicodeLocaleKeyword("ab", arg); }};
      }
  
+     @Test
      public void testBuilderPrivateUseExtension() {
          // normalizes hyphens to underscore, case to lower
          String source = "c-B-a";
          String target = "c-b-a";
          Builder builder = new Builder();

*** 1094,10 ***
--- 1118,11 ---
  
          // multiple hyphens are ill-formed
          new BuilderILE("a--b") { public void call() { b.setExtension(Locale.PRIVATE_USE_EXTENSION, arg); }};
      }
  
+     @Test
      public void testBuilderClear() {
          String monster = "en-latn-US-NewYork-a-bb-cc-u-co-japanese-x-z-y-x-x";
          Builder builder = new Builder();
          Locale locale = Locale.forLanguageTag(monster);
          String result = builder

*** 1106,18 ***
--- 1131,21 ---
              .build()
              .toLanguageTag();
          assertEquals("clear", "und", result);
      }
  
+     @Test
      public void testBuilderRemoveUnicodeAttribute() {
          // tested in testBuilderAddUnicodeAttribute
      }
  
+     @Test
      public void testBuilderBuild() {
          // tested in other test methods
      }
  
+     @Test
      public void testSerialize() {
          final Locale[] testLocales = {
              Locale.ROOT,
              Locale.ENGLISH,
              Locale.US,

*** 1159,15 ***
                  ObjectInputStream ois = new ObjectInputStream(bis);
                  Object o = ois.readObject();
  
                  assertEquals("roundtrip " + locale, locale, o);
              } catch (Exception e) {
!                 errln(locale + " encountered exception:" + e.getLocalizedMessage());
              }
          }
      }
  
      public void testDeserialize6() {
          final String TESTFILEPREFIX = "java6locale_";
  
          File dataDir = null;
          String dataDirName = System.getProperty("serialized.data.dir");
--- 1187,16 ---
                  ObjectInputStream ois = new ObjectInputStream(bis);
                  Object o = ois.readObject();
  
                  assertEquals("roundtrip " + locale, locale, o);
              } catch (Exception e) {
!                 fail(locale + " encountered exception:" + e.getLocalizedMessage());
              }
          }
      }
  
+     @Test
      public void testDeserialize6() {
          final String TESTFILEPREFIX = "java6locale_";
  
          File dataDir = null;
          String dataDirName = System.getProperty("serialized.data.dir");

*** 1182,14 ***
          } else {
              dataDir = new File(dataDirName);
          }
  
          if (dataDir == null) {
!             errln("'dataDir' is null. serialized.data.dir Property value is "+dataDirName);
              return;
          } else if (!dataDir.isDirectory()) {
!             errln("'dataDir' is not a directory. dataDir: "+dataDir.toString());
              return;
          }
  
          File[] files = dataDir.listFiles();
          for (File testfile : files) {
--- 1211,14 ---
          } else {
              dataDir = new File(dataDirName);
          }
  
          if (dataDir == null) {
!             fail("'dataDir' is null. serialized.data.dir Property value is "+dataDirName);
              return;
          } else if (!dataDir.isDirectory()) {
!             fail("'dataDir' is not a directory. dataDir: "+dataDir.toString());
              return;
          }
  
          File[] files = dataDir.listFiles();
          for (File testfile : files) {

*** 1217,15 ***
                   ObjectInputStream ois = new ObjectInputStream(fis))
              {
                  Object o = ois.readObject();
                  assertEquals("Deserialize Java 6 Locale " + locale, o, locale);
              } catch (Exception e) {
!                 errln("Exception while reading " + testfile.getAbsolutePath() + " - " + e.getMessage());
              }
          }
      }
  
      public void testBug7002320() {
          // forLanguageTag() and Builder.setLanguageTag(String)
          // should add a location extension for following two cases.
          //
          // 1. language/country are "ja"/"JP" and the resolved variant (x-lvariant-*)
--- 1246,16 ---
                   ObjectInputStream ois = new ObjectInputStream(fis))
              {
                  Object o = ois.readObject();
                  assertEquals("Deserialize Java 6 Locale " + locale, o, locale);
              } catch (Exception e) {
!                 fail("Exception while reading " + testfile.getAbsolutePath() + " - " + e.getMessage());
              }
          }
      }
  
+     @Test
      public void testBug7002320() {
          // forLanguageTag() and Builder.setLanguageTag(String)
          // should add a location extension for following two cases.
          //
          // 1. language/country are "ja"/"JP" and the resolved variant (x-lvariant-*)

*** 1265,10 ***
--- 1295,11 ---
              out = loc.toLanguageTag();
              assertEquals("Language tag roundtrip by Builder.setLanguageTag with input: " + in, expected, out);
          }
      }
  
+     @Test
      public void testBug7023613() {
          String[][] testdata = {
              {"en-Latn", "en__#Latn"},
              {"en-u-ca-japanese", "en__#u-ca-japanese"},
          };

*** 1284,10 ***
--- 1315,11 ---
      }
  
      /*
       * 7033504: (lc) incompatible behavior change for ja_JP_JP and th_TH_TH locales
       */
+     @Test
      public void testBug7033504() {
          checkCalendar(Locale.of("ja", "JP", "jp"), "java.util.GregorianCalendar");
          checkCalendar(Locale.of("ja", "jp", "jp"), "java.util.GregorianCalendar");
          checkCalendar(Locale.of("ja", "JP", "JP"), "java.util.JapaneseImperialCalendar");
          checkCalendar(Locale.of("ja", "jp", "JP"), "java.util.JapaneseImperialCalendar");

*** 1316,17 ***
      /// utility asserts
      ///
  
      private void assertTrue(String msg, boolean v) {
          if (!v) {
!             errln(msg + ": expected true");
          }
      }
  
      private void assertFalse(String msg, boolean v) {
          if (v) {
!             errln(msg + ": expected false");
          }
      }
  
      private void assertEquals(String msg, Object e, Object v) {
          if (e == null ? v != null : !e.equals(v)) {
--- 1348,17 ---
      /// utility asserts
      ///
  
      private void assertTrue(String msg, boolean v) {
          if (!v) {
!             fail(msg + ": expected true");
          }
      }
  
      private void assertFalse(String msg, boolean v) {
          if (v) {
!             fail(msg + ": expected false");
          }
      }
  
      private void assertEquals(String msg, Object e, Object v) {
          if (e == null ? v != null : !e.equals(v)) {

*** 1334,32 ***
                  e = "'" + e + "'";
              }
              if (v != null) {
                  v = "'" + v + "'";
              }
!             errln(msg + ": expected " + e + " but got " + v);
          }
      }
  
      private void assertNotEquals(String msg, Object e, Object v) {
          if (e == null ? v == null : e.equals(v)) {
              if (e != null) {
                  e = "'" + e + "'";
              }
!             errln(msg + ": expected not equal " + e);
          }
      }
  
      private void assertNull(String msg, Object o) {
          if (o != null) {
!             errln(msg + ": expected null but got '" + o + "'");
          }
      }
  
      private void assertNotNull(String msg, Object o) {
          if (o == null) {
!             errln(msg + ": expected non null");
          }
      }
  
      // not currently used, might get rid of exceptions from the API
      private abstract class ExceptionTest {
--- 1366,32 ---
                  e = "'" + e + "'";
              }
              if (v != null) {
                  v = "'" + v + "'";
              }
!             fail(msg + ": expected " + e + " but got " + v);
          }
      }
  
      private void assertNotEquals(String msg, Object e, Object v) {
          if (e == null ? v == null : e.equals(v)) {
              if (e != null) {
                  e = "'" + e + "'";
              }
!             fail(msg + ": expected not equal " + e);
          }
      }
  
      private void assertNull(String msg, Object o) {
          if (o != null) {
!             fail(msg + ": expected null but got '" + o + "'");
          }
      }
  
      private void assertNotNull(String msg, Object o) {
          if (o == null) {
!             fail(msg + ": expected non null");
          }
      }
  
      // not currently used, might get rid of exceptions from the API
      private abstract class ExceptionTest {

*** 1381,11 ***
                  }
              }
              if (failMsg != null) {
                  String msg = message();
                  msg = msg == null ? "" : msg + " ";
!                 errln(msg + failMsg);
              }
          }
  
          public String message() {
              return null;
--- 1413,11 ---
                  }
              }
              if (failMsg != null) {
                  String msg = message();
                  msg = msg == null ? "" : msg + " ";
!                 fail(msg + failMsg);
              }
          }
  
          public String message() {
              return null;
< prev index next >