james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [01/10] james-project git commit: JAMES-2361 Make some MIME4J build calls implicit
Date Wed, 18 Apr 2018 00:36:53 GMT
Repository: james-project
Updated Branches:
  refs/heads/master 2387fd8ee -> 3c379ddb4


JAMES-2361 Make some MIME4J build calls implicit


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/68d013ff
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/68d013ff
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/68d013ff

Branch: refs/heads/master
Commit: 68d013ff0e7a18d61222ff3ece2418c95722eb8f
Parents: 2387fd8
Author: benwa <btellier@linagora.com>
Authored: Tue Apr 17 10:46:47 2018 +0700
Committer: benwa <btellier@linagora.com>
Committed: Tue Apr 17 10:46:47 2018 +0700

----------------------------------------------------------------------
 .../search/AbstractMessageSearchIndexTest.java  | 13 ++++-----
 mdn/src/main/java/org/apache/james/mdn/MDN.java |  6 ++--
 .../util/mime/MessageContentExtractorTest.java  | 29 ++++++++------------
 .../integration/GetMessageListMethodTest.java   | 25 +++++++----------
 .../jmap/methods/MIMEMessageConverter.java      |  8 ++----
 .../jmap/methods/GetMessagesMethodTest.java     |  6 ++--
 6 files changed, 34 insertions(+), 53 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/68d013ff/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/AbstractMessageSearchIndexTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/AbstractMessageSearchIndexTest.java
b/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/AbstractMessageSearchIndexTest.java
index 47c5bb5..9a3803f 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/AbstractMessageSearchIndexTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/AbstractMessageSearchIndexTest.java
@@ -50,7 +50,6 @@ import org.apache.james.mailbox.store.StoreMessageManager;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
 import org.apache.james.mime4j.dom.Message;
 import org.apache.james.mime4j.dom.Multipart;
-import org.apache.james.mime4j.message.BodyPart;
 import org.apache.james.mime4j.message.BodyPartBuilder;
 import org.apache.james.mime4j.message.MultipartBuilder;
 import org.apache.james.util.ClassLoaderUtils;
