james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adup...@apache.org
Subject [06/11] james-project git commit: Revert "JAMES-1862 Use assertj in SMTPServer tests"
Date Tue, 06 Dec 2016 10:42:11 GMT
Revert "JAMES-1862 Use assertj in SMTPServer tests"

This reverts commit c9a20e43eed28ba06d46ae65fe8d70311c2d7f1e.


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

Branch: refs/heads/master
Commit: f75d4f7bbae2014f88f32060a5424cd0c4b89a5e
Parents: 41d9864
Author: Antoine Duprat <aduprat@apache.org>
Authored: Tue Dec 6 11:41:09 2016 +0100
Committer: Antoine Duprat <aduprat@apache.org>
Committed: Tue Dec 6 11:41:09 2016 +0100

----------------------------------------------------------------------
 server/protocols/protocols-smtp/pom.xml         |   6 -
 .../apache/james/smtpserver/SMTPServerTest.java | 464 +++++--------------
 2 files changed, 125 insertions(+), 345 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/f75d4f7b/server/protocols/protocols-smtp/pom.xml
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-smtp/pom.xml b/server/protocols/protocols-smtp/pom.xml
index a466eea..a4e4a3c 100644
--- a/server/protocols/protocols-smtp/pom.xml
+++ b/server/protocols/protocols-smtp/pom.xml
@@ -216,12 +216,6 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>org.assertj</groupId>
-            <artifactId>assertj-core</artifactId>
-            <version>${assertj-1.version}</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-log4j12</artifactId>
             <scope>test</scope>

http://git-wip-us.apache.org/repos/asf/james-project/blob/f75d4f7b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
index 578b824..780e919 100644
--- a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
+++ b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
@@ -18,7 +18,11 @@
  ****************************************************************/
 package org.apache.james.smtpserver;
 
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
@@ -340,14 +344,10 @@ public class SMTPServerTest {
         }
         smtpProtocol.sendCommand("EHLO " + sb.toString());
         System.out.println(smtpProtocol.getReplyString());
-        assertThat(smtpProtocol.getReplyCode())
-            .as("Line length exceed")
-            .isEqualTo(500);
+        assertEquals("Line length exceed", 500, smtpProtocol.getReplyCode());
 
         smtpProtocol.sendCommand("EHLO test");
-        assertThat(smtpProtocol.getReplyCode())
-            .as("Line length ok")
-            .isEqualTo(250);
+        assertEquals("Line length ok", 250, smtpProtocol.getReplyCode());
 
         smtpProtocol.quit();
         smtpProtocol.disconnect();
