james-mime4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mwiederk...@apache.org
Subject svn commit: r741178 - in /james/mime4j/trunk/src: main/java/org/apache/james/mime4j/descriptor/DefaultBodyDescriptor.java test/java/org/apache/james/mime4j/descriptor/BaseTestForBodyDescriptors.java
Date Thu, 05 Feb 2009 16:50:41 GMT
Author: mwiederkehr
Date: Thu Feb  5 16:50:40 2009
New Revision: 741178

URL: http://svn.apache.org/viewvc?rev=741178&view=rev
Log:
bug fix: getContentLength() did not work

Modified:
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/descriptor/DefaultBodyDescriptor.java
    james/mime4j/trunk/src/test/java/org/apache/james/mime4j/descriptor/BaseTestForBodyDescriptors.java

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/descriptor/DefaultBodyDescriptor.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/descriptor/DefaultBodyDescriptor.java?rev=741178&r1=741177&r2=741178&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/descriptor/DefaultBodyDescriptor.java
(original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/descriptor/DefaultBodyDescriptor.java
Thu Feb  5 16:50:40 2009
@@ -104,7 +104,7 @@
                 transferEncoding = value;
             }
             
-        } else if (name.equals("content-length")  &&  contentLength != -1) {
+        } else if (name.equals("content-length") && contentLength == -1) {
             try {
                 contentLength = Long.parseLong(value.trim());
             } catch (NumberFormatException e) {

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/descriptor/BaseTestForBodyDescriptors.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/descriptor/BaseTestForBodyDescriptors.java?rev=741178&r1=741177&r2=741178&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/descriptor/BaseTestForBodyDescriptors.java
(original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/descriptor/BaseTestForBodyDescriptors.java
Thu Feb  5 16:50:40 2009
@@ -185,6 +185,20 @@
         
     }
     
+    public void testGetContentLength() throws Exception {
+        MutableBodyDescriptor bd = null;
+
+        bd = newBodyDescriptor();
+        assertEquals(-1, bd.getContentLength());
+
+        bd.addField("Content-Length", "9901");
+        assertEquals(9901, bd.getContentLength());
+
+        // only the first content-length counts
+        bd.addField("Content-Length", "1239901");
+        assertEquals(9901, bd.getContentLength());
+    }
+    
     public void testDoDefaultToUsAsciiWhenUntyped() throws Exception {
         MutableBodyDescriptor descriptor = newBodyDescriptor();
         descriptor.addField("To", "me@example.org");



Mime
View raw message