@Test public void string_base64_encode_java_8() { String levelUpLunchURL = "http://leveluplunch.com/examples/?parm=This parameter"; String encodedURL = java.util.Base64.getEncoder().encodeToString( levelUpLunchURL.getBytes()); assertEquals( "aHR0cDovL2xldmVsdXBsdW5jaC5jb20vZXhhbXBsZXMvP3Bhcm09VGhpcyBwYXJhbWV0ZXI=", encodedURL); }
@Test public void string_base64_encode_guava() { String levelUpLunchURL = "http://leveluplunch.com/examples/?parm=This parameter"; String encodedURL = BaseEncoding.base64Url().encode( levelUpLunchURL.getBytes()); assertEquals( "aHR0cDovL2xldmVsdXBsdW5jaC5jb20vZXhhbXBsZXMvP3Bhcm09VGhpcyBwYXJhbWV0ZXI=", encodedURL); }
@Test public void string_base64_encoding_apache() { String levelUpLunchURL = "http://leveluplunch.com/examples/?parm=This parameter"; String encodedURL = Base64.encodeBase64URLSafeString(levelUpLunchURL .getBytes()); assertEquals( "aHR0cDovL2xldmVsdXBsdW5jaC5jb20vZXhhbXBsZXMvP3Bhcm09VGhpcyBwYXJhbWV0ZXI", encodedURL); }