message = new MimeMessage(Session.getDefaultInstance(new Properties()));
message.setSubject("prova");
message.setText("Questa \u00E8 una prova");
message.saveChanges();
mail = new FakeMail(message);
mailet.service(mail);
assertEquals("prova", mail.getMessage().getSubject());
assertEquals("Questa \u00E8 una prova", mail.getMessage().getContent());
// -----------------
message = new MimeMessage(Session.getDefaultInstance(new Properties()));
message.setSubject("prova");
MimeMultipart mp = new MimeMultipart();
MimeBodyPart bp = new MimeBodyPart();
bp.setText("Questo \u00E8 un part interno1");
mp.addBodyPart(bp);
bp = new MimeBodyPart();
bp.setText("Questo \u00E8 un part interno2");
mp.addBodyPart(bp);
bp = new MimeBodyPart();
MimeMessage message2 = new MimeMessage(Session
.getDefaultInstance(new Properties()));
bp.setContent(message2, "message/rfc822");
mp.addBodyPart(bp);
message.setContent(mp);
message.saveChanges();
mail = new FakeMail(message);
mailet.service(mail);
assertEquals("prova", mail.getMessage().getSubject());
assertEquals("Questo \u00E8 un part interno1", mail.getMessage()
.getContent());
// -----------------
message = new MimeMessage(Session.getDefaultInstance(new Properties()));
message.setSubject("prova");
mp = new MimeMultipart();
bp = new MimeBodyPart();
bp.setText("Questo \u00E8 un part interno1");
mp.addBodyPart(bp);
bp = new MimeBodyPart();
bp.setText("Questo \u00E8 un part interno2");
mp.addBodyPart(bp);
bp = new MimeBodyPart();
message2 = new MimeMessage(Session.getDefaultInstance(new Properties()));
bp.setContent(message2, "message/rfc822");
mp.addBodyPart(bp);
MimeMultipart mpext = new MimeMultipart();
bp = new MimeBodyPart();
bp.setContent(mp);
mpext.addBodyPart(bp);
message.setContent(mpext);
message.saveChanges();
mail = new FakeMail(message);
mailet.service(mail);
assertEquals("prova", mail.getMessage().getSubject());
assertEquals("Questo \u00E8 un part interno1", mail.getMessage()
.getContent());
// ---------------------
message = new MimeMessage(Session.getDefaultInstance(new Properties()));
message.setSubject("prova");
message.setContent("<p>Questa \u00E8 una prova<br />di html</p>",
"text/html");
message.saveChanges();
mail = new FakeMail(message);
mailet.service(mail);
assertEquals("prova", mail.getMessage().getSubject());
assertEquals("Questa \u00E8 una prova\ndi html\n", mail.getMessage()
.getContent());
assertTrue(mail.getMessage().isMimeType("text/plain"));
// -----------------
message = new MimeMessage(Session.getDefaultInstance(new Properties()));
message.setSubject("prova");
mp = new MimeMultipart();
bp = new MimeBodyPart();
message2 = new MimeMessage(Session.getDefaultInstance(new Properties()));
bp.setContent(message2, "message/rfc822");
mp.addBodyPart(bp);
bp = new MimeBodyPart();
bp.setContent("<p>Questa \u00E8 una prova<br />di html</p>", "text/html");
mp.addBodyPart(bp);
message.setContent(mp);
message.saveChanges();
mail = new FakeMail(message);
mailet.service(mail);
assertEquals("prova", mail.getMessage().getSubject());
assertEquals("Questa \u00E8 una prova\ndi html\n", mail.getMessage()
.getContent());