james-mime4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mwiederk...@apache.org
Subject svn commit: r778457 [11/13] - in /james/mime4j/trunk: benchmark/src/main/java/org/apache/james/mime4j/ core/src/main/java/org/apache/james/mime4j/ core/src/main/java/org/apache/james/mime4j/codec/ core/src/main/java/org/apache/james/mime4j/descriptor/ ...
Date Mon, 25 May 2009 17:20:52 GMT
Propchange: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/BufferedLineReaderInputStreamBufferTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/BufferedLineReaderInputStreamTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/EOLConvertingInputStreamTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/EOLConvertingInputStreamTest.java?rev=778457&r1=778456&r2=778457&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/EOLConvertingInputStreamTest.java (original)
+++ james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/EOLConvertingInputStreamTest.java Mon May 25 17:20:48 2009
@@ -1,120 +1,120 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.mime4j.io;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-
-import org.apache.james.mime4j.io.EOLConvertingInputStream;
-
-
-import junit.framework.TestCase;
-
-public class EOLConvertingInputStreamTest extends TestCase {
-
-    public void testRead() throws IOException {
-        testConvertBoth("Line 1\r\nLine 2\r\n", "Line 1\r\nLine 2\r\n");
-        testConvertCR("Line 1\r\nLine 2\r\n", "Line 1\r\nLine 2\r\n");
-        testConvertLF("Line 1\r\nLine 2\r\n", "Line 1\r\nLine 2\r\n");
-        
-        testConvertBoth("Line 1\n\rLine 2\n\r", "Line 1\r\n\r\nLine 2\r\n\r\n");
-        testConvertCR("Line 1\n\rLine 2\n\r", "Line 1\n\r\nLine 2\n\r\n");
-        testConvertLF("Line 1\n\rLine 2\n\r", "Line 1\r\n\rLine 2\r\n\r");
-        
-        testConvertBoth("Line 1\nLine 2\n", "Line 1\r\nLine 2\r\n");
-        testConvertCR("Line 1\nLine 2\n", "Line 1\nLine 2\n");
-        testConvertLF("Line 1\nLine 2\n", "Line 1\r\nLine 2\r\n");
-        
-        testConvertBoth("Line 1\rLine 2\r", "Line 1\r\nLine 2\r\n");
-        testConvertCR("Line 1\rLine 2\r", "Line 1\r\nLine 2\r\n");
-        testConvertLF("Line 1\rLine 2\r", "Line 1\rLine 2\r");
-        
-        testConvertBoth("\r\n", "\r\n");
-        testConvertCR("\r\n", "\r\n");
-        testConvertLF("\r\n", "\r\n");
-        
-        testConvertBoth("\n", "\r\n");
-        testConvertCR("\n", "\n");
-        testConvertLF("\n", "\r\n");
-        
-        testConvertBoth("\r", "\r\n");
-        testConvertCR("\r", "\r\n");
-        testConvertLF("\r", "\r");
-        
-        testConvertBoth("", "");
-        testConvertCR("", "");
-        testConvertLF("", "");
-    }
-
-    private void testConvertBoth(String s1, String s2) throws IOException {
-        byte[] bytes = new byte[1024];
-        
-        ByteArrayInputStream bais = new ByteArrayInputStream(fromString(s1));
-        EOLConvertingInputStream in = 
-            new EOLConvertingInputStream(bais, 
-                        EOLConvertingInputStream.CONVERT_BOTH);
-        int n = in.read(bytes);
-        assertEquals(s2, toString(bytes, n));
-    }
-    
-    private void testConvertCR(String s1, String s2) throws IOException {
-        byte[] bytes = new byte[1024];
-        
-        ByteArrayInputStream bais = new ByteArrayInputStream(fromString(s1));
-        EOLConvertingInputStream in = 
-            new EOLConvertingInputStream(bais, 
-                        EOLConvertingInputStream.CONVERT_CR);
-        int n = in.read(bytes);
-        assertEquals(s2, toString(bytes, n));
-    }
-    
-    private void testConvertLF(String s1, String s2) throws IOException {
-        byte[] bytes = new byte[1024];
-        
-        ByteArrayInputStream bais = new ByteArrayInputStream(fromString(s1));
-        EOLConvertingInputStream in = 
-            new EOLConvertingInputStream(bais, 
-                        EOLConvertingInputStream.CONVERT_LF);
-        int n = in.read(bytes);
-        assertEquals(s2, toString(bytes, n));
-    }
-    
-    private String toString(byte[] b, int len) {
-        try {
-            if (len == -1) {
-                return "";
-            }
-            return new String(b, 0, len, "US-ASCII");
-        } catch (UnsupportedEncodingException e) {
-            fail(e.getMessage());
-            return null;
-        }
-    }    
-    
-    private byte[] fromString(String s) {
-        try {
-            return s.getBytes("US-ASCII");
-        } catch (UnsupportedEncodingException e) {
-            fail(e.getMessage());
-            return null;
-        }
-    }    
-}
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.mime4j.io;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+
+import org.apache.james.mime4j.io.EOLConvertingInputStream;
+
+
+import junit.framework.TestCase;
+
+public class EOLConvertingInputStreamTest extends TestCase {
+
+    public void testRead() throws IOException {
+        testConvertBoth("Line 1\r\nLine 2\r\n", "Line 1\r\nLine 2\r\n");
+        testConvertCR("Line 1\r\nLine 2\r\n", "Line 1\r\nLine 2\r\n");
+        testConvertLF("Line 1\r\nLine 2\r\n", "Line 1\r\nLine 2\r\n");
+        
+        testConvertBoth("Line 1\n\rLine 2\n\r", "Line 1\r\n\r\nLine 2\r\n\r\n");
+        testConvertCR("Line 1\n\rLine 2\n\r", "Line 1\n\r\nLine 2\n\r\n");
+        testConvertLF("Line 1\n\rLine 2\n\r", "Line 1\r\n\rLine 2\r\n\r");
+        
+        testConvertBoth("Line 1\nLine 2\n", "Line 1\r\nLine 2\r\n");
+        testConvertCR("Line 1\nLine 2\n", "Line 1\nLine 2\n");
+        testConvertLF("Line 1\nLine 2\n", "Line 1\r\nLine 2\r\n");
+        
+        testConvertBoth("Line 1\rLine 2\r", "Line 1\r\nLine 2\r\n");
+        testConvertCR("Line 1\rLine 2\r", "Line 1\r\nLine 2\r\n");
+        testConvertLF("Line 1\rLine 2\r", "Line 1\rLine 2\r");
+        
+        testConvertBoth("\r\n", "\r\n");
+        testConvertCR("\r\n", "\r\n");
+        testConvertLF("\r\n", "\r\n");
+        
+        testConvertBoth("\n", "\r\n");
+        testConvertCR("\n", "\n");
+        testConvertLF("\n", "\r\n");
+        
+        testConvertBoth("\r", "\r\n");
+        testConvertCR("\r", "\r\n");
+        testConvertLF("\r", "\r");
+        
+        testConvertBoth("", "");
+        testConvertCR("", "");
+        testConvertLF("", "");
+    }
+
+    private void testConvertBoth(String s1, String s2) throws IOException {
+        byte[] bytes = new byte[1024];
+        
+        ByteArrayInputStream bais = new ByteArrayInputStream(fromString(s1));
+        EOLConvertingInputStream in = 
+            new EOLConvertingInputStream(bais, 
+                        EOLConvertingInputStream.CONVERT_BOTH);
+        int n = in.read(bytes);
+        assertEquals(s2, toString(bytes, n));
+    }
+    
+    private void testConvertCR(String s1, String s2) throws IOException {
+        byte[] bytes = new byte[1024];
+        
+        ByteArrayInputStream bais = new ByteArrayInputStream(fromString(s1));
+        EOLConvertingInputStream in = 
+            new EOLConvertingInputStream(bais, 
+                        EOLConvertingInputStream.CONVERT_CR);
+        int n = in.read(bytes);
+        assertEquals(s2, toString(bytes, n));
+    }
+    
+    private void testConvertLF(String s1, String s2) throws IOException {
+        byte[] bytes = new byte[1024];
+        
+        ByteArrayInputStream bais = new ByteArrayInputStream(fromString(s1));
+        EOLConvertingInputStream in = 
+            new EOLConvertingInputStream(bais, 
+                        EOLConvertingInputStream.CONVERT_LF);
+        int n = in.read(bytes);
+        assertEquals(s2, toString(bytes, n));
+    }
+    
+    private String toString(byte[] b, int len) {
+        try {
+            if (len == -1) {
+                return "";
+            }
+            return new String(b, 0, len, "US-ASCII");
+        } catch (UnsupportedEncodingException e) {
+            fail(e.getMessage());
+            return null;
+        }
+    }    
+    
+    private byte[] fromString(String s) {
+        try {
+            return s.getBytes("US-ASCII");
+        } catch (UnsupportedEncodingException e) {
+            fail(e.getMessage());
+            return null;
+        }
+    }    
+}

