< prev index next >

test/sun/nio/cs/TestISO2022JP.java

Print this page
rev 13451 : 8211382: ISO2022JP and GB18030 NIO converter issues
Reviewed-by: sherman, rriggs

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2018, 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.

@@ -20,11 +20,11 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
 
 /* @test
-   @bug 4626545 4879522 4913711 4119445
+   @bug 4626545 4879522 4913711 4119445 8211382
    @summary Check full coverage encode/decode for ISO-2022-JP
  */
 
 /*
  * Tests the NIO converter for J2RE >= 1.4.1

@@ -606,7 +606,20 @@
         byte[] encoded = testStr3.getBytes("ISO-2022-JP");
         for (int i = 0; i < expected.length; i++) {
             if (encoded[i] != expected[i])
                throw new Exception("ISO-2022-JP Decoder error");
         }
+
+        // Test for 11 iso2022jp decoder
+        encoded = new byte[] {
+            (byte)0x1B, (byte)0x28, (byte)0x49, (byte)0x60,
+            (byte)0x1B, (byte)0x28, (byte)0x42,
+        };
+        String unexpectedStr = "\uffa0";
+        String expectedStr = "\ufffd";
+        if (new String(encoded, "ISO2022JP").equals(unexpectedStr)) {
+               throw new Exception("ISO2022JP Decoder error: \\uFFA0");
+        } else if (!new String(encoded, "ISO2022JP").equals(expectedStr)) {
+               throw new Exception("ISO2022JP Decoder error: \\uFFFD");
+        }
     }
 }
< prev index next >