mp3.setFileName("temp.zip");
mm.addBodyPart(mp3);
message.setSubject("test");
message.setContent(mm);
message.saveChanges();
Mail mail = new FakeMail();
mail.setMessage(message);
assertTrue(mail.getMessage().getContent() instanceof MimeMultipart);
assertEquals(3, ((MimeMultipart) mail.getMessage().getContent())
.getCount());
strip.service(mail);
assertTrue(mail.getMessage().getContent() instanceof MimeMultipart);
assertEquals(1, ((MimeMultipart) mail.getMessage().getContent())
.getCount());
onlyText.service(mail);
assertFalse(mail.getMessage().getContent() instanceof MimeMultipart);
assertEquals("simple text", mail.getMessage().getContent());
// prova per caricare il mime message da input stream che altrimenti
// javamail si comporta differentemente.
String mimeSource = "Message-ID: <26194423.21197328775426.JavaMail.bago@bagovista>\r\nSubject: test\r\nMIME-Version: 1.0\r\nContent-Type: text/plain; charset=us-ascii\r\nContent-Transfer-Encoding: 7bit\r\n\r\nsimple text";
MimeMessage mmNew = new MimeMessage(Session
.getDefaultInstance(new Properties()),
new ByteArrayInputStream(mimeSource.getBytes("UTF-8")));
mmNew.writeTo(System.out);
mail.setMessage(mmNew);
recover.service(mail);
assertTrue(mail.getMessage().getContent() instanceof MimeMultipart);
assertEquals(2, ((MimeMultipart) mail.getMessage().getContent())
.getCount());
Object actual = ((MimeMultipart) mail.getMessage().getContent())
.getBodyPart(1).getContent();
if (actual instanceof ByteArrayInputStream) {
assertEquals(body2, toString((ByteArrayInputStream) actual));
} else {
assertEquals(body2, actual);