private static void assertEncoded(String clearText, String encoded) throws Exception { byte[] expected = clearText.getBytes(US_ASCII_CHARSET); ByteArrayOutputStream out = new ByteArrayOutputStream(encoded.length()); byte[] encodedData = encoded.getBytes(US_ASCII_CHARSET); Base64Decoder.decode(encodedData, out); byte[] actual = out.toByteArray(); assertArrayEquals(expected, actual); }
@Test(expected = IOException.class) public void truncatedString() throws Exception { final byte[] x = new byte[]{'n'}; Base64Decoder.decode(x, new ByteArrayOutputStream()); }
Base64Decoder.decode(encodedData, out); } else if (encoding.equals(QUOTEDPRINTABLE_ENCODING_MARKER)) { // maybe quoted printable. QuotedPrintableDecoder.decode(encodedData, out);
private static void assertIOException(String messageText, String encoded) throws UnsupportedEncodingException { ByteArrayOutputStream out = new ByteArrayOutputStream(encoded.length()); byte[] encodedData = encoded.getBytes(US_ASCII_CHARSET); try { Base64Decoder.decode(encodedData, out); fail("Expected IOException"); } catch (IOException e) { String em = e.getMessage(); assertTrue("Expected to find " + messageText + " in '" + em + "'",em.contains(messageText)); } }
Base64Decoder.decode(encodedData, out); } else if (encoding.equals(QUOTEDPRINTABLE_ENCODING_MARKER)) { // maybe quoted printable. QuotedPrintableDecoder.decode(encodedData, out);
Base64Decoder.decode(encodedData, out); } else if (encoding.equals(QUOTEDPRINTABLE_ENCODING_MARKER)) { // maybe quoted printable. QuotedPrintableDecoder.decode(encodedData, out);