Propchange: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/EOLConvertingInputStreamTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/LineNumberInputStreamTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/LineNumberInputStreamTest.java?rev=778457&r1=778456&r2=778457&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/LineNumberInputStreamTest.java (original)
+++ james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/LineNumberInputStreamTest.java Mon May 25 17:20:48 2009
@@ -1,81 +1,81 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.mime4j.io;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-
-import org.apache.james.mime4j.io.LineNumberInputStream;
-
-import junit.framework.TestCase;
-
-public class LineNumberInputStreamTest extends TestCase {
-    /**
-     * Tests that reading single bytes updates the line number appropriately.
-     */
-    public void testReadSingleByte() throws IOException {
-        String s = "Yada\r\nyada\r\nyada\r\n";
-        LineNumberInputStream is = new LineNumberInputStream(
-                new ByteArrayInputStream(s.getBytes()));
-
-        for (int i = 0; i < 6; i++) {
-            assertEquals(1, is.getLineNumber());
-            is.read();
-        }
-
-        for (int i = 6; i < 12; i++) {
-            assertEquals(2, is.getLineNumber());
-            is.read();
-        }
-
-        for (int i = 12; i < 18; i++) {
-            assertEquals(3, is.getLineNumber());
-            is.read();
-        }
-
-        assertEquals(4, is.getLineNumber());
-        assertEquals(-1, is.read());
-    }
-
-    /**
-     * Tests that reading multiple bytes at once updates the line number
-     * appropriately.
-     */
-    public void testReadManyBytes() throws IOException {
-        String s = "Yada\r\nyada\r\nyada\r\n";
-        LineNumberInputStream is = new LineNumberInputStream(
-                new ByteArrayInputStream(s.getBytes()));
-
-        byte[] buf = new byte[4];
-        assertEquals(1, is.getLineNumber());
-        is.read(buf);
-        assertEquals(1, is.getLineNumber());
-        is.read(buf);
-        assertEquals(2, is.getLineNumber());
-        is.read(buf);
-        assertEquals(3, is.getLineNumber());
-        is.read(buf);
-        assertEquals(3, is.getLineNumber());
-        is.read(buf);
-        assertEquals(4, is.getLineNumber());
-
-        assertEquals(-1, is.read());
-    }
-}
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.mime4j.io;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+
+import org.apache.james.mime4j.io.LineNumberInputStream;
+
+import junit.framework.TestCase;
+
+public class LineNumberInputStreamTest extends TestCase {
+    /**
+     * Tests that reading single bytes updates the line number appropriately.
+     */
+    public void testReadSingleByte() throws IOException {
+        String s = "Yada\r\nyada\r\nyada\r\n";
+        LineNumberInputStream is = new LineNumberInputStream(
+                new ByteArrayInputStream(s.getBytes()));
+
+        for (int i = 0; i < 6; i++) {
+            assertEquals(1, is.getLineNumber());
+            is.read();
+        }
+
+        for (int i = 6; i < 12; i++) {
+            assertEquals(2, is.getLineNumber());
+            is.read();
+        }
+
+        for (int i = 12; i < 18; i++) {
+            assertEquals(3, is.getLineNumber());
+            is.read();
+        }
+
+        assertEquals(4, is.getLineNumber());
+        assertEquals(-1, is.read());
+    }
+
+    /**
+     * Tests that reading multiple bytes at once updates the line number
+     * appropriately.
+     */
+    public void testReadManyBytes() throws IOException {
+        String s = "Yada\r\nyada\r\nyada\r\n";
+        LineNumberInputStream is = new LineNumberInputStream(
+                new ByteArrayInputStream(s.getBytes()));
+
+        byte[] buf = new byte[4];
+        assertEquals(1, is.getLineNumber());
+        is.read(buf);
+        assertEquals(1, is.getLineNumber());
+        is.read(buf);
+        assertEquals(2, is.getLineNumber());
+        is.read(buf);
+        assertEquals(3, is.getLineNumber());
+        is.read(buf);
+        assertEquals(3, is.getLineNumber());
+        is.read(buf);
+        assertEquals(4, is.getLineNumber());
+
+        assertEquals(-1, is.read());
+    }
+}

