@SuppressWarnings("restriction") @Test public void test2() throws IOException {
  final int maxLineLen=76 - 1;
  final int maxDataBlockLen=maxLineLen * 3 / 4;
  final sun.misc.BASE64Encoder sunEncoder=new sun.misc.BASE64Encoder();
  final sun.misc.BASE64Decoder sunDecoder=new sun.misc.BASE64Decoder();
  final Random rnd=new Random(0x538afb92);
  for (int i=0; i < 100; i++) {
    final int len=rnd.nextInt(maxDataBlockLen + 1);
    final byte[] b0=new byte[len];
    rnd.nextBytes(b0);
    final String e1=new String(Base64Coder.encode(b0));
    final String e2=sunEncoder.encode(b0);
    assertEquals("test2",e2,e1);
    final byte[] b1=Base64Coder.decode(e1);
    final byte[] b2=sunDecoder.decodeBuffer(e2);
    assertArrayEquals(b0,b1);
    assertArrayEquals(b0,b2);
  }
}

@ SuppressWarnings ( "restriction" ) @ Test public void test2 ( ) throws IOException { final int maxLineLen = 76 - 1 ; final int maxDataBlockLen = maxLineLen * 3 / 4 ; final sun . misc . BASE64Encoder sunEncoder = new sun . misc . BASE64Encoder ( ) ; final sun . misc . BASE64Decoder sunDecoder = new sun . misc . BASE64Decoder ( ) ; final Random rnd = new Random ( 0x538afb92 ) ; for ( int i = 0 ; i < 100 ; i ++ ) { final int len = rnd . nextInt ( maxDataBlockLen + 1 ) ; final byte [ ] b0 = new byte [ len ] ; rnd . nextBytes ( b0 ) ; final String e1 = new String ( Base64Coder . encode ( b0 ) ) ; final String e2 = sunEncoder . encode ( b0 ) ; assertEquals ( "test2" , e2 , e1 ) ; final byte [ ] b1 = Base64Coder . decode ( e1 ) ; final byte [ ] b2 = sunDecoder . decodeBuffer ( e2 ) ; assertArrayEquals ( b0 , b1 ) ; assertArrayEquals ( b0 , b2 ) ; } }
test base64coder against sun . misc . base64encoder / decoder with random data . line length below 76 .
