if (getName().startsWith("malformedHeaderStartsBody")) {
config.setMalformedHeaderStartsBody(true);
}
config.setMaxLineLen(-1);
DefaultMessageBuilder builder = new DefaultMessageBuilder();
DefaultMessageWriter writer = new DefaultMessageWriter();
builder.setMimeEntityConfig(config);
Message inputMessage = builder.parseMessage(url.openStream());
ByteArrayOutputStream out = new ByteArrayOutputStream();
writer.writeMessage(inputMessage, out);
String s = url.toString();
URL msgout = new URL(s.substring(0, s.lastIndexOf('.')) + ".out");
try {
ByteArrayOutputStream expectedstream = new ByteArrayOutputStream();
CodecUtil.copy(msgout.openStream(), expectedstream);
assertEquals("Wrong Expected result", new String(expectedstream.toByteArray()), new String(out.toByteArray()));
} catch (FileNotFoundException e) {
FileOutputStream fos = new FileOutputStream(msgout.getPath()+".expected");
writer.writeMessage(inputMessage, fos);
fos.close();
fail("Expected file created");
}
}