String body = servers.util().random();
String to = "test@localhost.com";
servers.util().sendAttachmentEmail(to, "from@localhost.com", subject, body, new byte[]{0, 1, 2}, "image/gif", "testimage_filename", "testimage_description", ServerSetupTest.SMTP);
servers.waitForIncomingEmail(5000, 1);
Retriever retriever = new Retriever(servers.getImap());
Message[] messages = retriever.getMessages(to);
Object o = messages[0].getContent();
assertTrue(o instanceof MimeMultipart);
MimeMultipart mp = (MimeMultipart) o;
assertEquals(2, mp.getCount());
BodyPart bp;
bp = mp.getBodyPart(0);
assertEquals(body, servers.util().getBody(bp).trim());
bp = mp.getBodyPart(1);
assertEquals("AAEC", servers.util().getBody(bp).trim());
ByteArrayOutputStream bout = new ByteArrayOutputStream();
servers.util().copyStream(bp.getInputStream(), bout);
byte[] gif = bout.toByteArray();
for (int i = 0; i < gif.length; i++) {
assertEquals(i, gif[i]);
}
retriever.logout();
}