@@ -41,16 +41,22 @@ public void testEncodeBytes() throws IOException {
4141 Assert .assertEquals ("" , Base64 .encodeBytes (new byte [0 ]));
4242 Assert .assertEquals ("QHE=" ,
4343 Base64 .encodeBytes (new byte []{49 , 121 , 64 , 113 , -63 , 43 , -24 , 62 , 4 , 48 }, 2 , 2 , 0 ));
44- Assert . assertEquals ( "H4sIAAAAAAAAADMEALfv3IMBAAAA " ,
44+ assertGzipEncodedBytes ( "H4sIAAAAAAAA" , "MEALfv3IMBAAAA " ,
4545 Base64 .encodeBytes (new byte []{49 , 121 , 64 , 113 , -63 , 43 , -24 , 62 , 4 , 48 }, 0 , 1 , 6 ));
46- Assert . assertEquals ( "H4sIAAAAAAAAAHMoBABQHKKWAgAAAA ==" ,
46+ assertGzipEncodedBytes ( "H4sIAAAAAAAA" , "MoBABQHKKWAgAAAA ==" ,
4747 Base64 .encodeBytes (new byte []{49 , 121 , 64 , 113 , -63 , 43 , -24 , 62 , 4 , 48 }, 2 , 2 , 18 ));
4848 Assert .assertEquals ("F63=" ,
4949 Base64 .encodeBytes (new byte []{49 , 121 , 64 , 113 , 63 , 43 , -24 , 62 , 4 , 48 }, 2 , 2 , 32 ));
50- Assert . assertEquals ("6sg7---------6Bc0 -0F699L-V----==" ,
50+ assertGzipEncodedBytes ("6sg7--------" , "Bc0 -0F699L-V----==" ,
5151 Base64 .encodeBytes (new byte []{49 , 121 , 64 , 113 , 63 , 43 , -24 , 62 , 4 , 48 }, 2 , 2 , 34 ));
5252 }
5353
54+ // see https://bugs.openjdk.org/browse/JDK-8253142
55+ private void assertGzipEncodedBytes (String expectedPrefix , String expectedSuffix , String actual ) {
56+ Assert .assertTrue (actual .startsWith (expectedPrefix ));
57+ Assert .assertTrue (actual .endsWith (expectedSuffix ));
58+ }
59+
5460 @ Test
5561 public void testEncodeBytes2 () throws IOException {
5662 thrown .expect (IllegalArgumentException .class );
0 commit comments