MimeMultipart multi = (MimeMultipart)o;
int numOfParts = multi.getCount();
boolean hasTheAttachment = false;
for (int i = 0; i < numOfParts; i++) {
BodyPart bp = multi.getBodyPart(i);
String disp = bp.getDisposition();
if (disp == null) { //the body of the email
Object innerContent = bp.getContent();
MimeMultipart innerMulti = (MimeMultipart)innerContent;
assertEquals(emailBody, innerMulti.getBodyPart(0).getContent());
} else if (disp.equals(Part.ATTACHMENT)) { //the attachment to the email
hasTheAttachment = true;
assertEquals(ATTACHMENT_NAME, bp.getFileName());
} else {
fail("Did not expect to be able to get here.");
}
}
assertTrue(hasTheAttachment);