@@ -1327,14 +1326,12 @@ public abstract class AbstractMessageSearchIndexTest {
     public void searchWithPDFAttachmentShouldReturnMailsWhenAttachmentContentMatches() throws
Exception {
         Assume.assumeTrue(storeMailboxManager.getSupportedSearchCapabilities().contains(MailboxManager.SearchCapabilities.Attachment));
         byte[] attachmentContent = ClassLoaderUtils.getSystemResourceAsByteArray("eml/attachment.pdf");
-        BodyPart attachment = BodyPartBuilder.create()
-                .setBody(attachmentContent, "application/pdf")
-                .setContentDisposition("attachment")
-                .build();
-        BodyPart textPart = BodyPartBuilder.create().setBody("The message has a PDF attachment.",
"plain", StandardCharsets.UTF_8).build();
         Multipart multipart = MultipartBuilder.create("mixed")
-                .addBodyPart(attachment)
-                .addBodyPart(textPart)
+                .addBodyPart(BodyPartBuilder.create()
+                    .setBody(attachmentContent, "application/pdf")
+                    .setContentDisposition("attachment"))
+                .addBodyPart(BodyPartBuilder.create()
+                    .setBody("The message has a PDF attachment.", "plain", StandardCharsets.UTF_8))
                 .build();
         Message message = Message.Builder.of()
                 .setBody(multipart)

http://git-wip-us.apache.org/repos/asf/james-project/blob/68d013ff/mdn/src/main/java/org/apache/james/mdn/MDN.java
----------------------------------------------------------------------
diff --git a/mdn/src/main/java/org/apache/james/mdn/MDN.java b/mdn/src/main/java/org/apache/james/mdn/MDN.java
index 02e1ac4..4a69548 100644
--- a/mdn/src/main/java/org/apache/james/mdn/MDN.java
+++ b/mdn/src/main/java/org/apache/james/mdn/MDN.java
@@ -140,13 +140,11 @@ public class MDN {
         builder.addBodyPart(BodyPartBuilder.create()
             .use(new BasicBodyFactory())
             .setBody(humanReadableText, Charsets.UTF_8)
-            .setContentType("text/plain", UTF_8_CHARSET)
-            .build());
+            .setContentType("text/plain", UTF_8_CHARSET));
         builder.addBodyPart(BodyPartBuilder.create()
             .use(new BasicBodyFactory())
             .setBody(report.formattedValue(), Charsets.UTF_8)
-            .setContentType(DISPOSITION_CONTENT_TYPE, UTF_8_CHARSET)
-            .build());
+            .setContentType(DISPOSITION_CONTENT_TYPE, UTF_8_CHARSET));
 
         return builder.build();
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/68d013ff/server/container/util-java8/src/test/java/org/apache/james/util/mime/MessageContentExtractorTest.java
----------------------------------------------------------------------
diff --git a/server/container/util-java8/src/test/java/org/apache/james/util/mime/MessageContentExtractorTest.java
b/server/container/util-java8/src/test/java/org/apache/james/util/mime/MessageContentExtractorTest.java
index 7f4a620..deae849 100644
--- a/server/container/util-java8/src/test/java/org/apache/james/util/mime/MessageContentExtractorTest.java
+++ b/server/container/util-java8/src/test/java/org/apache/james/util/mime/MessageContentExtractorTest.java
@@ -68,29 +68,26 @@ public class MessageContentExtractorTest {
 
     private MessageContentExtractor testee;
 
-    private BodyPart htmlPart;
-    private BodyPart textPart;
-    private BodyPart textAttachment;
-    private BodyPart inlineText;
-    private BodyPart inlineImage;
+    private BodyPartBuilder htmlPart;
+    private BodyPartBuilder textPart;
+    private BodyPartBuilder textAttachment;
+    private BodyPartBuilder inlineText;
+    private BodyPartBuilder inlineImage;
 
     @Before
     public void setup() throws IOException {
         testee = new MessageContentExtractor();
-        textPart = BodyPartBuilder.create().setBody(TEXT_CONTENT, "plain", StandardCharsets.UTF_8).build();
-        htmlPart = BodyPartBuilder.create().setBody(HTML_CONTENT, "html", StandardCharsets.UTF_8).build();
+        textPart = BodyPartBuilder.create().setBody(TEXT_CONTENT, "plain", StandardCharsets.UTF_8);
+        htmlPart = BodyPartBuilder.create().setBody(HTML_CONTENT, "html", StandardCharsets.UTF_8);
         textAttachment = BodyPartBuilder.create()
                 .setBody(ATTACHMENT_CONTENT, "plain", StandardCharsets.UTF_8)
-                .setContentDisposition("attachment")
-                .build();
+                .setContentDisposition("attachment");
         inlineText = BodyPartBuilder.create()
                 .setBody(ATTACHMENT_CONTENT, "plain", StandardCharsets.UTF_8)
-                .setContentDisposition("inline")
-                .build();
+                .setContentDisposition("inline");
         inlineImage = BodyPartBuilder.create()
                 .setBody(new byte[0], "image/png")
-                .setContentDisposition("inline")
-                .build();
+                .setContentDisposition("inline");
     }
 
     @Test
@@ -184,12 +181,10 @@ public class MessageContentExtractorTest {
         Multipart multipart = MultipartBuilder.create("report")
             .addBodyPart(BodyPartBuilder.create()
                 .setBody(textBody, "plain", StandardCharsets.UTF_8)
-                .setContentDisposition("inline")
-                .build())
+                .setContentDisposition("inline"))
             .addBodyPart(BodyPartBuilder.create()
                 .setBody("body 2", "rfc822-headers", StandardCharsets.UTF_8)
-                .setContentDisposition("inline")
-                .build())
+                .setContentDisposition("inline"))
             .build();
         Message message = Message.Builder.of()
             .setBody(multipart)

http://git-wip-us.apache.org/repos/asf/james-project/blob/68d013ff/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java
index c6337bb..65c464e 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java
@@ -60,7 +60,6 @@ import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.store.probe.MailboxProbe;
 import org.apache.james.mime4j.dom.Message;
 import org.apache.james.mime4j.dom.Multipart;
-import org.apache.james.mime4j.message.BodyPart;
 import org.apache.james.mime4j.message.BodyPartBuilder;
 import org.apache.james.mime4j.message.DefaultMessageWriter;
 import org.apache.james.mime4j.message.MultipartBuilder;
@@ -1124,14 +1123,12 @@ public abstract class GetMessageListMethodTest {
     public void getMessageListShouldExcludeMessagesWhenAttachmentFilterDoesntMatch() throws
Exception {
         mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, ALICE, "mailbox");
         byte[] attachmentContent = ClassLoaderUtils.getSystemResourceAsByteArray("eml/attachment.pdf");
-        BodyPart attachment = BodyPartBuilder.create()
-                .setBody(attachmentContent, "application/pdf")
-                .setContentDisposition("attachment")
-                .build();
-        BodyPart textPart = BodyPartBuilder.create().setBody("The message has a PDF attachment.",
"plain", StandardCharsets.UTF_8).build();
         Multipart multipart = MultipartBuilder.create("mixed")
-                .addBodyPart(attachment)
-                .addBodyPart(textPart)
+                .addBodyPart(BodyPartBuilder.create()
+                    .setBody(attachmentContent, "application/pdf")
+                    .setContentDisposition("attachment"))
+                .addBodyPart(BodyPartBuilder.create()
+                    .setBody("The message has a PDF attachment.", "plain", StandardCharsets.UTF_8))
                 .build();
         Message message = Message.Builder.of()
                 .setBody(multipart)
@@ -1154,14 +1151,12 @@ public abstract class GetMessageListMethodTest {
     public void getMessageListShouldIncludeMessagesWhenAttachmentFilterMatches() throws Exception
{
         mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, ALICE, "mailbox");
         byte[] attachmentContent = ClassLoaderUtils.getSystemResourceAsByteArray("eml/attachment.pdf");
-        BodyPart attachment = BodyPartBuilder.create()
-                .setBody(attachmentContent, "application/pdf")
-                .setContentDisposition("attachment")
-                .build();
-        BodyPart textPart = BodyPartBuilder.create().setBody("The message has a PDF attachment.",
"plain", StandardCharsets.UTF_8).build();
         Multipart multipart = MultipartBuilder.create("mixed")
-                .addBodyPart(attachment)
-                .addBodyPart(textPart)
+                .addBodyPart(BodyPartBuilder.create()
+                    .setBody(attachmentContent, "application/pdf")
+                    .setContentDisposition("attachment"))
+                .addBodyPart(BodyPartBuilder.create()
+                    .setBody("The message has a PDF attachment.", "plain", StandardCharsets.UTF_8))
                 .build();
         Message message = Message.Builder.of()
                 .setBody(multipart)

http://git-wip-us.apache.org/repos/asf/james-project/blob/68d013ff/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/MIMEMessageConverter.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/MIMEMessageConverter.java
b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/MIMEMessageConverter.java
index 63f999f..90a3ebd 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/MIMEMessageConverter.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/MIMEMessageConverter.java
@@ -224,7 +224,7 @@ public class MIMEMessageConverter {
     private void addBody(CreationMessage newMessage, MultipartBuilder builder) throws IOException
{
         if (newMessage.getHtmlBody().isPresent() && newMessage.getTextBody().isPresent())
{
             Multipart body = createMultipartAlternativeBody(newMessage);
-            builder.addBodyPart(BodyPartBuilder.create().setBody(body).build());
+            builder.addBodyPart(BodyPartBuilder.create().setBody(body));
         } else {
             addText(builder, newMessage.getTextBody());
             addHtml(builder, newMessage.getHtmlBody());
@@ -244,8 +244,7 @@ public class MIMEMessageConverter {
                 .use(bodyFactory)
                 .setBody(textBody.get(), Charsets.UTF_8)
                 .setContentType(PLAIN_TEXT_MEDIA_TYPE, UTF_8_CHARSET)
-                .setContentTransferEncoding(QUOTED_PRINTABLE)
-                .build());
+                .setContentTransferEncoding(QUOTED_PRINTABLE));
         }
     }
 
@@ -255,8 +254,7 @@ public class MIMEMessageConverter {
                 .use(bodyFactory)
                 .setBody(htmlBody.get(), Charsets.UTF_8)
                 .setContentType(HTML_MEDIA_TYPE, UTF_8_CHARSET)
-                .setContentTransferEncoding(QUOTED_PRINTABLE)
-                .build());
+                .setContentTransferEncoding(QUOTED_PRINTABLE));
         }
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/68d013ff/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/GetMessagesMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/GetMessagesMethodTest.java
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/GetMessagesMethodTest.java
index 05a148a..f237073 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/GetMessagesMethodTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/GetMessagesMethodTest.java
@@ -374,11 +374,9 @@ public class GetMessagesMethodTest {
                     .setBody(MultipartBuilder.create()
                         .setSubType("alternative")
                         .addBodyPart(BodyPartBuilder.create()
-                            .setBody("My plain message", "plain", StandardCharsets.UTF_8)
-                            .build())
+                            .setBody("My plain message", "plain", StandardCharsets.UTF_8))
                         .addBodyPart(BodyPartBuilder.create()
-                            .setBody("<a>The </a> <strong>HTML</strong>
message", "html", StandardCharsets.UTF_8)
-                            .build())
+                            .setBody("<a>The </a> <strong>HTML</strong>
message", "html", StandardCharsets.UTF_8))
                         .build())),
             session);
 


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


Mime
View raw message