http://git-wip-us.apache.org/repos/asf/james-project/blob/7244396c/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/NotifyMailetsMessageTest.java
----------------------------------------------------------------------
diff --git 
a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/NotifyMailetsMessageTest.java
 
b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/NotifyMailetsMessageTest.java
index a2fcb53..439c3d3 100644
--- 
a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/NotifyMailetsMessageTest.java
+++ 
b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/NotifyMailetsMessageTest.java
@@ -23,27 +23,22 @@ import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
-import java.io.ByteArrayInputStream;
 import java.util.Optional;
-import java.util.Properties;
 import java.util.TimeZone;
 
-import javax.mail.Message.RecipientType;
 import javax.mail.MessagingException;
-import javax.mail.Session;
-import javax.mail.internet.InternetAddress;
 import javax.mail.internet.MimeMessage;
 
 import org.apache.james.core.MailAddress;
+import org.apache.james.core.builder.MimeMessageBuilder;
 import org.apache.mailet.Mail;
 import org.apache.mailet.base.test.FakeMail;
+import org.apache.mailet.base.test.MimeMessageUtil;
 import org.joda.time.DateTime;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
-import com.google.common.collect.ImmutableList;
-
 public class NotifyMailetsMessageTest {
 
     private TimeZone timeZone;
@@ -61,42 +56,35 @@ public class NotifyMailetsMessageTest {
 
     @Test
     public void generateMessageShouldReturnTheMessageWhenSimpleMimeMessage() 
throws Exception {
-        MimeMessage message = new MimeMessage(Session.getDefaultInstance(new 
Properties()));
         FakeMail mail = FakeMail.builder()
-                .mimeMessage(message)
+                .mimeMessage(MimeMessageBuilder.mimeMessageBuilder())
                 .sender(new MailAddress("user", "james.org"))
                 .build();
 
         String generateMessage = new 
NotifyMailetsMessage().generateMessage("my message", mail);
 
-        assertThat(generateMessage).isEqualTo("my message\n" +
-                "\n" +
-                "Message details:\n" +
-                "  MAIL FROM: u...@james.org\n");
+        assertThat(generateMessage).contains("my message\n")
+            .contains("Message details:")
+            .contains("  MAIL FROM: u...@james.org\n");
     }
 
     @Test
     public void generateMessageShouldAddErrorMessageWhenMimeMessageAsSome() 
throws Exception {
-        MimeMessage message = new MimeMessage(Session.getDefaultInstance(new 
Properties()));
-        FakeMail mail = FakeMail.from(message);
-        mail.setErrorMessage("error message");
+        FakeMail mail = FakeMail.from(MimeMessageBuilder.mimeMessageBuilder());
+        String myErrorMessage = "my error message";
+        mail.setErrorMessage(myErrorMessage);
 
         String generateMessage = new 
NotifyMailetsMessage().generateMessage("my message", mail);
 
-        assertThat(generateMessage).isEqualTo("my message\n" +
-                "\n" +
+        assertThat(generateMessage).contains(
                 "Error message below:\n" +
-                "error message\n" +
-                "\n" +
-                "Message details:\n" +
-                "  MAIL FROM: null\n");
+                "my error message\n");
     }
 
     @Test
     public void generateMessageShouldAddSubjectWhenMimeMessageAsSome() throws 
Exception {
-        MimeMessage message = new MimeMessage(Session.getDefaultInstance(new 
Properties()));
-        message.setSubject("my subject");
-        FakeMail mail = FakeMail.from(message);
+        FakeMail mail = FakeMail.from(MimeMessageBuilder.mimeMessageBuilder()
+            .setSubject("my subject"));
 
         String generateMessage = new 
NotifyMailetsMessage().generateMessage("my message", mail);
 
@@ -105,7 +93,7 @@ public class NotifyMailetsMessageTest {
 
     @Test
     public void generateMessageShouldAddSentDateWhenMimeMessageAsSome() throws 
Exception {
-        MimeMessage message = new MimeMessage(Session.getDefaultInstance(new 
Properties()));
+        MimeMessage message = MimeMessageUtil.defaultMimeMessage();
         
message.setSentDate(DateTime.parse("2016-09-08T14:25:52.000Z").toDate());
         FakeMail mail = FakeMail.from(message);
 
@@ -116,9 +104,10 @@ public class NotifyMailetsMessageTest {
 
     @Test
     public void generateMessageShouldAddRecipientsWhenMimeMessageAsSome() 
throws Exception {
-        MimeMessage message = new MimeMessage(Session.getDefaultInstance(new 
Properties()));
-        FakeMail mail = FakeMail.from(message);
-        mail.setRecipients(ImmutableList.of(new MailAddress("user", 
"james.org"), new MailAddress("user2", "james.org")));
+        FakeMail mail = FakeMail.builder()
+            .mimeMessage(MimeMessageBuilder.mimeMessageBuilder())
+            .recipients("u...@james.org", "us...@james.org")
+            .build();
 
         String generateMessage = new 
NotifyMailetsMessage().generateMessage("my message", mail);
 
@@ -128,9 +117,8 @@ public class NotifyMailetsMessageTest {
 
     @Test
     public void generateMessageShouldAddFromWhenMimeMessageAsSome() throws 
Exception {
-        MimeMessage message = new MimeMessage(Session.getDefaultInstance(new 
Properties()));
-        message.setFrom(new InternetAddress("u...@james.org"));
-        FakeMail mail = FakeMail.from(message);
+        FakeMail mail = FakeMail.from(MimeMessageBuilder.mimeMessageBuilder()
+            .addFrom("u...@james.org"));
 
         String generateMessage = new 
NotifyMailetsMessage().generateMessage("my message", mail);
 
@@ -140,9 +128,8 @@ public class NotifyMailetsMessageTest {
 
     @Test
     public void generateMessageShouldAddToWhenMimeMessageAsSome() throws 
Exception {
-        MimeMessage message = new MimeMessage(Session.getDefaultInstance(new 
Properties()));
-        message.setRecipients(RecipientType.TO, new InternetAddress[] { new 
InternetAddress("u...@james.org"), new InternetAddress("us...@james.org") });
-        FakeMail mail = FakeMail.from(message);
+        FakeMail mail = FakeMail.from(MimeMessageBuilder.mimeMessageBuilder()
+            .addToRecipient("u...@james.org", "us...@james.org"));
 
         String generateMessage = new 
NotifyMailetsMessage().generateMessage("my message", mail);
 
@@ -153,9 +140,8 @@ public class NotifyMailetsMessageTest {
 
     @Test
     public void generateMessageShouldAddCCWhenMimeMessageAsSome() throws 
Exception {
-        MimeMessage message = new MimeMessage(Session.getDefaultInstance(new 
Properties()));
-        message.setRecipients(RecipientType.CC, new InternetAddress[] { new 
InternetAddress("u...@james.org"), new InternetAddress("us...@james.org") });
-        FakeMail mail = FakeMail.from(message);
+        FakeMail mail = FakeMail.from(MimeMessageBuilder.mimeMessageBuilder()
+            .addCcRecipient("u...@james.org", "us...@james.org"));
 
         String generateMessage = new 
NotifyMailetsMessage().generateMessage("my message", mail);
 
@@ -166,12 +152,7 @@ public class NotifyMailetsMessageTest {
 
     @Test
     public void generateMessageShouldAddSizeWhenPossible() throws Exception {
-        String content = "MIME-Version: 1.0\r\n" +
-                "Content-Type: text/plain; charset=utf-8\r\n" +
-                "\r\n" +
-                "test\r\n";
-        MimeMessage message = new MimeMessage(Session.getDefaultInstance(new 
Properties()), new ByteArrayInputStream(content.getBytes()));
-        FakeMail mail = FakeMail.from(message);
+        FakeMail mail = FakeMail.from(MimeMessageBuilder.mimeMessageBuilder());
         mail.setMessageSize(6);
 
         String generateMessage = new 
NotifyMailetsMessage().generateMessage("my message", mail);
@@ -186,8 +167,8 @@ public class NotifyMailetsMessageTest {
             "\r\n" +
             "test\r\n";
 
-        MimeMessage message = new MimeMessage(Session.getDefaultInstance(new 
Properties()), new ByteArrayInputStream(content.getBytes()));
-        FakeMail mail = FakeMail.from(message);
+
+        FakeMail mail = 
FakeMail.from(MimeMessageUtil.mimeMessageFromString(content));
         mail.setMessageSize((long)(5.9 * 1024));
 
         String generateMessage = new 
NotifyMailetsMessage().generateMessage("my message", mail);
@@ -241,8 +222,7 @@ public class NotifyMailetsMessageTest {
             "\r\n" +
             "test\r\n";
 
-        MimeMessage message = new MimeMessage(Session.getDefaultInstance(new 
Properties()), new ByteArrayInputStream(content.getBytes()));
-        FakeMail mail = FakeMail.from(message);
+        FakeMail mail = 
FakeMail.from(MimeMessageUtil.mimeMessageFromString(content));
 
         String generateMessage = new 
NotifyMailetsMessage().generateMessage("my message", mail);
 
@@ -257,8 +237,7 @@ public class NotifyMailetsMessageTest {
             "\r\n" +
             "test\r\n";
 
-        MimeMessage message = new MimeMessage(Session.getDefaultInstance(new 
Properties()), new ByteArrayInputStream(content.getBytes()));
-        FakeMail mail = FakeMail.from(message);
+        FakeMail mail = 
FakeMail.from(MimeMessageUtil.mimeMessageFromString(content));
 
         String generateMessage = new 
NotifyMailetsMessage().generateMessage("my message", mail);
 
@@ -274,8 +253,7 @@ public class NotifyMailetsMessageTest {
             "\r\n" +
             "test\r\n";
 
-        MimeMessage message = new MimeMessage(Session.getDefaultInstance(new 
Properties()), new ByteArrayInputStream(content.getBytes()));
-        FakeMail mail = FakeMail.from(message);
+        FakeMail mail = 
FakeMail.from(MimeMessageUtil.mimeMessageFromString(content));
 
         String generateMessage = new 
NotifyMailetsMessage().generateMessage("my message", mail);
 
@@ -291,8 +269,7 @@ public class NotifyMailetsMessageTest {
             "\r\n" +
             "test\r\n";
 
-        MimeMessage message = new MimeMessage(Session.getDefaultInstance(new 
Properties()), new ByteArrayInputStream(content.getBytes()));
-        FakeMail mail = FakeMail.from(message);
+        FakeMail mail = 
FakeMail.from(MimeMessageUtil.mimeMessageFromString(content));
 
         String generateMessage = new 
NotifyMailetsMessage().generateMessage("my message", mail);
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/7244396c/server/mailet/mailets/src/test/java/org/apache/james/transport/util/RecipientsUtilsTest.java
----------------------------------------------------------------------
diff --git 
a/server/mailet/mailets/src/test/java/org/apache/james/transport/util/RecipientsUtilsTest.java
 
b/server/mailet/mailets/src/test/java/org/apache/james/transport/util/RecipientsUtilsTest.java
index a993fa9..04224d1 100644
--- 
a/server/mailet/mailets/src/test/java/org/apache/james/transport/util/RecipientsUtilsTest.java
+++ 
b/server/mailet/mailets/src/test/java/org/apache/james/transport/util/RecipientsUtilsTest.java
@@ -23,13 +23,9 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 import java.util.List;
-import java.util.Properties;
-
-import javax.mail.Session;
-import javax.mail.internet.MimeMessage;
-import javax.mail.internet.MimeMessage.RecipientType;
 
 import org.apache.james.core.MailAddress;
+import org.apache.james.core.builder.MimeMessageBuilder;
 import org.apache.james.transport.mailets.redirect.RedirectNotify;
 import org.apache.james.transport.mailets.redirect.SpecialAddress;
 import org.apache.mailet.base.test.FakeMail;
@@ -103,15 +99,16 @@ public class RecipientsUtilsTest {
         when(mailet.getRecipients())
             .thenReturn(ImmutableList.of(SpecialAddress.FROM, 
SpecialAddress.TO));
 
-        MimeMessage mimeMessage = new 
MimeMessage(Session.getDefaultInstance(new Properties()));
-        mimeMessage.setRecipients(RecipientType.TO, "t...@james.org, 
t...@james.org");
         MailAddress from = new MailAddress("from", "james.org");
         MailAddress to = new MailAddress("to", "james.org");
         MailAddress to2 = new MailAddress("to2", "james.org");
         FakeMail fakeMail = FakeMail.builder()
                 .sender(from)
                 .recipients(to, to2)
-                .mimeMessage(mimeMessage)
+                .mimeMessage(MimeMessageBuilder.mimeMessageBuilder()
+                    .addToRecipient(to.asString(), to2.asString())
+                    .addFrom(from.asString())
+                    .build())
                 .build();
 
         List<MailAddress> recipients = testee.getRecipients(fakeMail);

http://git-wip-us.apache.org/repos/asf/james-project/blob/7244396c/server/mailet/mailets/src/test/java/org/apache/james/transport/util/SpecialAddressesUtilsTest.java
----------------------------------------------------------------------
diff --git 
a/server/mailet/mailets/src/test/java/org/apache/james/transport/util/SpecialAddressesUtilsTest.java
 
b/server/mailet/mailets/src/test/java/org/apache/james/transport/util/SpecialAddressesUtilsTest.java
index b7d50c8..636d729 100644
--- 
a/server/mailet/mailets/src/test/java/org/apache/james/transport/util/SpecialAddressesUtilsTest.java
+++ 
b/server/mailet/mailets/src/test/java/org/apache/james/transport/util/SpecialAddressesUtilsTest.java
@@ -25,19 +25,18 @@ import static org.mockito.Mockito.when;
 import java.util.Collection;
 import java.util.List;
 import java.util.Optional;
-import java.util.Properties;
 
-import javax.mail.Session;
 import javax.mail.internet.InternetAddress;
 import javax.mail.internet.MimeMessage;
 
 import org.apache.james.core.MailAddress;
+import org.apache.james.core.builder.MimeMessageBuilder;
 import org.apache.james.transport.mailets.redirect.RedirectNotify;
 import org.apache.james.transport.mailets.redirect.SpecialAddress;
 import org.apache.mailet.MailetContext;
 import org.apache.mailet.base.MailAddressFixture;
-import org.apache.mailet.base.RFC2822Headers;
 import org.apache.mailet.base.test.FakeMail;
+import org.apache.mailet.base.test.MimeMessageUtil;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
@@ -126,8 +125,7 @@ public class SpecialAddressesUtilsTest {
 
     @Test
     public void 
replaceMailAddressesShouldReturnEmptyWhenAddressesMatchReplyToAndReplyToIsNull()
 throws Exception {
-        MimeMessage message = new MimeMessage(Session.getDefaultInstance(new 
Properties()));
-        FakeMail mail = FakeMail.from(message);
+        FakeMail mail = FakeMail.from(MimeMessageBuilder.mimeMessageBuilder());
 
         Collection<MailAddress> addresses = 
testee.replaceSpecialAddresses(mail, ImmutableList.of(SpecialAddress.REPLY_TO));
 
@@ -136,7 +134,7 @@ public class SpecialAddressesUtilsTest {
 
     @Test
     public void 
replaceMailAddressesShouldReturnReplyToWhenAddressesMatchReplyTo() throws 
Exception {
-        MimeMessage message = new MimeMessage(Session.getDefaultInstance(new 
Properties()));
+        MimeMessage message = MimeMessageUtil.defaultMimeMessage();
         
message.setReplyTo(InternetAddress.parse(MailAddressFixture.ANY_AT_JAMES.toString()
 + ", " + MailAddressFixture.OTHER_AT_JAMES.toString()));
         FakeMail mail = FakeMail.from(message);
 
@@ -153,7 +151,7 @@ public class SpecialAddressesUtilsTest {
         MailAddress sender = MailAddressFixture.ANY_AT_JAMES;
         FakeMail mail = FakeMail.builder()
                 .sender(sender)
-                .mimeMessage(new MimeMessage(Session.getDefaultInstance(new 
Properties())))
+                .mimeMessage(MimeMessageBuilder.mimeMessageBuilder())
                 .build();
 
         Collection<MailAddress> addresses = 
testee.replaceSpecialAddresses(mail, ImmutableList.of(SpecialAddress.REPLY_TO));
@@ -292,9 +290,8 @@ public class SpecialAddressesUtilsTest {
     public void 
replaceInternetAddressesShouldReturnFromWhenAddressesMatchFrom() throws 
Exception {
         MailAddress from = MailAddressFixture.ANY_AT_JAMES;
         MailAddress from2 = MailAddressFixture.OTHER_AT_JAMES;
-        MimeMessage message = new MimeMessage(Session.getDefaultInstance(new 
Properties()));
-        message.addFrom(new InternetAddress[] { from.toInternetAddress(), 
from2.toInternetAddress() });
-        FakeMail mail = FakeMail.from(message);
+        FakeMail mail = FakeMail.from(MimeMessageBuilder.mimeMessageBuilder()
+            .addFrom(from.toInternetAddress(), from2.toInternetAddress()));
 
         List<MailAddress> addresses = testee.replaceInternetAddresses(mail, 
ImmutableList.of(SpecialAddress.FROM.toInternetAddress()));
 
@@ -305,7 +302,7 @@ public class SpecialAddressesUtilsTest {
     public void 
replaceInternetAddressesShouldReturnSenderWhenAddressesMatchFromAndNoFrom() 
throws Exception {
         MailAddress sender = MailAddressFixture.ANY_AT_JAMES;
         FakeMail mail = FakeMail.builder()
-                .mimeMessage(new MimeMessage(Session.getDefaultInstance(new 
Properties())))
+                .mimeMessage(MimeMessageBuilder.mimeMessageBuilder())
                 .sender(sender)
                 .build();
 
@@ -326,8 +323,7 @@ public class SpecialAddressesUtilsTest {
 
     @Test
     public void 
replaceInternetAddressesShouldReturnEmptyWhenAddressesMatchReplyToAndReplyToIsNull()
 throws Exception {
-        MimeMessage message = new MimeMessage(Session.getDefaultInstance(new 
Properties()));
-        FakeMail mail = FakeMail.from(message);
+        FakeMail mail = FakeMail.from(MimeMessageBuilder.mimeMessageBuilder());
 
         List<MailAddress> addresses = testee.replaceInternetAddresses(mail, 
ImmutableList.of(SpecialAddress.REPLY_TO.toInternetAddress()));
 
@@ -336,7 +332,7 @@ public class SpecialAddressesUtilsTest {
 
     @Test
     public void 
replaceInternetAddressesShouldReturnReplyToWhenAddressesMatchReplyTo() throws 
Exception {
-        MimeMessage message = new MimeMessage(Session.getDefaultInstance(new 
Properties()));
+        MimeMessage message = MimeMessageUtil.defaultMimeMessage();
         
message.setReplyTo(InternetAddress.parse(MailAddressFixture.ANY_AT_JAMES.toString()
 + ", " + MailAddressFixture.OTHER_AT_JAMES.toString()));
         FakeMail mail = FakeMail.from(message);
 
@@ -353,7 +349,7 @@ public class SpecialAddressesUtilsTest {
         MailAddress sender = MailAddressFixture.ANY_AT_JAMES;
         FakeMail mail = FakeMail.builder()
                 .sender(sender)
-                .mimeMessage(new MimeMessage(Session.getDefaultInstance(new 
Properties())))
+                .mimeMessage(MimeMessageBuilder.mimeMessageBuilder())
                 .build();
 
         List<MailAddress> addresses = testee.replaceInternetAddresses(mail, 
ImmutableList.of(SpecialAddress.REPLY_TO.toInternetAddress()));
@@ -387,9 +383,8 @@ public class SpecialAddressesUtilsTest {
     public void 
replaceInternetAddressesShouldReturnToWhenAddressesMatchRecipients() throws 
Exception {
         MailAddress to = MailAddressFixture.ANY_AT_JAMES;
         MailAddress to2 = MailAddressFixture.OTHER_AT_JAMES;
-        MimeMessage message = new MimeMessage(Session.getDefaultInstance(new 
Properties()));
-        message.addHeader(RFC2822Headers.TO, 
MailAddressFixture.ANY_AT_JAMES.toString() + ", " + 
MailAddressFixture.OTHER_AT_JAMES.toString());
-        FakeMail mail = FakeMail.from(message);
+        FakeMail mail = FakeMail.from(MimeMessageBuilder.mimeMessageBuilder()
+            .addToRecipient(to.asString(), to2.asString()));
 
         List<MailAddress> addresses = testee.replaceInternetAddresses(mail, 
ImmutableList.of(SpecialAddress.RECIPIENTS.toInternetAddress()));
 
@@ -400,9 +395,8 @@ public class SpecialAddressesUtilsTest {
     public void replaceInternetAddressesShouldReturnToWhenAddressesMatchTo() 
throws Exception {
         MailAddress to = MailAddressFixture.ANY_AT_JAMES;
         MailAddress to2 = MailAddressFixture.OTHER_AT_JAMES;
-        MimeMessage message = new MimeMessage(Session.getDefaultInstance(new 
Properties()));
-        message.addHeader(RFC2822Headers.TO, 
MailAddressFixture.ANY_AT_JAMES.toString() + ", " + 
MailAddressFixture.OTHER_AT_JAMES);
-        FakeMail mail = FakeMail.from(message);
+        FakeMail mail = FakeMail.from(MimeMessageBuilder.mimeMessageBuilder()
+            .addToRecipient(to.asString(), to2.asString()));
 
         List<MailAddress> addresses = testee.replaceInternetAddresses(mail, 
ImmutableList.of(SpecialAddress.TO.toInternetAddress()));
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/7244396c/server/mailet/mailets/src/test/java/org/apache/james/transport/util/TosUtilsTest.java
----------------------------------------------------------------------
diff --git 
a/server/mailet/mailets/src/test/java/org/apache/james/transport/util/TosUtilsTest.java
 
b/server/mailet/mailets/src/test/java/org/apache/james/transport/util/TosUtilsTest.java
index ff229ef..f7b276a 100644
--- 
a/server/mailet/mailets/src/test/java/org/apache/james/transport/util/TosUtilsTest.java
+++ 
b/server/mailet/mailets/src/test/java/org/apache/james/transport/util/TosUtilsTest.java
@@ -23,14 +23,11 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 import java.util.List;
-import java.util.Properties;
 
-import javax.mail.Session;
 import javax.mail.internet.InternetAddress;
-import javax.mail.internet.MimeMessage;
-import javax.mail.internet.MimeMessage.RecipientType;
 
 import org.apache.james.core.MailAddress;
+import org.apache.james.core.builder.MimeMessageBuilder;
 import org.apache.james.transport.mailets.redirect.RedirectNotify;
 import org.apache.james.transport.mailets.redirect.SpecialAddress;
 import org.apache.mailet.base.test.FakeMail;
@@ -106,15 +103,14 @@ public class TosUtilsTest {
         when(mailet.getTo())
             
.thenReturn(ImmutableList.of(SpecialAddress.FROM.toInternetAddress(), 
SpecialAddress.TO.toInternetAddress()));
 
-        MimeMessage mimeMessage = new 
MimeMessage(Session.getDefaultInstance(new Properties()));
-        mimeMessage.setRecipients(RecipientType.TO, "t...@james.org, 
t...@james.org");
         MailAddress from = new MailAddress("from", "james.org");
         MailAddress toMailAddress = new MailAddress("to", "james.org");
         MailAddress toMailAddress2 = new MailAddress("to2", "james.org");
         FakeMail fakeMail = FakeMail.builder()
                 .sender(from)
                 .recipients(toMailAddress, toMailAddress2)
-                .mimeMessage(mimeMessage)
+                .mimeMessage(MimeMessageBuilder.mimeMessageBuilder()
+                    .addToRecipient("t...@james.org", "t...@james.org"))
                 .build();
 
         List<MailAddress> to = testee.getTo(fakeMail);

http://git-wip-us.apache.org/repos/asf/james-project/blob/7244396c/server/protocols/jmap/src/test/java/org/apache/james/jmap/mailet/TextCalendarBodyToAttachmentTest.java
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap/src/test/java/org/apache/james/jmap/mailet/TextCalendarBodyToAttachmentTest.java
 
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/mailet/TextCalendarBodyToAttachmentTest.java
index 1ebd61c..1dc3357 100644
--- 
a/server/protocols/jmap/src/test/java/org/apache/james/jmap/mailet/TextCalendarBodyToAttachmentTest.java
+++ 
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/mailet/TextCalendarBodyToAttachmentTest.java
@@ -24,9 +24,6 @@ import static org.mockito.Matchers.anyString;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
-import java.io.ByteArrayInputStream;
-import java.nio.charset.StandardCharsets;
-
 import javax.mail.BodyPart;
 import javax.mail.MessagingException;
 import javax.mail.Multipart;
@@ -91,7 +88,7 @@ public class TextCalendarBodyToAttachmentTest {
             "Content-transfer-encoding: 8BIT\n" +
             "\n" +
             "BEGIN:VCALENDAR";
-        MimeMessage message = MimeMessageUtil.mimeMessageFromStream(new 
ByteArrayInputStream(messageContent.getBytes(StandardCharsets.US_ASCII)));
+        MimeMessage message = 
MimeMessageUtil.mimeMessageFromString(messageContent);
 
         Mail mail = FakeMail.builder()
             .mimeMessage(message)
@@ -109,7 +106,7 @@ public class TextCalendarBodyToAttachmentTest {
             "Content-transfer-encoding: 8BIT\n" +
             "\n" +
             "BEGIN:VCALENDAR";
-        MimeMessage message = MimeMessageUtil.mimeMessageFromStream(new 
ByteArrayInputStream(messageContent.getBytes(StandardCharsets.US_ASCII)));
+        MimeMessage message = 
MimeMessageUtil.mimeMessageFromString(messageContent);
 
         Mail mail = FakeMail.builder()
             .mimeMessage(message)
@@ -128,7 +125,7 @@ public class TextCalendarBodyToAttachmentTest {
             "BEGIN:VCALENDAR\n" +
             "END:VEVENT\n" +
             "END:VCALENDAR";
-        MimeMessage message = MimeMessageUtil.mimeMessageFromStream(new 
ByteArrayInputStream(messageContent.getBytes(StandardCharsets.US_ASCII)));
+        MimeMessage message = 
MimeMessageUtil.mimeMessageFromString(messageContent);
 
         Mail mail = FakeMail.builder()
             .mimeMessage(message)
@@ -207,7 +204,7 @@ public class TextCalendarBodyToAttachmentTest {
             "BEGIN:VCALENDAR\n" +
             "END:VEVENT\n" +
             "END:VCALENDAR";
-        MimeMessage message = MimeMessageUtil.mimeMessageFromStream(new 
ByteArrayInputStream(messageContent.getBytes(StandardCharsets.US_ASCII)));
+        MimeMessage message = 
MimeMessageUtil.mimeMessageFromString(messageContent);
 
         Mail mail = FakeMail.builder()
             .mimeMessage(message)
@@ -226,7 +223,7 @@ public class TextCalendarBodyToAttachmentTest {
             "BEGIN:VCALENDAR\n" +
             "END:VEVENT\n" +
             "END:VCALENDAR";
-        MimeMessage message = MimeMessageUtil.mimeMessageFromStream(new 
ByteArrayInputStream(messageContent.getBytes(StandardCharsets.US_ASCII)));
+        MimeMessage message = 
MimeMessageUtil.mimeMessageFromString(messageContent);
 
         Mail mail = FakeMail.builder()
             .mimeMessage(message)

http://git-wip-us.apache.org/repos/asf/james-project/blob/7244396c/server/protocols/jmap/src/test/java/org/apache/james/jmap/mailet/VacationReplyTest.java
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap/src/test/java/org/apache/james/jmap/mailet/VacationReplyTest.java
 
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/mailet/VacationReplyTest.java
index 7dff577..6147814 100644
--- 
a/server/protocols/jmap/src/test/java/org/apache/james/jmap/mailet/VacationReplyTest.java
+++ 
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/mailet/VacationReplyTest.java
@@ -27,16 +27,15 @@ import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
 import java.util.Optional;
-import java.util.Properties;
 
 import javax.mail.MessagingException;
-import javax.mail.Session;
 import javax.mail.internet.MimeMessage;
 
 import org.apache.james.core.MailAddress;
 import org.apache.james.jmap.api.vacation.Vacation;
 import org.apache.james.jmap.utils.MimeMessageBodyGenerator;
 import org.apache.mailet.base.test.FakeMail;
+import org.apache.mailet.base.test.MimeMessageUtil;
 import org.hamcrest.BaseMatcher;
 import org.hamcrest.Description;
 import org.junit.Before;
@@ -62,12 +61,13 @@ public class VacationReplyTest {
         originalRecipient = new MailAddress("be...@apache.org");
 
         mail = FakeMail.builder()
-                .mimeMessage(new MimeMessage(Session.getInstance(new 
Properties()), ClassLoader.getSystemResourceAsStream("spamMail.eml")))
+                .mimeMessage(
+                    
MimeMessageUtil.mimeMessageFromStream(ClassLoader.getSystemResourceAsStream("spamMail.eml")))
                 .sender(originalSender)
                 .build();
 
         mimeMessageBodyGenerator = mock(MimeMessageBodyGenerator.class);
-        generatedBody = new MimeMessage(Session.getInstance(new Properties()));
+        generatedBody = MimeMessageUtil.defaultMimeMessage();
         when(mimeMessageBodyGenerator.from(any(MimeMessage.class), any(), 
any())).thenReturn(generatedBody);
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/7244396c/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/MimeMessageBodyGeneratorTest.java
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/MimeMessageBodyGeneratorTest.java
 
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/MimeMessageBodyGeneratorTest.java
index 4b283ab..f5586f1 100644
--- 
a/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/MimeMessageBodyGeneratorTest.java
+++ 
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/MimeMessageBodyGeneratorTest.java
@@ -27,12 +27,11 @@ import static org.mockito.Mockito.when;
 
 import java.nio.charset.StandardCharsets;
 import java.util.Optional;
-import java.util.Properties;
 
-import javax.mail.Session;
 import javax.mail.internet.MimeMessage;
 
 import org.apache.commons.io.IOUtils;
+import org.apache.mailet.base.test.MimeMessageUtil;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -44,7 +43,7 @@ public class MimeMessageBodyGeneratorTest {
 
     @Before
     public void setUp() {
-        original = new MimeMessage(Session.getDefaultInstance(new 
Properties()));
+        original = MimeMessageUtil.defaultMimeMessage();
         htmlTextExtractor = mock(HtmlTextExtractor.class);
         mimeMessageBodyGenerator = new 
MimeMessageBodyGenerator(htmlTextExtractor);
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
For additional commands, e-mail: server-dev-h...@james.apache.org

Reply via email to