james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r718018 [2/3] - in /james/mime4j/trunk: ./ examples/src/java/org/apache/james/mime4j/samples/tree/ src/main/java/org/apache/james/mime4j/decoder/ src/main/java/org/apache/james/mime4j/descriptor/ src/main/java/org/apache/james/mime4j/field/...
Date Sun, 16 Nov 2008 12:56:22 GMT
Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/MimeEntityConfig.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/MimeEntityConfig.java?rev=718018&r1=718017&r2=718018&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/MimeEntityConfig.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/MimeEntityConfig.java Sun Nov 16 04:56:20 2008
@@ -34,7 +34,6 @@
     private long maxContentLen;
     
     public MimeEntityConfig() {
-        super();
         this.maximalBodyDescriptor = false;
         this.strictParsing = false;
         this.maxLineLen = 1000;
@@ -139,10 +138,17 @@
         return maxContentLen;
     }
 
-    public Object clone() throws CloneNotSupportedException {
-        return super.clone();
+    @Override
+    public MimeEntityConfig clone() {
+        try {
+            return (MimeEntityConfig) super.clone();
+        } catch (CloneNotSupportedException e) {
+            // this shouldn't happen, since we are Cloneable
+            throw new InternalError();
+        }
     }
     
+    @Override
     public String toString() {
         CharArrayBuffer buffer = new CharArrayBuffer(128);
         buffer.append("[max body descriptor: ");

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/MimeStreamParser.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/MimeStreamParser.java?rev=718018&r1=718017&r2=718018&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/MimeStreamParser.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/MimeStreamParser.java Sun Nov 16 04:56:20 2008
@@ -52,12 +52,7 @@
         super();
         MimeEntityConfig localConfig;
         if (config != null) {
-            try {
-                localConfig = (MimeEntityConfig) config.clone();
-            } catch (CloneNotSupportedException ex) {
-                // should never happen
-                localConfig = new MimeEntityConfig();
-            }
+            localConfig = config.clone();
         } else {
             localConfig = new MimeEntityConfig();
         }

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/MimeTokenStream.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/MimeTokenStream.java?rev=718018&r1=718017&r2=718018&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/MimeTokenStream.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/MimeTokenStream.java Sun Nov 16 04:56:20 2008
@@ -101,7 +101,7 @@
     }
     
     private final MimeEntityConfig config;
-    private final LinkedList entities = new LinkedList();
+    private final LinkedList<EntityStateMachine> entities = new LinkedList<EntityStateMachine>();
     
     private int state = T_END_OF_STREAM;
     private EntityStateMachine currentStateMachine;
@@ -381,7 +381,7 @@
             if (entities.isEmpty()) {
                 currentStateMachine = null;
             } else {
-                currentStateMachine = (EntityStateMachine) entities.getLast();
+                currentStateMachine = entities.getLast();
                 currentStateMachine.setRecursionMode(recursionMode);
             }
         }

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/ByteArrayBuffer.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/ByteArrayBuffer.java?rev=718018&r1=718017&r2=718018&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/ByteArrayBuffer.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/ByteArrayBuffer.java Sun Nov 16 04:56:20 2008
@@ -134,6 +134,7 @@
         return this.len == this.buffer.length; 
     }
 
+    @Override
     public String toString() {
         return new String(toByteArray());
     }

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/CharArrayBuffer.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/CharArrayBuffer.java?rev=718018&r1=718017&r2=718018&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/CharArrayBuffer.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/CharArrayBuffer.java Sun Nov 16 04:56:20 2008
@@ -239,6 +239,7 @@
         return new String(this.buffer, beginIndex, endIndex - beginIndex);
     }
     
+    @Override
     public String toString() {
         return new String(this.buffer, 0, this.len);
     }

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/CharsetUtil.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/CharsetUtil.java?rev=718018&r1=718017&r2=718018&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/CharsetUtil.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/CharsetUtil.java Sun Nov 16 04:56:20 2008
@@ -23,6 +23,8 @@
 import java.nio.charset.IllegalCharsetNameException;
 import java.nio.charset.UnsupportedCharsetException;
 import java.util.HashMap;
+import java.util.Map;
+import java.util.SortedSet;
 import java.util.TreeSet;
 
 import org.apache.commons.logging.Log;
