]> granicus.if.org Git - icu/commitdiff
ICU-8557 Skipping a couple of spoof checker test cases on IBM Java 5 because of UTF...
authorYoshito Umaoka <y.umaoka@gmail.com>
Wed, 11 May 2011 02:11:17 +0000 (02:11 +0000)
committerYoshito Umaoka <y.umaoka@gmail.com>
Wed, 11 May 2011 02:11:17 +0000 (02:11 +0000)
X-SVN-Rev: 30090

icu4j/main/tests/core/src/com/ibm/icu/dev/test/text/SpoofCheckerTest.java
icu4j/main/tests/framework/src/com/ibm/icu/dev/test/TestUtil.java

index a1f58471d00ce49f3376a33b468a62fac1b39026..17972cd91115eee715e057bb356d6919ba3cb0d7 100644 (file)
@@ -17,6 +17,7 @@ import java.util.regex.Pattern;
 
 import com.ibm.icu.dev.test.TestFmwk;
 import com.ibm.icu.dev.test.TestUtil;
+import com.ibm.icu.dev.test.TestUtil.JavaVendor;
 import com.ibm.icu.impl.Utility;
 import com.ibm.icu.text.Normalizer2;
 import com.ibm.icu.text.SpoofChecker;
@@ -100,6 +101,11 @@ public class SpoofCheckerTest extends TestFmwk {
      * Test build from source rules.
      */
     public void TestOpenFromSourceRules() {
+        if (TestUtil.getJavaVendor() == JavaVendor.IBM && TestUtil.getJavaVersion() == 5) {
+            // Note: IBM Java 5 has a bug reading a large UTF-8 text contents
+            logln("Skip this test case because of the IBM Java 5 bug");
+            return;
+        }
         setup();
         String fileName;
         Reader confusables;
@@ -501,6 +507,11 @@ public class SpoofCheckerTest extends TestFmwk {
     // Verify that each item from the Unicode confusables.txt file
     // transforms into the expected skeleton.
     public void testConfData() {
+        if (TestUtil.getJavaVendor() == JavaVendor.IBM && TestUtil.getJavaVersion() == 5) {
+            // Note: IBM Java 5 has a bug reading a large UTF-8 text contents
+            logln("Skip this test case because of the IBM Java 5 bug");
+            return;
+        }
         try {
             // Read in the confusables.txt file. (Distributed by Unicode.org)
             String fileName = "unicode/confusables.txt";
index d9e72489ef2e907a2a5fef6d01a29452a1ce0ba2..fbb3946dba51e445689834fe1614ff3d970a736b 100644 (file)
@@ -1,6 +1,6 @@
 /**
  *******************************************************************************
- * Copyright (C) 2001-2009, International Business Machines Corporation and    *
+ * Copyright (C) 2001-2011, International Business Machines Corporation and    *
  * others. All Rights Reserved.                                                *
  *******************************************************************************
  */
@@ -12,6 +12,7 @@ import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.util.Locale;
 
 public final class TestUtil {
     /**
@@ -208,4 +209,34 @@ public final class TestUtil {
             4*1024);
     }
 
+    public enum JavaVendor {
+        Unknown,
+        Oracle,
+        IBM
+    }
+
+    public static JavaVendor getJavaVendor() {
+        JavaVendor vendor = JavaVendor.Unknown;
+        String javaVendorProp = System.getProperty("java.vendor", "").toLowerCase(Locale.US).trim();
+        if (javaVendorProp.startsWith("ibm")) {
+            vendor = JavaVendor.IBM;
+        } else if (javaVendorProp.startsWith("sun") || javaVendorProp.startsWith("oracle")) {
+            vendor = JavaVendor.Oracle;
+        }
+        return vendor;
+    }
+
+    public static int getJavaVersion() {
+        int ver = -1;
+        String verstr = System.getProperty("java.version");
+        if (verstr != null) {
+            String[] numbers = verstr.split("\\.");
+            try {
+                ver = Integer.parseInt(numbers[1]);
+            } catch (NumberFormatException e) {
+                ver = -1;
+            }
+        }
+        return ver;
+    }
 }