### Question:
Base64 { public static String encode(byte[] rawData) { ifNull(rawData); StringBuilder buffer = new StringBuilder(4 * rawData.length / 3); int pos = 0; int iterations = rawData.length / 3; for (int i=0; i < iterations; i++) { int value = ((rawData[pos++] & 0xFF) << 16) | ((rawData[pos++] & 0xFF) << 8) | (rawData[pos++] & 0xFF); buffer.append(BASE64_ALPHABET[(value >>> 18) & 0x3F]); buffer.append(BASE64_ALPHABET[(value >>> 12) & 0x3F]); buffer.append(BASE64_ALPHABET[(value >>> 6) & 0x3F]); buffer.append(BASE64_ALPHABET[value & 0x3F]); } switch (rawData.length % 3) { case 1: buffer.append(BASE64_ALPHABET[(rawData[pos] >>> 2) & 0x3F]); buffer.append(BASE64_ALPHABET[(rawData[pos] << 4) & 0x3F]); buffer.append("=="); break; case 2: int value = ((rawData[pos++] & 0xFF) << 8) | (rawData[pos] & 0xFF); buffer.append(BASE64_ALPHABET[(value >>> 10) & 0x3F]); buffer.append(BASE64_ALPHABET[(value >>> 4) & 0x3F]); buffer.append(BASE64_ALPHABET[(value << 2) & 0x3F]); buffer.append("="); break; } return buffer.toString(); } private  Base64(); static String encode(byte[] rawData); static String encode(ByteSequence rawData); static byte[] decode(String encodedData); static void main(String[] args);  }### Answer:
@Test(dataProvider = "validData") public void testEncode(String hexData, String encodedData) throws Exception { byte[] data = getBytes(hexData); String base64 = Base64.encode(data); Assert.assertEquals(base64, encodedData); }