james-mime4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1178629 - in /james/mime4j/trunk/dom/src: main/java/org/apache/james/mime4j/message/MessageImpl.java test/java/org/apache/james/mime4j/dom/MessageTest.java test/java/org/apache/james/mime4j/dom/MimeBuilderCopyTest.java
Date Mon, 03 Oct 2011 23:13:45 GMT
Author: olegk
Date: Mon Oct  3 23:13:45 2011
New Revision: 1178629

URL: http://svn.apache.org/viewvc?rev=1178629&view=rev
Log:
MIME4J-205: new instances of MessageImpl class to contain a MIME-version field per default

Modified:
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MessageImpl.java
    james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageTest.java
    james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MimeBuilderCopyTest.java

Modified: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MessageImpl.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MessageImpl.java?rev=1178629&r1=1178628&r2=1178629&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MessageImpl.java
(original)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MessageImpl.java
Mon Oct  3 23:13:45 2011
@@ -24,6 +24,8 @@ import java.util.Date;
 import java.util.Map;
 import java.util.TimeZone;
 
+import org.apache.james.mime4j.codec.DecodeMonitor;
+import org.apache.james.mime4j.dom.Header;
 import org.apache.james.mime4j.dom.Message;
 import org.apache.james.mime4j.dom.address.Address;
 import org.apache.james.mime4j.dom.address.Mailbox;
@@ -39,6 +41,8 @@ import org.apache.james.mime4j.dom.field
 import org.apache.james.mime4j.field.ContentTransferEncodingFieldImpl;
 import org.apache.james.mime4j.field.ContentTypeFieldImpl;
 import org.apache.james.mime4j.field.Fields;
+import org.apache.james.mime4j.field.MimeVersionFieldLenientImpl;
+import org.apache.james.mime4j.stream.RawField;
 import org.apache.james.mime4j.util.MimeUtil;
 
 /**
@@ -50,6 +54,10 @@ public class MessageImpl extends Abstrac
      * Creates a new empty <code>Message</code>.
      */
     public MessageImpl() {
+        super();
+        Header header = obtainHeader();
+        RawField rawField = new RawField(FieldName.MIME_VERSION, "1.0");
+        header.addField(MimeVersionFieldLenientImpl.PARSER.parse(rawField, DecodeMonitor.SILENT));
     }
 
     @Override

Modified: james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageTest.java?rev=1178629&r1=1178628&r2=1178629&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageTest.java (original)
+++ james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageTest.java Mon
Oct  3 23:13:45 2011
@@ -39,6 +39,8 @@ import org.apache.james.mime4j.dom.Multi
 import org.apache.james.mime4j.dom.SingleBody;
 import org.apache.james.mime4j.dom.address.Group;
 import org.apache.james.mime4j.dom.address.Mailbox;
+import org.apache.james.mime4j.dom.field.FieldName;
+import org.apache.james.mime4j.dom.field.MimeVersionField;
 import org.apache.james.mime4j.field.DefaultFieldParser;
 import org.apache.james.mime4j.field.address.AddressBuilder;
 import org.apache.james.mime4j.message.BodyPart;
@@ -177,6 +179,15 @@ public class MessageTest extends TestCas
         assertTrue("header added", lines.contains(testheader));
     }
 
+    public void testMimeVersion() throws Exception {
+        MessageImpl m = new MessageImpl();
+        assertNotNull(m.getHeader());
+        MimeVersionField field = (MimeVersionField) m.getHeader().getField(FieldName.MIME_VERSION);
+        assertNotNull(field);
+        assertEquals(1, field.getMajorVersion());
+        assertEquals(0, field.getMinorVersion());
+    }
+
     public void testGetMessageId() throws Exception {
         MessageImpl m = new MessageImpl();
         assertNull(m.getMessageId());

Modified: james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MimeBuilderCopyTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MimeBuilderCopyTest.java?rev=1178629&r1=1178628&r2=1178629&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MimeBuilderCopyTest.java
(original)
+++ james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MimeBuilderCopyTest.java
Mon Oct  3 23:13:45 2011
@@ -39,17 +39,6 @@ import junit.framework.TestCase;
 
 public class MimeBuilderCopyTest extends TestCase {
 
-    public void testCopyEmptyMessage() throws Exception {
-        MessageImpl original = new MessageImpl();
-
-        DefaultMessageBuilder builder = new DefaultMessageBuilder();
-        Message copy = builder.copy(original);
-
-        assertNull(copy.getHeader());
-        assertNull(copy.getBody());
-        assertNull(copy.getParent());
-    }
-
     public void testCopyMessage() throws Exception {
         MessageImpl parent = new MessageImpl();
         Header header = new HeaderImpl();



Mime
View raw message