Propchange: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/LineNumberInputStreamTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/LineReaderInputStreamAdaptorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/MimeBoundaryInputStreamTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/MimeBoundaryInputStreamTest.java?rev=778457&r1=778456&r2=778457&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/MimeBoundaryInputStreamTest.java (original)
+++ james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/MimeBoundaryInputStreamTest.java Mon May 25 17:20:48 2009
@@ -1,343 +1,343 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.mime4j.io;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.apache.james.mime4j.io.BufferedLineReaderInputStream;
-import org.apache.james.mime4j.io.LineReaderInputStream;
-import org.apache.james.mime4j.io.MimeBoundaryInputStream;
-import org.apache.james.mime4j.util.ByteArrayBuffer;
-
-
-import junit.framework.TestCase;
-
-public class MimeBoundaryInputStreamTest extends TestCase {
-
-    public void testBasicReading() throws IOException {
-        String text = "Line 1\r\nLine 2\r\n--boundary\r\n" +
-                "Line 3\r\nLine 4\r\n--boundary--";
-        
-        ByteArrayInputStream bis = new ByteArrayInputStream(text.getBytes("US-ASCII"));
-        
-        BufferedLineReaderInputStream buffer = new BufferedLineReaderInputStream(bis, 4096); 
-        
-        MimeBoundaryInputStream mime1 = new MimeBoundaryInputStream(buffer, "boundary");
-        assertEquals("Line 1\r\nLine 2", read(mime1, 5));
-        
-        assertFalse(mime1.isLastPart());
-        
-        MimeBoundaryInputStream mime2 = new MimeBoundaryInputStream(buffer, "boundary");
-        assertEquals("Line 3\r\nLine 4", read(mime2, 5));
-
-        assertTrue(mime2.isLastPart());
-    }
-    
-    public void testLenientLineDelimiterReading() throws IOException {
-        String text = "Line 1\r\nLine 2\n--boundary\n" +
-                "Line 3\r\nLine 4\n--boundary--\n";
-        
-        ByteArrayInputStream bis = new ByteArrayInputStream(text.getBytes("US-ASCII"));
-        
-        BufferedLineReaderInputStream buffer = new BufferedLineReaderInputStream(bis, 4096); 
-        
-        MimeBoundaryInputStream mime1 = new MimeBoundaryInputStream(buffer, "boundary");
-        assertEquals("Line 1\r\nLine 2", read(mime1, 5));
-        
-        assertFalse(mime1.isLastPart());
-        
-        MimeBoundaryInputStream mime2 = new MimeBoundaryInputStream(buffer, "boundary");
-        assertEquals("Line 3\r\nLine 4", read(mime2, 5));
-
-        assertTrue(mime2.isLastPart());
-    }
-    
-    public void testBasicReadingSmallBuffer1() throws IOException {
-        String text = "yadayadayadayadayadayadayadayadayadayadayadayadayadayadayadayada\r\n--boundary\r\n" +
-                "blahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblah\r\n--boundary--";
-        
-        ByteArrayInputStream bis = new ByteArrayInputStream(text.getBytes("US-ASCII"));
-        
-        BufferedLineReaderInputStream buffer = new BufferedLineReaderInputStream(bis, 20); 
-        
-        MimeBoundaryInputStream mime1 = new MimeBoundaryInputStream(buffer, "boundary");
-        assertEquals("yadayadayadayadayadayadayadayadayadayadayadayadayadayadayadayada", 
-                read(mime1, 10));
-        
-        assertFalse(mime1.isLastPart());
-        
-        MimeBoundaryInputStream mime2 = new MimeBoundaryInputStream(buffer, "boundary");
-        assertEquals("blahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblah", 
-                read(mime2, 10));
-
-        assertTrue(mime2.isLastPart());
-    }
-    
-    public void testBasicReadingSmallBuffer2() throws IOException {
-        String text = "yadayadayadayadayadayadayadayadayadayadayadayadayadayadayadayada\r\n--boundary\r\n" +
-                "blahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblah\r\n--boundary--";
-        
-        ByteArrayInputStream bis = new ByteArrayInputStream(text.getBytes("US-ASCII"));
-        
-        BufferedLineReaderInputStream buffer = new BufferedLineReaderInputStream(bis, 20); 
-        
-        MimeBoundaryInputStream mime1 = new MimeBoundaryInputStream(buffer, "boundary");
-        
-        assertEquals("yadayadayadayadayadayadayadayadayadayadayadayadayadayadayadayada", 
-                read(mime1, 25));
-        
-        assertFalse(mime1.isLastPart());
-        
-        MimeBoundaryInputStream mime2 = new MimeBoundaryInputStream(buffer, "boundary");
-        assertEquals("blahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblah", 
-                read(mime2, 25));
-
-        assertTrue(mime2.isLastPart());
-    }
-    
-    public void testBasicReadingByOneByte() throws IOException {
-        String text = "Line 1\r\nLine 2\r\n--boundary\r\n" +
-                "Line 3\r\nLine 4\r\n--boundary--";
-        
-        ByteArrayInputStream bis = new ByteArrayInputStream(text.getBytes("US-ASCII"));
-        
-        BufferedLineReaderInputStream buffer = new BufferedLineReaderInputStream(bis, 4096); 
-        
-        MimeBoundaryInputStream mime1 = new MimeBoundaryInputStream(buffer, "boundary");
-        assertEquals("Line 1\r\nLine 2", readByOneByte(mime1));
-        
-        assertFalse(mime1.isLastPart());
-        
-        MimeBoundaryInputStream mime2 = new MimeBoundaryInputStream(buffer, "boundary");
-        assertEquals("Line 3\r\nLine 4", readByOneByte(mime2));
-
-        assertTrue(mime2.isLastPart());
-    }
-    
-    /**
-     * Tests that a CRLF immediately preceding a boundary isn't included in
-     * the stream.
-     */
-    public void testCRLFPrecedingBoundary() throws IOException {
-        String text = "Line 1\r\nLine 2\r\n--boundary\r\n" +
-                "Line 3\r\nLine 4\r\n\r\n--boundary\r\n";
-        
-        ByteArrayInputStream bis = new ByteArrayInputStream(text.getBytes("US-ASCII"));
-        
-        BufferedLineReaderInputStream buffer = new BufferedLineReaderInputStream(bis, 4096); 
-        
-        MimeBoundaryInputStream mime1 = new MimeBoundaryInputStream(buffer, "boundary");
-        assertEquals("Line 1\r\nLine 2", read(mime1, 5));
-        
-        assertFalse(mime1.isLastPart());
-        
-        MimeBoundaryInputStream mime2 = new MimeBoundaryInputStream(buffer, "boundary");
-        assertEquals("Line 3\r\nLine 4\r\n", read(mime2, 5));
-
-        assertFalse(mime2.isLastPart());
-    }
-    
-    private String readByOneByte(InputStream is) throws IOException {
-        StringBuilder sb = new StringBuilder();
-        int b = 0;
-        while ((b = is.read()) != -1) {
-            sb.append((char) b);
-        }
-        return sb.toString();
-    }
-
-    private String read(InputStream is, int bufsize) throws IOException {
-        StringBuilder sb = new StringBuilder();
-        int l;
-        byte[] tmp = new byte[bufsize];
-        while ((l = is.read(tmp)) != -1) {
-            for (int i = 0; i < l; i++) {
-                sb.append((char) tmp[i]);
-            }
-        }
-        return sb.toString();
-    }
-    
-    /**
-     * Tests that a stream containing only a boundary is empty.
-     */
-    public void testImmediateBoundary() throws IOException {
-        String text = "--boundary\r\n";
-        
-        ByteArrayInputStream bis = new ByteArrayInputStream(text.getBytes());
-        BufferedLineReaderInputStream buffer = new BufferedLineReaderInputStream(bis, 4096); 
-        
-        MimeBoundaryInputStream stream = 
-            new MimeBoundaryInputStream(buffer, "boundary");
-        assertEquals(-1, stream.read());
-        
-        text = "\r\n--boundary\r\n";
-        
-        bis = new ByteArrayInputStream(text.getBytes());
-        buffer = new BufferedLineReaderInputStream(bis, 4096); 
-        stream = 
-            new MimeBoundaryInputStream(buffer, "boundary");
-        assertEquals(-1, stream.read());
-    }
-    
-    /**
-     * Tests that hasMoreParts behave as expected.
-     */
-    public void testHasMoreParts() throws IOException {
-        String text = "--boundary--\r\n";
-        
-        ByteArrayInputStream bis = new ByteArrayInputStream(text.getBytes());
-        BufferedLineReaderInputStream buffer = new BufferedLineReaderInputStream(bis, 4096); 
-        MimeBoundaryInputStream stream = 
-            new MimeBoundaryInputStream(buffer, "boundary");
-        assertEquals(-1, stream.read());
-        assertTrue(stream.isLastPart());
-    }
-    
-    /**
-     * Tests that a stream containing only a boundary is empty.
-     */
-    public void testPrefixIsBoundary() throws IOException {
-        String text = "Line 1\r\n\r\n--boundaryyada\r\n";
-        
-        ByteArrayInputStream bis = new ByteArrayInputStream(text.getBytes());
-        BufferedLineReaderInputStream buffer = new BufferedLineReaderInputStream(bis, 4096); 
-        MimeBoundaryInputStream stream = 
-            new MimeBoundaryInputStream(buffer, "boundary");
-        assertEquals("Line 1\r\n", read(stream, 100));
-        
-        text = "--boundaryyada\r\n";
-        
-        bis = new ByteArrayInputStream(text.getBytes());
-        buffer = new BufferedLineReaderInputStream(bis, 4096); 
-        stream = new MimeBoundaryInputStream(buffer, "boundary");
-        assertEquals(-1, stream.read());
-    }
-    
-    
-    public void testBasicReadLine() throws Exception {
-        
-        String[] teststrs = new String[5];
-        teststrs[0] = "Hello\r\n";
-        teststrs[1] = "This string should be much longer than the size of the input buffer " +
-                "which is only 20 bytes for this test\r\n";
-        StringBuilder sb = new StringBuilder();
-        for (int i = 0; i < 15; i++) {
-            sb.append("123456789 ");
-        }
-        sb.append("and stuff like that\r\n");
-        teststrs[2] = sb.toString();
-        teststrs[3] = "\r\n";
-        teststrs[4] = "And goodbye\r\n";
-
-        String term = "\r\n--1234\r\n";
-        
-        ByteArrayOutputStream outstream = new ByteArrayOutputStream();
-        
-        for (String teststr : teststrs) {
-            outstream.write(teststr.getBytes("US-ASCII"));
-        }
-        outstream.write(term.getBytes("US-ASCII"));
-        byte[] raw = outstream.toByteArray();
-        
-        BufferedLineReaderInputStream inbuffer = new BufferedLineReaderInputStream(new ByteArrayInputStream(raw), 20); 
-        LineReaderInputStream instream = new MimeBoundaryInputStream(inbuffer, "1234"); 
-        
-        ByteArrayBuffer linebuf = new ByteArrayBuffer(8); 
-        for (String teststr : teststrs) {
-            linebuf.clear();
-            instream.readLine(linebuf);
-            String s = new String(linebuf.toByteArray(), "US-ASCII");
-            assertEquals(teststr, s);
-        }
-        assertEquals(-1, instream.readLine(linebuf));
-        assertEquals(-1, instream.readLine(linebuf));
-    }
-    
-    public void testReadEmptyLine() throws Exception {
-        
-        String teststr = "01234567890123456789\n\n\r\n\r\r\n\n\n\n\n\n--1234\r\n";
-        byte[] raw = teststr.getBytes("US-ASCII");
-        
-        BufferedLineReaderInputStream inbuffer = new BufferedLineReaderInputStream(new ByteArrayInputStream(raw), 20); 
-        LineReaderInputStream instream = new MimeBoundaryInputStream(inbuffer, "1234"); 
-        
-        ByteArrayBuffer linebuf = new ByteArrayBuffer(8); 
-        linebuf.clear();
-        instream.readLine(linebuf);
-        String s = new String(linebuf.toByteArray(), "US-ASCII");
-        assertEquals("01234567890123456789\n", s);
-        
-        linebuf.clear();
-        instream.readLine(linebuf);
-        s = new String(linebuf.toByteArray(), "US-ASCII");
-        assertEquals("\n", s);
-        
-        linebuf.clear();
-        instream.readLine(linebuf);
-        s = new String(linebuf.toByteArray(), "US-ASCII");
-        assertEquals("\r\n", s);
-
-        linebuf.clear();
-        instream.readLine(linebuf);
-        s = new String(linebuf.toByteArray(), "US-ASCII");
-        assertEquals("\r\r\n", s);
-
-        linebuf.clear();
-        instream.readLine(linebuf);
-        s = new String(linebuf.toByteArray(), "US-ASCII");
-        assertEquals("\n", s);
-
-        linebuf.clear();
-        instream.readLine(linebuf);
-        s = new String(linebuf.toByteArray(), "US-ASCII");
-        assertEquals("\n", s);
-
-        linebuf.clear();
-        instream.readLine(linebuf);
-        s = new String(linebuf.toByteArray(), "US-ASCII");
-        assertEquals("\n", s);
-
-        linebuf.clear();
-        instream.readLine(linebuf);
-        s = new String(linebuf.toByteArray(), "US-ASCII");
-        assertEquals("\n", s);
-
-        assertEquals(-1, instream.readLine(linebuf));
-        assertEquals(-1, instream.readLine(linebuf));
-    }
-    
-    public void testboundaryLongerThanBuffer() throws IOException {
-        String text = "--looooooooooooooooooooooooooong-boundary\r\n";
-        
-        ByteArrayInputStream bis = new ByteArrayInputStream(text.getBytes());
-        BufferedLineReaderInputStream buffer = new BufferedLineReaderInputStream(bis, 10); 
-        
-        try {
-            new MimeBoundaryInputStream(buffer, "looooooooooooooooooooooooooong-boundary");
-            fail("IllegalArgumentException should have been thrown");
-        } catch (IllegalArgumentException expected) {
-        }
-    }
-
-}
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.mime4j.io;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.james.mime4j.io.BufferedLineReaderInputStream;
+import org.apache.james.mime4j.io.LineReaderInputStream;
+import org.apache.james.mime4j.io.MimeBoundaryInputStream;
+import org.apache.james.mime4j.util.ByteArrayBuffer;
+
+
+import junit.framework.TestCase;
+
+public class MimeBoundaryInputStreamTest extends TestCase {
+
+    public void testBasicReading() throws IOException {
+        String text = "Line 1\r\nLine 2\r\n--boundary\r\n" +
+                "Line 3\r\nLine 4\r\n--boundary--";
+        
+        ByteArrayInputStream bis = new ByteArrayInputStream(text.getBytes("US-ASCII"));
+        
+        BufferedLineReaderInputStream buffer = new BufferedLineReaderInputStream(bis, 4096); 
+        
+        MimeBoundaryInputStream mime1 = new MimeBoundaryInputStream(buffer, "boundary");
+        assertEquals("Line 1\r\nLine 2", read(mime1, 5));
+        
+        assertFalse(mime1.isLastPart());
+        
+        MimeBoundaryInputStream mime2 = new MimeBoundaryInputStream(buffer, "boundary");
+        assertEquals("Line 3\r\nLine 4", read(mime2, 5));
+
+        assertTrue(mime2.isLastPart());
+    }
+    
+    public void testLenientLineDelimiterReading() throws IOException {
+        String text = "Line 1\r\nLine 2\n--boundary\n" +
+                "Line 3\r\nLine 4\n--boundary--\n";
+        
+        ByteArrayInputStream bis = new ByteArrayInputStream(text.getBytes("US-ASCII"));
+        
+        BufferedLineReaderInputStream buffer = new BufferedLineReaderInputStream(bis, 4096); 
+        
+        MimeBoundaryInputStream mime1 = new MimeBoundaryInputStream(buffer, "boundary");
+        assertEquals("Line 1\r\nLine 2", read(mime1, 5));
+        
+        assertFalse(mime1.isLastPart());
+        
+        MimeBoundaryInputStream mime2 = new MimeBoundaryInputStream(buffer, "boundary");
+        assertEquals("Line 3\r\nLine 4", read(mime2, 5));
+
+        assertTrue(mime2.isLastPart());
+    }
+    
+    public void testBasicReadingSmallBuffer1() throws IOException {
+        String text = "yadayadayadayadayadayadayadayadayadayadayadayadayadayadayadayada\r\n--boundary\r\n" +
+                "blahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblah\r\n--boundary--";
+        
+        ByteArrayInputStream bis = new ByteArrayInputStream(text.getBytes("US-ASCII"));
+        
+        BufferedLineReaderInputStream buffer = new BufferedLineReaderInputStream(bis, 20); 
+        
+        MimeBoundaryInputStream mime1 = new MimeBoundaryInputStream(buffer, "boundary");
+        assertEquals("yadayadayadayadayadayadayadayadayadayadayadayadayadayadayadayada", 
+                read(mime1, 10));
+        
+        assertFalse(mime1.isLastPart());
+        
+        MimeBoundaryInputStream mime2 = new MimeBoundaryInputStream(buffer, "boundary");
+        assertEquals("blahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblah", 
+                read(mime2, 10));
+
+        assertTrue(mime2.isLastPart());
+    }
+    
+    public void testBasicReadingSmallBuffer2() throws IOException {
+        String text = "yadayadayadayadayadayadayadayadayadayadayadayadayadayadayadayada\r\n--boundary\r\n" +
+                "blahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblah\r\n--boundary--";
+        
+        ByteArrayInputStream bis = new ByteArrayInputStream(text.getBytes("US-ASCII"));
+        
+        BufferedLineReaderInputStream buffer = new BufferedLineReaderInputStream(bis, 20); 
+        
+        MimeBoundaryInputStream mime1 = new MimeBoundaryInputStream(buffer, "boundary");
+        
+        assertEquals("yadayadayadayadayadayadayadayadayadayadayadayadayadayadayadayada", 
+                read(mime1, 25));
+        
+        assertFalse(mime1.isLastPart());
+        
+        MimeBoundaryInputStream mime2 = new MimeBoundaryInputStream(buffer, "boundary");
+        assertEquals("blahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblah", 
+                read(mime2, 25));
+
+        assertTrue(mime2.isLastPart());
+    }
+    
+    public void testBasicReadingByOneByte() throws IOException {
+        String text = "Line 1\r\nLine 2\r\n--boundary\r\n" +
+                "Line 3\r\nLine 4\r\n--boundary--";
+        
+        ByteArrayInputStream bis = new ByteArrayInputStream(text.getBytes("US-ASCII"));
+        
+        BufferedLineReaderInputStream buffer = new BufferedLineReaderInputStream(bis, 4096); 
+        
+        MimeBoundaryInputStream mime1 = new MimeBoundaryInputStream(buffer, "boundary");
+        assertEquals("Line 1\r\nLine 2", readByOneByte(mime1));
+        
+        assertFalse(mime1.isLastPart());
+        
+        MimeBoundaryInputStream mime2 = new MimeBoundaryInputStream(buffer, "boundary");
+        assertEquals("Line 3\r\nLine 4", readByOneByte(mime2));
+
+        assertTrue(mime2.isLastPart());
+    }
+    
+    /**
+     * Tests that a CRLF immediately preceding a boundary isn't included in
+     * the stream.
+     */
+    public void testCRLFPrecedingBoundary() throws IOException {
+        String text = "Line 1\r\nLine 2\r\n--boundary\r\n" +
+                "Line 3\r\nLine 4\r\n\r\n--boundary\r\n";
+        
+        ByteArrayInputStream bis = new ByteArrayInputStream(text.getBytes("US-ASCII"));
+        
+        BufferedLineReaderInputStream buffer = new BufferedLineReaderInputStream(bis, 4096); 
+        
+        MimeBoundaryInputStream mime1 = new MimeBoundaryInputStream(buffer, "boundary");
+        assertEquals("Line 1\r\nLine 2", read(mime1, 5));
+        
+        assertFalse(mime1.isLastPart());
+        
+        MimeBoundaryInputStream mime2 = new MimeBoundaryInputStream(buffer, "boundary");
+        assertEquals("Line 3\r\nLine 4\r\n", read(mime2, 5));
+
+        assertFalse(mime2.isLastPart());
+    }
+    
+    private String readByOneByte(InputStream is) throws IOException {
+        StringBuilder sb = new StringBuilder();
+        int b = 0;
+        while ((b = is.read()) != -1) {
+            sb.append((char) b);
+        }
+        return sb.toString();
+    }
+
+    private String read(InputStream is, int bufsize) throws IOException {
+        StringBuilder sb = new StringBuilder();
+        int l;
+        byte[] tmp = new byte[bufsize];
+        while ((l = is.read(tmp)) != -1) {
+            for (int i = 0; i < l; i++) {
+                sb.append((char) tmp[i]);
+            }
+        }
+        return sb.toString();
+    }
+    
+    /**
+     * Tests that a stream containing only a boundary is empty.
+     */
+    public void testImmediateBoundary() throws IOException {
+        String text = "--boundary\r\n";
+        
+        ByteArrayInputStream bis = new ByteArrayInputStream(text.getBytes());
+        BufferedLineReaderInputStream buffer = new BufferedLineReaderInputStream(bis, 4096); 
+        
+        MimeBoundaryInputStream stream = 
+            new MimeBoundaryInputStream(buffer, "boundary");
+        assertEquals(-1, stream.read());
+        
+        text = "\r\n--boundary\r\n";
+        
+        bis = new ByteArrayInputStream(text.getBytes());
+        buffer = new BufferedLineReaderInputStream(bis, 4096); 
+        stream = 
+            new MimeBoundaryInputStream(buffer, "boundary");
+        assertEquals(-1, stream.read());
+    }
+    
+    /**
+     * Tests that hasMoreParts behave as expected.
+     */
+    public void testHasMoreParts() throws IOException {
+        String text = "--boundary--\r\n";
+        
+        ByteArrayInputStream bis = new ByteArrayInputStream(text.getBytes());
+        BufferedLineReaderInputStream buffer = new BufferedLineReaderInputStream(bis, 4096); 
+        MimeBoundaryInputStream stream = 
+            new MimeBoundaryInputStream(buffer, "boundary");
+        assertEquals(-1, stream.read());
+        assertTrue(stream.isLastPart());
+    }
+    
+    /**
+     * Tests that a stream containing only a boundary is empty.
+     */
+    public void testPrefixIsBoundary() throws IOException {
+        String text = "Line 1\r\n\r\n--boundaryyada\r\n";
+        
+        ByteArrayInputStream bis = new ByteArrayInputStream(text.getBytes());
+        BufferedLineReaderInputStream buffer = new BufferedLineReaderInputStream(bis, 4096); 
+        MimeBoundaryInputStream stream = 
+            new MimeBoundaryInputStream(buffer, "boundary");
+        assertEquals("Line 1\r\n", read(stream, 100));
+        
+        text = "--boundaryyada\r\n";
+        
+        bis = new ByteArrayInputStream(text.getBytes());
+        buffer = new BufferedLineReaderInputStream(bis, 4096); 
+        stream = new MimeBoundaryInputStream(buffer, "boundary");
+        assertEquals(-1, stream.read());
+    }
+    
+    
+    public void testBasicReadLine() throws Exception {
+        
+        String[] teststrs = new String[5];
+        teststrs[0] = "Hello\r\n";
+        teststrs[1] = "This string should be much longer than the size of the input buffer " +
+                "which is only 20 bytes for this test\r\n";
+        StringBuilder sb = new StringBuilder();
+        for (int i = 0; i < 15; i++) {
+            sb.append("123456789 ");
+        }
+        sb.append("and stuff like that\r\n");
+        teststrs[2] = sb.toString();
+        teststrs[3] = "\r\n";
+        teststrs[4] = "And goodbye\r\n";
+
+        String term = "\r\n--1234\r\n";
+        
+        ByteArrayOutputStream outstream = new ByteArrayOutputStream();
+        
+        for (String teststr : teststrs) {
+            outstream.write(teststr.getBytes("US-ASCII"));
+        }
+        outstream.write(term.getBytes("US-ASCII"));
+        byte[] raw = outstream.toByteArray();
+        
+        BufferedLineReaderInputStream inbuffer = new BufferedLineReaderInputStream(new ByteArrayInputStream(raw), 20); 
+        LineReaderInputStream instream = new MimeBoundaryInputStream(inbuffer, "1234"); 
+        
+        ByteArrayBuffer linebuf = new ByteArrayBuffer(8); 
+        for (String teststr : teststrs) {
+            linebuf.clear();
+            instream.readLine(linebuf);
+            String s = new String(linebuf.toByteArray(), "US-ASCII");
+            assertEquals(teststr, s);
+        }
+        assertEquals(-1, instream.readLine(linebuf));
+        assertEquals(-1, instream.readLine(linebuf));
+    }
+    
+    public void testReadEmptyLine() throws Exception {
+        
+        String teststr = "01234567890123456789\n\n\r\n\r\r\n\n\n\n\n\n--1234\r\n";
+        byte[] raw = teststr.getBytes("US-ASCII");
+        
+        BufferedLineReaderInputStream inbuffer = new BufferedLineReaderInputStream(new ByteArrayInputStream(raw), 20); 
+        LineReaderInputStream instream = new MimeBoundaryInputStream(inbuffer, "1234"); 
+        
+        ByteArrayBuffer linebuf = new ByteArrayBuffer(8); 
+        linebuf.clear();
+        instream.readLine(linebuf);
+        String s = new String(linebuf.toByteArray(), "US-ASCII");
+        assertEquals("01234567890123456789\n", s);
+        
+        linebuf.clear();
+        instream.readLine(linebuf);
+        s = new String(linebuf.toByteArray(), "US-ASCII");
+        assertEquals("\n", s);
+        
+        linebuf.clear();
+        instream.readLine(linebuf);
+        s = new String(linebuf.toByteArray(), "US-ASCII");
+        assertEquals("\r\n", s);
+
+        linebuf.clear();
+        instream.readLine(linebuf);
+        s = new String(linebuf.toByteArray(), "US-ASCII");
+        assertEquals("\r\r\n", s);
+
+        linebuf.clear();
+        instream.readLine(linebuf);
+        s = new String(linebuf.toByteArray(), "US-ASCII");
+        assertEquals("\n", s);
+
+        linebuf.clear();
+        instream.readLine(linebuf);
+        s = new String(linebuf.toByteArray(), "US-ASCII");
+        assertEquals("\n", s);
+
+        linebuf.clear();
+        instream.readLine(linebuf);
+        s = new String(linebuf.toByteArray(), "US-ASCII");
+        assertEquals("\n", s);
+
+        linebuf.clear();
+        instream.readLine(linebuf);
+        s = new String(linebuf.toByteArray(), "US-ASCII");
+        assertEquals("\n", s);
+
+        assertEquals(-1, instream.readLine(linebuf));
+        assertEquals(-1, instream.readLine(linebuf));
+    }
+    
+    public void testboundaryLongerThanBuffer() throws IOException {
+        String text = "--looooooooooooooooooooooooooong-boundary\r\n";
+        
+        ByteArrayInputStream bis = new ByteArrayInputStream(text.getBytes());
+        BufferedLineReaderInputStream buffer = new BufferedLineReaderInputStream(bis, 10); 
+        
+        try {
+            new MimeBoundaryInputStream(buffer, "looooooooooooooooooooooooooong-boundary");
+            fail("IllegalArgumentException should have been thrown");
+        } catch (IllegalArgumentException expected) {
+        }
+    }
+
+}

