Exemplo n.º 1
0
 @Test
 public void testBase64Long() throws Exception {
   // This one has spaces in it
   byte[] bytes = Base64.decode(longMsg);
   assertNotNull(bytes);
   byte[] encBytes = Base64.encode(bytes, false);
   String str1 = new String(encBytes);
   String str2 = new String(longMsg);
   // Should not be same, str2 has blanks in it
   assertFalse(str1 == str2);
   str2 = StringUtils.deleteWhitespace(str2);
   // now it should be same
   assertEquals(str1, str2);
 }
Exemplo n.º 2
0
 @Test
 public void testBase64Small() throws Exception {
   // Testcert is on long line of base 64 encoded stuff
   byte[] certBytes = Base64.decode(testcert_oneline.getBytes());
   assertNotNull(certBytes);
   // This should be a cert
   Certificate cert = CertTools.getCertfromByteArray(certBytes);
   assertNotNull(cert);
   // Base64 encode it again
   byte[] encBytes = Base64.encode(cert.getEncoded(), false);
   assertEquals(new String(encBytes), testcert_oneline);
   // Testcert_crlf has \n after each line
   certBytes = Base64.decode(testcert_crlf.getBytes());
   assertNotNull(certBytes);
   // This should be a cert
   cert = CertTools.getCertfromByteArray(certBytes);
   assertNotNull(cert);
   // Base64 encode it again
   encBytes = Base64.encode(cert.getEncoded(), true);
   assertEquals(new String(encBytes), testcert_crlf);
   // This is the same method as above
   encBytes = Base64.encode(cert.getEncoded());
   assertEquals(new String(encBytes), testcert_crlf);
 }