BasicConfigurator.resetConfiguration();
BasicConfigurator.configure();
}
protected void runTest() throws Throwable {
Message inputMessage = new Message(new FileInputStream(file));
ByteArrayOutputStream out = new ByteArrayOutputStream();
inputMessage.writeTo(out, MessageUtils.LENIENT);
String msgoutFile = file.getAbsolutePath().substring(0, file.getAbsolutePath().lastIndexOf('.')) + ".out";
String msgoutFileMime4j = file.getAbsolutePath().substring(0, file.getAbsolutePath().lastIndexOf('.')) + ".mime4j.out";
try {
ByteArrayOutputStream expectedstream = new ByteArrayOutputStream();
CodecUtil.copy(new FileInputStream(msgoutFile), expectedstream);
assertEquals("Wrong Expected result", new String(expectedstream.toByteArray()), new String(out.toByteArray()));
Message roundtripMessage = new Message(new FileInputStream(msgoutFile));
ByteArrayOutputStream outRoundtrip = new ByteArrayOutputStream();
roundtripMessage.writeTo(outRoundtrip, MessageUtils.LENIENT);
assertEquals("Failed LENIENT roundtrip", new String(out.toByteArray()), new String(outRoundtrip.toByteArray()));
roundtripMessage = new Message(new FileInputStream(msgoutFile));
outRoundtrip = new ByteArrayOutputStream();
roundtripMessage.writeTo(outRoundtrip, MessageUtils.STRICT_ERROR);
assertEquals("Failed STRICT roundtrip", new String(out.toByteArray()), new String(outRoundtrip.toByteArray()));
} catch (FileNotFoundException e) {
FileOutputStream fos = new FileOutputStream(msgoutFileMime4j);
fos.write(out.toByteArray());