@@ -791,7 +793,7 @@
 public class CharsetUtil {
     private static Log log = LogFactory.getLog(CharsetUtil.class);
     
-    private static class Charset implements Comparable {
+    private static class Charset implements Comparable<Charset> {
         private String canonical = null;
         private String mime = null;
         private String[] aliases = null;
@@ -802,8 +804,7 @@
             this.aliases = aliases;
         }
 
-        public int compareTo(Object o) {
-            Charset c = (Charset) o;
+        public int compareTo(Charset c) {
             return this.canonical.compareTo(c.canonical);
         }
     }
@@ -1001,49 +1002,48 @@
      * Contains the canonical names of character sets which can be used to 
      * decode bytes into Java chars.
      */
-    private static TreeSet decodingSupported = null;
+    private static SortedSet<String> decodingSupported = null;
     
     /**
      * Contains the canonical names of character sets which can be used to 
      * encode Java chars into bytes.
      */
-    private static TreeSet encodingSupported = null;
+    private static SortedSet<String> encodingSupported = null;
     
     /**
      * Maps character set names to Charset objects. All possible names of
      * a charset will be mapped to the Charset.
      */
-    private static HashMap charsetMap = null;
+    private static Map<String, Charset> charsetMap = null;
     
     static {
-        decodingSupported = new TreeSet();
-        encodingSupported = new TreeSet();
+        decodingSupported = new TreeSet<String>();
+        encodingSupported = new TreeSet<String>();
         byte[] dummy = new byte[] {'d', 'u', 'm', 'm', 'y'};
-        for (int i = 0; i < JAVA_CHARSETS.length; i++) {
+        for (Charset c : JAVA_CHARSETS) {
             try {
-                new String(dummy, JAVA_CHARSETS[i].canonical);
-                decodingSupported.add(JAVA_CHARSETS[i].canonical.toLowerCase());
+                new String(dummy, c.canonical);
+                decodingSupported.add(c.canonical.toLowerCase());
             } catch (UnsupportedOperationException e) {
             } catch (UnsupportedEncodingException e) {
             }
             try {
-                "dummy".getBytes(JAVA_CHARSETS[i].canonical);
-                encodingSupported.add(JAVA_CHARSETS[i].canonical.toLowerCase());
+                "dummy".getBytes(c.canonical);
+                encodingSupported.add(c.canonical.toLowerCase());
             } catch (UnsupportedOperationException e) {
             } catch (UnsupportedEncodingException e) {
             }
         }
         
-        charsetMap = new HashMap();
-        for (int i = 0; i < JAVA_CHARSETS.length; i++) {
-            Charset c = JAVA_CHARSETS[i];
+        charsetMap = new HashMap<String, Charset>();
+        for (Charset c : JAVA_CHARSETS) {
             charsetMap.put(c.canonical.toLowerCase(), c);
             if (c.mime != null) {
                 charsetMap.put(c.mime.toLowerCase(), c);
             }
             if (c.aliases != null) {
-                for (int j = 0; j < c.aliases.length; j++) {
-                    charsetMap.put(c.aliases[j].toLowerCase(), c);
+                for (String str : c.aliases) {
+                    charsetMap.put(str.toLowerCase(), c);
                 }
             }
         }
@@ -1094,7 +1094,7 @@
      * @return the MIME preferred name or <code>null</code> if not known.
      */
     public static String toMimeCharset(String charsetName) {
-        Charset c = (Charset) charsetMap.get(charsetName.toLowerCase());
+        Charset c = charsetMap.get(charsetName.toLowerCase());
         if (c != null) {
             return c.mime;
         }
@@ -1113,7 +1113,7 @@
      * @return the canonical Java name or <code>null</code> if not known.
      */
     public static String toJavaCharset(String charsetName) {
-        Charset c = (Charset) charsetMap.get(charsetName.toLowerCase());
+        Charset c = charsetMap.get(charsetName.toLowerCase());
         if (c != null) {
             return c.canonical;
         }
@@ -1148,7 +1148,7 @@
     private static String dumpHtmlTable() {
         LinkedList l = new LinkedList(Arrays.asList(JAVA_CHARSETS));
         Collections.sort(l);
-        StringBuffer sb = new StringBuffer();
+        StringBuilder sb = new StringBuilder();
         sb.append(" * <table>\n");
         sb.append(" *     <tr>\n");
         sb.append(" *         <td>Canonical (Java) name</td>\n");

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/MessageUtils.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/MessageUtils.java?rev=718018&r1=718017&r2=718018&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/MessageUtils.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/MessageUtils.java Sun Nov 16 04:56:20 2008
@@ -28,10 +28,6 @@
  * @version $Id:$
  */
 public final class MessageUtils {
- 
-    public static final int STRICT_IGNORE     = 1;
-    public static final int STRICT_ERROR      = 2;
-    public static final int LENIENT           = 3;
     
     public static final Charset ASCII = CharsetUtil.getCharset("US-ASCII");
 

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/MimeUtil.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/MimeUtil.java?rev=718018&r1=718017&r2=718018&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/MimeUtil.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/MimeUtil.java Sun Nov 16 04:56:20 2008
@@ -166,7 +166,7 @@
      * @param pValue The field value to parse.
      * @return The result map; use the key "" to retrieve the first value.
      */
-    public static Map getHeaderParams(String pValue) {
+    public static Map<String, String> getHeaderParams(String pValue) {
         pValue = pValue.trim();
         
         /*
@@ -182,7 +182,7 @@
         }
         pValue = sb.toString();
         
-        Map result = new HashMap();
+        Map<String, String> result = new HashMap<String, String>();
 
         // split main value and parameters
         String main;
@@ -211,9 +211,7 @@
 
             byte state = READY_FOR_NAME;
             boolean escaped = false;
-            for (int i = 0; i < chars.length; i++) {
-                char c = chars[i];
-
+            for (char c : chars) {
                 switch (state) {
                     case ERROR:
                         if (c == ';')
@@ -355,7 +353,7 @@
      * @return a new unique message boundary string.
      */
     public static String createUniqueBoundary() {
-        StringBuffer sb = new StringBuffer();
+        StringBuilder sb = new StringBuilder();
         sb.append("-=Part.");
         sb.append(Integer.toHexString(nextCounterValue()));
         sb.append('.');
@@ -381,7 +379,7 @@
      * @return a new unique message identifier.
      */
     public static String createUniqueMessageId(String hostName) {
-        StringBuffer sb = new StringBuffer("<Mime4j.");
+        StringBuilder sb = new StringBuilder("<Mime4j.");
         sb.append(Integer.toHexString(nextCounterValue()));
         sb.append('.');
         sb.append(Long.toHexString(random.nextLong()));

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/StringArrayMap.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/StringArrayMap.java?rev=718018&r1=718017&r2=718018&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/StringArrayMap.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/StringArrayMap.java Sun Nov 16 04:56:20 2008
@@ -22,7 +22,6 @@
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.NoSuchElementException;
@@ -35,7 +34,7 @@
  */
 public class StringArrayMap implements Serializable {
     private static final long serialVersionUID = -5833051164281786907L;
-    private final Map map = new HashMap();
+    private final Map<String, Object> map = new HashMap<String, Object>();
 
     /**
      * <p>Converts the given object into a string. The object may be either of:
@@ -56,7 +55,7 @@
             return ((String[]) pValue)[0];
         }
         if (pValue instanceof List) {
-            return (String) ((List) pValue).get(0);
+            return (String) ((List<?>) pValue).get(0);
         }
         throw new IllegalStateException("Invalid parameter class: " + pValue.getClass().getName());
     }
@@ -80,8 +79,8 @@
             return (String[]) pValue;
         }
         if (pValue instanceof List) {
-            final List l = (List) pValue;
-            return (String[]) l.toArray(new String[l.size()]);
+            final List<?> l = (List<?>) pValue;
+            return l.toArray(new String[l.size()]);
         }
         throw new IllegalStateException("Invalid parameter class: " + pValue.getClass().getName());
     }
@@ -94,17 +93,17 @@
      *   <li>an array of strings, which is being converted into a string enumeration</li>
      * </ul>
      */
-    public static Enumeration asStringEnum(final Object pValue) {
+    public static Enumeration<String> asStringEnum(final Object pValue) {
         if (pValue == null) {
             return null;
         }
         if (pValue instanceof String) {
-            return new Enumeration(){
+            return new Enumeration<String>(){
                 private Object value = pValue;
                 public boolean hasMoreElements() {
                     return value != null;
                 }
-                public Object nextElement() {
+                public String nextElement() {
                     if (value == null) {
                         throw new NoSuchElementException();
                     }
@@ -116,12 +115,12 @@
         }
         if (pValue instanceof String[]) {
             final String[] values = (String[]) pValue;
-            return new Enumeration() {
+            return new Enumeration<String>() {
                 private int offset;
                 public boolean hasMoreElements() {
                     return offset < values.length;
                 }
-                public Object nextElement() {
+                public String nextElement() {
                     if (offset >= values.length) {
                         throw new NoSuchElementException();
                     }
@@ -130,7 +129,9 @@
             };
         }
         if (pValue instanceof List) {
-            return Collections.enumeration((List) pValue);
+            @SuppressWarnings("unchecked")
+            final List<String> stringList = (List<String>) pValue; 
+            return Collections.enumeration(stringList);
         }
         throw new IllegalStateException("Invalid parameter class: " + pValue.getClass().getName());
     }
@@ -139,34 +140,36 @@
      * Converts the given map into a string array map: The map values
      * are string arrays.
      */
-    public static Map asMap(final Map pMap) {
-        for (Iterator iter = pMap.entrySet().iterator();  iter.hasNext();  ) {
-            final Map.Entry entry = (Map.Entry) iter.next();
+    public static Map<String, String[]> asMap(final Map<String, Object> pMap) {
+        Map<String, String[]> result = new HashMap<String, String[]>(pMap.size());
+        for (Map.Entry<String, Object> entry : pMap.entrySet()) {
             final String[] value = asStringArray(entry.getValue());
-            entry.setValue(value);
+            result.put(entry.getKey(), value);
         }
-        return Collections.unmodifiableMap(pMap);
+        return Collections.unmodifiableMap(result);
     }
 
     /**
      * Adds a value to the given map.
      */
-    protected void addMapValue(Map pMap, String pName, String pValue) {
+    protected void addMapValue(Map<String, Object> pMap, String pName, String pValue) {
         Object o = pMap.get(pName);
         if (o == null) {
             o = pValue;
         } else if (o instanceof String) {
-            final List list = new ArrayList();
+            final List<Object> list = new ArrayList<Object>();
             list.add(o);
             list.add(pValue);
             o = list;
         } else if (o instanceof List) {
-            ((List) o).add(pValue);
+            @SuppressWarnings("unchecked")
+            final List<String> stringList = (List<String>) o; 
+            stringList.add(pValue);
         } else if (o instanceof String[]) {
-            final List list = new ArrayList();
+            final List<String> list = new ArrayList<String>();
             final String[] arr = (String[]) o;
-            for (int i = 0;  i < arr.length;  i++) {
-                list.add(arr[i]);
+            for (String str : arr) {
+                list.add(str);
             }
             list.add(pValue);
             o = list;
@@ -200,7 +203,7 @@
     /**
      * Returns the requested values as an enumeration.
      */
-    public Enumeration getValueEnum(String pName) {
+    public Enumeration<String> getValueEnum(String pName) {
         return asStringEnum(map.get(convertName(pName)));
     }
 
@@ -208,7 +211,7 @@
      * Returns the set of registered names as an enumeration.
      * @see #getNameArray()
      */
-    public Enumeration getNames() {
+    public Enumeration<String> getNames() {
         return Collections.enumeration(map.keySet());
     }
 
@@ -217,7 +220,7 @@
      * are the lower cased parameter/header names. The map values are
      * string arrays.
      */
-    public Map getMap() {
+    public Map<String, String[]> getMap() {
         return asMap(map);
     }
 
@@ -233,7 +236,7 @@
      * @see #getNames()
      */
     public String[] getNameArray() {
-        final Collection c = map.keySet();
-        return (String[]) c.toArray(new String[c.size()]);
+        final Collection<String> c = map.keySet();
+        return c.toArray(new String[c.size()]);
     }
 }

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/ExampleMail.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/ExampleMail.java?rev=718018&r1=718017&r2=718018&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/ExampleMail.java (original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/ExampleMail.java Sun Nov 16 04:56:20 2008
@@ -654,14 +654,12 @@
     
     public static final byte[] join(byte[][] byteArrays) {
         int length = 0;
-        for (int i = 0; i < byteArrays.length; i++) {
-            byte[] bytes = byteArrays[i];
+        for (byte[] bytes : byteArrays) {
             length += bytes.length;
         }
         byte[] results = new byte[length];
         int count = 0;
-        for (int i = 0; i < byteArrays.length; i++) {
-            byte[] bytes = byteArrays[i];
+        for (byte[] bytes : byteArrays) {
             System.arraycopy(bytes, 0, results, count, bytes.length);
             count += bytes.length;
         }
@@ -669,7 +667,7 @@
     }
     
     public static String breakLines(String original) {
-        StringBuffer buffer = new StringBuffer(original);
+        StringBuilder buffer = new StringBuilder(original);
         int count = 76;
         while(count < buffer.length()) {
             if (buffer.charAt(count) == '=') {

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/decoder/Base64InputStreamTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/decoder/Base64InputStreamTest.java?rev=718018&r1=718017&r2=718018&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/decoder/Base64InputStreamTest.java (original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/decoder/Base64InputStreamTest.java Sun Nov 16 04:56:20 2008
@@ -38,6 +38,7 @@
  */
 public class Base64InputStreamTest extends TestCase {
 
+    @Override
     public void setUp() {
         BasicConfigurator.resetConfiguration();
         BasicConfigurator.configure();

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/decoder/CodecUtilTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/decoder/CodecUtilTest.java?rev=718018&r1=718017&r2=718018&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/decoder/CodecUtilTest.java (original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/decoder/CodecUtilTest.java Sun Nov 16 04:56:20 2008
@@ -30,10 +30,12 @@
 
 public class CodecUtilTest extends TestCase {
 
+    @Override
     protected void setUp() throws Exception {
         super.setUp();
     }
 
+    @Override
     protected void tearDown() throws Exception {
         super.tearDown();
     }
@@ -47,7 +49,7 @@
     }
     
     public void testEncodeQuotedPrintableLargeInput() throws Exception {
-        StringBuffer sb = new StringBuffer();
+        StringBuilder sb = new StringBuilder();
         for (int i = 0; i < 1024 * 5; i++) {
             sb.append((char) ('0' + (i % 10)));
         }
@@ -70,7 +72,7 @@
     }
     
     public void testBase64OutputStream() throws Exception {
-        StringBuffer sb = new StringBuffer(2048);
+        StringBuilder sb = new StringBuilder(2048);
         for (int i = 0; i < 128; i++) {
             sb.append("0123456789ABCDEF");
         }
@@ -98,7 +100,7 @@
      */
     /* Currently commented because we don't want failing tests.
     public void testBase64Encoder() throws Exception {
-        StringBuffer sb = new StringBuffer(2048);
+        StringBuilder sb = new StringBuilder(2048);
         for (int i = 0; i < 128; i++) {
             sb.append("0123456789ABCDEF");
         }
@@ -153,7 +155,7 @@
     */
     
     private void assertEquals(byte[] expected, byte[] actual) {
-        StringBuffer buffer = new StringBuffer(expected.length);
+        StringBuilder buffer = new StringBuilder(expected.length);
         assertEquals(expected.length, actual.length);
         for (int i = 0; i < actual.length; i++) {
             buffer.append((char)actual[i]);

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/decoder/DecoderUtilTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/decoder/DecoderUtilTest.java?rev=718018&r1=718017&r2=718018&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/decoder/DecoderUtilTest.java (original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/decoder/DecoderUtilTest.java Sun Nov 16 04:56:20 2008
@@ -34,6 +34,7 @@
  */
 public class DecoderUtilTest extends TestCase {
 
+    @Override
     public void setUp() {
         BasicConfigurator.resetConfiguration();
         BasicConfigurator.configure();

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/decoder/QuotedPrintableEncodeTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/decoder/QuotedPrintableEncodeTest.java?rev=718018&r1=718017&r2=718018&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/decoder/QuotedPrintableEncodeTest.java (original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/decoder/QuotedPrintableEncodeTest.java Sun Nov 16 04:56:20 2008
@@ -34,10 +34,12 @@
 
     private static final Charset US_ASCII = Charset.forName("US-ASCII");
     
+    @Override
     protected void setUp() throws Exception {
         super.setUp();
     }
 
+    @Override
     protected void tearDown() throws Exception {
         super.tearDown();
     }

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/decoder/QuotedPrintableInputStreamTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/decoder/QuotedPrintableInputStreamTest.java?rev=718018&r1=718017&r2=718018&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/decoder/QuotedPrintableInputStreamTest.java (original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/decoder/QuotedPrintableInputStreamTest.java Sun Nov 16 04:56:20 2008
@@ -38,6 +38,7 @@
  */
 public class QuotedPrintableInputStreamTest extends TestCase {
 
+    @Override
     public void setUp() {
         BasicConfigurator.resetConfiguration();
         BasicConfigurator.configure();

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/decoder/QuotedPrintableTextEncodeTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/decoder/QuotedPrintableTextEncodeTest.java?rev=718018&r1=718017&r2=718018&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/decoder/QuotedPrintableTextEncodeTest.java (original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/decoder/QuotedPrintableTextEncodeTest.java Sun Nov 16 04:56:20 2008
@@ -34,10 +34,12 @@
 
     private static final Charset US_ASCII = Charset.forName("US-ASCII");
     
+    @Override
     protected void setUp() throws Exception {
         super.setUp();
     }
 
+    @Override
     protected void tearDown() throws Exception {
         super.tearDown();
     }
@@ -110,7 +112,7 @@
     }
     
     public void testCRLFShouldResetLineCount() throws Exception {
-        StringBuffer buffer = new StringBuffer(4096);
+        StringBuilder buffer = new StringBuilder(4096);
         for (int i=0;i<1000;i++) {
             buffer.append("Hugo\r\n");
         }

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=718018&r1=718017&r2=718018&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 Sun Nov 16 04:56:20 2008
@@ -40,25 +40,25 @@
         bd.addField("Content-Type ", "text/plain; charset=ISO-8859-1; "
                 + "boundary=foo; param1=value1; param2=value2; param3=value3");
         assertEquals(3, bd.getContentTypeParameters().size());
-        assertEquals("value1", (String) bd.getContentTypeParameters().get("param1"));
-        assertEquals("value2", (String) bd.getContentTypeParameters().get("param2"));
-        assertEquals("value3", (String) bd.getContentTypeParameters().get("param3"));
+        assertEquals("value1", bd.getContentTypeParameters().get("param1"));
+        assertEquals("value2", bd.getContentTypeParameters().get("param2"));
+        assertEquals("value3", bd.getContentTypeParameters().get("param3"));
         
         bd = newBodyDescriptor();
         bd.addField("Content-Type ", "text/plain; param1=value1; param2=value2;"
                      + " param3=value3");
         assertEquals(3, bd.getContentTypeParameters().size());
-        assertEquals("value1", (String) bd.getContentTypeParameters().get("param1"));
-        assertEquals("value2", (String) bd.getContentTypeParameters().get("param2"));
-        assertEquals("value3", (String) bd.getContentTypeParameters().get("param3"));
+        assertEquals("value1", bd.getContentTypeParameters().get("param1"));
+        assertEquals("value2", bd.getContentTypeParameters().get("param2"));
+        assertEquals("value3", bd.getContentTypeParameters().get("param3"));
         
         bd = newBodyDescriptor();
         bd.addField("Content-Type ", "text/plain; "
                 + "param1= \" value with\tspaces \" ; "
                 + "param2=\"\\\"value4 with escaped \\\" \\\"\";");
         assertEquals(2, bd.getContentTypeParameters().size());
-        assertEquals(" value with\tspaces ", (String) bd.getContentTypeParameters().get("param1"));
-        assertEquals("\"value4 with escaped \" \"", (String) bd.getContentTypeParameters().get("param2"));
+        assertEquals(" value with\tspaces ", bd.getContentTypeParameters().get("param1"));
+        assertEquals("\"value4 with escaped \" \"", bd.getContentTypeParameters().get("param2"));
         
         /*
          * Make sure escaped characters (except ") are still escaped.
@@ -67,7 +67,7 @@
         bd = newBodyDescriptor();
         bd.addField("Content-Type ", "text/plain; param=\"\\n\\\\\\\"\"");
         assertEquals(1, bd.getContentTypeParameters().size());
-        assertEquals("\\n\\\"", (String) bd.getContentTypeParameters().get("param"));
+        assertEquals("\\n\\\"", bd.getContentTypeParameters().get("param"));
     }
     
     public void testAddField() {

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/descriptor/DefaultBodyDescriptorTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/descriptor/DefaultBodyDescriptorTest.java?rev=718018&r1=718017&r2=718018&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/descriptor/DefaultBodyDescriptorTest.java (original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/descriptor/DefaultBodyDescriptorTest.java Sun Nov 16 04:56:20 2008
@@ -21,10 +21,12 @@
 import org.apache.james.mime4j.descriptor.DefaultBodyDescriptor;
 
 public class DefaultBodyDescriptorTest extends BaseTestForBodyDescriptors {
+    @Override
     protected MutableBodyDescriptor newBodyDescriptor() {
         return new DefaultBodyDescriptor();
     }
 
+    @Override
     protected MutableBodyDescriptor newBodyDescriptor(BodyDescriptor parent) {
         return new DefaultBodyDescriptor(parent);
     }

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/descriptor/MaximalBodyDescriptorTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/descriptor/MaximalBodyDescriptorTest.java?rev=718018&r1=718017&r2=718018&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/descriptor/MaximalBodyDescriptorTest.java (original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/descriptor/MaximalBodyDescriptorTest.java Sun Nov 16 04:56:20 2008
@@ -33,11 +33,13 @@
 
     MimeTokenStream parser;
     
+    @Override
     protected void setUp() throws Exception {
         super.setUp();
         parser = MimeTokenStream.createMaximalDescriptorStream();
     }
 
+    @Override
     protected void tearDown() throws Exception {
         super.tearDown();
     }
@@ -179,10 +181,12 @@
         return (MaximalBodyDescriptor) descriptor;
     }
 
+    @Override
     protected MutableBodyDescriptor newBodyDescriptor() {
         return new MaximalBodyDescriptor();
     }
 
+    @Override
     protected MutableBodyDescriptor newBodyDescriptor(BodyDescriptor parent) {
         return new MaximalBodyDescriptor(parent);
     }

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/field/ContentTypeFieldTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/field/ContentTypeFieldTest.java?rev=718018&r1=718017&r2=718018&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/field/ContentTypeFieldTest.java (original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/field/ContentTypeFieldTest.java Sun Nov 16 04:56:20 2008
@@ -33,6 +33,7 @@
  */
 public class ContentTypeFieldTest extends TestCase {
 
+    @Override
     public void setUp() {
         BasicConfigurator.resetConfiguration();
         BasicConfigurator.configure();

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/field/address/AddressTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/field/address/AddressTest.java?rev=718018&r1=718017&r2=718018&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/field/address/AddressTest.java (original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/field/address/AddressTest.java Sun Nov 16 04:56:20 2008
@@ -31,6 +31,7 @@
 import java.io.PrintWriter;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.List;
 
 import junit.framework.TestCase;
 
@@ -190,7 +191,7 @@
     
     public void testAddressList() throws ParseException {
         AddressList addlist = AddressList.parse("foo@example.com, bar@example.com, third@example.com");
-        ArrayList al = new ArrayList();
+        List<Address> al = new ArrayList<Address>();
         al.add(addlist.get(0));
 
         // shared arraylist
@@ -229,6 +230,7 @@
             System.setOut(outPs);
             System.setErr(errPs);
             Thread t = new Thread() {
+                @Override
                 public void run() {
                     try {
                         AddressList.main(null);
@@ -292,7 +294,7 @@
     }
     
     public void testDomainList() {
-        ArrayList al = new ArrayList();
+        List<String> al = new ArrayList<String>();
         al.add("example.com");
 
         // shared arraylist
@@ -330,7 +332,7 @@
     }
 
     public void testMailboxList() {
-        ArrayList al = new ArrayList();
+        List<Mailbox> al = new ArrayList<Mailbox>();
         al.add(new Mailbox("local","example.com"));
 
         // shared arraylist
@@ -349,10 +351,10 @@
     }
     
     public void testGroupSerialization() {
-        ArrayList al = new ArrayList();
+        List<Mailbox> al = new ArrayList<Mailbox>();
         al.add(new Mailbox("test", "example.com"));
         al.add(new NamedMailbox("Foo!", "foo", "example.com"));
-        DomainList dl = new DomainList(new ArrayList(Arrays.asList(new String[] {"foo.example.com"})), true);
+        DomainList dl = new DomainList(new ArrayList<String>(Arrays.asList(new String[] {"foo.example.com"})), true);
         NamedMailbox namedMailbox = new NamedMailbox("Foo Bar", dl, "foo2", "example.com");
         assertSame(dl, namedMailbox.getRoute());
         al.add(namedMailbox);

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/field/mimeversion/MimeVersionParserTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/field/mimeversion/MimeVersionParserTest.java?rev=718018&r1=718017&r2=718018&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/field/mimeversion/MimeVersionParserTest.java (original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/field/mimeversion/MimeVersionParserTest.java Sun Nov 16 04:56:20 2008
@@ -25,10 +25,12 @@
 
 public class MimeVersionParserTest extends TestCase {
 
+    @Override
     protected void setUp() throws Exception {
         super.setUp();
     }
 
+    @Override
     protected void tearDown() throws Exception {
         super.tearDown();
     }

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/field/structured/StructuredFieldParserTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/field/structured/StructuredFieldParserTest.java?rev=718018&r1=718017&r2=718018&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/field/structured/StructuredFieldParserTest.java (original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/field/structured/StructuredFieldParserTest.java Sun Nov 16 04:56:20 2008
@@ -24,10 +24,12 @@
 
 public class StructuredFieldParserTest extends TestCase {
 
+    @Override
     protected void setUp() throws Exception {
         super.setUp();
     }
 
+    @Override
     protected void tearDown() throws Exception {
         super.tearDown();
     }

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/io/BufferedLineReaderInputStreamTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/io/BufferedLineReaderInputStreamTest.java?rev=718018&r1=718017&r2=718018&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/io/BufferedLineReaderInputStreamTest.java (original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/io/BufferedLineReaderInputStreamTest.java Sun Nov 16 04:56:20 2008
@@ -56,7 +56,7 @@
         teststrs[0] = "Hello\r\n";
         teststrs[1] = "This string should be much longer than the size of the input buffer " +
                 "which is only 16 bytes for this test\r\n";
-        StringBuffer sb = new StringBuffer();
+        StringBuilder sb = new StringBuilder();
         for (int i = 0; i < 15; i++) {
             sb.append("123456789 ");
         }
@@ -67,19 +67,19 @@
 
         ByteArrayOutputStream outstream = new ByteArrayOutputStream();
         
-        for (int i = 0; i < teststrs.length; i++) {
-            outstream.write(teststrs[i].getBytes("US-ASCII"));
+        for (String teststr : teststrs) {
+            outstream.write(teststr.getBytes("US-ASCII"));
         }
         byte[] raw = outstream.toByteArray();
         
         BufferedLineReaderInputStream instream = new BufferedLineReaderInputStream(new ByteArrayInputStream(raw), 16); 
         
         ByteArrayBuffer linebuf = new ByteArrayBuffer(8); 
-        for (int i = 0; i < teststrs.length; i++) {
+        for (String teststr : teststrs) {
             linebuf.clear();
             instream.readLine(linebuf);
             String s = new String(linebuf.toByteArray(), "US-ASCII");
-            assertEquals(teststrs[i], s);
+            assertEquals(teststr, s);
         }
         assertEquals(-1, instream.readLine(linebuf));
         assertEquals(-1, instream.readLine(linebuf));

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/io/LineReaderInputStreamAdaptorTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/io/LineReaderInputStreamAdaptorTest.java?rev=718018&r1=718017&r2=718018&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/io/LineReaderInputStreamAdaptorTest.java (original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/io/LineReaderInputStreamAdaptorTest.java Sun Nov 16 04:56:20 2008
@@ -57,7 +57,7 @@
         teststrs[0] = "Hello\r\n";
         teststrs[1] = "This string should be much longer than the size of the input buffer " +
                 "which is only 16 bytes for this test\r\n";
-        StringBuffer sb = new StringBuffer();
+        StringBuilder sb = new StringBuilder();
         for (int i = 0; i < 15; i++) {
             sb.append("123456789 ");
         }
@@ -68,8 +68,8 @@
 
         ByteArrayOutputStream outstream = new ByteArrayOutputStream();
         
-        for (int i = 0; i < teststrs.length; i++) {
-            outstream.write(teststrs[i].getBytes("US-ASCII"));
+        for (String teststr : teststrs) {
+            outstream.write(teststr.getBytes("US-ASCII"));
         }
         byte[] raw = outstream.toByteArray();
         
@@ -77,11 +77,11 @@
                 new ByteArrayInputStream(raw)); 
         
         ByteArrayBuffer linebuf = new ByteArrayBuffer(8); 
-        for (int i = 0; i < teststrs.length; i++) {
+        for (String teststr : teststrs) {
             linebuf.clear();
             instream.readLine(linebuf);
             String s = new String(linebuf.toByteArray(), "US-ASCII");
-            assertEquals(teststrs[i], s);
+            assertEquals(teststr, s);
         }
         assertEquals(-1, instream.readLine(linebuf));
         assertEquals(-1, instream.readLine(linebuf));

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/io/MimeBoundaryInputStreamTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/io/MimeBoundaryInputStreamTest.java?rev=718018&r1=718017&r2=718018&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/io/MimeBoundaryInputStreamTest.java (original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/io/MimeBoundaryInputStreamTest.java Sun Nov 16 04:56:20 2008
@@ -164,7 +164,7 @@
     }
     
     private String readByOneByte(InputStream is) throws IOException {
-        StringBuffer sb = new StringBuffer();
+        StringBuilder sb = new StringBuilder();
         int b = 0;
         while ((b = is.read()) != -1) {
             sb.append((char) b);
@@ -173,7 +173,7 @@
     }
 
     private String read(InputStream is, int bufsize) throws IOException {
-        StringBuffer sb = new StringBuffer();
+        StringBuilder sb = new StringBuilder();
         int l;
         byte[] tmp = new byte[bufsize];
         while ((l = is.read(tmp)) != -1) {
@@ -247,7 +247,7 @@
         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";
-        StringBuffer sb = new StringBuffer();
+        StringBuilder sb = new StringBuilder();
         for (int i = 0; i < 15; i++) {
             sb.append("123456789 ");
         }
@@ -260,8 +260,8 @@
         
         ByteArrayOutputStream outstream = new ByteArrayOutputStream();
         
-        for (int i = 0; i < teststrs.length; i++) {
-            outstream.write(teststrs[i].getBytes("US-ASCII"));
+        for (String teststr : teststrs) {
+            outstream.write(teststr.getBytes("US-ASCII"));
         }
         outstream.write(term.getBytes("US-ASCII"));
         byte[] raw = outstream.toByteArray();
@@ -270,11 +270,11 @@
         LineReaderInputStream instream = new MimeBoundaryInputStream(inbuffer, "1234"); 
         
         ByteArrayBuffer linebuf = new ByteArrayBuffer(8); 
-        for (int i = 0; i < teststrs.length; i++) {
+        for (String teststr : teststrs) {
             linebuf.clear();
             instream.readLine(linebuf);
             String s = new String(linebuf.toByteArray(), "US-ASCII");
-            assertEquals(teststrs[i], s);
+            assertEquals(teststr, s);
         }
         assertEquals(-1, instream.readLine(linebuf));
         assertEquals(-1, instream.readLine(linebuf));

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/ExampleMessagesRoundtripTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/ExampleMessagesRoundtripTest.java?rev=718018&r1=718017&r2=718018&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/ExampleMessagesRoundtripTest.java (original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/ExampleMessagesRoundtripTest.java Sun Nov 16 04:56:20 2008
@@ -20,9 +20,7 @@
 package org.apache.james.mime4j.message;
 
 import org.apache.james.mime4j.decoder.CodecUtil;
-import org.apache.james.mime4j.message.Message;
 import org.apache.james.mime4j.parser.MimeEntityConfig;
-import org.apache.james.mime4j.util.MessageUtils;
 import org.apache.log4j.BasicConfigurator;
 
 import java.io.ByteArrayOutputStream;
@@ -54,17 +52,19 @@
         this.file = testFile;
     }
 
+    @Override
     public void setUp() {
         BasicConfigurator.resetConfiguration();
         BasicConfigurator.configure();
     }
    
+    @Override
     protected void runTest() throws Throwable {
         MimeEntityConfig config = new MimeEntityConfig();
         config.setMaxLineLen(-1);
         Message inputMessage = new Message(new FileInputStream(file), config);
         ByteArrayOutputStream out = new ByteArrayOutputStream();
-        inputMessage.writeTo(out, MessageUtils.LENIENT);
+        inputMessage.writeTo(out, Mode.LENIENT);
         
         String msgoutFile = file.getAbsolutePath().substring(0, file.getAbsolutePath().lastIndexOf('.')) + ".out";
         String msgoutFileMime4j = file.getAbsolutePath().substring(0, file.getAbsolutePath().lastIndexOf('.')) + ".mime4j.out";
@@ -76,12 +76,12 @@
             
             Message roundtripMessage = new Message(new FileInputStream(msgoutFile), config);
             ByteArrayOutputStream outRoundtrip = new ByteArrayOutputStream();
-            roundtripMessage.writeTo(outRoundtrip, MessageUtils.LENIENT);
+            roundtripMessage.writeTo(outRoundtrip, Mode.LENIENT);
             assertEquals("Failed LENIENT roundtrip", new String(out.toByteArray()), new String(outRoundtrip.toByteArray()));
 
             roundtripMessage = new Message(new FileInputStream(msgoutFile), config);
             outRoundtrip = new ByteArrayOutputStream();
-            roundtripMessage.writeTo(outRoundtrip, MessageUtils.STRICT_ERROR);
+            roundtripMessage.writeTo(outRoundtrip, Mode.STRICT_ERROR);
             assertEquals("Failed STRICT roundtrip", new String(out.toByteArray()), new String(outRoundtrip.toByteArray()));
 
         } catch (FileNotFoundException e) {
@@ -109,9 +109,7 @@
             File dir = TESTS_FOLDER;
             File[] files = dir.listFiles();
             
-            for (int i = 0; i < files.length; i++) {
-                File f = files[i];
-                
+            for (File f : files) {
                 if (f.getName().toLowerCase().endsWith(".msg")) {
                     addTest(new ExampleMessagesRoundtripTest(f.getName().substring(0, f.getName().length()-4), f));
                 }

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/HeaderTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/HeaderTest.java?rev=718018&r1=718017&r2=718018&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/HeaderTest.java (original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/HeaderTest.java Sun Nov 16 04:56:20 2008
@@ -50,10 +50,10 @@
     };
         
     private static String constructString(int [] unicodeChars) {
-        StringBuffer buffer = new StringBuffer();
+        StringBuilder buffer = new StringBuilder();
         if (unicodeChars != null) {
-            for (int i = 0; i < unicodeChars.length; i++) {
-                buffer.append((char)unicodeChars[i]); 
+            for (int unicodeChar : unicodeChars) {
+                buffer.append((char) unicodeChar); 
             }
         }
         return buffer.toString();
@@ -70,7 +70,7 @@
         
         ByteArrayOutputStream buffer = new ByteArrayOutputStream();
         
-        header.writeTo(buffer, MessageUtils.STRICT_IGNORE);
+        header.writeTo(buffer, Mode.STRICT_IGNORE);
         String s = buffer.toString(MessageUtils.ASCII.name());
         
         assertEquals("Hello: Gr?ezi_z?m?\r\n\r\n", s);
@@ -78,7 +78,7 @@
         buffer.reset();
         
         try {
-            header.writeTo(buffer, MessageUtils.STRICT_ERROR);
+            header.writeTo(buffer, Mode.STRICT_ERROR);
             fail("MimeException should have been thrown");
         } catch (MimeException expected) {
         }
@@ -97,7 +97,7 @@
         
         ByteArrayOutputStream buffer = new ByteArrayOutputStream();
         
-        header.writeTo(buffer, MessageUtils.LENIENT);
+        header.writeTo(buffer, Mode.LENIENT);
         String s = buffer.toString(MessageUtils.ISO_8859_1.name());
         
         assertEquals("Hello: " + hello + "\r\n" +
@@ -120,7 +120,7 @@
         assertEquals(0, header.getFields("received").size());
         assertEquals(1, header.getFields("Content-Type").size());
 
-        assertEquals("Content-type", ((Field) header.getFields().get(0)).getName());
+        assertEquals("Content-type", header.getFields().get(0).getName());
     }
 
     public void testRemoveNonExistantField() throws Exception {
@@ -148,9 +148,9 @@
         assertEquals(3, header.getFields().size());
         assertEquals(1, header.getFields("received").size());
 
-        assertEquals("From", ((Field) header.getFields().get(0)).getName());
-        assertEquals("received", ((Field) header.getFields().get(1)).getName());
-        assertEquals("Content-type", ((Field) header.getFields().get(2)).getName());
+        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 {
@@ -164,7 +164,7 @@
         assertEquals(4, header.getFields().size());
         assertEquals(1, header.getFields("message-id").size());
 
-        assertEquals("Message-ID", ((Field) header.getFields().get(3)).getName());
+        assertEquals("Message-ID", header.getFields().get(3).getName());
     }
     
 }

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/MessageCompleteMailTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/MessageCompleteMailTest.java?rev=718018&r1=718017&r2=718018&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/MessageCompleteMailTest.java (original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/MessageCompleteMailTest.java Sun Nov 16 04:56:20 2008
@@ -26,10 +26,12 @@
 
 public class MessageCompleteMailTest extends TestCase {
 
+    @Override
     protected void setUp() throws Exception {
         super.setUp();
     }
 
+    @Override
     protected void tearDown() throws Exception {
         super.tearDown();
     }

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/MessageParserTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/MessageParserTest.java?rev=718018&r1=718017&r2=718018&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/MessageParserTest.java (original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/MessageParserTest.java Sun Nov 16 04:56:20 2008
@@ -34,7 +34,6 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.UnsupportedEncodingException;
-import java.util.Iterator;
 import java.util.List;
 
 import junit.framework.Test;
@@ -60,6 +59,7 @@
         this.file = file;
     }
 
+    @Override
     public void setUp() {
         BasicConfigurator.resetConfiguration();
         BasicConfigurator.configure();
@@ -90,6 +90,7 @@
         }
     }
     
+    @Override
     protected void runTest() throws IOException {
         File f = file;
         String fileName = file.getAbsolutePath();
@@ -139,7 +140,7 @@
     private String getStructure(Entity e, String prefix, String id) 
             throws IOException {
         
-        StringBuffer sb = new StringBuffer();
+        StringBuilder sb = new StringBuilder();
         
         if (e instanceof Message) {
             sb.append("<message>\r\n");
@@ -148,8 +149,8 @@
         }            
         
         sb.append("<header>\r\n");
-        for (Iterator it = e.getHeader().getFields().iterator(); it.hasNext();) {
-            sb.append("<field>\r\n" + escape(((Field) it.next()).getRaw()) 
+        for (Field field : e.getHeader().getFields()) {
+            sb.append("<field>\r\n" + escape(field.getRaw()) 
                     + "</field>\r\n");
         }
         sb.append("</header>\r\n");
@@ -158,15 +159,15 @@
             sb.append("<multipart>\r\n");
             
             Multipart multipart =(Multipart) e.getBody(); 
-            List parts =multipart.getBodyParts();
+            List<BodyPart> parts = multipart.getBodyParts();
 
             sb.append("<preamble>\r\n");
             sb.append(escape(multipart.getPreamble()));
             sb.append("</preamble>\r\n");
             
             int i = 1;
-            for (Iterator it = parts.iterator(); it.hasNext();) {
-                sb.append(getStructure((Entity) it.next(), prefix, id + "_" + (i++)));
+            for (BodyPart bodyPart : parts) {
+                sb.append(getStructure(bodyPart, prefix, id + "_" + (i++)));
             }
 
             sb.append("<epilogue>\r\n");

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/MessageTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/MessageTest.java?rev=718018&r1=718017&r2=718018&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/MessageTest.java (original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/MessageTest.java Sun Nov 16 04:56:20 2008
@@ -33,7 +33,6 @@
 import org.apache.commons.io.IOUtils;
 import org.apache.james.mime4j.MimeException;
 import org.apache.james.mime4j.field.Field;
-import org.apache.james.mime4j.util.MessageUtils;
 
 /**
  * 
@@ -48,6 +47,7 @@
     private Header headerMultipartMixed = null;
     private Header headerMultipartDigest = null;
 
+    @Override
     public void setUp() throws Exception {
         headerTextPlain = new Header();
         headerMessageRFC822 = new Header();
@@ -132,7 +132,7 @@
         Message m = new Message(new ByteArrayInputStream(inputByte));
         ByteArrayOutputStream out = new ByteArrayOutputStream();
 
-        m.writeTo(out, MessageUtils.LENIENT);
+        m.writeTo(out, Mode.LENIENT);
 
         InputStream output = new ByteArrayInputStream(out.toByteArray());
 
@@ -158,8 +158,8 @@
                 .getBody(), headerValue);
 
         ByteArrayOutputStream out = new ByteArrayOutputStream();
-        m.writeTo(out, MessageUtils.LENIENT);
-        List lines = IOUtils.readLines((new BufferedReader(
+        m.writeTo(out, Mode.LENIENT);
+        List<?> lines = IOUtils.readLines((new BufferedReader(
                 new InputStreamReader(new ByteArrayInputStream(out
                         .toByteArray())))));
 
@@ -195,9 +195,9 @@
     }
 
     private byte[] getRawMessageAsByteArray() {
-        StringBuffer header = new StringBuffer();
-        StringBuffer body = new StringBuffer();
-        StringBuffer complete = new StringBuffer();
+        StringBuilder header = new StringBuilder();
+        StringBuilder body = new StringBuilder();
+        StringBuilder complete = new StringBuilder();
 
         header.append("Date: Wed, 21 Feb 2007 11:09:27 +0100\r\n");
         header.append("From: Test <test@test>\r\n");
@@ -217,11 +217,12 @@
 
         public boolean disposed = false;
 
-        public void writeTo(OutputStream out, int mode) throws IOException,
+        public void writeTo(OutputStream out, Mode mode) throws IOException,
                 MimeException {
             out.write("dummy".getBytes("US-ASCII"));
         }
 
+        @Override
         public void dispose() {
             disposed = true;
         }

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/MessageWriteToTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/MessageWriteToTest.java?rev=718018&r1=718017&r2=718018&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/MessageWriteToTest.java (original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/MessageWriteToTest.java Sun Nov 16 04:56:20 2008
@@ -22,16 +22,17 @@
 import java.io.ByteArrayOutputStream;
 
 import org.apache.james.mime4j.ExampleMail;
-import org.apache.james.mime4j.util.MessageUtils;
 
 import junit.framework.TestCase;
 
 public class MessageWriteToTest extends TestCase {
 
+    @Override
     protected void setUp() throws Exception {
         super.setUp();
     }
 
+    @Override
     protected void tearDown() throws Exception {
         super.tearDown();
     }
@@ -40,7 +41,7 @@
         Message message = createMessage(ExampleMail.RFC822_SIMPLE_BYTES);
         assertFalse("Not multipart", message.isMultipart());
         ByteArrayOutputStream out = new ByteArrayOutputStream();
-        message.writeTo(out, MessageUtils.STRICT_IGNORE);
+        message.writeTo(out, Mode.STRICT_IGNORE);
         assertEquals(out.toByteArray(), ExampleMail.RFC822_SIMPLE_BYTES);
     }
     
@@ -48,7 +49,7 @@
         Message message = createMessage(ExampleMail.RFC822_SIMPLE_BYTES);
         assertFalse("Not multipart", message.isMultipart());
         ByteArrayOutputStream out = new ByteArrayOutputStream();
-        message.writeTo(out, MessageUtils.STRICT_ERROR);
+        message.writeTo(out, Mode.STRICT_ERROR);
         assertEquals(out.toByteArray(), ExampleMail.RFC822_SIMPLE_BYTES);
     }
     
@@ -56,12 +57,12 @@
         Message message = createMessage(ExampleMail.RFC822_SIMPLE_BYTES);
         assertFalse("Not multipart", message.isMultipart());
         ByteArrayOutputStream out = new ByteArrayOutputStream();
-        message.writeTo(out, MessageUtils.LENIENT);
+        message.writeTo(out, Mode.LENIENT);
         assertEquals(out.toByteArray(), ExampleMail.RFC822_SIMPLE_BYTES);
     }
     
     private void assertEquals(byte[] expected, byte[] actual) {
-        StringBuffer buffer = new StringBuffer(expected.length);
+        StringBuilder buffer = new StringBuilder(expected.length);
         assertEquals(expected.length, actual.length);
         for (int i = 0; i < actual.length; i++) {
             buffer.append((char)actual[i]);
@@ -73,7 +74,7 @@
         Message message = createMessage(ExampleMail.MULTIPART_WITH_BINARY_ATTACHMENTS_BYTES);
         assertTrue("Is multipart", message.isMultipart());
         ByteArrayOutputStream out = new ByteArrayOutputStream();
-        message.writeTo(out, MessageUtils.LENIENT);
+        message.writeTo(out, Mode.LENIENT);
         assertEquals(ExampleMail.MULTIPART_WITH_BINARY_ATTACHMENTS_BYTES, out.toByteArray());
     }
     
@@ -81,7 +82,7 @@
         Message message = createMessage(ExampleMail.MULTIPART_WITH_BINARY_ATTACHMENTS_BYTES);
         assertTrue("Is multipart", message.isMultipart());
         ByteArrayOutputStream out = new ByteArrayOutputStream();
-        message.writeTo(out, MessageUtils.STRICT_ERROR);
+        message.writeTo(out, Mode.STRICT_ERROR);
         assertEquals(ExampleMail.MULTIPART_WITH_BINARY_ATTACHMENTS_BYTES, out.toByteArray());
     }
     
@@ -89,7 +90,7 @@
         Message message = createMessage(ExampleMail.MULTIPART_WITH_BINARY_ATTACHMENTS_BYTES);
         assertTrue("Is multipart", message.isMultipart());
         ByteArrayOutputStream out = new ByteArrayOutputStream();
-        message.writeTo(out, MessageUtils.STRICT_IGNORE);
+        message.writeTo(out, Mode.STRICT_IGNORE);
         assertEquals(ExampleMail.MULTIPART_WITH_BINARY_ATTACHMENTS_BYTES, out.toByteArray());
     }
     

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/MultipartFormTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/MultipartFormTest.java?rev=718018&r1=718017&r2=718018&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/MultipartFormTest.java (original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/MultipartFormTest.java Sun Nov 16 04:56:20 2008
@@ -27,7 +27,6 @@
 
 import org.apache.commons.io.IOUtils;
 import org.apache.james.mime4j.field.Field;
-import org.apache.james.mime4j.util.MessageUtils;
 
 import junit.framework.TestCase;
 
@@ -69,7 +68,7 @@
         multipart.addBodyPart(p3);
         
         ByteArrayOutputStream out = new ByteArrayOutputStream();
-        multipart.writeTo(out, MessageUtils.LENIENT);
+        multipart.writeTo(out, Mode.LENIENT);
         out.close();
         
         String expected = "\r\n" + 
@@ -115,7 +114,7 @@
             return new StringReader(this.text);
         }
 
-        public void writeTo(final OutputStream out, int mode) throws IOException {
+        public void writeTo(final OutputStream out, Mode mode) throws IOException {
             if (out == null) {
                 throw new IllegalArgumentException("Output stream may not be null");
             }

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/MimeStreamParserExampleMessagesTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/MimeStreamParserExampleMessagesTest.java?rev=718018&r1=718017&r2=718018&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/MimeStreamParserExampleMessagesTest.java (original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/MimeStreamParserExampleMessagesTest.java Sun Nov 16 04:56:20 2008
@@ -51,11 +51,13 @@
         this.file = testFile;
     }
 
+    @Override
     public void setUp() {
         BasicConfigurator.resetConfiguration();
         BasicConfigurator.configure();
     }
    
+    @Override
     protected void runTest() throws Throwable {
         MimeStreamParser parser = null;
         TestHandler handler = null;
@@ -98,9 +100,7 @@
             File dir = TESTS_FOLDER;
             File[] files = dir.listFiles();
             
-            for (int i = 0; i < files.length; i++) {
-                File f = files[i];
-                
+            for (File f : files) {
                 if (f.getName().toLowerCase().endsWith(".msg")) {
                     addTest(new MimeStreamParserExampleMessagesTest(f.getName().substring(0, f.getName().length()-4), f));
                 }

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/MimeStreamParserTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/MimeStreamParserTest.java?rev=718018&r1=718017&r2=718018&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/MimeStreamParserTest.java (original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/MimeStreamParserTest.java Sun Nov 16 04:56:20 2008
@@ -39,6 +39,7 @@
  */
 public class MimeStreamParserTest extends TestCase {
 
+    @Override
     public void setUp() {
         BasicConfigurator.resetConfiguration();
         BasicConfigurator.configure();
@@ -67,8 +68,8 @@
                            new EOLConvertingInputStream(
                                  new RandomAccessFileInputStream(file, pos, file.length()));
                        
-                       StringBuffer sb1 = new StringBuffer();
-                       StringBuffer sb2 = new StringBuffer();
+                       StringBuilder sb1 = new StringBuilder();
+                       StringBuilder sb2 = new StringBuilder();
                        int b = 0;
                        while ((b = expected.read()) != -1) {
                            sb1.append((char) (b & 0xff));
@@ -88,7 +89,7 @@
     }*/
     
     public void testBoundaryInEpilogue() throws Exception {
-        StringBuffer sb = new StringBuffer();
+        StringBuilder sb = new StringBuilder();
         sb.append("From: foo@bar.com\r\n");
         sb.append("To: someone@else.com\r\n");
         sb.append("Content-type: multipart/something; boundary=myboundary\r\n");
@@ -103,7 +104,7 @@
         sb.append("\r\n");
         sb.append("--myboundary--\r\n");
         
-        StringBuffer epilogue = new StringBuffer();
+        StringBuilder epilogue = new StringBuilder();
         epilogue.append("Content-type: text/plain\r\n");
         epilogue.append("\r\n");
         epilogue.append("This is actually the epilogue but it looks like a second body.\r\n");
@@ -116,10 +117,11 @@
         
         ByteArrayInputStream bais = new ByteArrayInputStream(sb.toString().getBytes("US-ASCII"));
         
-        final StringBuffer actual = new StringBuffer();
+        final StringBuilder actual = new StringBuilder();
         
         MimeStreamParser parser = new MimeStreamParser();
         parser.setContentHandler(new AbstractContentHandler() {
+            @Override
             public void epilogue(InputStream is) throws IOException {
                 int b;
                 while ((b = is.read()) != -1) {
@@ -133,17 +135,18 @@
     }
     
     public void testParseOneLineFields() throws Exception {
-        StringBuffer sb = new StringBuffer();
-        final LinkedList expected = new LinkedList();
+        StringBuilder sb = new StringBuilder();
+        final LinkedList<String> expected = new LinkedList<String>();
         expected.add("From: foo@abr.com");
-        sb.append(expected.getLast().toString() + "\r\n");
+        sb.append(expected.getLast() + "\r\n");
         expected.add("Subject: A subject");
-        sb.append(expected.getLast().toString() + "\r\n");
+        sb.append(expected.getLast() + "\r\n");
         
         MimeStreamParser parser = new MimeStreamParser();
         parser.setContentHandler(new AbstractContentHandler() {
+            @Override
             public void field(String fieldData) {
-                assertEquals((String) expected.removeFirst(), fieldData);
+                assertEquals(expected.removeFirst(), fieldData);
             }
         });
         
@@ -157,16 +160,17 @@
          * Test added because \r:s not followed by \n:s in the header would
          * cause an infinite loop. 
          */
-        StringBuffer sb = new StringBuffer();
-        final LinkedList expected = new LinkedList();
+        StringBuilder sb = new StringBuilder();
+        final LinkedList<String> expected = new LinkedList<String>();
         expected.add("The-field: This field\r\rcontains CR:s\r\r"
                         + "not\r\n\tfollowed by LF");
-        sb.append(expected.getLast().toString() + "\r\n");
+        sb.append(expected.getLast() + "\r\n");
         
         MimeStreamParser parser = new MimeStreamParser();
         parser.setContentHandler(new AbstractContentHandler() {
+            @Override
             public void field(String fieldData) {
-                assertEquals((String) expected.removeFirst(), fieldData);
+                assertEquals(expected.removeFirst(), fieldData);
             }
         });
         
@@ -176,20 +180,21 @@
     }
     
     public void testParseMultiLineFields() throws Exception {
-        StringBuffer sb = new StringBuffer();
-        final LinkedList expected = new LinkedList();
+        StringBuilder sb = new StringBuilder();
+        final LinkedList<String> expected = new LinkedList<String>();
         expected.add("Received: by netmbx.netmbx.de (/\\==/\\ Smail3.1.28.1)\r\n"
                    + "\tfrom mail.cs.tu-berlin.de with smtp\r\n"
                    + "\tid &lt;m0uWPrO-0004wpC&gt;;"
                         + " Wed, 19 Jun 96 18:12 MES");
-        sb.append(expected.getLast().toString() + "\r\n");
+        sb.append(expected.getLast() + "\r\n");
         expected.add("Subject: A folded subject\r\n Line 2\r\n\tLine 3");
-        sb.append(expected.getLast().toString() + "\r\n");
+        sb.append(expected.getLast() + "\r\n");
         
         MimeStreamParser parser = new MimeStreamParser();
         parser.setContentHandler(new AbstractContentHandler() {
+            @Override
             public void field(String fieldData) {
-                assertEquals((String) expected.removeFirst(), fieldData);
+                assertEquals(expected.removeFirst(), fieldData);
             }
         });
         
@@ -201,6 +206,7 @@
     public void testStop() throws Exception {
         final MimeStreamParser parser = new MimeStreamParser();
         TestHandler handler = new TestHandler() {
+            @Override
             public void endHeader() {
                 super.endHeader();
                 parser.stop();
@@ -236,19 +242,20 @@
      * Tests that invalid fields are ignored.
      */
     public void testInvalidFields() throws Exception {
-        StringBuffer sb = new StringBuffer();
-        final LinkedList expected = new LinkedList();
+        StringBuilder sb = new StringBuilder();
+        final LinkedList<String> expected = new LinkedList<String>();
         sb.append("From - foo@abr.com\r\n");
         expected.add("From: some@one.com");
-        sb.append(expected.getLast().toString() + "\r\n");
+        sb.append(expected.getLast() + "\r\n");
         expected.add("Subject: A subject");
-        sb.append(expected.getLast().toString() + "\r\n");
+        sb.append(expected.getLast() + "\r\n");
         sb.append("A line which should be ignored\r\n");
         
         MimeStreamParser parser = new MimeStreamParser();
         parser.setContentHandler(new AbstractContentHandler() {
+            @Override
             public void field(String fieldData) {
-                assertEquals((String) expected.removeFirst(), fieldData);
+                assertEquals(expected.removeFirst(), fieldData);
             }
         });
         
@@ -261,7 +268,7 @@
      * Tests that empty streams still generate the expected series of events.
      */
     public void testEmptyStream() throws Exception {
-        final LinkedList expected = new LinkedList();
+        final LinkedList<String> expected = new LinkedList<String>();
         expected.add("startMessage");
         expected.add("startHeader");
         expected.add("endHeader");
@@ -270,44 +277,54 @@
         
         MimeStreamParser parser = new MimeStreamParser();
         parser.setContentHandler(new AbstractContentHandler() {
+            @Override
             public void body(BodyDescriptor bd, InputStream is) {
-                assertEquals((String) expected.removeFirst(), "body");
+                assertEquals(expected.removeFirst(), "body");
             }
             
+            @Override
             public void endMultipart() {
                 fail("endMultipart shouldn't be called for empty stream");
             }
 
+            @Override
             public void endBodyPart() {
                 fail("endBodyPart shouldn't be called for empty stream");
             }
 
+            @Override
             public void endHeader() {
-                assertEquals((String) expected.removeFirst(), "endHeader");
+                assertEquals(expected.removeFirst(), "endHeader");
             }
 
+            @Override
             public void endMessage() {
-                assertEquals((String) expected.removeFirst(), "endMessage");
+                assertEquals(expected.removeFirst(), "endMessage");
             }
 
+            @Override
             public void field(String fieldData) {
                 fail("field shouldn't be called for empty stream");
             }
 
+            @Override
             public void startMultipart(BodyDescriptor bd) {
                 fail("startMultipart shouldn't be called for empty stream");
             }
 
+            @Override
             public void startBodyPart() {
                 fail("startBodyPart shouldn't be called for empty stream");
             }
 
+            @Override
             public void startHeader() {
-                assertEquals((String) expected.removeFirst(), "startHeader");
+                assertEquals(expected.removeFirst(), "startHeader");
             }
 
+            @Override
             public void startMessage() {
-                assertEquals((String) expected.removeFirst(), "startMessage");
+                assertEquals(expected.removeFirst(), "startMessage");
             }
         });
         
@@ -320,17 +337,19 @@
      * Tests parsing of empty headers.
      */
     public void testEmpyHeader() throws Exception {
-        StringBuffer sb = new StringBuffer();
+        StringBuilder sb = new StringBuilder();
         sb.append("\r\n");
         sb.append("The body is right here\r\n");
         
-        final StringBuffer body = new StringBuffer();
+        final StringBuilder body = new StringBuilder();
         
         MimeStreamParser parser = new MimeStreamParser();
         parser.setContentHandler(new AbstractContentHandler() {
+            @Override
             public void field(String fieldData) {
                 fail("No fields should be reported");
             }
+            @Override
             public void body(BodyDescriptor bd, InputStream is) throws IOException {
                 int b;
                 while ((b = is.read()) != -1) {
@@ -348,18 +367,20 @@
      * Tests parsing of empty body.
      */
     public void testEmptyBody() throws Exception {
-        StringBuffer sb = new StringBuffer();
-        final LinkedList expected = new LinkedList();
+        StringBuilder sb = new StringBuilder();
+        final LinkedList<String> expected = new LinkedList<String>();
         expected.add("From: some@one.com");
-        sb.append(expected.getLast().toString() + "\r\n");
+        sb.append(expected.getLast() + "\r\n");
         expected.add("Subject: A subject");
-        sb.append(expected.getLast().toString() + "\r\n\r\n");
+        sb.append(expected.getLast() + "\r\n\r\n");
         
         MimeStreamParser parser = new MimeStreamParser();
         parser.setContentHandler(new AbstractContentHandler() {
+            @Override
             public void field(String fieldData) {
-                assertEquals((String) expected.removeFirst(), fieldData);
+                assertEquals(expected.removeFirst(), fieldData);
             }
+            @Override
             public void body(BodyDescriptor bd, InputStream is) throws IOException {
                 assertEquals(-1, is.read());
             }
@@ -374,17 +395,18 @@
      * Tests that invalid fields are ignored.
      */
     public void testPrematureEOFAfterFields() throws Exception {
-        StringBuffer sb = new StringBuffer();
-        final LinkedList expected = new LinkedList();
+        StringBuilder sb = new StringBuilder();
+        final LinkedList<String> expected = new LinkedList<String>();
         expected.add("From: some@one.com");
-        sb.append(expected.getLast().toString() + "\r\n");
+        sb.append(expected.getLast() + "\r\n");
         expected.add("Subject: A subject");
-        sb.append(expected.getLast().toString());
+        sb.append(expected.getLast());
         
         MimeStreamParser parser = new MimeStreamParser();
         parser.setContentHandler(new AbstractContentHandler() {
+            @Override
             public void field(String fieldData) {
-                assertEquals((String) expected.removeFirst(), fieldData);
+                assertEquals(expected.removeFirst(), fieldData);
             }
         });
         
@@ -392,17 +414,18 @@
         
         assertEquals(0, expected.size());
         
-        sb = new StringBuffer();
+        sb = new StringBuilder();
         expected.clear();
         expected.add("From: some@one.com");
-        sb.append(expected.getLast().toString() + "\r\n");
+        sb.append(expected.getLast() + "\r\n");
         expected.add("Subject: A subject");
-        sb.append(expected.getLast().toString() + "\r\n");
+        sb.append(expected.getLast() + "\r\n");
         
         parser = new MimeStreamParser();
         parser.setContentHandler(new AbstractContentHandler() {
+            @Override
             public void field(String fieldData) {
-                assertEquals((String) expected.removeFirst(), fieldData);
+                assertEquals(expected.removeFirst(), fieldData);
             }
         });
         

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/MimeStreamTokenMessageRfc822Test.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/MimeStreamTokenMessageRfc822Test.java?rev=718018&r1=718017&r2=718018&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/MimeStreamTokenMessageRfc822Test.java (original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/MimeStreamTokenMessageRfc822Test.java Sun Nov 16 04:56:20 2008
@@ -30,12 +30,14 @@
 
     MimeTokenStream stream;
     
+    @Override
     protected void setUp() throws Exception {
         super.setUp();
         stream = new MimeTokenStream();
         stream.parse(new ByteArrayInputStream(ExampleMail.MIME_RFC822_SIMPLE_BYTES));
     }
 
+    @Override
     protected void tearDown() throws Exception {
         super.tearDown();
     }

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/MimeTokenEmbeddedMessageTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/MimeTokenEmbeddedMessageTest.java?rev=718018&r1=718017&r2=718018&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/MimeTokenEmbeddedMessageTest.java (original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/MimeTokenEmbeddedMessageTest.java Sun Nov 16 04:56:20 2008
@@ -31,6 +31,7 @@
     
     MimeTokenStream stream;
     
+    @Override
     protected void setUp() throws Exception {
         super.setUp();
         stream = new MimeTokenStream();
@@ -38,6 +39,7 @@
         stream.parse(in);
     }
 
+    @Override
     protected void tearDown() throws Exception {
         super.tearDown();
     }

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/MimeTokenNoRecurseTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/MimeTokenNoRecurseTest.java?rev=718018&r1=718017&r2=718018&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/MimeTokenNoRecurseTest.java (original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/MimeTokenNoRecurseTest.java Sun Nov 16 04:56:20 2008
@@ -65,6 +65,7 @@
     
     MimeTokenStream stream;
     
+    @Override
     protected void setUp() throws Exception {
         super.setUp();
         stream = new MimeTokenStream();
@@ -73,6 +74,7 @@
         stream.parse(in);
     }
 
+    @Override
     protected void tearDown() throws Exception {
         super.tearDown();
     }

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/MimeTokenStreamBodyDescriptorTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/MimeTokenStreamBodyDescriptorTest.java?rev=718018&r1=718017&r2=718018&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/MimeTokenStreamBodyDescriptorTest.java (original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/MimeTokenStreamBodyDescriptorTest.java Sun Nov 16 04:56:20 2008
@@ -30,12 +30,14 @@
 
     MimeTokenStream parser;
     
+    @Override
     protected void setUp() throws Exception {
         super.setUp();
         parser = new MimeTokenStream();
         parser.parse(new ByteArrayInputStream(ExampleMail.MIME_MULTIPART_ALTERNATIVE_BYTES));
     }
 
+    @Override
     protected void tearDown() throws Exception {
         super.tearDown();
     }

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/MimeTokenStreamReaderTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/MimeTokenStreamReaderTest.java?rev=718018&r1=718017&r2=718018&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/MimeTokenStreamReaderTest.java (original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/MimeTokenStreamReaderTest.java Sun Nov 16 04:56:20 2008
@@ -34,11 +34,13 @@
     
     MimeTokenStream parser;
     
+    @Override
     protected void setUp() throws Exception {
         super.setUp();
         parser = new MimeTokenStream();
     }
 
+    @Override
     protected void tearDown() throws Exception {
         super.tearDown();
     }

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/MimeTokenStreamTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/MimeTokenStreamTest.java?rev=718018&r1=718017&r2=718018&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/MimeTokenStreamTest.java (original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/MimeTokenStreamTest.java Sun Nov 16 04:56:20 2008
@@ -31,6 +31,7 @@
 
     MimeTokenStream stream;
     
+    @Override
     public void setUp() throws Exception {
         stream = new MimeTokenStream();
     }

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/MultipartStreamTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/MultipartStreamTest.java?rev=718018&r1=718017&r2=718018&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/MultipartStreamTest.java (original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/MultipartStreamTest.java Sun Nov 16 04:56:20 2008
@@ -69,11 +69,13 @@
     
     MimeTokenStream parser;
     
+    @Override
     protected void setUp() throws Exception {
         super.setUp();
         parser = new MimeTokenStream();
     }
 
+    @Override
     protected void tearDown() throws Exception {
         super.tearDown();
     }

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/MultipartTokensTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/MultipartTokensTest.java?rev=718018&r1=718017&r2=718018&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/MultipartTokensTest.java (original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/MultipartTokensTest.java Sun Nov 16 04:56:20 2008
@@ -93,11 +93,13 @@
     
     MimeTokenStream parser;
     
+    @Override
     protected void setUp() throws Exception {
         super.setUp();
         parser = new MimeTokenStream();
     }
 
+    @Override
     protected void tearDown() throws Exception {
         super.tearDown();
     }

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/TestHandler.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/TestHandler.java?rev=718018&r1=718017&r2=718018&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/TestHandler.java (original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/TestHandler.java Sun Nov 16 04:56:20 2008
@@ -29,7 +29,7 @@
  * Helper class to run comparison of parsed results
  */
 class TestHandler implements ContentHandler {
-    StringBuffer sb = new StringBuffer();
+    StringBuilder sb = new StringBuilder();
 
     private String escape(char c) {
         if (c == '&') {

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/util/MessageUtilsTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/util/MessageUtilsTest.java?rev=718018&r1=718017&r2=718018&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/util/MessageUtilsTest.java (original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/util/MessageUtilsTest.java Sun Nov 16 04:56:20 2008
@@ -35,10 +35,10 @@
     };
         
     private static String constructString(int [] unicodeChars) {
-        StringBuffer buffer = new StringBuffer();
+        StringBuilder buffer = new StringBuilder();
         if (unicodeChars != null) {
-            for (int i = 0; i < unicodeChars.length; i++) {
-                buffer.append((char)unicodeChars[i]); 
+            for (int unicodeChar : unicodeChars) {
+                buffer.append((char) unicodeChar); 
             }
         }
         return buffer.toString();



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