BasicConfigurator.configure();
}
public void testDecode() throws IOException, UnsupportedEncodingException {
ByteArrayInputStream bis = null;
QuotedPrintableInputStream decoder = null;
bis = new ByteArrayInputStream("=e1=e2=E3=E4\r\n".getBytes("US-ASCII"));
decoder = new QuotedPrintableInputStream(bis);
assertEquals("\u00e1\u00e2\u00e3\u00e4\r\n", new String(read(decoder), "ISO8859-1"));
bis = new ByteArrayInputStream("=e1=g2=E3=E4\r\n".getBytes("US-ASCII"));
decoder = new QuotedPrintableInputStream(bis);
assertEquals("\u00e1=g2\u00e3\u00e4\r\n", new String(read(decoder), "ISO8859-1"));
bis = new ByteArrayInputStream(" =e1 =e2 =E3\t=E4 \t \t \r\n".getBytes("US-ASCII"));
decoder = new QuotedPrintableInputStream(bis);
assertEquals(" \u00e1 \u00e2 \u00e3\t\u00e4\r\n", new String(read(decoder), "ISO8859-1"));
/*
* Test soft line breaks.
*/
bis = new ByteArrayInputStream("Soft line = \t \r\nHard line \r\n".getBytes("US-ASCII"));
decoder = new QuotedPrintableInputStream(bis);
assertEquals("Soft line Hard line\r\n", new String(read(decoder), "ISO8859-1"));
/*
* This isn't valid qp (==) but it is known to occur in certain
* messages, especially spam.
*/
bis = new ByteArrayInputStream("width==\r\n340 height=3d200\r\n".getBytes("US-ASCII"));
decoder = new QuotedPrintableInputStream(bis);
assertEquals("width=340 height=200\r\n", new String(read(decoder), "ISO8859-1"));
}