Author: sebb
Date: Mon Aug 24 13:05:38 2015
New Revision: 1697380

URL: http://svn.apache.org/r1697380
Log:
NET-582 SimpleSMTPHeader does not allow for missing To: field

Added:
    commons/proper/net/trunk/src/test/java/org/apache/commons/net/smtp/
    
commons/proper/net/trunk/src/test/java/org/apache/commons/net/smtp/SimpleSMTPHeaderTestCase.java
   (with props)

Added: 
commons/proper/net/trunk/src/test/java/org/apache/commons/net/smtp/SimpleSMTPHeaderTestCase.java
URL: 
http://svn.apache.org/viewvc/commons/proper/net/trunk/src/test/java/org/apache/commons/net/smtp/SimpleSMTPHeaderTestCase.java?rev=1697380&view=auto
==============================================================================
--- 
commons/proper/net/trunk/src/test/java/org/apache/commons/net/smtp/SimpleSMTPHeaderTestCase.java
 (added)
+++ 
commons/proper/net/trunk/src/test/java/org/apache/commons/net/smtp/SimpleSMTPHeaderTestCase.java
 Mon Aug 24 13:05:38 2015
@@ -0,0 +1,47 @@
+package org.apache.commons.net.smtp;
+
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class SimpleSMTPHeaderTestCase {
+
+    private SimpleSMTPHeader header;
+
+    @Before
+    public void setUp() {
+        header = new SimpleSMTPHeader("from@here.invalid", "to@there.invalid", 
"Test email");
+    }
+
+    @Test
+    public void testToString() {
+        assertNotNull(header);
+        // Note that the DotTerminatedMessageWriter converts LF to CRLF
+        assertEquals("From: from@here.invalid\nTo: to@there.invalid\nSubject: 
Test email\n\n", header.toString());
+    }
+
+    @Test
+    public void testToStringNoSubject() {
+        SimpleSMTPHeader hdr = new SimpleSMTPHeader("from@here.invalid", 
"to@there.invalid", null);
+        assertNotNull(hdr);
+        // Note that the DotTerminatedMessageWriter converts LF to CRLF
+        assertEquals("From: from@here.invalid\nTo: to@there.invalid\n\n", 
hdr.toString());
+    }
+
+    @Test(expected=IllegalArgumentException.class)
+    public void testToStringNoFrom() {
+        SimpleSMTPHeader hdr = new SimpleSMTPHeader(null, null, null);
+        assertNotNull(hdr);
+        // Note that the DotTerminatedMessageWriter converts LF to CRLF
+        assertEquals("From: from@here.invalid\n\n", hdr.toString());
+    }
+    @Test
+
+    public void testToStringNoTo() {
+        SimpleSMTPHeader hdr = new SimpleSMTPHeader("from@here.invalid", null, 
null);
+        assertNotNull(hdr);
+        // Note that the DotTerminatedMessageWriter converts LF to CRLF
+        assertEquals("From: from@here.invalid\n\n", hdr.toString());
+    }
+}

Propchange: 
commons/proper/net/trunk/src/test/java/org/apache/commons/net/smtp/SimpleSMTPHeaderTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native


Reply via email to