james-mime4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mwiederk...@apache.org
Subject svn commit: r804953 - /james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/codec/DecoderUtilTest.java
Date Mon, 17 Aug 2009 12:28:27 GMT
Author: mwiederkehr
Date: Mon Aug 17 12:28:27 2009
New Revision: 804953

URL: http://svn.apache.org/viewvc?rev=804953&view=rev
Log:
split up big test method

Modified:
    james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/codec/DecoderUtilTest.java

Modified: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/codec/DecoderUtilTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/codec/DecoderUtilTest.java?rev=804953&r1=804952&r2=804953&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/codec/DecoderUtilTest.java
(original)
+++ james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/codec/DecoderUtilTest.java
Mon Aug 17 12:28:27 2009
@@ -32,6 +32,7 @@
         BasicConfigurator.resetConfiguration();
         BasicConfigurator.configure();
     }
+
     /*
     public void testDecodeEncodedWords() {
         String s = "=?ISO-2022-JP?B?GyRCTCQbKEobJEI+NRsoShskQkJ6GyhKGyRCOS0bKEo=?= "
@@ -43,23 +44,24 @@
         s = DecoderUtil.decodeEncodedWords(s);
         System.out.println(s);
     }*/
-    
+
     public void testDecodeB() throws UnsupportedEncodingException {
         String s = DecoderUtil.decodeB("VGhpcyBpcyB0aGUgcGxhaW4gd"
                     + "GV4dCBtZXNzYWdlIQ==", "ISO8859-1");
         assertEquals("This is the plain text message!", s);
     }
-    
 
     public void testDecodeQ() throws UnsupportedEncodingException {
-        String s = DecoderUtil.decodeQ("=e1_=e2=09=E3_=E4_", 
-                                                         "ISO8859-1");
+        String s = DecoderUtil.decodeQ("=e1_=e2=09=E3_=E4_", "ISO8859-1");
         assertEquals("\u00e1 \u00e2\t\u00e3 \u00e4 ", s);
     }
-    
-    public void testDecodeEncodedWords() {
+
+    public void testNonEncodedWordsAreIgnored() {
         assertEquals("", DecoderUtil.decodeEncodedWords(""));
         assertEquals("Yada yada", DecoderUtil.decodeEncodedWords("Yada yada"));
+    }
+
+    public void testDecodeSomeEncodedWords() {
         assertEquals("  \u00e1\u00e2\u00e3\t\u00e4", 
                 DecoderUtil.decodeEncodedWords("=?iso-8859-1?Q?_=20=e1=e2=E3=09=E4?="));
         assertEquals("Word 1 '  \u00e2\u00e3\t\u00e4'. Word 2 '  \u00e2\u00e3\t\u00e4'",

@@ -71,18 +73,23 @@
                 DecoderUtil.decodeEncodedWords("=?US-ASCII?B?QSBzaG9ydCB0ZXh0?="));
         assertEquals("A short text again!", 
                 DecoderUtil.decodeEncodedWords("=?US-ASCII?b?QSBzaG9ydCB0ZXh0IGFnYWluIQ==?="));
+    }
 
-        // invalid encoded words should be returned unchanged
+    public void testInvalidEncodedWordsAreIgnored() {
         assertEquals("=?iso8859-1?Q?=", DecoderUtil.decodeEncodedWords("=?iso8859-1?Q?="));
         assertEquals("=?iso8859-1?b?=", DecoderUtil.decodeEncodedWords("=?iso8859-1?b?="));
         assertEquals("=?ISO-8859-1?Q?", DecoderUtil.decodeEncodedWords("=?ISO-8859-1?Q?"));
         assertEquals("=?ISO-8859-1?R?abc?=", DecoderUtil.decodeEncodedWords("=?ISO-8859-1?R?abc?="));
+    }
 
+    public void testEmptyEncodedTextIsIgnored() {
         // encoded-text requires at least one character according to rfc 2047
         assertEquals("=?ISO-8859-1?Q??=", DecoderUtil.decodeEncodedWords("=?ISO-8859-1?Q??="));
         assertEquals("=?ISO-8859-1?B??=", DecoderUtil.decodeEncodedWords("=?ISO-8859-1?B??="));
-        
-        // white space between encoded words should be removed (MIME4J-104)
+    }
+
+    // see MIME4J-104
+    public void testWhiteSpaceBetweenEncodedWordsGetsRemoved() {
         assertEquals("a", DecoderUtil.decodeEncodedWords("=?ISO-8859-1?Q?a?="));
         assertEquals("a b", DecoderUtil.decodeEncodedWords("=?ISO-8859-1?Q?a?= b"));
         assertEquals("ab", DecoderUtil.decodeEncodedWords("=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?="));
@@ -90,16 +97,19 @@
         assertEquals("ab", DecoderUtil.decodeEncodedWords("=?ISO-8859-1?Q?a?=\r\n  =?ISO-8859-1?Q?b?="));
         assertEquals("a b", DecoderUtil.decodeEncodedWords("=?ISO-8859-1?Q?a_b?="));
         assertEquals("a b", DecoderUtil.decodeEncodedWords("=?ISO-8859-1?Q?a?= =?ISO-8859-2?Q?_b?="));
+    }
 
-        // non white space between encoded words should be retained
+    public void testNonWhiteSpaceBetweenEncodedWordsIsRetained() {
         assertEquals("a b c", DecoderUtil.decodeEncodedWords("=?ISO-8859-1?Q?a?= b =?ISO-8859-1?Q?c?="));
+    }
 
-        // text before and after encoded words should be retained
+    public void testTextBeforeAndAfterEncodedWordIsRetained() {
         assertEquals(" a b c ", DecoderUtil.decodeEncodedWords(" =?ISO-8859-1?Q?a?= b =?ISO-8859-1?Q?c?=
"));
         assertEquals("! a b c !", DecoderUtil.decodeEncodedWords("! =?ISO-8859-1?Q?a?= b
=?ISO-8859-1?Q?c?= !"));
-        
-        // Bug detected on June 7, 2005. Decoding the following string caused
-        // OutOfMemoryError.
+    }
+
+    public void testFunnyInputDoesNotRaiseOutOfMemoryError() {
+        // Bug detected on June 7, 2005. Decoding the following string caused OutOfMemoryError.
         assertEquals("=3?!!\\=?\"!g6P\"!Xp:\"!", DecoderUtil.decodeEncodedWords("=3?!!\\=?\"!g6P\"!Xp:\"!"));
     }    
 }



Mime
View raw message