String testheader = headerName + ": " + headerValue;
byte[] inputByte = getRawMessageAsByteArray();
DefaultMessageBuilder builder = new DefaultMessageBuilder();
DefaultMessageWriter writer = new DefaultMessageWriter();
Message m = builder.parseMessage(new ByteArrayInputStream(inputByte));
m.getHeader().addField(DefaultFieldParser.parse(testheader));
assertEquals("header added", m.getHeader().getField(headerName)
.getBody(), headerValue);
ByteArrayOutputStream out = new ByteArrayOutputStream();
writer.writeMessage(m, out);
List<?> lines = IOUtils.readLines((new BufferedReader(
new InputStreamReader(new ByteArrayInputStream(out
.toByteArray())))));
assertTrue("header added", lines.contains(testheader));