@@ -390,33 +390,25 @@ public class SMTPServerTest {
 
     public void verifyLastMail(String sender, String recipient, MimeMessage msg) throws IOException,
MessagingException {
         Mail mailData = queue.getLastMail();
-        assertThat(mailData)
-            .as("mail received by mail server")
-            .isNotNull();
+        assertNotNull("mail received by mail server", mailData);
 
         if (sender == null && recipient == null && msg == null) {
             fail("no verification can be done with all arguments null");
         }
 
         if (sender != null) {
-            assertThat(mailData.getSender().toString())
-                .as("sender verfication")
-                .isEqualTo(sender);
+            assertEquals("sender verfication", sender, mailData.getSender().toString());
         }
         if (recipient != null) {
-            assertThat(mailData.getRecipients())
-                .as("recipient verfication")
-                .containsOnly(new MailAddress(recipient));
+            assertTrue("recipient verfication", mailData.getRecipients().contains(new MailAddress(recipient)));
         }
         if (msg != null) {
             ByteArrayOutputStream bo1 = new ByteArrayOutputStream();
             msg.writeTo(bo1);
             ByteArrayOutputStream bo2 = new ByteArrayOutputStream();
             mailData.getMessage().writeTo(bo2);
-            assertThat(bo2.toString()).isEqualTo(bo1.toString());
-            assertThat(mailData.getMessage())
-                .as("message verification")
-                .isEqualTo(msg);
+            assertEquals(bo1.toString(), bo2.toString());
+            assertEquals("message verification", msg, mailData.getMessage());
         }
     }
 
@@ -428,9 +420,7 @@ public class SMTPServerTest {
         smtpProtocol.connect("127.0.0.1", smtpListenerPort);
 
         // no message there, yet
-        assertThat(queue.getLastMail())
-            .as("no mail received by mail server")
-            .isNull();;
+        assertNull("no mail received by mail server", queue.getLastMail());
 
         smtpProtocol.sendCommand("EHLO " + InetAddress.getLocalHost());
         String[] capabilityRes = smtpProtocol.getReplyStrings();
@@ -440,18 +430,10 @@ public class SMTPServerTest {
             capabilitieslist.add(capabilityRes[i].substring(4));
         }
 
-        assertThat(capabilitieslist)
-            .as("capabilities")
-            .hasSize(3);
-        assertThat(capabilitieslist.contains("PIPELINING"))
-            .as("capabilities present PIPELINING")
-            .isTrue();
-        assertThat(capabilitieslist.contains("ENHANCEDSTATUSCODES"))
-            .as("capabilities present ENHANCEDSTATUSCODES")
-            .isTrue();
-        assertThat(capabilitieslist.contains("8BITMIME"))
-            .as("capabilities present 8BITMIME")
-            .isTrue();
+        assertEquals("capabilities", 3, capabilitieslist.size());
+        assertTrue("capabilities present PIPELINING", capabilitieslist.contains("PIPELINING"));
+        assertTrue("capabilities present ENHANCEDSTATUSCODES", capabilitieslist.contains("ENHANCEDSTATUSCODES"));
+        assertTrue("capabilities present 8BITMIME", capabilitieslist.contains("8BITMIME"));
 
         smtpProtocol.setSender("mail@localhost");
         smtpProtocol.addRecipient("mail@localhost");
@@ -461,9 +443,7 @@ public class SMTPServerTest {
         smtpProtocol.disconnect();
 
         // mail was propagated by SMTPServer
-        assertThat(queue.getLastMail())
-            .as("mail received by mail server")
-            .isNotNull();
+        assertNotNull("mail received by mail server", queue.getLastMail());
     }
 
     @Test
@@ -475,9 +455,7 @@ public class SMTPServerTest {
         smtpProtocol.connect("127.0.0.1", smtpListenerPort);
 
         // no message there, yet
-        assertThat(queue.getLastMail())
-            .as("no mail received by mail server")
-            .isNull();;
+        assertNull("no mail received by mail server", queue.getLastMail());
 
         smtpProtocol.sendCommand("EHLO " + InetAddress.getLocalHost());
         String[] capabilityRes = smtpProtocol.getReplyStrings();
@@ -487,12 +465,11 @@ public class SMTPServerTest {
             capabilitieslist.add(capabilityRes[i].substring(4));
         }
 
-        assertThat(capabilitieslist)
-            .as("capabilities")
-            .hasSize(4);
-        assertThat(capabilitieslist)
-            .as("capabilities present PIPELINING ENHANCEDSTATUSCODES 8BITMIME STARTTLS")
-            .containsOnly("PIPELINING", "ENHANCEDSTATUSCODES", "8BITMIME", "STARTTLS");
+        assertEquals("capabilities", 4, capabilitieslist.size());
+        assertTrue("capabilities present PIPELINING", capabilitieslist.contains("PIPELINING"));
+        assertTrue("capabilities present ENHANCEDSTATUSCODES", capabilitieslist.contains("ENHANCEDSTATUSCODES"));
+        assertTrue("capabilities present 8BITMIME", capabilitieslist.contains("8BITMIME"));
+        assertTrue("capabilities present STARTTLS", capabilitieslist.contains("STARTTLS"));
 
         smtpProtocol.quit();
         smtpProtocol.disconnect();
@@ -526,9 +503,7 @@ public class SMTPServerTest {
         SMTPClient smtp = newSMTPClient();
 
         // no message there, yet
-        assertThat(queue.getLastMail())
-            .as("no mail received by mail server")
-            .isNull();;
+        assertNull("no mail received by mail server", queue.getLastMail());
 
         smtp.helo(InetAddress.getLocalHost().toString());
         smtp.setSender("mail@localhost");
@@ -538,9 +513,8 @@ public class SMTPServerTest {
         smtp.quit();
         smtp.disconnect();
 
-        assertThat(queue.getLastMail().getMessage().getHeader("Received"))
-            .as("spooled mail has Received header")
-            .isNotNull();
+        assertNotNull("spooled mail has Received header",
+                queue.getLastMail().getMessage().getHeader("Received"));
     }
 
     // FIXME
@@ -552,9 +526,7 @@ public class SMTPServerTest {
         SMTPClient smtp = newSMTPClient();
 
         // no message there, yet
-        assertThat(queue.getLastMail())
-            .as("no mail received by mail server")
-            .isNull();;
+        assertNull("no mail received by mail server", queue.getLastMail());
 
         smtp.helo(InetAddress.getLocalHost().toString());
         smtp.setSender("mail@localhost");
@@ -564,9 +536,8 @@ public class SMTPServerTest {
         smtp.quit();
         smtp.disconnect();
 
-        assertThat(queue.getLastMail().getMessage().getHeader("Received"))
-            .as("spooled mail has Received header")
-            .isNotNull();
+        assertNotNull("spooled mail has Received header",
+                queue.getLastMail().getMessage().getHeader("Received"));
         // TODO: test body size
     }
 
@@ -578,9 +549,7 @@ public class SMTPServerTest {
         smtpProtocol.connect("127.0.0.1", smtpListenerPort);
 
         // no message there, yet
-        assertThat(queue.getLastMail())
-            .as("no mail received by mail server")
-            .isNull();
+        assertNull("no mail received by mail server", queue.getLastMail());
 
         smtpProtocol.helo(InetAddress.getLocalHost().toString());
 
@@ -594,9 +563,7 @@ public class SMTPServerTest {
         smtpProtocol.disconnect();
 
         // mail was propagated by SMTPServer
-        assertThat(queue.getLastMail())
-            .as("mail received by mail server")
-            .isNotNull();
+        assertNotNull("mail received by mail server", queue.getLastMail());
     }
 
     @Test
@@ -608,17 +575,11 @@ public class SMTPServerTest {
         SMTPClient smtpProtocol2 = new SMTPClient();
         smtpProtocol2.connect("127.0.0.1", smtpListenerPort);
 
-        assertThat(smtpProtocol1.isConnected())
-            .as("first connection taken")
-            .isTrue();
-        assertThat(smtpProtocol2.isConnected())
-            .as("second connection taken")
-            .isTrue();
+        assertTrue("first connection taken", smtpProtocol1.isConnected());
+        assertTrue("second connection taken", smtpProtocol2.isConnected());
 
         // no message there, yet
-        assertThat(queue.getLastMail())
-            .as("no mail received by mail server")
-            .isNull();
+        assertNull("no mail received by mail server", queue.getLastMail());
 
         smtpProtocol1.helo(InetAddress.getLocalHost().toString());
         smtpProtocol2.helo(InetAddress.getLocalHost().toString());
@@ -653,14 +614,10 @@ public class SMTPServerTest {
         SMTPClient smtpProtocol1 = new SMTPClient();
         smtpProtocol1.connect("127.0.0.1", smtpListenerPort);
 
-        assertThat(smtpProtocol1.isConnected())
-            .as("first connection taken")
-            .isTrue();
+        assertTrue("first connection taken", smtpProtocol1.isConnected());
 
         // no message there, yet
-        assertThat(queue.getLastMail())
-            .as("no mail received by mail server")
-            .isNull();
+        assertNull("no mail received by mail server", queue.getLastMail());
 
         smtpProtocol1.helo(InetAddress.getLocalHost().toString());
 
@@ -697,14 +654,10 @@ public class SMTPServerTest {
         SMTPClient smtpProtocol = new SMTPClient();
         smtpProtocol.connect("127.0.0.1", smtpListenerPort);
 
-        assertThat(smtpProtocol.isConnected())
-            .as("first connection taken")
-            .isTrue();
+        assertTrue("first connection taken", smtpProtocol.isConnected());
 
         // no message there, yet
-        assertThat(queue.getLastMail())
-            .as("no mail received by mail server")
-            .isNull();
+        assertNull("no mail received by mail server", queue.getLastMail());
 
         String fictionalDomain = "abgsfe3rsf.de";
         String existingDomain = "james.apache.org";
@@ -716,9 +669,7 @@ public class SMTPServerTest {
         smtpProtocol.addRecipient(rcpt);
 
         // this should give a 501 code cause the helo/ehlo could not resolved
-        assertThat(smtpProtocol.getReplyCode())
-            .as("expected error: " + heloCommand + " could not resolved")
-            .isEqualTo(501);
+        assertEquals("expected error: " + heloCommand + " could not resolved", 501, smtpProtocol.getReplyCode());
 
         smtpProtocol.sendCommand(heloCommand, existingDomain);
         smtpProtocol.setSender(mail);
@@ -728,9 +679,7 @@ public class SMTPServerTest {
             fail(existingDomain + " domain currently cannot be resolved (check your DNS/internet
connection/proxy settings to make test pass)");
         }
         // helo/ehlo is resolvable. so this should give a 250 code
-        assertThat(smtpProtocol.getReplyCode())
-            .as(heloCommand + " accepted")
-            .isEqualTo(250);
+        assertEquals(heloCommand + " accepted", 250, smtpProtocol.getReplyCode());
 
         smtpProtocol.quit();
     }
@@ -744,9 +693,7 @@ public class SMTPServerTest {
 
         smtpProtocol1.helo("abgsfe3rsf.de");
         // helo should not be checked. so this should give a 250 code
-        assertThat(smtpProtocol1.getReplyCode())
-            .as("Helo accepted")
-            .isEqualTo(250);
+        assertEquals("Helo accepted", 250, smtpProtocol1.getReplyCode());
 
         smtpProtocol1.quit();
     }
@@ -767,14 +714,10 @@ public class SMTPServerTest {
             SMTPClient smtpProtocol1 = new SMTPClient();
             smtpProtocol1.connect("127.0.0.1", smtpListenerPort);
 
-            assertThat(smtpProtocol1.isConnected())
-                .as("first connection taken")
-                .isTrue();
+            assertTrue("first connection taken", smtpProtocol1.isConnected());
 
             // no message there, yet
-            assertThat(queue.getLastMail())
-                .as("no mail received by mail server")
-                .isNull();
+            assertNull("no mail received by mail server", queue.getLastMail());
 
             String helo1 = "abgsfe3rsf.de";
             String helo2 = "james.apache.org";
@@ -787,18 +730,14 @@ public class SMTPServerTest {
 
             // this should give a 501 code cause the helo not equal reverse of
             // ip
-            assertThat(smtpProtocol1.getReplyCode())
-                .as("expected error: helo not equals reverse of ip")
-                .isEqualTo(501);
+            assertEquals("expected error: helo not equals reverse of ip", 501, smtpProtocol1.getReplyCode());
 
             smtpProtocol1.sendCommand("helo", helo2);
             smtpProtocol1.setSender(mail);
             smtpProtocol1.addRecipient(rcpt);
 
             // helo is resolvable. so this should give a 250 code
-            assertThat(smtpProtocol1.getReplyCode())
-                .as("Helo accepted")
-                .isEqualTo(250);
+            assertEquals("Helo accepted", 250, smtpProtocol1.getReplyCode());
 
             smtpProtocol1.quit();
         } finally {
@@ -815,28 +754,20 @@ public class SMTPServerTest {
         SMTPClient smtpProtocol1 = new SMTPClient();
         smtpProtocol1.connect("127.0.0.1", smtpListenerPort);
 
-        assertThat(smtpProtocol1.isConnected())
-            .as("first connection taken")
-            .isTrue();
+        assertTrue("first connection taken", smtpProtocol1.isConnected());
 
         // no message there, yet
-        assertThat(queue.getLastMail())
-            .as("no mail received by mail server")
-            .isNull();
+        assertNull("no mail received by mail server", queue.getLastMail());
 
         smtpProtocol1.helo(InetAddress.getLocalHost().toString());
 
         String sender1 = "mail_sender1@xfwrqqfgfe.de";
 
         smtpProtocol1.setSender(sender1);
-        assertThat(smtpProtocol1.getReplyCode())
-            .as("expected 501 error")
-            .isEqualTo(501);
+        assertEquals("expected 501 error", 501, smtpProtocol1.getReplyCode());
 
         smtpProtocol1.addRecipient("test@localhost");
-        assertThat(smtpProtocol1.getReplyCode())
-            .as("Recipient not accepted cause no valid sender")
-            .isEqualTo(503);
+        assertEquals("Recipient not accepted cause no valid sender", 503, smtpProtocol1.getReplyCode());
         smtpProtocol1.quit();
 
     }
@@ -865,14 +796,10 @@ public class SMTPServerTest {
         SMTPClient smtpProtocol1 = new SMTPClient();
         smtpProtocol1.connect("127.0.0.1", smtpListenerPort);
 
-        assertThat(smtpProtocol1.isConnected())
-            .as("first connection taken")
-            .isTrue();
+        assertTrue("first connection taken", smtpProtocol1.isConnected());
 
         // no message there, yet
-        assertThat(queue.getLastMail())
-            .as("no mail received by mail server")
-            .isNull();
+        assertNull("no mail received by mail server", queue.getLastMail());
 
         smtpProtocol1.helo(InetAddress.getLocalHost().toString());
 
@@ -894,14 +821,10 @@ public class SMTPServerTest {
         SMTPClient smtpProtocol1 = new SMTPClient();
         smtpProtocol1.connect("127.0.0.1", smtpListenerPort);
 
-        assertThat(smtpProtocol1.isConnected())
-            .as("first connection taken")
-            .isTrue();
+        assertTrue("first connection taken", smtpProtocol1.isConnected());
 
         // no message there, yet
-        assertThat(queue.getLastMail())
-            .as("no mail received by mail server")
-            .isNull();
+        assertNull("no mail received by mail server", queue.getLastMail());
 
         smtpProtocol1.helo(InetAddress.getLocalHost().toString());
 
@@ -909,9 +832,7 @@ public class SMTPServerTest {
         String sender2 = "mail_sender2@james.apache.org";
 
         smtpProtocol1.setSender(sender1);
-        assertThat(smtpProtocol1.getReplyCode())
-            .as("expected 501 error")
-            .isEqualTo(501);
+        assertEquals("expected 501 error", 501, smtpProtocol1.getReplyCode());
 
         smtpProtocol1.setSender(sender2);
 
@@ -927,14 +848,10 @@ public class SMTPServerTest {
         SMTPClient smtpProtocol1 = new SMTPClient();
         smtpProtocol1.connect("127.0.0.1", smtpListenerPort);
 
-        assertThat(smtpProtocol1.isConnected())
-            .as("first connection taken")
-            .isTrue();
+        assertTrue("first connection taken", smtpProtocol1.isConnected());
 
         // no message there, yet
-        assertThat(queue.getLastMail())
-            .as("no mail received by mail server")
-            .isNull();
+        assertNull("no mail received by mail server", queue.getLastMail());
 
         smtpProtocol1.helo(InetAddress.getLocalHost().toString());
 
@@ -946,9 +863,7 @@ public class SMTPServerTest {
         smtpProtocol1.addRecipient(rcpt1);
 
         smtpProtocol1.addRecipient(rcpt2);
-        assertThat(smtpProtocol1.getReplyCode())
-            .as("expected 452 error")
-            .isEqualTo(452);
+        assertEquals("expected 452 error", 452, smtpProtocol1.getReplyCode());
 
         smtpProtocol1.sendShortMessageData("Subject: test\r\n\r\nTest body testMaxRcpt1\r\n");
 
@@ -1004,9 +919,7 @@ public class SMTPServerTest {
 
         smtpProtocol1.sendCommand("ehlo", "abgsfe3rsf.de");
         // ehlo should not be checked. so this should give a 250 code
-        assertThat(smtpProtocol1.getReplyCode())
-            .as("ehlo accepted")
-            .isEqualTo(250);
+        assertEquals("ehlo accepted", 250, smtpProtocol1.getReplyCode());
 
         smtpProtocol1.quit();
     }
@@ -1038,13 +951,10 @@ public class SMTPServerTest {
             SMTPClient smtpProtocol1 = new SMTPClient();
             smtpProtocol1.connect("127.0.0.1", smtpListenerPort);
 
-            assertThat(smtpProtocol1.isConnected())
-                .as("first connection taken")
-                .isTrue();
+            assertTrue("first connection taken", smtpProtocol1.isConnected());
+
             // no message there, yet
-            assertThat(queue.getLastMail())
-                .as("no mail received by mail server")
-                .isNull();
+            assertNull("no mail received by mail server", queue.getLastMail());
 
             String ehlo1 = "abgsfe3rsf.de";
             String ehlo2 = "james.apache.org";
@@ -1057,18 +967,14 @@ public class SMTPServerTest {
 
             // this should give a 501 code cause the ehlo not equals reverse of
             // ip
-            assertThat(smtpProtocol1.getReplyCode())
-                .as("expected error: ehlo not equals reverse of ip")
-                .isEqualTo(501);
+            assertEquals("expected error: ehlo not equals reverse of ip", 501, smtpProtocol1.getReplyCode());
 
             smtpProtocol1.sendCommand("ehlo", ehlo2);
             smtpProtocol1.setSender(mail);
             smtpProtocol1.addRecipient(rcpt);
 
             // ehlo is resolvable. so this should give a 250 code
-            assertThat(smtpProtocol1.getReplyCode())
-                .as("ehlo accepted")
-                .isEqualTo(250);
+            assertEquals("ehlo accepted", 250, smtpProtocol1.getReplyCode());
 
             smtpProtocol1.quit();
         } finally {
@@ -1083,20 +989,14 @@ public class SMTPServerTest {
         SMTPClient smtpProtocol1 = new SMTPClient();
         smtpProtocol1.connect("127.0.0.1", smtpListenerPort);
 
-        assertThat(smtpProtocol1.isConnected())
-            .as("first connection taken")
-            .isTrue();
+        assertTrue("first connection taken", smtpProtocol1.isConnected());
 
         // no message there, yet
-        assertThat(queue.getLastMail())
-            .as("no mail received by mail server")
-            .isNull();
+        assertNull("no mail received by mail server", queue.getLastMail());
 
         String sender1 = "mail_sender1@localhost";
         smtpProtocol1.setSender(sender1);
-        assertThat(smtpProtocol1.getReplyCode())
-            .as("expected 503 error")
-            .isEqualTo(503);
+        assertEquals("expected 503 error", 503, smtpProtocol1.getReplyCode());
 
         smtpProtocol1.helo(InetAddress.getLocalHost().toString());
 
@@ -1113,14 +1013,10 @@ public class SMTPServerTest {
         SMTPClient smtpProtocol1 = new SMTPClient();
         smtpProtocol1.connect("127.0.0.1", smtpListenerPort);
 
-        assertThat(smtpProtocol1.isConnected())
-            .as("first connection taken")
-            .isTrue();
+        assertTrue("first connection taken", smtpProtocol1.isConnected());
 
         // no message there, yet
-        assertThat(queue.getLastMail())
-            .as("no mail received by mail server")
-            .isNull();
+        assertNull("no mail received by mail server", queue.getLastMail());
 
         String sender1 = "mail_sender1@localhost";
 
@@ -1142,15 +1038,11 @@ public class SMTPServerTest {
 
         smtpProtocol.sendCommand("AUTH PLAIN");
 
-        assertThat(smtpProtocol.getReplyCode())
-            .as("start auth.")
-            .isEqualTo(334);
+        assertEquals("start auth.", 334, smtpProtocol.getReplyCode());
 
         smtpProtocol.sendCommand("*");
 
-        assertThat(smtpProtocol.getReplyCode())
-            .as("cancel auth.")
-            .isEqualTo(501);
+        assertEquals("cancel auth.", 501, smtpProtocol.getReplyCode());
 
         smtpProtocol.quit();
 
@@ -1174,9 +1066,7 @@ public class SMTPServerTest {
             capabilitieslist.add(capabilityRes[i].substring(4));
         }
 
-        assertThat(capabilitieslist.contains("AUTH LOGIN PLAIN"))
-            .as("anouncing auth required")
-            .isTrue();
+        assertTrue("anouncing auth required", capabilitieslist.contains("AUTH LOGIN PLAIN"));
         // is this required or just for compatibility?
         // assertTrue("anouncing auth required",
         // capabilitieslist.contains("AUTH=LOGIN PLAIN"));
@@ -1185,46 +1075,32 @@ public class SMTPServerTest {
         String noexistUserName = "noexist_test_user_smtp";
         String sender = "test_user_smtp@localhost";
         smtpProtocol.sendCommand("AUTH FOO", null);
-        assertThat(smtpProtocol.getReplyCode())
-            .as("expected error: unrecognized authentication type")
-            .isEqualTo(504);
+        assertEquals("expected error: unrecognized authentication type", 504, smtpProtocol.getReplyCode());
 
         smtpProtocol.setSender(sender);
 
         smtpProtocol.addRecipient("mail@sample.com");
-        assertThat(smtpProtocol.getReplyCode())
-            .as("expected 530 error")
-            .isEqualTo(530);
+        assertEquals("expected 530 error", 530, smtpProtocol.getReplyCode());
 
-        assertThat(usersRepository.contains(noexistUserName))
-            .as("user not existing")
-            .isFalse();
+        assertFalse("user not existing", usersRepository.contains(noexistUserName));
 
         smtpProtocol.sendCommand("AUTH PLAIN");
         smtpProtocol.sendCommand(Base64.encodeAsString("\0" + noexistUserName + "\0pwd\0"));
         // smtpProtocol.sendCommand(noexistUserName+"pwd".toCharArray());
-        assertThat(smtpProtocol.getReplyCode())
-            .as("expected error")
-            .isEqualTo(535);
+        assertEquals("expected error", 535, smtpProtocol.getReplyCode());
 
         usersRepository.addUser(userName, "pwd");
 
         smtpProtocol.sendCommand("AUTH PLAIN");
         smtpProtocol.sendCommand(Base64.encodeAsString("\0" + userName + "\0wrongpwd\0"));
-        assertThat(smtpProtocol.getReplyCode())
-            .as("expected error")
-            .isEqualTo(535);
+        assertEquals("expected error", 535, smtpProtocol.getReplyCode());
 
         smtpProtocol.sendCommand("AUTH PLAIN");
         smtpProtocol.sendCommand(Base64.encodeAsString("\0" + userName + "\0pwd\0"));
-        assertThat(smtpProtocol.getReplyCode())
-            .as("authenticated")
-            .isEqualTo(235);
+        assertEquals("authenticated", 235, smtpProtocol.getReplyCode());
 
         smtpProtocol.sendCommand("AUTH PLAIN");
-        assertThat(smtpProtocol.getReplyCode())
-            .as("expected error: User has previously authenticated.")
-            .isEqualTo(503);
+        assertEquals("expected error: User has previously authenticated.", 503, smtpProtocol.getReplyCode());
 
         smtpProtocol.addRecipient("mail@sample.com");
         smtpProtocol.sendShortMessageData("Subject: test\r\n\r\nTest body testAuth\r\n");
@@ -1232,9 +1108,7 @@ public class SMTPServerTest {
         smtpProtocol.quit();
 
         // mail was propagated by SMTPServer
-        assertThat(queue.getLastMail())
-            .as("mail received by mail server")
-            .isNotNull();
+        assertNotNull("mail received by mail server", queue.getLastMail());
     }
 
     @Test
@@ -1255,14 +1129,10 @@ public class SMTPServerTest {
 
         smtpProtocol.sendCommand("AUTH PLAIN");
         smtpProtocol.sendCommand(Base64.encodeAsString("\0" + userName + "\0pwd\0"));
-        assertThat(smtpProtocol.getReplyCode())
-            .as("authenticated")
-            .isEqualTo(235);
+        assertEquals("authenticated", 235, smtpProtocol.getReplyCode());
 
         smtpProtocol.addRecipient("mail@sample.com");
-        assertThat(smtpProtocol.getReplyCode())
-            .as("expected error")
-            .isEqualTo(503);
+        assertEquals("expected error", 503, smtpProtocol.getReplyCode());
 
         smtpProtocol.quit();
     }
@@ -1281,16 +1151,12 @@ public class SMTPServerTest {
         // left out for test smtpProtocol.rcpt(new Address("mail@localhost"));
 
         smtpProtocol.sendShortMessageData("Subject: test\r\n\r\nTest body testNoRecepientSpecified\r\n");
-        assertThat(SMTPReply.isNegativePermanent(smtpProtocol.getReplyCode()))
-            .as("sending succeeded without recepient")
-            .isTrue();
+        assertTrue("sending succeeded without recepient", SMTPReply.isNegativePermanent(smtpProtocol.getReplyCode()));
 
         smtpProtocol.quit();
 
         // mail was propagated by SMTPServer
-        assertThat(queue.getLastMail())
-            .as("no mail received by mail server")
-            .isNull();
+        assertNull("no mail received by mail server", queue.getLastMail());
     }
 
     @Test
@@ -1311,9 +1177,7 @@ public class SMTPServerTest {
         smtpProtocol.quit();
 
         // mail was propagated by SMTPServer
-        assertThat(queue.getLastMail())
-            .as("no mail received by mail server")
-            .isNull();
+        assertNull("no mail received by mail server", queue.getLastMail());
     }
 
     @Test
@@ -1329,9 +1193,7 @@ public class SMTPServerTest {
         smtpProtocol.setSender("mail@sample.com");
 
         smtpProtocol.addRecipient("maila@sample.com");
-        assertThat(smtpProtocol.getReplyCode())
-            .as("expected 550 error")
-            .isEqualTo(550);
+        assertEquals("expected 550 error", 550, smtpProtocol.getReplyCode());
     }
 
     @Test
@@ -1345,14 +1207,10 @@ public class SMTPServerTest {
         smtpProtocol.sendCommand("ehlo " + InetAddress.getLocalHost());
 
         smtpProtocol.sendCommand("MAIL FROM:<mail@localhost> SIZE=1025", null);
-        assertThat(smtpProtocol.getReplyCode())
-            .as("expected error: max msg size exceeded")
-            .isEqualTo(552);
+        assertEquals("expected error: max msg size exceeded", 552, smtpProtocol.getReplyCode());
 
         smtpProtocol.addRecipient("mail@localhost");
-        assertThat(smtpProtocol.getReplyCode())
-            .as("expected error")
-            .isEqualTo(503);
+        assertEquals("expected error", 503, smtpProtocol.getReplyCode());
     }
 
     public void testHandleMessageSizeLimitExceeded() throws Exception {
@@ -1384,12 +1242,9 @@ public class SMTPServerTest {
         wr.write("123456781012345678201\r\n"); // 521 + CRLF = 523 + 502 => 1025
         wr.close();
 
-        assertThat(smtpProtocol.completePendingCommand())
-            .isFalse();
+        assertFalse(smtpProtocol.completePendingCommand());
 
-        assertThat(smtpProtocol.getReplyCode())
-            .as("expected 552 error")
-            .isEqualTo(552);
+        assertEquals("expected 552 error", 552, smtpProtocol.getReplyCode());
 
     }
 
@@ -1421,12 +1276,9 @@ public class SMTPServerTest {
         wr.write("1234567810123456782012\r\n"); // 1022 + CRLF = 1024
         wr.close();
 
-        assertThat(smtpProtocol.completePendingCommand())
-            .isTrue();
+        assertTrue(smtpProtocol.completePendingCommand());
 
-        assertThat(smtpProtocol.getReplyCode())
-            .as("expected 250 ok")
-            .isEqualTo(250);
+        assertEquals("expected 250 ok", 250, smtpProtocol.getReplyCode());
 
     }
     // Check if auth users get not rejected cause rbl. See JAMES-566
@@ -1451,9 +1303,7 @@ public class SMTPServerTest {
             capabilitieslist.add(capabilityRes[i].substring(4));
         }
 
-        assertThat(capabilitieslist.contains("AUTH LOGIN PLAIN"))
-            .as("anouncing auth required")
-            .isTrue();
+        assertTrue("anouncing auth required", capabilitieslist.contains("AUTH LOGIN PLAIN"));
         // is this required or just for compatibility? assertTrue("anouncing
         // auth required", capabilitieslist.contains("AUTH=LOGIN PLAIN"));
 
@@ -1466,23 +1316,17 @@ public class SMTPServerTest {
 
         smtpProtocol.sendCommand("AUTH PLAIN");
         smtpProtocol.sendCommand(Base64.encodeAsString("\0" + userName + "\0pwd\0"));
-        assertThat(smtpProtocol.getReplyCode())
-            .as("authenticated")
-            .isEqualTo(235);
+        assertEquals("authenticated", 235, smtpProtocol.getReplyCode());
 
         smtpProtocol.addRecipient("mail@sample.com");
-        assertThat(smtpProtocol.getReplyCode())
-            .as("authenticated.. not reject")
-            .isEqualTo(250);
+        assertEquals("authenticated.. not reject", 250, smtpProtocol.getReplyCode());
 
         smtpProtocol.sendShortMessageData("Subject: test\r\n\r\nTest body testDNSRBLNotRejectAuthUser\r\n");
 
         smtpProtocol.quit();
 
         // mail was propagated by SMTPServer
-        assertThat(queue.getLastMail())
-            .as("mail received by mail server")
-            .isNotNull();
+        assertNotNull("mail received by mail server", queue.getLastMail());
     }
 
     @Test
@@ -1503,18 +1347,14 @@ public class SMTPServerTest {
         smtpProtocol.setSender(sender);
 
         smtpProtocol.addRecipient("mail@sample.com");
-        assertThat(smtpProtocol.getReplyCode())
-            .as("reject")
-            .isEqualTo(554);
+        assertEquals("reject", 554, smtpProtocol.getReplyCode());
 
         smtpProtocol.sendShortMessageData("Subject: test\r\n\r\nTest body testDNSRBLRejectWorks\r\n");
 
         smtpProtocol.quit();
 
         // mail was rejected by SMTPServer
-        assertThat(queue.getLastMail())
-            .as("mail reject by mail server")
-            .isNull();
+        assertNull("mail reject by mail server", queue.getLastMail());
     }
 
     @Test
@@ -1527,14 +1367,10 @@ public class SMTPServerTest {
         smtpProtocol.sendCommand("ehlo", InetAddress.getLocalHost().toString());
 
         smtpProtocol.sendCommand("mail from:", "test@localhost");
-        assertThat(smtpProtocol.getReplyCode())
-            .as("accept")
-            .isEqualTo(250);
+        assertEquals("accept", 250, smtpProtocol.getReplyCode());
 
         smtpProtocol.sendCommand("rcpt to:", "mail@sample.com");
-        assertThat(smtpProtocol.getReplyCode())
-            .as("accept")
-            .isEqualTo(250);
+        assertEquals("accept", 250, smtpProtocol.getReplyCode());
 
         smtpProtocol.quit();
 
@@ -1543,14 +1379,10 @@ public class SMTPServerTest {
         smtpProtocol.sendCommand("ehlo", InetAddress.getLocalHost().toString());
 
         smtpProtocol.sendCommand("mail from:", "<test@localhost>");
-        assertThat(smtpProtocol.getReplyCode())
-            .as("accept")
-            .isEqualTo(250);
+        assertEquals("accept", 250, smtpProtocol.getReplyCode());
 
         smtpProtocol.sendCommand("rcpt to:", "<mail@sample.com>");
-        assertThat(smtpProtocol.getReplyCode())
-            .as("accept")
-            .isEqualTo(250);
+        assertEquals("accept", 250, smtpProtocol.getReplyCode());
 
         smtpProtocol.quit();
     }
@@ -1564,22 +1396,14 @@ public class SMTPServerTest {
         smtpProtocol.sendCommand("ehlo", InetAddress.getLocalHost().toString());
 
         smtpProtocol.sendCommand("mail from:", "test@localhost");
-        assertThat(smtpProtocol.getReplyCode())
-            .as("reject")
-            .isEqualTo(501);
+        assertEquals("reject", 501, smtpProtocol.getReplyCode());
         smtpProtocol.sendCommand("mail from:", "<test@localhost>");
-        assertThat(smtpProtocol.getReplyCode())
-            .as("accept")
-            .isEqualTo(250);
+        assertEquals("accept", 250, smtpProtocol.getReplyCode());
 
         smtpProtocol.sendCommand("rcpt to:", "mail@sample.com");
-        assertThat(smtpProtocol.getReplyCode())
-            .as("reject")
-            .isEqualTo(501);
+        assertEquals("reject", 501, smtpProtocol.getReplyCode());
         smtpProtocol.sendCommand("rcpt to:", "<mail@sample.com>");
-        assertThat(smtpProtocol.getReplyCode())
-            .as("accept")
-            .isEqualTo(250);
+        assertEquals("accept", 250, smtpProtocol.getReplyCode());
 
         smtpProtocol.quit();
     }
@@ -1617,24 +1441,12 @@ public class SMTPServerTest {
 
         BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream()));
 
-        assertThat(Integer.parseInt(in.readLine().split(" ")[0]))
-            .as("Connection made")
-            .isEqualTo(220);
-        assertThat(Integer.parseInt(in.readLine().split(" ")[0]))
-            .as("HELO accepted")
-            .isEqualTo(250);
-        assertThat(Integer.parseInt(in.readLine().split(" ")[0]))
-            .as("MAIL FROM accepted")
-            .isEqualTo(250);
-        assertThat(Integer.parseInt(in.readLine().split(" ")[0]))
-            .as("RCPT TO accepted")
-            .isEqualTo(250);
-        assertThat(Integer.parseInt(in.readLine().split(" ")[0]))
-            .as("DATA accepted")
-            .isEqualTo(354);
-        assertThat(Integer.parseInt(in.readLine().split(" ")[0]))
-            .as("Message accepted")
-            .isEqualTo(250);
+        assertEquals("Connection made", 220, Integer.parseInt(in.readLine().split(" ")[0]));
+        assertEquals("HELO accepted", 250, Integer.parseInt(in.readLine().split(" ")[0]));
+        assertEquals("MAIL FROM accepted", 250, Integer.parseInt(in.readLine().split(" ")[0]));
+        assertEquals("RCPT TO accepted", 250, Integer.parseInt(in.readLine().split(" ")[0]));
+        assertEquals("DATA accepted", 354, Integer.parseInt(in.readLine().split(" ")[0]));
+        assertEquals("Message accepted", 250, Integer.parseInt(in.readLine().split(" ")[0]));
         in.close();
         out.close();
         client.close();
@@ -1676,24 +1488,12 @@ public class SMTPServerTest {
 
         BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream()));
 
-        assertThat(Integer.parseInt(in.readLine().split(" ")[0]))
-            .as("Connection made")
-            .isEqualTo(220);
-        assertThat(Integer.parseInt(in.readLine().split(" ")[0]))
-            .as("HELO accepted")
-            .isEqualTo(250);
-        assertThat(Integer.parseInt(in.readLine().split(" ")[0]))
-            .as("MAIL FROM accepted")
-            .isEqualTo(250);
-        assertThat(Integer.parseInt(in.readLine().split(" ")[0]))
-            .as("RCPT TO rejected")
-            .isEqualTo(550);
-        assertThat(Integer.parseInt(in.readLine().split(" ")[0]))
-            .as("RCPT TO rejected")
-            .isEqualTo(550);
-        assertThat(Integer.parseInt(in.readLine().split(" ")[0]))
-            .as("DATA not accepted")
-            .isEqualTo(503);
+        assertEquals("Connection made", 220, Integer.parseInt(in.readLine().split(" ")[0]));
+        assertEquals("HELO accepted", 250, Integer.parseInt(in.readLine().split(" ")[0]));
+        assertEquals("MAIL FROM accepted", 250, Integer.parseInt(in.readLine().split(" ")[0]));
+        assertEquals("RCPT TO rejected", 550, Integer.parseInt(in.readLine().split(" ")[0]));
+        assertEquals("RCPT TO rejected", 550, Integer.parseInt(in.readLine().split(" ")[0]));
+        assertEquals("DATA not accepted", 503, Integer.parseInt(in.readLine().split(" ")[0]));
         in.close();
         out.close();
         client.close();
@@ -1734,27 +1534,13 @@ public class SMTPServerTest {
 
         BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream()));
 
-        assertThat(Integer.parseInt(in.readLine().split(" ")[0]))
-            .as("Connection made")
-            .isEqualTo(220);
-        assertThat(Integer.parseInt(in.readLine().split(" ")[0]))
-            .as("HELO accepted")
-            .isEqualTo(250);
-        assertThat(Integer.parseInt(in.readLine().split(" ")[0]))
-            .as("MAIL FROM accepted")
-            .isEqualTo(250);
-        assertThat(Integer.parseInt(in.readLine().split(" ")[0]))
-            .as("RCPT TO rejected")
-            .isEqualTo(550);
-        assertThat(Integer.parseInt(in.readLine().split(" ")[0]))
-            .as("RCPT accepted")
-            .isEqualTo(250);
-        assertThat(Integer.parseInt(in.readLine().split(" ")[0]))
-            .as("DATA accepted")
-            .isEqualTo(354);
-        assertThat(Integer.parseInt(in.readLine().split(" ")[0]))
-            .as("Message accepted")
-            .isEqualTo(250);
+        assertEquals("Connection made", 220, Integer.parseInt(in.readLine().split(" ")[0]));
+        assertEquals("HELO accepted", 250, Integer.parseInt(in.readLine().split(" ")[0]));
+        assertEquals("MAIL FROM accepted", 250, Integer.parseInt(in.readLine().split(" ")[0]));
+        assertEquals("RCPT TO rejected", 550, Integer.parseInt(in.readLine().split(" ")[0]));
+        assertEquals("RCPT accepted", 250, Integer.parseInt(in.readLine().split(" ")[0]));
+        assertEquals("DATA accepted", 354, Integer.parseInt(in.readLine().split(" ")[0]));
+        assertEquals("Message accepted", 250, Integer.parseInt(in.readLine().split(" ")[0]));
         in.close();
         out.close();
         client.close();


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