james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rouaz...@apache.org
Subject [1/3] james-project git commit: MAILET-102 upgrade Null mailet and tests to modern standards
Date Tue, 20 Sep 2016 09:24:37 GMT
Repository: james-project
Updated Branches:
  refs/heads/master 3a8592d67 -> 12eb738de


MAILET-102 upgrade Null mailet and tests to modern standards


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

Branch: refs/heads/master
Commit: 0ef78d6420f4a10f317b1cbd8232458f3094ae86
Parents: 3a8592d
Author: Matthieu Baechler <matthieu.baechler@linagora.com>
Authored: Thu Aug 25 15:53:29 2016 +0200
Committer: Matthieu Baechler <matthieu.baechler@linagora.com>
Committed: Tue Sep 20 09:12:09 2016 +0200

----------------------------------------------------------------------
 .../apache/james/transport/mailets/Null.java    | 17 ++-----
 .../james/transport/mailets/NullTest.java       | 49 ++++++--------------
 2 files changed, 17 insertions(+), 49 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/0ef78d64/mailet/standard/src/main/java/org/apache/james/transport/mailets/Null.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/mailets/Null.java b/mailet/standard/src/main/java/org/apache/james/transport/mailets/Null.java
index 176d2a3..7f25514 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/mailets/Null.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/mailets/Null.java
@@ -25,26 +25,17 @@ import org.apache.mailet.base.GenericMailet;
 import org.apache.mailet.Mail;
 
 /**
- * Simplest Mailet which destroys any incoming messages.
- *
+ * Simplest Mailet which destroys any incoming messages
+ * by setting their state to GHOST
  */
 public class Null extends GenericMailet {
 
-    /**
-     * Set this mail to GHOST state, indicating that no further processing 
-     * should take place.
-     *
-     * @param mail the mail to process
-     */
+    @Override
     public void service(Mail mail) {
         mail.setState(Mail.GHOST);
     }
 
-    /**
-     * Return a string describing this mailet.
-     *
-     * @return a string describing this mailet
-     */
+    @Override
     public String getMailetInfo() {
         return "Null Mailet";
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/0ef78d64/mailet/standard/src/test/java/org/apache/james/transport/mailets/NullTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/mailets/NullTest.java
b/mailet/standard/src/test/java/org/apache/james/transport/mailets/NullTest.java
index 99c7ced..53fb282 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/mailets/NullTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/mailets/NullTest.java
@@ -20,54 +20,31 @@
 
 package org.apache.james.transport.mailets;
 
-import java.io.UnsupportedEncodingException;
-import java.util.Arrays;
+import static org.assertj.core.api.Assertions.assertThat;
 
 import javax.mail.MessagingException;
-import javax.mail.internet.MimeMessage;
-import javax.mail.internet.ParseException;
 
-import junit.framework.TestCase;
-
-import org.apache.james.transport.mailets.Null;
-import org.apache.mailet.base.test.FakeMail;
-import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
 import org.apache.mailet.Mailet;
+import org.apache.mailet.base.test.FakeMail;
+import org.junit.Before;
+import org.junit.Test;
 
-public class NullTest extends TestCase {
-
-    private MimeMessage mockedMimeMessage;
-
-    private Mail mockedMail;
+public class NullTest {
 
     private Mailet mailet;
 
-    public NullTest(String arg0) throws UnsupportedEncodingException {
-        super(arg0);
-    }
-
-    private void setupMockedMail(MimeMessage m) throws ParseException {
-        mockedMail = new FakeMail();
-        mockedMail.setMessage(m);
-        mockedMail.setRecipients(Arrays.asList(new MailAddress("test@james.apache.org"),
-                new MailAddress("test2@james.apache.org")));
-
-    }
-
-    private void setupMailet() throws MessagingException {
+    @Before
+    public void setup() {
         mailet = new Null();
     }
 
-    // test if the right state was set
-    public void testNullMailet() throws MessagingException {
-        setupMockedMail(mockedMimeMessage);
-        setupMailet();
-
-        mailet.service(mockedMail);
+    @Test
+    public void shouldChangeStateToGhost() throws MessagingException {
+        FakeMail mail = new FakeMail();
+        
+        mailet.service(mail);
 
-        String PROCESSOR = "ghost";
-        assertEquals(PROCESSOR, mockedMail.getState());
+        assertThat(mail.getState()).isEqualTo("ghost");
     }
 
 }


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