예제 #1
0
  /**
   * Encodes a sample string, decodes it and makes sure that the decoded string has the same value
   * as the original
   */
  public void testEncodeDecode() {
    String data = "string to encode";
    byte[] expectedReturn = data.getBytes();

    byte[] encodedData = base64.encode(data.getBytes());
    byte[] actualReturn = base64.decode(encodedData);
    assertTrue("encode decode failed.", Arrays.equals(expectedReturn, actualReturn));
  }
예제 #2
0
  /**
   * Encodes a sample string, decodes it and makes sure that the decoded string has the same value
   * as the original
   */
  public void testEncodeDecode1() {
    String data = "string to encode";
    byte[] expectedReturn = data.getBytes();

    byte[] encodedData = base64.encode(data.getBytes());

    String encodedString = new String(encodedData);

    byte[] actualReturn = base64.decode(encodedString);
    assertTrue("encode decode failed.", Arrays.equals(expectedReturn, actualReturn));

    assertEquals("Original and destination string do not match", data, new String(actualReturn));
  }