james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From matth...@apache.org
Subject [2/5] james-project git commit: MAILET-111 Fake mail should accept mail without MimeMessage
Date Tue, 30 Aug 2016 14:56:54 GMT
MAILET-111 Fake mail should accept mail without MimeMessage

Some mailets / matcher only have actions on Mail object and not on the embedded MimeMessage.
Thus making compulsory to have a MimeMessage makes these tests more complex.


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

Branch: refs/heads/master
Commit: ce00790797cd871f9d5c6c8cb874d97607e28822
Parents: 4d97b06
Author: Benoit Tellier <btellier@linagora.com>
Authored: Tue Aug 30 11:48:09 2016 +0700
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Tue Aug 30 11:49:05 2016 +0700

----------------------------------------------------------------------
 .../test/java/org/apache/mailet/base/test/FakeMail.java   | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/ce007907/mailet/base/src/test/java/org/apache/mailet/base/test/FakeMail.java
----------------------------------------------------------------------
diff --git a/mailet/base/src/test/java/org/apache/mailet/base/test/FakeMail.java b/mailet/base/src/test/java/org/apache/mailet/base/test/FakeMail.java
index 01740ce..1adbf2a 100644
--- a/mailet/base/src/test/java/org/apache/mailet/base/test/FakeMail.java
+++ b/mailet/base/src/test/java/org/apache/mailet/base/test/FakeMail.java
@@ -39,6 +39,8 @@ import javax.mail.internet.MimeMessage;
 import org.apache.mailet.Mail;
 import org.apache.mailet.MailAddress;
 
+import com.google.common.base.Optional;
+
 public class FakeMail implements Mail {
 
     public static FakeMail fromMime(String text, String javaEncodingCharset, String javamailDefaultEncodingCharset)
throws MessagingException, UnsupportedEncodingException {
@@ -58,12 +60,12 @@ public class FakeMail implements Mail {
 
     public static class Builder {
 
-        private String fileName;
+        private Optional<String> fileName = Optional.absent();
         private List<MailAddress> recipients = new ArrayList<MailAddress>();
         private MailAddress sender;
 
         public Builder fileName(String fileName) {
-            this.fileName = fileName;
+            this.fileName = Optional.of(fileName);
             return this;
         }
 
@@ -84,7 +86,9 @@ public class FakeMail implements Mail {
 
         public FakeMail build() throws MessagingException {
             FakeMail mail = new FakeMail();
-            mail.setMessage(new MimeMessage(Session.getInstance(new Properties()), ClassLoader.getSystemResourceAsStream(fileName)));
+            if (fileName.isPresent()) {
+                mail.setMessage(new MimeMessage(Session.getInstance(new Properties()), ClassLoader.getSystemResourceAsStream(fileName.get())));
+            }
             mail.setSender(sender);
             mail.setRecipients(recipients);
             return mail;


---------------------------------------------------------------------
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