james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r674338 - in /james/mime4j/trunk/src: main/java/org/apache/james/mime4j/MimeTokenStream.java test/java/org/apache/james/mime4j/MimeTokenNoRecurseTest.java
Date Sun, 06 Jul 2008 19:52:58 GMT
Author: rdonkin
Date: Sun Jul  6 12:52:58 2008
New Revision: 674338

URL: http://svn.apache.org/viewvc?rev=674338&view=rev
Log:
Fix changing recursion mode half way through an operation

Modified:
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/MimeTokenStream.java
    james/mime4j/trunk/src/test/java/org/apache/james/mime4j/MimeTokenNoRecurseTest.java

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/MimeTokenStream.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/MimeTokenStream.java?rev=674338&r1=674337&r2=674338&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/MimeTokenStream.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/MimeTokenStream.java Sun Jul
 6 12:52:58 2008
@@ -364,6 +364,7 @@
                 currentStateMachine = null;
             } else {
                 currentStateMachine = (EntityStateMachine) entities.getLast();
+                currentStateMachine.setRecursionMode(recursionMode);
             }
         }
         state = T_END_OF_STREAM;

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/MimeTokenNoRecurseTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/MimeTokenNoRecurseTest.java?rev=674338&r1=674337&r2=674338&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/MimeTokenNoRecurseTest.java (original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/MimeTokenNoRecurseTest.java Sun
Jul  6 12:52:58 2008
@@ -170,6 +170,37 @@
         }
         assertEquals(INNER_MAIL.length()-2, i);
     }
+    
+    public void testSetNoRecurseSoInputStreamShouldContainInnerMail() throws Exception {
+        nextIs(MimeTokenStream.T_START_HEADER);
+        nextIs(MimeTokenStream.T_FIELD);
+        nextIs(MimeTokenStream.T_FIELD);
+        nextIs(MimeTokenStream.T_FIELD);
+        nextIs(MimeTokenStream.T_FIELD);
+        nextIs(MimeTokenStream.T_FIELD);
+        nextIs(MimeTokenStream.T_FIELD);
+        nextIs(MimeTokenStream.T_END_HEADER);
+        
+        nextIs(MimeTokenStream.T_START_MULTIPART);
+        nextIs(MimeTokenStream.T_PREAMBLE);
+        nextShouldBeStandardPart(false);
+        
+        nextShouldBeStandardPart(true);
+        stream.setRecursionMode(MimeTokenStream.M_NO_RECURSE);
+        nextIs(MimeTokenStream.T_START_BODYPART);
+        nextIs(MimeTokenStream.T_START_HEADER);
+        nextIs(MimeTokenStream.T_FIELD);
+        nextIs(MimeTokenStream.T_END_HEADER);
+        nextIs(MimeTokenStream.T_BODY);
+        InputStream inputStream = stream.getInputStream();
+        int next = inputStream.read();
+        int i=0;
+        while (next != -1) {
+            assertEquals("@" + i, INNER_MAIL.charAt(i++), (char) next);
+            next = inputStream.read();
+        }
+        assertEquals(INNER_MAIL.length()-2, i);
+    }
 
     private void nextShouldBeStandardPart(boolean withHeader) throws Exception {
         nextIs(MimeTokenStream.T_START_BODYPART);



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