Propchange: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/MimeBoundaryInputStreamTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/message/CopyConstructorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/message/EntityTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/message/HeaderTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/message/HeaderTest.java?rev=778457&r1=778456&r2=778457&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/message/HeaderTest.java (original)
+++ james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/message/HeaderTest.java Mon May 25 17:20:48 2009
@@ -1,129 +1,129 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.mime4j.message;
-
-import junit.framework.TestCase;
-
-import org.apache.commons.io.output.ByteArrayOutputStream;
-import org.apache.james.mime4j.field.AbstractField;
-import org.apache.james.mime4j.parser.Field;
-import org.apache.james.mime4j.util.CharsetUtil;
-
-public class HeaderTest extends TestCase {
-
-    public static final String SUBJECT = "Subject: test";
-
-    public static final String TO = "To: anyuser <any@user>";
-
-    public void testHeader() throws Exception {
-        Header header = new Header();
-        header.addField(AbstractField.parse(SUBJECT));
-        header.addField(AbstractField.parse(TO));
-
-        assertNotNull("Subject found", header.getField("Subject"));
-        assertNotNull("To found", header.getField("To"));
-
-        assertEquals("Headers equals", SUBJECT + "\r\n" + TO + "\r\n", header
-                .toString());
-    }
-    
-    private static final String SWISS_GERMAN_HELLO = "Gr\374ezi_z\344m\344";
-
-    public void testWriteSpecialCharacters() throws Exception {
-        String hello = SWISS_GERMAN_HELLO;
-        Header header = new Header();
-        header.addField(AbstractField.parse("Hello: " + hello));
-        
-        Field field = header.getField("Hello");
-        assertNotNull(field);
-        assertEquals(hello, field.getBody());
-        
-        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
-        
-        MessageWriter.DEFAULT.writeHeader(header, buffer);
-        String s = buffer.toString(CharsetUtil.US_ASCII.name());
-        
-        assertEquals("Hello: Gr?ezi_z?m?\r\n\r\n", s);
-    }
-
-    public void testRemoveFields() throws Exception {
-        Header header = new Header();
-        header.addField(AbstractField.parse("Received: from foo by bar for james"));
-        header.addField(AbstractField.parse("Content-type: text/plain; charset=US-ASCII"));
-        header.addField(AbstractField.parse("ReCeIvEd: from bar by foo for james"));
-
-        assertEquals(3, header.getFields().size());
-        assertEquals(2, header.getFields("received").size());
-        assertEquals(1, header.getFields("Content-Type").size());
-
-        assertEquals(2, header.removeFields("rEcEiVeD"));
-
-        assertEquals(1, header.getFields().size());
-        assertEquals(0, header.getFields("received").size());
-        assertEquals(1, header.getFields("Content-Type").size());
-
-        assertEquals("Content-type", header.getFields().get(0).getName());
-    }
-
-    public void testRemoveNonExistantField() throws Exception {
-        Header header = new Header();
-        header.addField(AbstractField.parse("Received: from foo by bar for james"));
-        header.addField(AbstractField.parse("Content-type: text/plain; charset=US-ASCII"));
-        header.addField(AbstractField.parse("ReCeIvEd: from bar by foo for james"));
-
-        assertEquals(0, header.removeFields("noSuchField"));
-
-        assertEquals(3, header.getFields().size());
-        assertEquals(2, header.getFields("received").size());
-        assertEquals(1, header.getFields("Content-Type").size());
-    }
-
-    public void testSetField() throws Exception {
-        Header header = new Header();
-        header.addField(AbstractField.parse("From: mime4j@james.apache.org"));
-        header.addField(AbstractField.parse("Received: from foo by bar for james"));
-        header.addField(AbstractField.parse("Content-type: text/plain; charset=US-ASCII"));
-        header.addField(AbstractField.parse("ReCeIvEd: from bar by foo for james"));
-
-        header.setField(AbstractField.parse("received: from nobody by noone for james"));
-
-        assertEquals(3, header.getFields().size());
-        assertEquals(1, header.getFields("received").size());
-
-        assertEquals("From", header.getFields().get(0).getName());
-        assertEquals("received", header.getFields().get(1).getName());
-        assertEquals("Content-type", header.getFields().get(2).getName());
-    }
-
-    public void testSetNonExistantField() throws Exception {
-        Header header = new Header();
-        header.addField(AbstractField.parse("Received: from foo by bar for james"));
-        header.addField(AbstractField.parse("Content-type: text/plain; charset=US-ASCII"));
-        header.addField(AbstractField.parse("ReCeIvEd: from bar by foo for james"));
-
-        header.setField(AbstractField.parse("Message-ID: <msg9901@apache.org>"));
-
-        assertEquals(4, header.getFields().size());
-        assertEquals(1, header.getFields("message-id").size());
-
-        assertEquals("Message-ID", header.getFields().get(3).getName());
-    }
-    
-}
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.mime4j.message;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.io.output.ByteArrayOutputStream;
+import org.apache.james.mime4j.field.AbstractField;
+import org.apache.james.mime4j.parser.Field;
+import org.apache.james.mime4j.util.CharsetUtil;
+
+public class HeaderTest extends TestCase {
+
+    public static final String SUBJECT = "Subject: test";
+
+    public static final String TO = "To: anyuser <any@user>";
+
+    public void testHeader() throws Exception {
+        Header header = new Header();
+        header.addField(AbstractField.parse(SUBJECT));
+        header.addField(AbstractField.parse(TO));
+
+        assertNotNull("Subject found", header.getField("Subject"));
+        assertNotNull("To found", header.getField("To"));
+
+        assertEquals("Headers equals", SUBJECT + "\r\n" + TO + "\r\n", header
+                .toString());
+    }
+    
+    private static final String SWISS_GERMAN_HELLO = "Gr\374ezi_z\344m\344";
+
+    public void testWriteSpecialCharacters() throws Exception {
+        String hello = SWISS_GERMAN_HELLO;
+        Header header = new Header();
+        header.addField(AbstractField.parse("Hello: " + hello));
+        
+        Field field = header.getField("Hello");
+        assertNotNull(field);
+        assertEquals(hello, field.getBody());
+        
+        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+        
+        MessageWriter.DEFAULT.writeHeader(header, buffer);
+        String s = buffer.toString(CharsetUtil.US_ASCII.name());
+        
+        assertEquals("Hello: Gr?ezi_z?m?\r\n\r\n", s);
+    }
+
+    public void testRemoveFields() throws Exception {
+        Header header = new Header();
+        header.addField(AbstractField.parse("Received: from foo by bar for james"));
+        header.addField(AbstractField.parse("Content-type: text/plain; charset=US-ASCII"));
+        header.addField(AbstractField.parse("ReCeIvEd: from bar by foo for james"));
+
+        assertEquals(3, header.getFields().size());
+        assertEquals(2, header.getFields("received").size());
+        assertEquals(1, header.getFields("Content-Type").size());
+
+        assertEquals(2, header.removeFields("rEcEiVeD"));
+
+        assertEquals(1, header.getFields().size());
+        assertEquals(0, header.getFields("received").size());
+        assertEquals(1, header.getFields("Content-Type").size());
+
+        assertEquals("Content-type", header.getFields().get(0).getName());
+    }
+
+    public void testRemoveNonExistantField() throws Exception {
+        Header header = new Header();
+        header.addField(AbstractField.parse("Received: from foo by bar for james"));
+        header.addField(AbstractField.parse("Content-type: text/plain; charset=US-ASCII"));
+        header.addField(AbstractField.parse("ReCeIvEd: from bar by foo for james"));
+
+        assertEquals(0, header.removeFields("noSuchField"));
+
+        assertEquals(3, header.getFields().size());
+        assertEquals(2, header.getFields("received").size());
+        assertEquals(1, header.getFields("Content-Type").size());
+    }
+
+    public void testSetField() throws Exception {
+        Header header = new Header();
+        header.addField(AbstractField.parse("From: mime4j@james.apache.org"));
+        header.addField(AbstractField.parse("Received: from foo by bar for james"));
+        header.addField(AbstractField.parse("Content-type: text/plain; charset=US-ASCII"));
+        header.addField(AbstractField.parse("ReCeIvEd: from bar by foo for james"));
+
+        header.setField(AbstractField.parse("received: from nobody by noone for james"));
+
+        assertEquals(3, header.getFields().size());
+        assertEquals(1, header.getFields("received").size());
+
+        assertEquals("From", header.getFields().get(0).getName());
+        assertEquals("received", header.getFields().get(1).getName());
+        assertEquals("Content-type", header.getFields().get(2).getName());
+    }
+
+    public void testSetNonExistantField() throws Exception {
+        Header header = new Header();
+        header.addField(AbstractField.parse("Received: from foo by bar for james"));
+        header.addField(AbstractField.parse("Content-type: text/plain; charset=US-ASCII"));
+        header.addField(AbstractField.parse("ReCeIvEd: from bar by foo for james"));
+
+        header.setField(AbstractField.parse("Message-ID: <msg9901@apache.org>"));
+
+        assertEquals(4, header.getFields().size());
+        assertEquals(1, header.getFields("message-id").size());
+
+        assertEquals("Message-ID", header.getFields().get(3).getName());
+    }
+    
+}

Propchange: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/message/HeaderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/message/MessageCompleteMailTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/message/MessageParserTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/message/MessageTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/message/MessageWriteToTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/message/MultipartFormTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/message/SingleBodyCopyTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message