changeset 10518:57e4d7182890

8055262: Update jdk/test/java/util/Base64 tests to remove use of sun.misc.BASE64Encoder/Decoder Reviewed-by: mchung, sherman Contributed-by: amy.lu@oracle.com
author mchung
date Tue, 19 Aug 2014 12:26:34 -0700
parents c78600cab5ab
children fe18ff3239e4
files test/java/util/Base64/TestBase64.java test/java/util/Base64/TestBase64Golden.java
diffstat 2 files changed, 0 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/test/java/util/Base64/TestBase64.java	Tue Aug 19 10:34:07 2014 -0700
+++ b/test/java/util/Base64/TestBase64.java	Tue Aug 19 12:26:34 2014 -0700
@@ -114,8 +114,6 @@
         testDecodeIgnoredAfterPadding();
     }
 
-    private static sun.misc.BASE64Encoder sunmisc = new sun.misc.BASE64Encoder();
-
     private static void test(Base64.Encoder enc, Base64.Decoder dec,
                              int numRuns, int numBytes) throws Throwable {
         Random rnd = new java.util.Random();
@@ -143,21 +141,6 @@
                             throw new RuntimeException(
                                "Base64 enc.encode().withoutPadding() has padding!");
                     }
-                    // compare to sun.misc.BASE64Encoder
-
-                    byte[] encoded2 = sunmisc.encode(orig).getBytes("ASCII");
-                    if (!withoutPadding) {    // don't test for withoutPadding()
-                        checkEqual(normalize(encoded), normalize(encoded2),
-                                   "Base64 enc.encode() does not match sun.misc.base64!");
-                    }
-                    // remove padding '=' to test non-padding decoding case
-                    if (encoded[encoded.length -2] == '=')
-                        encoded2 = Arrays.copyOf(encoded,  encoded.length -2);
-                    else if (encoded[encoded.length -1] == '=')
-                        encoded2 = Arrays.copyOf(encoded, encoded.length -1);
-                    else
-                        encoded2 = null;
-
                     // --------testing encodetoString(byte[])/decode(String)--------
                     String str = enc.encodeToString(orig);
                     if (!Arrays.equals(str.getBytes("ASCII"), encoded)) {
@@ -167,11 +150,6 @@
                     byte[] buf = dec.decode(new String(encoded, "ASCII"));
                     checkEqual(buf, orig, "Base64 decoding(String) failed!");
 
-                    if (encoded2 != null) {
-                        buf = dec.decode(new String(encoded2, "ASCII"));
-                        checkEqual(buf, orig, "Base64 decoding(String) failed!");
-                    }
-
                     //-------- testing encode/decode(Buffer)--------
                     testEncode(enc, ByteBuffer.wrap(orig), encoded);
                     ByteBuffer bin = ByteBuffer.allocateDirect(orig.length);
@@ -183,9 +161,6 @@
                     bin.put(encoded).flip();
                     testDecode(dec, bin, orig);
 
-                    if (encoded2 != null)
-                        testDecode(dec, ByteBuffer.wrap(encoded2), orig);
-
                     // --------testing decode.wrap(input stream)--------
                     // 1) random buf length
                     ByteArrayInputStream bais = new ByteArrayInputStream(encoded);
--- a/test/java/util/Base64/TestBase64Golden.java	Tue Aug 19 10:34:07 2014 -0700
+++ b/test/java/util/Base64/TestBase64Golden.java	Tue Aug 19 12:26:34 2014 -0700
@@ -40,9 +40,6 @@
 import java.util.Objects;
 import java.util.Random;
 
-import sun.misc.BASE64Decoder;
-import sun.misc.BASE64Encoder;
-
 public class TestBase64Golden {
 
     public static void main(String[] args) throws Exception {
@@ -138,16 +135,6 @@
             resArr = decoder.decode(encodedStr);
             assertEqual(resArr, srcArr);
 
-            // test compatible with sun.misc.Base64Encoder
-            if (type == Base64Type.MIME) {
-                sun.misc.BASE64Encoder miscEncoder = new BASE64Encoder();
-                sun.misc.BASE64Decoder miscDecoder = new BASE64Decoder();
-                resArr = decoder.decode(miscEncoder.encode(srcArr));
-                assertEqual(resArr, srcArr);
-
-                resArr = encoder.encode(miscDecoder.decodeBuffer(encodedStr));
-                assertEqual(new String(resArr, DEF_CHARSET), encodedStr);
-            }
         }
     }