james-mime4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ieu...@apache.org
Subject svn commit: r1426193 [4/7] - in /james/mime4j/trunk: ./ core/src/test/java/org/apache/james/mime4j/ core/src/test/java/org/apache/james/mime4j/codec/ core/src/test/java/org/apache/james/mime4j/io/ core/src/test/java/org/apache/james/mime4j/parser/ core...
Date Thu, 27 Dec 2012 13:23:56 GMT
Modified: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MultipartTokensTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MultipartTokensTest.java?rev=1426193&r1=1426192&r2=1426193&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MultipartTokensTest.java (original)
+++ james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MultipartTokensTest.java Thu Dec 27 13:23:54 2012
@@ -19,28 +19,30 @@
 
 package org.apache.james.mime4j.stream;
 
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.nio.charset.Charset;
-
-import junit.framework.TestCase;
-
 import org.apache.commons.io.IOUtils;
 import org.apache.james.mime4j.MimeException;
 import org.apache.james.mime4j.util.CharsetUtil;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.nio.charset.Charset;
 
-public class MultipartTokensTest extends TestCase {
+public class MultipartTokensTest {
 
     private static final Charset US_ASCII = CharsetUtil.US_ASCII;
 
     private static final String BODY = "A Preamble\r\n" +
-                "--1729\r\n\r\n" +
-                "Simple plain text\r\n" +
-                "--1729\r\n" +
-                "Content-Type: text/plain; charset=US-ASCII\r\n\r\n" +
-                "Some more text\r\n" +
-                "--1729--\r\n" +
-                "An Epilogue\r\n";
+            "--1729\r\n\r\n" +
+            "Simple plain text\r\n" +
+            "--1729\r\n" +
+            "Content-Type: text/plain; charset=US-ASCII\r\n\r\n" +
+            "Some more text\r\n" +
+            "--1729--\r\n" +
+            "An Epilogue\r\n";
     public static final String MESSAGE = "To: Road Runner <runner@example.org>\r\n" +
             "From: Wile E. Cayote <wile@example.org>\r\n" +
             "Date: Tue, 12 Feb 2008 17:34:09 +0000 (GMT)\r\n" +
@@ -49,63 +51,62 @@ public class MultipartTokensTest extends
             BODY;
 
     public static final String COMPLEX_MESSAGE = "To: Wile E. Cayote <wile@example.org>\r\n" +
-    "From: Road Runner <runner@example.org>\r\n" +
-    "Date: Tue, 19 Feb 2008 17:34:09 +0000 (GMT)\r\n" +
-    "Subject: Mail\r\n" +
-    "Content-Type: multipart/mixed;boundary=42\r\n\r\n" +
-    "A little preamble\r\n" +
-    "--42\r\n" +
-    "Content-Type: text/plain; charset=US-ASCII\r\n\r\n" +
-    "Rhubard!\r\n" +
-    "--42\r\n" +
-    "Content-Type: message/rfc822\r\n\r\n" +
-    MESSAGE +
-    "\r\n" +
-    "--42\r\n" +
-    "\r\n" +
-    "Custard!" +
-    "\r\n" +
-    "--42--\r\n" +
-    "A little epilogue\r\n";
+            "From: Road Runner <runner@example.org>\r\n" +
+            "Date: Tue, 19 Feb 2008 17:34:09 +0000 (GMT)\r\n" +
+            "Subject: Mail\r\n" +
+            "Content-Type: multipart/mixed;boundary=42\r\n\r\n" +
+            "A little preamble\r\n" +
+            "--42\r\n" +
+            "Content-Type: text/plain; charset=US-ASCII\r\n\r\n" +
+            "Rhubard!\r\n" +
+            "--42\r\n" +
+            "Content-Type: message/rfc822\r\n\r\n" +
+            MESSAGE +
+            "\r\n" +
+            "--42\r\n" +
+            "\r\n" +
+            "Custard!" +
+            "\r\n" +
+            "--42--\r\n" +
+            "A little epilogue\r\n";
 
     public static final String COMPLEX_QP_MESSAGE =
-        "Content-Transfer-Encoding: quoted-printable\r\n" +
-        "Content-Type: message/rfc822; charset=us-ascii\r\n" +
-        "\r\n" +
-        "Subject: The subject\r\n" +
-        "Content-Type: multipart/alternative;\r\n" +
-        "        boundary=3D=22----=3DNextPart=22\r\n" +
-        "\r\n" +
-        "This is a multi-part message in MIME format.\r\n" +
-        "\r\n" +
-        "------=3DNextPart\r\n" +
-        "Content-Type: text/plain;\r\n" +
-        "        charset=3D=22iso-8859-1=22\r\n" +
-        "\r\n" +
-        "Some text\r\n" +
-        "\r\n" +
-        "------=3DNextPart\r\n" +
-        "Content-Type: text/html;\r\n" +
-        "        charset=3D=22iso-8859-1=22\r\n" +
-        "\r\n" +
-        "<HTML><BODY>=3D Some HTML =3D</BODY></HTML>\r\n" +
-        "------=3DNextPart--\r\n" +
-        "\r\n" +
-        "\r\n";
+            "Content-Transfer-Encoding: quoted-printable\r\n" +
+                    "Content-Type: message/rfc822; charset=us-ascii\r\n" +
+                    "\r\n" +
+                    "Subject: The subject\r\n" +
+                    "Content-Type: multipart/alternative;\r\n" +
+                    "        boundary=3D=22----=3DNextPart=22\r\n" +
+                    "\r\n" +
+                    "This is a multi-part message in MIME format.\r\n" +
+                    "\r\n" +
+                    "------=3DNextPart\r\n" +
+                    "Content-Type: text/plain;\r\n" +
+                    "        charset=3D=22iso-8859-1=22\r\n" +
+                    "\r\n" +
+                    "Some text\r\n" +
+                    "\r\n" +
+                    "------=3DNextPart\r\n" +
+                    "Content-Type: text/html;\r\n" +
+                    "        charset=3D=22iso-8859-1=22\r\n" +
+                    "\r\n" +
+                    "<HTML><BODY>=3D Some HTML =3D</BODY></HTML>\r\n" +
+                    "------=3DNextPart--\r\n" +
+                    "\r\n" +
+                    "\r\n";
 
     MimeTokenStream parser;
 
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
+    @Before
+    public void setUp() throws Exception {
         parser = new MimeTokenStream();
     }
 
-    @Override
-    protected void tearDown() throws Exception {
-        super.tearDown();
+    @After
+    public void tearDown() throws Exception {
     }
 
+    @Test
     public void testShouldParseSimpleMessage() throws Exception {
         parser.parse(new ByteArrayInputStream(US_ASCII.encode(MESSAGE).array()));
         checkState(EntityState.T_START_HEADER);
@@ -134,21 +135,22 @@ public class MultipartTokensTest extends
         checkState(EntityState.T_END_OF_STREAM);
     }
 
+    @Test
     public void testShouldParseMoreComplexMessage() throws Exception {
         String message =
-            "Content-Type: multipart/alternative; boundary=\"outer-boundary\"\r\n" +
-            "\r\n" +
-            "--outer-boundary\r\n" +
-            "Content-Type: multipart/alternative; boundary=\"inner-boundary\"\r\n" +
-            "\r\n" +
-            "--inner-boundary\r\n" +
-            "Content-Type: text/plain\r\n" +
-            "\r\n" +
-            "Some text\r\n" +
-            "--inner-boundary--\r\n" +
-            "\r\n" +
-            "foo\r\n" +
-            "--outer-boundary--\r\n";
+                "Content-Type: multipart/alternative; boundary=\"outer-boundary\"\r\n" +
+                        "\r\n" +
+                        "--outer-boundary\r\n" +
+                        "Content-Type: multipart/alternative; boundary=\"inner-boundary\"\r\n" +
+                        "\r\n" +
+                        "--inner-boundary\r\n" +
+                        "Content-Type: text/plain\r\n" +
+                        "\r\n" +
+                        "Some text\r\n" +
+                        "--inner-boundary--\r\n" +
+                        "\r\n" +
+                        "foo\r\n" +
+                        "--outer-boundary--\r\n";
 
         parser.parse(new ByteArrayInputStream(US_ASCII.encode(message).array()));
         checkState(EntityState.T_START_HEADER);
@@ -174,63 +176,65 @@ public class MultipartTokensTest extends
         checkState(EntityState.T_END_OF_STREAM);
     }
 
+    @Test
     public void testShouldParseMessageWithEmbeddedMessage() throws Exception {
         parser.parse(new ByteArrayInputStream(US_ASCII.encode(COMPLEX_MESSAGE).array()));
         checkState(EntityState.T_START_HEADER);
-            checkState(EntityState.T_FIELD);
-            checkState(EntityState.T_FIELD);
-            checkState(EntityState.T_FIELD);
-            checkState(EntityState.T_FIELD);
-            checkState(EntityState.T_FIELD);
+        checkState(EntityState.T_FIELD);
+        checkState(EntityState.T_FIELD);
+        checkState(EntityState.T_FIELD);
+        checkState(EntityState.T_FIELD);
+        checkState(EntityState.T_FIELD);
+        checkState(EntityState.T_END_HEADER);
+        checkState(EntityState.T_START_MULTIPART);
+        checkState(EntityState.T_PREAMBLE);
+        checkState(EntityState.T_START_BODYPART);
+        checkState(EntityState.T_START_HEADER);
+        checkState(EntityState.T_FIELD);
+        checkState(EntityState.T_END_HEADER);
+        checkState(EntityState.T_BODY);
+        checkState(EntityState.T_END_BODYPART);
+        checkState(EntityState.T_START_BODYPART);
+        checkState(EntityState.T_START_HEADER);
+        checkState(EntityState.T_FIELD);
+        checkState(EntityState.T_END_HEADER);
+        checkState(EntityState.T_START_MESSAGE);
+        checkState(EntityState.T_START_HEADER);
+        checkState(EntityState.T_FIELD);
+        checkState(EntityState.T_FIELD);
+        checkState(EntityState.T_FIELD);
+        checkState(EntityState.T_FIELD);
+        checkState(EntityState.T_FIELD);
         checkState(EntityState.T_END_HEADER);
         checkState(EntityState.T_START_MULTIPART);
-            checkState(EntityState.T_PREAMBLE);
-            checkState(EntityState.T_START_BODYPART);
-                checkState(EntityState.T_START_HEADER);
-                    checkState(EntityState.T_FIELD);
-                checkState(EntityState.T_END_HEADER);
-                checkState(EntityState.T_BODY);
-            checkState(EntityState.T_END_BODYPART);
-            checkState(EntityState.T_START_BODYPART);
-                checkState(EntityState.T_START_HEADER);
-                    checkState(EntityState.T_FIELD);
-                checkState(EntityState.T_END_HEADER);
-                checkState(EntityState.T_START_MESSAGE);
-                    checkState(EntityState.T_START_HEADER);
-                        checkState(EntityState.T_FIELD);
-                        checkState(EntityState.T_FIELD);
-                        checkState(EntityState.T_FIELD);
-                        checkState(EntityState.T_FIELD);
-                        checkState(EntityState.T_FIELD);
-                    checkState(EntityState.T_END_HEADER);
-                    checkState(EntityState.T_START_MULTIPART);
-                        checkState(EntityState.T_PREAMBLE);
-                        checkState(EntityState.T_START_BODYPART);
-                            checkState(EntityState.T_START_HEADER);
-                            checkState(EntityState.T_END_HEADER);
-                            checkState(EntityState.T_BODY);
-                        checkState(EntityState.T_END_BODYPART);
-                        checkState(EntityState.T_START_BODYPART);
-                            checkState(EntityState.T_START_HEADER);
-                                checkState(EntityState.T_FIELD);
-                            checkState(EntityState.T_END_HEADER);
-                            checkState(EntityState.T_BODY);
-                        checkState(EntityState.T_END_BODYPART);
-                        checkState(EntityState.T_EPILOGUE);
-                    checkState(EntityState.T_END_MULTIPART);
-                checkState(EntityState.T_END_MESSAGE);
-            checkState(EntityState.T_END_BODYPART);
-            checkState(EntityState.T_START_BODYPART);
-                checkState(EntityState.T_START_HEADER);
-                checkState(EntityState.T_END_HEADER);
-                checkState(EntityState.T_BODY);
-            checkState(EntityState.T_END_BODYPART);
-            checkState(EntityState.T_EPILOGUE);
+        checkState(EntityState.T_PREAMBLE);
+        checkState(EntityState.T_START_BODYPART);
+        checkState(EntityState.T_START_HEADER);
+        checkState(EntityState.T_END_HEADER);
+        checkState(EntityState.T_BODY);
+        checkState(EntityState.T_END_BODYPART);
+        checkState(EntityState.T_START_BODYPART);
+        checkState(EntityState.T_START_HEADER);
+        checkState(EntityState.T_FIELD);
+        checkState(EntityState.T_END_HEADER);
+        checkState(EntityState.T_BODY);
+        checkState(EntityState.T_END_BODYPART);
+        checkState(EntityState.T_EPILOGUE);
+        checkState(EntityState.T_END_MULTIPART);
+        checkState(EntityState.T_END_MESSAGE);
+        checkState(EntityState.T_END_BODYPART);
+        checkState(EntityState.T_START_BODYPART);
+        checkState(EntityState.T_START_HEADER);
+        checkState(EntityState.T_END_HEADER);
+        checkState(EntityState.T_BODY);
+        checkState(EntityState.T_END_BODYPART);
+        checkState(EntityState.T_EPILOGUE);
         checkState(EntityState.T_END_MULTIPART);
         checkState(EntityState.T_END_MESSAGE);
         checkState(EntityState.T_END_OF_STREAM);
     }
 
+    @Test
     public void testShouldParseMessagesWithEmbeddedQuotedPrintableEncodedMessage() throws Exception {
         parser.parse(new ByteArrayInputStream(US_ASCII.encode(COMPLEX_QP_MESSAGE).array()));
         checkState(EntityState.T_START_HEADER);
@@ -249,9 +253,9 @@ public class MultipartTokensTest extends
         checkState(EntityState.T_FIELD);
         checkState(EntityState.T_END_HEADER);
         checkState(EntityState.T_BODY);
-        assertEquals("text/plain", parser.getBodyDescriptor().getMimeType());
-        assertEquals("iso-8859-1", parser.getBodyDescriptor().getCharset());
-        assertEquals("Some text\r\n",
+        Assert.assertEquals("text/plain", parser.getBodyDescriptor().getMimeType());
+        Assert.assertEquals("iso-8859-1", parser.getBodyDescriptor().getCharset());
+        Assert.assertEquals("Some text\r\n",
                 IOUtils.toString(parser.getInputStream()));
         checkState(EntityState.T_END_BODYPART);
         checkState(EntityState.T_START_BODYPART);
@@ -259,9 +263,9 @@ public class MultipartTokensTest extends
         checkState(EntityState.T_FIELD);
         checkState(EntityState.T_END_HEADER);
         checkState(EntityState.T_BODY);
-        assertEquals("text/html", parser.getBodyDescriptor().getMimeType());
-        assertEquals("iso-8859-1", parser.getBodyDescriptor().getCharset());
-        assertEquals("<HTML><BODY>= Some HTML =</BODY></HTML>",
+        Assert.assertEquals("text/html", parser.getBodyDescriptor().getMimeType());
+        Assert.assertEquals("iso-8859-1", parser.getBodyDescriptor().getCharset());
+        Assert.assertEquals("<HTML><BODY>= Some HTML =</BODY></HTML>",
                 IOUtils.toString(parser.getInputStream()));
         checkState(EntityState.T_END_BODYPART);
         checkState(EntityState.T_EPILOGUE);
@@ -271,6 +275,7 @@ public class MultipartTokensTest extends
         checkState(EntityState.T_END_OF_STREAM);
     }
 
+    @Test
     public void testMultipartMessageWithoutHeader() throws Exception {
         parser.parseHeadless(new ByteArrayInputStream(US_ASCII.encode(BODY).array()),
                 "multipart/mixed;boundary=1729");
@@ -301,6 +306,6 @@ public class MultipartTokensTest extends
     }
 
     private void checkState(final EntityState state) throws IOException, MimeException {
-        assertEquals(MimeTokenStream.stateToString(state), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(state), MimeTokenStream.stateToString(parser.next()));
     }
 }

Modified: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/RawFieldParserTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/RawFieldParserTest.java?rev=1426193&r1=1426192&r2=1426193&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/RawFieldParserTest.java (original)
+++ james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/RawFieldParserTest.java Thu Dec 27 13:23:54 2012
@@ -19,24 +19,25 @@
 
 package org.apache.james.mime4j.stream;
 
-import java.util.List;
-
+import junit.framework.Assert;
 import org.apache.james.mime4j.MimeException;
 import org.apache.james.mime4j.util.ByteSequence;
 import org.apache.james.mime4j.util.ContentUtil;
+import org.junit.Before;
+import org.junit.Test;
 
-import junit.framework.Assert;
-import junit.framework.TestCase;
+import java.util.List;
 
-public class RawFieldParserTest extends TestCase {
+public class RawFieldParserTest {
 
     private RawFieldParser parser;
 
-    @Override
-    protected void setUp() throws Exception {
+    @Before
+    public void setUp() throws Exception {
         parser = new RawFieldParser();
     }
 
+    @Test
     public void testBasicTokenParsing() throws Exception {
         String s = "   raw: \" some stuff \"";
         ByteSequence raw = ContentUtil.encode(s);
@@ -74,6 +75,7 @@ public class RawFieldParserTest extends 
         Assert.assertTrue(cursor.atEnd());
     }
 
+    @Test
     public void testTokenParsingWithQuotedPairs() throws Exception {
         String s = "raw: \"\\\"some\\stuff\\\\\"";
         ByteSequence raw = ContentUtil.encode(s);
@@ -103,6 +105,7 @@ public class RawFieldParserTest extends 
         Assert.assertEquals("\"some\\stuff\\", strbuf2.toString());
     }
 
+    @Test
     public void testTokenParsingIncompleteQuote() throws Exception {
         String s = "\"stuff and more stuff  ";
         ByteSequence raw = ContentUtil.encode(s);
@@ -112,6 +115,7 @@ public class RawFieldParserTest extends 
         Assert.assertEquals("stuff and more stuff  ", strbuf1.toString());
     }
 
+    @Test
     public void testSkipComments() throws Exception {
         String s = "(some (((maybe))human readable) stuff())";
         ByteSequence raw = ContentUtil.encode(s);
@@ -121,6 +125,7 @@ public class RawFieldParserTest extends 
         Assert.assertTrue(cursor.atEnd());
     }
 
+    @Test
     public void testSkipCommentsWithQuotedPairs() throws Exception {
         String s = "(some (((\\)maybe))human readable\\() stuff())";
         ByteSequence raw = ContentUtil.encode(s);
@@ -130,6 +135,7 @@ public class RawFieldParserTest extends 
         Assert.assertTrue(cursor.atEnd());
     }
 
+    @Test
     public void testTokenParsingTokensWithUnquotedBlanks() throws Exception {
         String s = "  stuff and   \tsome\tmore  stuff  ;";
         ByteSequence raw = ContentUtil.encode(s);
@@ -138,6 +144,7 @@ public class RawFieldParserTest extends 
         Assert.assertEquals("stuff and some more stuff", result);
     }
 
+    @Test
     public void testTokenParsingTokensWithComments() throws Exception {
         String s = " (blah-blah)  stuff(blah-blah) and some mo(blah-blah)re  stuff (blah-blah) ;";
         ByteSequence raw = ContentUtil.encode(s);
@@ -146,6 +153,7 @@ public class RawFieldParserTest extends 
         Assert.assertEquals("stuff and some more stuff", result);
     }
 
+    @Test
     public void testTokenParsingMixedValuesAndQuotedValues() throws Exception {
         String s = "  stuff and    \" some more \"   \"stuff  ;";
         ByteSequence raw = ContentUtil.encode(s);
@@ -154,6 +162,7 @@ public class RawFieldParserTest extends 
         Assert.assertEquals("stuff and  some more  stuff  ;", result);
     }
 
+    @Test
     public void testTokenParsingQuotedValuesWithComments() throws Exception {
         String s = " (blah blah)  \"(stuff)(and)(some)(more)(stuff)\" (yada yada) ";
         ByteSequence raw = ContentUtil.encode(s);
@@ -162,6 +171,7 @@ public class RawFieldParserTest extends 
         Assert.assertEquals("(stuff)(and)(some)(more)(stuff)", result);
     }
 
+    @Test
     public void testBasicParsing() throws Exception {
         String s = "raw: stuff;\r\n  more stuff";
         ByteSequence raw = ContentUtil.encode(s);
@@ -173,6 +183,7 @@ public class RawFieldParserTest extends 
         Assert.assertEquals(s, field.toString());
     }
 
+    @Test
     public void testParsingNoBlankAfterColon() throws Exception {
         String s = "raw:stuff";
         ByteSequence raw = ContentUtil.encode(s);
@@ -184,6 +195,7 @@ public class RawFieldParserTest extends 
         Assert.assertEquals(s, field.toString());
     }
 
+    @Test
     public void testParsingObsoleteSyntax() throws Exception {
         String s = "raw  \t  : stuff;\r\n  more stuff";
         ByteSequence raw = ContentUtil.encode(s);
@@ -195,239 +207,249 @@ public class RawFieldParserTest extends 
         Assert.assertEquals(s, field.toString());
     }
 
+    @Test
     public void testParsingInvalidSyntax1() throws Exception {
         String s = "raw    stuff;\r\n  more stuff";
         ByteSequence raw = ContentUtil.encode(s);
 
         try {
             parser.parseField(raw);
-            fail("MimeException should have been thrown");
+            org.junit.Assert.fail("MimeException should have been thrown");
         } catch (MimeException expected) {
         }
     }
 
+    @Test
     public void testParsingInvalidSyntax2() throws Exception {
         String s = "raw    \t \t";
         ByteSequence raw = ContentUtil.encode(s);
 
         try {
             parser.parseField(raw);
-            fail("MimeException should have been thrown");
+            org.junit.Assert.fail("MimeException should have been thrown");
         } catch (MimeException expected) {
         }
     }
 
+    @Test
     public void testNameValueParseBasics() {
         String s = "test";
         ByteSequence buf = ContentUtil.encode(s);
         ParserCursor cursor = new ParserCursor(0, s.length());
 
         NameValuePair param = parser.parseParameter(buf, cursor);
-        assertEquals("test", param.getName());
-        assertEquals(null, param.getValue());
-        assertEquals(s.length(), cursor.getPos());
-        assertTrue(cursor.atEnd());
+        org.junit.Assert.assertEquals("test", param.getName());
+        org.junit.Assert.assertEquals(null, param.getValue());
+        org.junit.Assert.assertEquals(s.length(), cursor.getPos());
+        org.junit.Assert.assertTrue(cursor.atEnd());
 
         s = "test;";
         buf = ContentUtil.encode(s);
         cursor = new ParserCursor(0, s.length());
 
         param = parser.parseParameter(buf, cursor);
-        assertEquals("test", param.getName());
-        assertEquals(null, param.getValue());
-        assertEquals(s.length(), cursor.getPos());
-        assertTrue(cursor.atEnd());
+        org.junit.Assert.assertEquals("test", param.getName());
+        org.junit.Assert.assertEquals(null, param.getValue());
+        org.junit.Assert.assertEquals(s.length(), cursor.getPos());
+        org.junit.Assert.assertTrue(cursor.atEnd());
 
         s = "test=stuff";
         buf = ContentUtil.encode(s);
         cursor = new ParserCursor(0, s.length());
 
         param = parser.parseParameter(buf, cursor);
-        assertEquals("test", param.getName());
-        assertEquals("stuff", param.getValue());
-        assertEquals(s.length(), cursor.getPos());
-        assertTrue(cursor.atEnd());
+        org.junit.Assert.assertEquals("test", param.getName());
+        org.junit.Assert.assertEquals("stuff", param.getValue());
+        org.junit.Assert.assertEquals(s.length(), cursor.getPos());
+        org.junit.Assert.assertTrue(cursor.atEnd());
 
         s = "   test  =   stuff ";
         buf = ContentUtil.encode(s);
         cursor = new ParserCursor(0, s.length());
 
         param = parser.parseParameter(buf, cursor);
-        assertEquals("test", param.getName());
-        assertEquals("stuff", param.getValue());
-        assertEquals(s.length(), cursor.getPos());
-        assertTrue(cursor.atEnd());
+        org.junit.Assert.assertEquals("test", param.getName());
+        org.junit.Assert.assertEquals("stuff", param.getValue());
+        org.junit.Assert.assertEquals(s.length(), cursor.getPos());
+        org.junit.Assert.assertTrue(cursor.atEnd());
 
         s = "   test  =   stuff ;1234";
         buf = ContentUtil.encode(s);
         cursor = new ParserCursor(0, s.length());
 
         param = parser.parseParameter(buf, cursor);
-        assertEquals("test", param.getName());
-        assertEquals("stuff", param.getValue());
-        assertEquals(s.length() - 4, cursor.getPos());
-        assertFalse(cursor.atEnd());
+        org.junit.Assert.assertEquals("test", param.getName());
+        org.junit.Assert.assertEquals("stuff", param.getValue());
+        org.junit.Assert.assertEquals(s.length() - 4, cursor.getPos());
+        org.junit.Assert.assertFalse(cursor.atEnd());
 
         s = "test  = \"stuff\"";
         buf = ContentUtil.encode(s);
         cursor = new ParserCursor(0, s.length());
 
         param = parser.parseParameter(buf, cursor);
-        assertEquals("test", param.getName());
-        assertEquals("stuff", param.getValue());
+        org.junit.Assert.assertEquals("test", param.getName());
+        org.junit.Assert.assertEquals("stuff", param.getValue());
 
         s = "test  = text(text of some kind)/stuff(stuff of some kind)";
         buf = ContentUtil.encode(s);
         cursor = new ParserCursor(0, s.length());
 
         param = parser.parseParameter(buf, cursor);
-        assertEquals("test", param.getName());
-        assertEquals("text/stuff", param.getValue());
+        org.junit.Assert.assertEquals("test", param.getName());
+        org.junit.Assert.assertEquals("text/stuff", param.getValue());
 
         s = "test  = \"  stuff\\\"\"";
         buf = ContentUtil.encode(s);
         cursor = new ParserCursor(0, s.length());
 
         param = parser.parseParameter(buf, cursor);
-        assertEquals("test", param.getName());
-        assertEquals("  stuff\"", param.getValue());
+        org.junit.Assert.assertEquals("test", param.getName());
+        org.junit.Assert.assertEquals("  stuff\"", param.getValue());
 
         s = "test  = \"  stuff\\\\\\\"\"";
         buf = ContentUtil.encode(s);
         cursor = new ParserCursor(0, s.length());
 
         param = parser.parseParameter(buf, cursor);
-        assertEquals("test", param.getName());
-        assertEquals("  stuff\\\"", param.getValue());
+        org.junit.Assert.assertEquals("test", param.getName());
+        org.junit.Assert.assertEquals("  stuff\\\"", param.getValue());
 
         s = "  test";
         buf = ContentUtil.encode(s);
         cursor = new ParserCursor(0, s.length());
 
         param = parser.parseParameter(buf, cursor);
-        assertEquals("test", param.getName());
-        assertEquals(null, param.getValue());
+        org.junit.Assert.assertEquals("test", param.getName());
+        org.junit.Assert.assertEquals(null, param.getValue());
 
         s = "  ";
         buf = ContentUtil.encode(s);
         cursor = new ParserCursor(0, s.length());
 
         param = parser.parseParameter(buf, cursor);
-        assertEquals("", param.getName());
-        assertEquals(null, param.getValue());
+        org.junit.Assert.assertEquals("", param.getName());
+        org.junit.Assert.assertEquals(null, param.getValue());
 
         s = " = stuff ";
         buf = ContentUtil.encode(s);
         cursor = new ParserCursor(0, s.length());
 
         param = parser.parseParameter(buf, cursor);
-        assertEquals("", param.getName());
-        assertEquals("stuff", param.getValue());
+        org.junit.Assert.assertEquals("", param.getName());
+        org.junit.Assert.assertEquals("stuff", param.getValue());
     }
 
+    @Test
     public void testNameValueListParseBasics() {
         ByteSequence buf = ContentUtil.encode(
                 "test; test1 =  stuff   ; test2 =  \"stuff; stuff\"; test3=\"stuff");
         ParserCursor cursor = new ParserCursor(0, buf.length());
         List<NameValuePair> params = parser.parseParameters(buf, cursor);
 
-        assertEquals("test", params.get(0).getName());
-        assertEquals(null, params.get(0).getValue());
-        assertEquals("test1", params.get(1).getName());
-        assertEquals("stuff", params.get(1).getValue());
-        assertEquals("test2", params.get(2).getName());
-        assertEquals("stuff; stuff", params.get(2).getValue());
-        assertEquals("test3", params.get(3).getName());
-        assertEquals("stuff", params.get(3).getValue());
-        assertEquals(buf.length(), cursor.getPos());
-        assertTrue(cursor.atEnd());
+        org.junit.Assert.assertEquals("test", params.get(0).getName());
+        org.junit.Assert.assertEquals(null, params.get(0).getValue());
+        org.junit.Assert.assertEquals("test1", params.get(1).getName());
+        org.junit.Assert.assertEquals("stuff", params.get(1).getValue());
+        org.junit.Assert.assertEquals("test2", params.get(2).getName());
+        org.junit.Assert.assertEquals("stuff; stuff", params.get(2).getValue());
+        org.junit.Assert.assertEquals("test3", params.get(3).getName());
+        org.junit.Assert.assertEquals("stuff", params.get(3).getValue());
+        org.junit.Assert.assertEquals(buf.length(), cursor.getPos());
+        org.junit.Assert.assertTrue(cursor.atEnd());
     }
 
+    @Test
     public void testNameValueListParseEmpty() {
         ByteSequence buf = ContentUtil.encode("    ");
         ParserCursor cursor = new ParserCursor(0, buf.length());
         List<NameValuePair> params = parser.parseParameters(buf, cursor);
-        assertEquals(0, params.size());
+        org.junit.Assert.assertEquals(0, params.size());
     }
 
+    @Test
     public void testNameValueListParseEscaped() {
         ByteSequence buf = ContentUtil.encode(
-          "test1 =  \"\\\"stuff\\\"\"; test2= \"\\\\\"; test3 = \"stuff; stuff\"");
+                "test1 =  \"\\\"stuff\\\"\"; test2= \"\\\\\"; test3 = \"stuff; stuff\"");
         ParserCursor cursor = new ParserCursor(0, buf.length());
         List<NameValuePair> params = parser.parseParameters(buf, cursor);
-        assertEquals(3, params.size());
-        assertEquals("test1", params.get(0).getName());
-        assertEquals("\"stuff\"", params.get(0).getValue());
-        assertEquals("test2", params.get(1).getName());
-        assertEquals("\\", params.get(1).getValue());
-        assertEquals("test3", params.get(2).getName());
-        assertEquals("stuff; stuff", params.get(2).getValue());
+        org.junit.Assert.assertEquals(3, params.size());
+        org.junit.Assert.assertEquals("test1", params.get(0).getName());
+        org.junit.Assert.assertEquals("\"stuff\"", params.get(0).getValue());
+        org.junit.Assert.assertEquals("test2", params.get(1).getName());
+        org.junit.Assert.assertEquals("\\", params.get(1).getValue());
+        org.junit.Assert.assertEquals("test3", params.get(2).getName());
+        org.junit.Assert.assertEquals("stuff; stuff", params.get(2).getValue());
     }
 
+    @Test
     public void testRawBodyParse() {
         ByteSequence buf = ContentUtil.encode(
                 "  text/plain ; charset=ISO-8859-1; "
-                + "boundary=foo; param1=value1; param2=\"value2\"; param3=value3");
+                        + "boundary=foo; param1=value1; param2=\"value2\"; param3=value3");
         ParserCursor cursor = new ParserCursor(0, buf.length());
         RawBody body = parser.parseRawBody(buf, cursor);
-        assertNotNull(body);
-        assertEquals("text/plain", body.getValue());
+        org.junit.Assert.assertNotNull(body);
+        org.junit.Assert.assertEquals("text/plain", body.getValue());
         List<NameValuePair> params = body.getParams();
-        assertEquals(5, params.size());
-        assertEquals("charset", params.get(0).getName());
-        assertEquals("ISO-8859-1", params.get(0).getValue());
-        assertEquals("boundary", params.get(1).getName());
-        assertEquals("foo", params.get(1).getValue());
-        assertEquals("param1", params.get(2).getName());
-        assertEquals("value1", params.get(2).getValue());
-        assertEquals("param2", params.get(3).getName());
-        assertEquals("value2", params.get(3).getValue());
-        assertEquals("param3", params.get(4).getName());
-        assertEquals("value3", params.get(4).getValue());
+        org.junit.Assert.assertEquals(5, params.size());
+        org.junit.Assert.assertEquals("charset", params.get(0).getName());
+        org.junit.Assert.assertEquals("ISO-8859-1", params.get(0).getValue());
+        org.junit.Assert.assertEquals("boundary", params.get(1).getName());
+        org.junit.Assert.assertEquals("foo", params.get(1).getValue());
+        org.junit.Assert.assertEquals("param1", params.get(2).getName());
+        org.junit.Assert.assertEquals("value1", params.get(2).getValue());
+        org.junit.Assert.assertEquals("param2", params.get(3).getName());
+        org.junit.Assert.assertEquals("value2", params.get(3).getValue());
+        org.junit.Assert.assertEquals("param3", params.get(4).getName());
+        org.junit.Assert.assertEquals("value3", params.get(4).getValue());
     }
 
+    @Test
     public void testRawBodyParseWithComments() {
         ByteSequence buf = ContentUtil.encode(
                 "  text/(nothing special)plain ; charset=(latin)ISO-8859-1; "
-                + "boundary=foo(bar);");
+                        + "boundary=foo(bar);");
         ParserCursor cursor = new ParserCursor(0, buf.length());
         RawBody body = parser.parseRawBody(buf, cursor);
-        assertNotNull(body);
-        assertEquals("text/plain", body.getValue());
+        org.junit.Assert.assertNotNull(body);
+        org.junit.Assert.assertEquals("text/plain", body.getValue());
         List<NameValuePair> params = body.getParams();
-        assertEquals(2, params.size());
-        assertEquals("charset", params.get(0).getName());
-        assertEquals("ISO-8859-1", params.get(0).getValue());
-        assertEquals("boundary", params.get(1).getName());
-        assertEquals("foo", params.get(1).getValue());
+        org.junit.Assert.assertEquals(2, params.size());
+        org.junit.Assert.assertEquals("charset", params.get(0).getName());
+        org.junit.Assert.assertEquals("ISO-8859-1", params.get(0).getValue());
+        org.junit.Assert.assertEquals("boundary", params.get(1).getName());
+        org.junit.Assert.assertEquals("foo", params.get(1).getValue());
     }
 
+    @Test
     public void testRawBodyParseEmptyParam() {
         ByteSequence buf = ContentUtil.encode(
                 "multipart/alternative;; boundary=\"boundary\"");
         ParserCursor cursor = new ParserCursor(0, buf.length());
         RawBody body = parser.parseRawBody(buf, cursor);
-        assertNotNull(body);
-        assertEquals("multipart/alternative", body.getValue());
+        org.junit.Assert.assertNotNull(body);
+        org.junit.Assert.assertEquals("multipart/alternative", body.getValue());
         List<NameValuePair> params = body.getParams();
-        assertEquals(2, params.size());
-        assertEquals("", params.get(0).getName());
-        assertEquals(null, params.get(0).getValue());
-        assertEquals("boundary", params.get(1).getName());
-        assertEquals("boundary", params.get(1).getValue());
+        org.junit.Assert.assertEquals(2, params.size());
+        org.junit.Assert.assertEquals("", params.get(0).getName());
+        org.junit.Assert.assertEquals(null, params.get(0).getValue());
+        org.junit.Assert.assertEquals("boundary", params.get(1).getName());
+        org.junit.Assert.assertEquals("boundary", params.get(1).getValue());
     }
 
+    @Test
     public void testRawBodyParseFolded() {
         ByteSequence buf = ContentUtil.encode(
                 "multipart/alternative; boundary=\"simple\r\n boundary\"");
         ParserCursor cursor = new ParserCursor(0, buf.length());
         RawBody body = parser.parseRawBody(buf, cursor);
-        assertNotNull(body);
-        assertEquals("multipart/alternative", body.getValue());
+        org.junit.Assert.assertNotNull(body);
+        org.junit.Assert.assertEquals("multipart/alternative", body.getValue());
         List<NameValuePair> params = body.getParams();
-        assertEquals(1, params.size());
-        assertEquals("boundary", params.get(0).getName());
-        assertEquals("simple boundary", params.get(0).getValue());
+        org.junit.Assert.assertEquals(1, params.size());
+        org.junit.Assert.assertEquals("boundary", params.get(0).getName());
+        org.junit.Assert.assertEquals("simple boundary", params.get(0).getValue());
     }
 
 }

Modified: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/RawFieldTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/RawFieldTest.java?rev=1426193&r1=1426192&r2=1426193&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/RawFieldTest.java (original)
+++ james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/RawFieldTest.java Thu Dec 27 13:23:54 2012
@@ -19,14 +19,14 @@
 
 package org.apache.james.mime4j.stream;
 
+import junit.framework.Assert;
 import org.apache.james.mime4j.util.ByteSequence;
 import org.apache.james.mime4j.util.ContentUtil;
+import org.junit.Test;
 
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-public class RawFieldTest extends TestCase {
+public class RawFieldTest {
 
+    @Test
     public void testPrivateConstructor() throws Exception {
         String s = "raw: stuff;\r\n  more stuff";
         ByteSequence raw = ContentUtil.encode(s);
@@ -37,6 +37,7 @@ public class RawFieldTest extends TestCa
         Assert.assertEquals(s, field.toString());
     }
 
+    @Test
     public void testPublicConstructor() throws Exception {
         RawField field1 = new RawField("raw", "stuff");
         Assert.assertNull(field1.getRaw());
@@ -51,6 +52,7 @@ public class RawFieldTest extends TestCa
         Assert.assertEquals("raw: ", field2.toString());
     }
 
+    @Test
     public void testTabAfterDelimiter() throws Exception {
         String s = "raw:\tstuff;\r\n  more stuff";
         ByteSequence raw = ContentUtil.encode(s);
@@ -60,5 +62,5 @@ public class RawFieldTest extends TestCa
         Assert.assertEquals("stuff;  more stuff", field.getBody());
         Assert.assertEquals(s, field.toString());
     }
-    
+
 }

Modified: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/StrictMimeTokenStreamTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/StrictMimeTokenStreamTest.java?rev=1426193&r1=1426192&r2=1426193&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/StrictMimeTokenStreamTest.java (original)
+++ james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/StrictMimeTokenStreamTest.java Thu Dec 27 13:23:54 2012
@@ -19,33 +19,30 @@
 
 package org.apache.james.mime4j.stream;
 
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-
 import org.apache.james.mime4j.MimeIOException;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
 
-import junit.framework.TestCase;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
 
-public class StrictMimeTokenStreamTest extends TestCase {
+public class StrictMimeTokenStreamTest {
 
     private static final String HEADER_ONLY = "From: foo@abr.com\r\nSubject: A subject\r\n";
     private static final String CORRECT_HEADERS = HEADER_ONLY + "\r\n";
 
     MimeTokenStream parser;
 
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
+    @Before
+    public void setUp() throws Exception {
         MimeConfig config = new MimeConfig();
         config.setStrictParsing(true);
         parser = new MimeTokenStream(config);
     }
 
-    @Override
-    protected void tearDown() throws Exception {
-        super.tearDown();
-    }
-
+    @Test
     public void testUnexpectedEndOfHeaders() throws Exception {
         parser.parse(new ByteArrayInputStream(HEADER_ONLY.getBytes("US-ASCII")));
 
@@ -53,12 +50,13 @@ public class StrictMimeTokenStreamTest e
         checkNextIs(EntityState.T_FIELD);
         try {
             parser.next();
-            fail("Expected exception to be thrown");
+            Assert.fail("Expected exception to be thrown");
         } catch (MimeParseEventException e) {
-            assertEquals("Premature end of headers", Event.HEADERS_PREMATURE_END, e.getEvent());
+            Assert.assertEquals("Premature end of headers", Event.HEADERS_PREMATURE_END, e.getEvent());
         }
-     }
+    }
 
+    @Test
     public void testCorrectEndOfHeaders() throws Exception {
         parser.parse(new ByteArrayInputStream(CORRECT_HEADERS.getBytes("US-ASCII")));
 
@@ -66,14 +64,15 @@ public class StrictMimeTokenStreamTest e
         checkNextIs(EntityState.T_FIELD);
         checkNextIs(EntityState.T_FIELD);
         checkNextIs(EntityState.T_END_HEADER);
-     }
+    }
 
+    @Test
     public void testMissingBoundary() throws Exception {
         String message =
-            "Content-Type: multipart/mixed;boundary=aaaa\r\n\r\n" +
-            "--aaaa\r\n" +
-            "Content-Type:text/plain; charset=US-ASCII\r\n\r\n" +
-            "Oh my god! Boundary is missing!\r\n";
+                "Content-Type: multipart/mixed;boundary=aaaa\r\n\r\n" +
+                        "--aaaa\r\n" +
+                        "Content-Type:text/plain; charset=US-ASCII\r\n\r\n" +
+                        "Oh my god! Boundary is missing!\r\n";
         parser.parse(new ByteArrayInputStream(message.getBytes("US-ASCII")));
         checkNextIs(EntityState.T_START_HEADER);
         checkNextIs(EntityState.T_FIELD);
@@ -92,13 +91,13 @@ public class StrictMimeTokenStreamTest e
             while ((l = in.read(tmp)) != -1) {
                 sb.append(new String(tmp, 0, l, "US-ASCII"));
             }
-            fail("MimeIOException should have been thrown");
+            Assert.fail("MimeIOException should have been thrown");
         } catch (MimeIOException expected) {
-            assertEquals("Oh my god! Boundary is missing!\r\n", sb.toString());
+            Assert.assertEquals("Oh my god! Boundary is missing!\r\n", sb.toString());
         }
-     }
+    }
 
     private void checkNextIs(EntityState expected) throws Exception {
-        assertEquals(MimeTokenStream.stateToString(expected), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(expected), MimeTokenStream.stateToString(parser.next()));
     }
 }

Copied: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/util/ByteArrayBufferTest.java (from r1426178, james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/util/TestByteArrayBuffer.java)
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/util/ByteArrayBufferTest.java?p2=james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/util/ByteArrayBufferTest.java&p1=james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/util/TestByteArrayBuffer.java&r1=1426178&r2=1426193&rev=1426193&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/util/TestByteArrayBuffer.java (original)
+++ james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/util/ByteArrayBufferTest.java Thu Dec 27 13:23:54 2012
@@ -19,210 +19,215 @@
 
 package org.apache.james.mime4j.util;
 
-import org.apache.james.mime4j.util.ByteArrayBuffer;
+import org.junit.Assert;
+import org.junit.Test;
 
-import junit.framework.TestCase;
-
-/**
- * Unit tests for {@link ByteArrayBuffer}.
- */
-public class TestByteArrayBuffer extends TestCase {
+public class ByteArrayBufferTest {
 
+    @Test
     public void testConstructor() throws Exception {
         ByteArrayBuffer buffer = new ByteArrayBuffer(16);
-        assertEquals(16, buffer.capacity());
-        assertEquals(0, buffer.length());
-        assertNotNull(buffer.buffer());
-        assertEquals(16, buffer.buffer().length);
+        Assert.assertEquals(16, buffer.capacity());
+        Assert.assertEquals(0, buffer.length());
+        Assert.assertNotNull(buffer.buffer());
+        Assert.assertEquals(16, buffer.buffer().length);
         try {
             new ByteArrayBuffer(-1);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
     }
 
+    @Test
     public void testSimpleAppend() throws Exception {
         ByteArrayBuffer buffer = new ByteArrayBuffer(16);
-        assertEquals(16, buffer.capacity());
-        assertEquals(0, buffer.length());
+        Assert.assertEquals(16, buffer.capacity());
+        Assert.assertEquals(0, buffer.length());
         byte[] b1 = buffer.toByteArray();
-        assertNotNull(b1);
-        assertEquals(0, b1.length);
-        assertTrue(buffer.isEmpty());
-        assertFalse(buffer.isFull());
+        Assert.assertNotNull(b1);
+        Assert.assertEquals(0, b1.length);
+        Assert.assertTrue(buffer.isEmpty());
+        Assert.assertFalse(buffer.isFull());
 
-        byte[] tmp = new byte[] { 1, 2, 3, 4};
+        byte[] tmp = new byte[]{1, 2, 3, 4};
         buffer.append(tmp, 0, tmp.length);
-        assertEquals(16, buffer.capacity());
-        assertEquals(4, buffer.length());
-        assertFalse(buffer.isEmpty());
-        assertFalse(buffer.isFull());
+        Assert.assertEquals(16, buffer.capacity());
+        Assert.assertEquals(4, buffer.length());
+        Assert.assertFalse(buffer.isEmpty());
+        Assert.assertFalse(buffer.isFull());
 
         byte[] b2 = buffer.toByteArray();
-        assertNotNull(b2);
-        assertEquals(4, b2.length);
+        Assert.assertNotNull(b2);
+        Assert.assertEquals(4, b2.length);
         for (int i = 0; i < tmp.length; i++) {
-            assertEquals(tmp[i], b2[i]);
-            assertEquals(tmp[i], buffer.byteAt(i));
+            Assert.assertEquals(tmp[i], b2[i]);
+            Assert.assertEquals(tmp[i], buffer.byteAt(i));
         }
         buffer.clear();
-        assertEquals(16, buffer.capacity());
-        assertEquals(0, buffer.length());
-        assertTrue(buffer.isEmpty());
-        assertFalse(buffer.isFull());
+        Assert.assertEquals(16, buffer.capacity());
+        Assert.assertEquals(0, buffer.length());
+        Assert.assertTrue(buffer.isEmpty());
+        Assert.assertFalse(buffer.isFull());
     }
 
+    @Test
     public void testExpandAppend() throws Exception {
         ByteArrayBuffer buffer = new ByteArrayBuffer(4);
-        assertEquals(4, buffer.capacity());
+        Assert.assertEquals(4, buffer.capacity());
 
-        byte[] tmp = new byte[] { 1, 2, 3, 4};
+        byte[] tmp = new byte[]{1, 2, 3, 4};
         buffer.append(tmp, 0, 2);
         buffer.append(tmp, 0, 4);
         buffer.append(tmp, 0, 0);
 
-        assertEquals(8, buffer.capacity());
-        assertEquals(6, buffer.length());
+        Assert.assertEquals(8, buffer.capacity());
+        Assert.assertEquals(6, buffer.length());
 
         buffer.append(tmp, 0, 4);
 
-        assertEquals(16, buffer.capacity());
-        assertEquals(10, buffer.length());
+        Assert.assertEquals(16, buffer.capacity());
+        Assert.assertEquals(10, buffer.length());
     }
 
+    @Test
     public void testInvalidAppend() throws Exception {
         ByteArrayBuffer buffer = new ByteArrayBuffer(4);
-        buffer.append((byte[])null, 0, 0);
+        buffer.append((byte[]) null, 0, 0);
 
-        byte[] tmp = new byte[] { 1, 2, 3, 4};
+        byte[] tmp = new byte[]{1, 2, 3, 4};
         try {
             buffer.append(tmp, -1, 0);
-            fail("IndexOutOfBoundsException should have been thrown");
+            Assert.fail("IndexOutOfBoundsException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
         try {
             buffer.append(tmp, 0, -1);
-            fail("IndexOutOfBoundsException should have been thrown");
+            Assert.fail("IndexOutOfBoundsException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
         try {
             buffer.append(tmp, 0, 8);
-            fail("IndexOutOfBoundsException should have been thrown");
+            Assert.fail("IndexOutOfBoundsException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
         try {
             buffer.append(tmp, 10, Integer.MAX_VALUE);
-            fail("IndexOutOfBoundsException should have been thrown");
+            Assert.fail("IndexOutOfBoundsException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
         try {
             buffer.append(tmp, 2, 4);
-            fail("IndexOutOfBoundsException should have been thrown");
+            Assert.fail("IndexOutOfBoundsException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
     }
 
+    @Test
     public void testAppendOneByte() throws Exception {
         ByteArrayBuffer buffer = new ByteArrayBuffer(4);
-        assertEquals(4, buffer.capacity());
+        Assert.assertEquals(4, buffer.capacity());
 
-        byte[] tmp = new byte[] { 1, 127, -1, -128, 1, -2};
+        byte[] tmp = new byte[]{1, 127, -1, -128, 1, -2};
         for (byte b : tmp) {
             buffer.append(b);
         }
-        assertEquals(8, buffer.capacity());
-        assertEquals(6, buffer.length());
+        Assert.assertEquals(8, buffer.capacity());
+        Assert.assertEquals(6, buffer.length());
 
         for (int i = 0; i < tmp.length; i++) {
-            assertEquals(tmp[i], buffer.byteAt(i));
+            Assert.assertEquals(tmp[i], buffer.byteAt(i));
         }
     }
 
+    @Test
     public void testSetLength() throws Exception {
         ByteArrayBuffer buffer = new ByteArrayBuffer(4);
         buffer.setLength(2);
-        assertEquals(2, buffer.length());
+        Assert.assertEquals(2, buffer.length());
     }
 
+    @Test
     public void testSetInvalidLength() throws Exception {
         ByteArrayBuffer buffer = new ByteArrayBuffer(4);
         try {
             buffer.setLength(-2);
-            fail("IndexOutOfBoundsException should have been thrown");
+            Assert.fail("IndexOutOfBoundsException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
         try {
             buffer.setLength(200);
-            fail("IndexOutOfBoundsException should have been thrown");
+            Assert.fail("IndexOutOfBoundsException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
     }
 
+    @Test
     public void testRemove() throws Exception {
         ByteArrayBuffer b = new ByteArrayBuffer(16);
         byte tmp[] = "--+++-".getBytes("US-ASCII");
         b.append(tmp, 0, tmp.length);
 
         b.remove(2, 3);
-        assertEquals(3, b.length());
-        assertEquals("---", new String(b.buffer(), 0, b.length(), "US-ASCII"));
+        Assert.assertEquals(3, b.length());
+        Assert.assertEquals("---", new String(b.buffer(), 0, b.length(), "US-ASCII"));
         b.remove(2, 1);
         b.remove(1, 1);
         b.remove(0, 1);
-        assertEquals(0, b.length());
+        Assert.assertEquals(0, b.length());
 
         tmp = "+++---".getBytes("US-ASCII");
         b.append(tmp, 0, tmp.length);
 
         b.remove(0, 3);
-        assertEquals(3, b.length());
-        assertEquals("---", new String(b.buffer(), 0, b.length(), "US-ASCII"));
+        Assert.assertEquals(3, b.length());
+        Assert.assertEquals("---", new String(b.buffer(), 0, b.length(), "US-ASCII"));
         b.remove(0, 3);
-        assertEquals(0, b.length());
+        Assert.assertEquals(0, b.length());
 
         tmp = "---+++".getBytes("US-ASCII");
         b.append(tmp, 0, tmp.length);
 
         b.remove(3, 3);
-        assertEquals(3, b.length());
-        assertEquals("---", new String(b.buffer(), 0, b.length(), "US-ASCII"));
+        Assert.assertEquals(3, b.length());
+        Assert.assertEquals("---", new String(b.buffer(), 0, b.length(), "US-ASCII"));
         b.remove(0, 3);
 
-        assertEquals(0, b.length());
+        Assert.assertEquals(0, b.length());
     }
 
+    @Test
     public void testInvalidRemove() throws Exception {
         ByteArrayBuffer buffer = new ByteArrayBuffer(16);
         buffer.setLength(8);
         try {
             buffer.remove(-1, 0);
-            fail("IndexOutOfBoundsException should have been thrown");
+            Assert.fail("IndexOutOfBoundsException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
         try {
             buffer.remove(0, -1);
-            fail("IndexOutOfBoundsException should have been thrown");
+            Assert.fail("IndexOutOfBoundsException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
         try {
             buffer.remove(0, 9);
-            fail("IndexOutOfBoundsException should have been thrown");
+            Assert.fail("IndexOutOfBoundsException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
         try {
             buffer.remove(10, 2);
-            fail("IndexOutOfBoundsException should have been thrown");
+            Assert.fail("IndexOutOfBoundsException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }

Modified: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/util/CharsetUtilTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/util/CharsetUtilTest.java?rev=1426193&r1=1426192&r2=1426193&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/util/CharsetUtilTest.java (original)
+++ james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/util/CharsetUtilTest.java Thu Dec 27 13:23:54 2012
@@ -19,40 +19,46 @@
 
 package org.apache.james.mime4j.util;
 
-import java.nio.charset.Charset;
+import org.junit.Assert;
+import org.junit.Test;
 
-import junit.framework.TestCase;
+import java.nio.charset.Charset;
 
-public class CharsetUtilTest extends TestCase {
+public class CharsetUtilTest {
 
     private static final String SWISS_GERMAN_HELLO = "Gr\374ezi_z\344m\344";
     private static final String RUSSIAN_HELLO = "\u0412\u0441\u0435\u043C_\u043F\u0440\u0438\u0432\u0435\u0442";
 
+    @Test
     public void testAllASCII() {
         String s = "Like hello and stuff";
-        assertTrue(CharsetUtil.isASCII(s));
+        Assert.assertTrue(CharsetUtil.isASCII(s));
     }
 
+    @Test
     public void testNonASCII() {
-        assertFalse(CharsetUtil.isASCII(SWISS_GERMAN_HELLO));
-        assertFalse(CharsetUtil.isASCII(RUSSIAN_HELLO));
+        Assert.assertFalse(CharsetUtil.isASCII(SWISS_GERMAN_HELLO));
+        Assert.assertFalse(CharsetUtil.isASCII(RUSSIAN_HELLO));
     }
 
+    @Test
     public void testCharsetLookup() {
         Charset c1 = CharsetUtil.lookup("us-ascii");
         Charset c2 = CharsetUtil.lookup("ascii");
-        assertEquals(CharsetUtil.US_ASCII, c1);
-        assertEquals(CharsetUtil.US_ASCII, c2);
+        Assert.assertEquals(CharsetUtil.US_ASCII, c1);
+        Assert.assertEquals(CharsetUtil.US_ASCII, c2);
     }
 
+    @Test
     public void testCharsetLookupNullInput() {
         Charset c1 = CharsetUtil.lookup(null);
-        assertNull(c1);
+        Assert.assertNull(c1);
     }
 
+    @Test
     public void testCharsetLookupFailure() {
         Charset c1 = CharsetUtil.lookup("whatever");
-        assertNull(c1);
+        Assert.assertNull(c1);
     }
 
 }

Modified: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/util/MimeUtilTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/util/MimeUtilTest.java?rev=1426193&r1=1426192&r2=1426193&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/util/MimeUtilTest.java (original)
+++ james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/util/MimeUtilTest.java Thu Dec 27 13:23:54 2012
@@ -19,18 +19,21 @@
 
 package org.apache.james.mime4j.util;
 
-import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.Test;
 
-public class MimeUtilTest extends TestCase {
+public class MimeUtilTest {
 
+    @Test
     public void testFold() throws Exception {
-        assertEquals("this is\r\n a test", MimeUtil.fold("this is a test", 68));
-        assertEquals("this is\r\n a test", MimeUtil.fold("this is a test", 69));
-        assertEquals("this\r\n is a test", MimeUtil.fold("this is a test", 70));
-        assertEquals("this  \r\n   is a test", MimeUtil.fold(
+        Assert.assertEquals("this is\r\n a test", MimeUtil.fold("this is a test", 68));
+        Assert.assertEquals("this is\r\n a test", MimeUtil.fold("this is a test", 69));
+        Assert.assertEquals("this\r\n is a test", MimeUtil.fold("this is a test", 70));
+        Assert.assertEquals("this  \r\n   is a test", MimeUtil.fold(
                 "this     is a test", 70));
     }
 
+    @Test
     public void testFoldOverlyLongNonWhitespace() throws Exception {
         String ninety = "1234567890123456789012345678901234567890"
                 + "12345678901234567890123456789012345678901234567890";
@@ -40,30 +43,31 @@ public class MimeUtilTest extends TestCa
         String expected = String.format(
                 "testing 1 2\r\n %s\r\n testing\r\n %s", ninety, ninety);
 
-        assertEquals(expected, MimeUtil.fold(input, 0));
+        Assert.assertEquals(expected, MimeUtil.fold(input, 0));
     }
 
+    @Test
     public void testUnfold() throws Exception {
-        assertEquals("", MimeUtil.unfold(""));
-        assertEquals("x", MimeUtil.unfold("x"));
-        assertEquals(" x ", MimeUtil.unfold(" x "));
-
-        assertEquals("", MimeUtil.unfold("\r"));
-        assertEquals("", MimeUtil.unfold("\n"));
-        assertEquals("", MimeUtil.unfold("\r\n"));
-
-        assertEquals(" ", MimeUtil.unfold(" \n"));
-        assertEquals(" ", MimeUtil.unfold("\n "));
-        assertEquals(" ", MimeUtil.unfold(" \r\n"));
-        assertEquals(" ", MimeUtil.unfold("\r\n "));
-
-        assertEquals("this is a test", MimeUtil.unfold("this is\r\n a test"));
-        assertEquals("this is a test", MimeUtil.unfold("this is\r\n a test"));
-        assertEquals("this is a test", MimeUtil.unfold("this\r\n is a test"));
-        assertEquals("this     is a test", MimeUtil
+        Assert.assertEquals("", MimeUtil.unfold(""));
+        Assert.assertEquals("x", MimeUtil.unfold("x"));
+        Assert.assertEquals(" x ", MimeUtil.unfold(" x "));
+
+        Assert.assertEquals("", MimeUtil.unfold("\r"));
+        Assert.assertEquals("", MimeUtil.unfold("\n"));
+        Assert.assertEquals("", MimeUtil.unfold("\r\n"));
+
+        Assert.assertEquals(" ", MimeUtil.unfold(" \n"));
+        Assert.assertEquals(" ", MimeUtil.unfold("\n "));
+        Assert.assertEquals(" ", MimeUtil.unfold(" \r\n"));
+        Assert.assertEquals(" ", MimeUtil.unfold("\r\n "));
+
+        Assert.assertEquals("this is a test", MimeUtil.unfold("this is\r\n a test"));
+        Assert.assertEquals("this is a test", MimeUtil.unfold("this is\r\n a test"));
+        Assert.assertEquals("this is a test", MimeUtil.unfold("this\r\n is a test"));
+        Assert.assertEquals("this     is a test", MimeUtil
                 .unfold("this  \r\n   is a test"));
 
-        assertEquals("this is a test", MimeUtil
+        Assert.assertEquals("this is a test", MimeUtil
                 .unfold("this\r\n is\r\n a\r\n test"));
     }
 

Modified: james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/ExampleMessagesRoundtripTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/ExampleMessagesRoundtripTest.java?rev=1426193&r1=1426192&r2=1426193&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/ExampleMessagesRoundtripTest.java (original)
+++ james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/ExampleMessagesRoundtripTest.java Thu Dec 27 13:23:54 2012
@@ -19,6 +19,14 @@
 
 package org.apache.james.mime4j.dom;
 
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import org.apache.james.mime4j.codec.CodecUtil;
+import org.apache.james.mime4j.message.DefaultMessageBuilder;
+import org.apache.james.mime4j.message.DefaultMessageWriter;
+import org.apache.james.mime4j.stream.MimeConfig;
+
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileNotFoundException;
@@ -32,16 +40,6 @@ import java.util.Enumeration;
 import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
 
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.apache.james.mime4j.codec.CodecUtil;
-import org.apache.james.mime4j.dom.Message;
-import org.apache.james.mime4j.message.DefaultMessageBuilder;
-import org.apache.james.mime4j.message.DefaultMessageWriter;
-import org.apache.james.mime4j.stream.MimeConfig;
-
 /**
  * Creates a TestSuite running the test for each .msg file in the test resouce folder.
  * Allow running of a single test from Unit testing GUIs
@@ -76,7 +74,7 @@ public class ExampleMessagesRoundtripTes
             CodecUtil.copy(msgout.openStream(), expectedstream);
             assertEquals("Wrong Expected result", new String(expectedstream.toByteArray()), new String(out.toByteArray()));
         } catch (FileNotFoundException e) {
-            FileOutputStream fos = new FileOutputStream(msgout.getPath()+".expected");
+            FileOutputStream fos = new FileOutputStream(msgout.getPath() + ".expected");
             writer.writeMessage(inputMessage, fos);
             fos.close();
             fail("Expected file created");

Modified: james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/HeaderTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/HeaderTest.java?rev=1426193&r1=1426192&r2=1426193&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/HeaderTest.java (original)
+++ james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/HeaderTest.java Thu Dec 27 13:23:54 2012
@@ -19,47 +19,48 @@
 
 package org.apache.james.mime4j.dom;
 
-import junit.framework.TestCase;
-
 import org.apache.commons.io.output.ByteArrayOutputStream;
-import org.apache.james.mime4j.dom.Header;
 import org.apache.james.mime4j.field.DefaultFieldParser;
-import org.apache.james.mime4j.message.HeaderImpl;
 import org.apache.james.mime4j.message.DefaultMessageWriter;
+import org.apache.james.mime4j.message.HeaderImpl;
 import org.apache.james.mime4j.stream.Field;
 import org.apache.james.mime4j.util.ByteArrayBuffer;
 import org.apache.james.mime4j.util.ContentUtil;
+import org.junit.Assert;
+import org.junit.Test;
 
-public class HeaderTest extends TestCase {
+public class HeaderTest {
 
     public static final String SUBJECT = "Subject: test";
 
     public static final String TO = "To: anyuser <any@user>";
 
+    @Test
     public void testHeader() throws Exception {
         Header header = new HeaderImpl();
         header.addField(DefaultFieldParser.parse(SUBJECT));
         header.addField(DefaultFieldParser.parse(TO));
 
-        assertNotNull("Subject found", header.getField("Subject"));
-        assertNotNull("To found", header.getField("To"));
+        Assert.assertNotNull("Subject found", header.getField("Subject"));
+        Assert.assertNotNull("To found", header.getField("To"));
 
-        assertEquals("Headers equals", SUBJECT + "\r\n" + TO + "\r\n", header
+        Assert.assertEquals("Headers equals", SUBJECT + "\r\n" + TO + "\r\n", header
                 .toString());
     }
 
     private static final String SWISS_GERMAN_HELLO = "Gr\374ezi_z\344m\344";
 
+    @Test
     public void testWriteSpecialCharacters() throws Exception {
         String hello = SWISS_GERMAN_HELLO;
         Header header = new HeaderImpl();
         header.addField(DefaultFieldParser.parse("Hello: " + hello));
 
         Field field = header.getField("Hello");
-        assertNotNull(field);
+        Assert.assertNotNull(field);
         // field.getBody is already a 7 bit ASCII string, after MIME4J-151
         // assertEquals(hello, field.getBody());
-        assertEquals(SWISS_GERMAN_HELLO, field.getBody());
+        Assert.assertEquals(SWISS_GERMAN_HELLO, field.getBody());
 
         ByteArrayOutputStream outstream = new ByteArrayOutputStream();
 
@@ -70,41 +71,44 @@ public class HeaderTest extends TestCase
         buf.append(b, 0, b.length);
         String s = ContentUtil.decode(buf);
 
-        assertEquals("Hello: " + SWISS_GERMAN_HELLO + "\r\n\r\n", s);
+        Assert.assertEquals("Hello: " + SWISS_GERMAN_HELLO + "\r\n\r\n", s);
     }
 
+    @Test
     public void testRemoveFields() throws Exception {
         Header header = new HeaderImpl();
         header.addField(DefaultFieldParser.parse("Received: from foo by bar for james"));
         header.addField(DefaultFieldParser.parse("Content-type: text/plain; charset=US-ASCII"));
         header.addField(DefaultFieldParser.parse("ReCeIvEd: from bar by foo for james"));
 
-        assertEquals(3, header.getFields().size());
-        assertEquals(2, header.getFields("received").size());
-        assertEquals(1, header.getFields("Content-Type").size());
+        Assert.assertEquals(3, header.getFields().size());
+        Assert.assertEquals(2, header.getFields("received").size());
+        Assert.assertEquals(1, header.getFields("Content-Type").size());
 
-        assertEquals(2, header.removeFields("rEcEiVeD"));
+        Assert.assertEquals(2, header.removeFields("rEcEiVeD"));
 
-        assertEquals(1, header.getFields().size());
-        assertEquals(0, header.getFields("received").size());
-        assertEquals(1, header.getFields("Content-Type").size());
+        Assert.assertEquals(1, header.getFields().size());
+        Assert.assertEquals(0, header.getFields("received").size());
+        Assert.assertEquals(1, header.getFields("Content-Type").size());
 
-        assertEquals("Content-type", header.getFields().get(0).getName());
+        Assert.assertEquals("Content-type", header.getFields().get(0).getName());
     }
 
+    @Test
     public void testRemoveNonExistantField() throws Exception {
         Header header = new HeaderImpl();
         header.addField(DefaultFieldParser.parse("Received: from foo by bar for james"));
         header.addField(DefaultFieldParser.parse("Content-type: text/plain; charset=US-ASCII"));
         header.addField(DefaultFieldParser.parse("ReCeIvEd: from bar by foo for james"));
 
-        assertEquals(0, header.removeFields("noSuchField"));
+        Assert.assertEquals(0, header.removeFields("noSuchField"));
 
-        assertEquals(3, header.getFields().size());
-        assertEquals(2, header.getFields("received").size());
-        assertEquals(1, header.getFields("Content-Type").size());
+        Assert.assertEquals(3, header.getFields().size());
+        Assert.assertEquals(2, header.getFields("received").size());
+        Assert.assertEquals(1, header.getFields("Content-Type").size());
     }
 
+    @Test
     public void testSetField() throws Exception {
         Header header = new HeaderImpl();
         header.addField(DefaultFieldParser.parse("From: mime4j@james.apache.org"));
@@ -114,14 +118,15 @@ public class HeaderTest extends TestCase
 
         header.setField(DefaultFieldParser.parse("received: from nobody by noone for james"));
 
-        assertEquals(3, header.getFields().size());
-        assertEquals(1, header.getFields("received").size());
+        Assert.assertEquals(3, header.getFields().size());
+        Assert.assertEquals(1, header.getFields("received").size());
 
-        assertEquals("From", header.getFields().get(0).getName());
-        assertEquals("received", header.getFields().get(1).getName());
-        assertEquals("Content-type", header.getFields().get(2).getName());
+        Assert.assertEquals("From", header.getFields().get(0).getName());
+        Assert.assertEquals("received", header.getFields().get(1).getName());
+        Assert.assertEquals("Content-type", header.getFields().get(2).getName());
     }
 
+    @Test
     public void testSetNonExistantField() throws Exception {
         Header header = new HeaderImpl();
         header.addField(DefaultFieldParser.parse("Received: from foo by bar for james"));
@@ -130,10 +135,10 @@ public class HeaderTest extends TestCase
 
         header.setField(DefaultFieldParser.parse("Message-ID: <msg9901@apache.org>"));
 
-        assertEquals(4, header.getFields().size());
-        assertEquals(1, header.getFields("message-id").size());
+        Assert.assertEquals(4, header.getFields().size());
+        Assert.assertEquals(1, header.getFields("message-id").size());
 
-        assertEquals("Message-ID", header.getFields().get(3).getName());
+        Assert.assertEquals("Message-ID", header.getFields().get(3).getName());
     }
 
 }

Modified: james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageCompleteMailTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageCompleteMailTest.java?rev=1426193&r1=1426192&r2=1426193&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageCompleteMailTest.java (original)
+++ james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageCompleteMailTest.java Thu Dec 27 13:23:54 2012
@@ -19,38 +19,29 @@
 
 package org.apache.james.mime4j.dom;
 
-import java.io.ByteArrayInputStream;
-
-import junit.framework.TestCase;
-
 import org.apache.james.mime4j.ExampleMail;
-import org.apache.james.mime4j.dom.Multipart;
 import org.apache.james.mime4j.message.DefaultMessageBuilder;
+import org.junit.Assert;
+import org.junit.Test;
 
-public class MessageCompleteMailTest extends TestCase {
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-    }
+import java.io.ByteArrayInputStream;
 
-    @Override
-    protected void tearDown() throws Exception {
-        super.tearDown();
-    }
+public class MessageCompleteMailTest {
 
+    @Test
     public void testMultipartAlternative() throws Exception {
         Message message = createMessage(ExampleMail.MIME_MULTIPART_ALTERNATIVE_BYTES);
-        assertTrue("Should be a multipart/alternative mail", message.isMultipart());
-        Multipart part = (Multipart)message.getBody();
-        assertEquals("alternative", part.getSubType());
+        Assert.assertTrue("Should be a multipart/alternative mail", message.isMultipart());
+        Multipart part = (Multipart) message.getBody();
+        Assert.assertEquals("alternative", part.getSubType());
     }
 
+    @Test
     public void testMultipartMixed() throws Exception {
         Message message = createMessage(ExampleMail.MIME_MIXED_MULTIPART_VARIOUS_ENCODINGS_BYTES);
-        assertTrue("Should be a multipart/mixed mail", message.isMultipart());
-        Multipart part = (Multipart)message.getBody();
-        assertEquals("mixed", part.getSubType());
+        Assert.assertTrue("Should be a multipart/mixed mail", message.isMultipart());
+        Multipart part = (Multipart) message.getBody();
+        Assert.assertEquals("mixed", part.getSubType());
     }
 
     private Message createMessage(byte[] octets) throws Exception {

Modified: james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageHeadlessParserTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageHeadlessParserTest.java?rev=1426193&r1=1426192&r2=1426193&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageHeadlessParserTest.java (original)
+++ james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageHeadlessParserTest.java Thu Dec 27 13:23:54 2012
@@ -19,21 +19,19 @@
 
 package org.apache.james.mime4j.dom;
 
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-
-import junit.framework.TestCase;
-
-import org.apache.james.mime4j.dom.Multipart;
-import org.apache.james.mime4j.dom.TextBody;
 import org.apache.james.mime4j.dom.field.ContentTypeField;
 import org.apache.james.mime4j.dom.field.FieldName;
 import org.apache.james.mime4j.message.DefaultMessageBuilder;
 import org.apache.james.mime4j.stream.MimeConfig;
+import org.junit.Assert;
+import org.junit.Test;
 
-public class MessageHeadlessParserTest extends TestCase {
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
 
+public class MessageHeadlessParserTest {
 
+    @Test
     public void testMalformedHeaderShouldEndHeader() throws Exception {
         String headlessContent = "Subject: my subject\r\n"
                 + "Hi, how are you?\r\n"
@@ -48,13 +46,14 @@ public class MessageHeadlessParserTest e
         builder.setMimeEntityConfig(config);
         Message message = builder.parseMessage(
                 new ByteArrayInputStream(headlessContent.getBytes("UTF-8")));
-        assertEquals("text/plain", message.getMimeType());
-        assertEquals(1, message.getHeader().getFields().size());
+        Assert.assertEquals("text/plain", message.getMimeType());
+        Assert.assertEquals(1, message.getHeader().getFields().size());
         BufferedReader reader = new BufferedReader(((TextBody) message.getBody()).getReader());
         String firstLine = reader.readLine();
-        assertEquals("Hi, how are you?", firstLine);
+        Assert.assertEquals("Hi, how are you?", firstLine);
     }
 
+    @Test
     public void testSimpleNonMimeTextHeadless() throws Exception {
         String headlessContent = "Hi, how are you?\r\n"
                 + "This is a simple message with no headers. While mime messages should start with\r\n"
@@ -68,13 +67,14 @@ public class MessageHeadlessParserTest e
         builder.setMimeEntityConfig(config);
         Message message = builder.parseMessage(
                 new ByteArrayInputStream(headlessContent.getBytes("UTF-8")));
-        assertEquals("text/plain", message.getMimeType());
-        assertEquals(0, message.getHeader().getFields().size());
+        Assert.assertEquals("text/plain", message.getMimeType());
+        Assert.assertEquals(0, message.getHeader().getFields().size());
         BufferedReader reader = new BufferedReader(((TextBody) message.getBody()).getReader());
         String firstLine = reader.readLine();
-        assertEquals("Hi, how are you?", firstLine);
+        Assert.assertEquals("Hi, how are you?", firstLine);
     }
 
+    @Test
     public void testMultipartFormContent() throws Exception {
         String contentType = "multipart/form-data; boundary=foo";
         String headlessContent = "\r\n"
@@ -98,12 +98,12 @@ public class MessageHeadlessParserTest e
 
         Message message = builder.parseMessage(
                 new ByteArrayInputStream(headlessContent.getBytes("UTF-8")));
-        assertEquals("multipart/form-data", message.getMimeType());
-        assertEquals(1, message.getHeader().getFields().size());
+        Assert.assertEquals("multipart/form-data", message.getMimeType());
+        Assert.assertEquals(1, message.getHeader().getFields().size());
         ContentTypeField contentTypeField = ((ContentTypeField) message
                 .getHeader().getField(FieldName.CONTENT_TYPE));
-        assertEquals("foo", contentTypeField.getBoundary());
+        Assert.assertEquals("foo", contentTypeField.getBoundary());
         Multipart multipart = (Multipart) message.getBody();
-        assertEquals(3, multipart.getCount());
+        Assert.assertEquals(3, multipart.getCount());
     }
 }

Modified: james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageParserTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageParserTest.java?rev=1426193&r1=1426192&r2=1426193&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageParserTest.java (original)
+++ james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageParserTest.java Thu Dec 27 13:23:54 2012
@@ -19,6 +19,16 @@
 
 package org.apache.james.mime4j.dom;
 
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import org.apache.commons.io.IOUtils;
+import org.apache.james.mime4j.field.FieldsTest;
+import org.apache.james.mime4j.message.DefaultMessageBuilder;
+import org.apache.james.mime4j.message.MessageImpl;
+import org.apache.james.mime4j.stream.Field;
+import org.apache.james.mime4j.stream.MimeConfig;
+
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
@@ -33,22 +43,6 @@ import java.util.List;
 import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
 
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.james.mime4j.dom.BinaryBody;
-import org.apache.james.mime4j.dom.Body;
-import org.apache.james.mime4j.dom.Entity;
-import org.apache.james.mime4j.dom.Multipart;
-import org.apache.james.mime4j.dom.TextBody;
-import org.apache.james.mime4j.field.FieldsTest;
-import org.apache.james.mime4j.message.MessageImpl;
-import org.apache.james.mime4j.message.DefaultMessageBuilder;
-import org.apache.james.mime4j.stream.Field;
-import org.apache.james.mime4j.stream.MimeConfig;
-
 public class MessageParserTest extends TestCase {
 
     private URL url;
@@ -121,7 +115,7 @@ public class MessageParserTest extends T
             String expected = IOUtils.toString(xmlFileUrl.openStream(), "ISO8859-1");
             assertEquals(expected, result);
         } catch (FileNotFoundException ex) {
-            IOUtils.write(result, new FileOutputStream(xmlFileUrl.getPath()+".expected"), "ISO8859-1");
+            IOUtils.write(result, new FileOutputStream(xmlFileUrl.getPath() + ".expected"), "ISO8859-1");
             fail("Expected file created.");
         }
     }
@@ -154,7 +148,7 @@ public class MessageParserTest extends T
         if (e.getBody() instanceof Multipart) {
             sb.append("<multipart>\r\n");
 
-            Multipart multipart =(Multipart) e.getBody();
+            Multipart multipart = (Multipart) e.getBody();
             List<Entity> parts = multipart.getBodyParts();
 
             if (multipart.getPreamble() != null) {
@@ -181,7 +175,7 @@ public class MessageParserTest extends T
         } else {
             Body b = e.getBody();
             String s = prefix + "_decoded_" + id
-                            + (b instanceof TextBody ? ".txt" : ".bin");
+                    + (b instanceof TextBody ? ".txt" : ".bin");
             String tag = b instanceof TextBody ? "text-body" : "binary-body";
             File f = new File(s);
             sb.append("<" + tag + " name=\"" + f.getName() + "\"/>\r\n");
@@ -198,15 +192,15 @@ public class MessageParserTest extends T
                     String s1 = IOUtils.toString(expectedUrl.openStream(), charset);
                     assertEquals(f.getName(), s1, s2);
                 } catch (FileNotFoundException ex) {
-                    IOUtils.write(s2, new FileOutputStream(expectedUrl.getPath()+".expected"));
+                    IOUtils.write(s2, new FileOutputStream(expectedUrl.getPath() + ".expected"));
                     fail("Expected file created.");
                 }
             } else {
                 try {
                     assertEqualsBinary(f.getName(), expectedUrl.openStream(),
-                        ((BinaryBody) b).getInputStream());
+                            ((BinaryBody) b).getInputStream());
                 } catch (FileNotFoundException ex) {
-                    IOUtils.copy(((BinaryBody) b).getInputStream(), new FileOutputStream(expectedUrl.getPath()+".expected"));
+                    IOUtils.copy(((BinaryBody) b).getInputStream(), new FileOutputStream(expectedUrl.getPath() + ".expected"));
                     fail("Expected file created.");
                 }
             }

Modified: james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageServiceFactoryTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageServiceFactoryTest.java?rev=1426193&r1=1426192&r2=1426193&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageServiceFactoryTest.java (original)
+++ james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageServiceFactoryTest.java Thu Dec 27 13:23:54 2012
@@ -19,23 +19,25 @@
 package org.apache.james.mime4j.dom;
 
 import org.apache.james.mime4j.MimeException;
+import org.junit.Assert;
+import org.junit.Test;
 
-import junit.framework.TestCase;
-
-public class MessageServiceFactoryTest extends TestCase {
+public class MessageServiceFactoryTest {
 
+    @Test
     public void testNewInstance() throws MimeException {
         MessageServiceFactory factory = MessageServiceFactory.newInstance();
-        assertNotNull(factory);
+        Assert.assertNotNull(factory);
     }
 
 
+    @Test
     public void testNewMessageBuilder() throws MimeException {
         MessageServiceFactory factory = MessageServiceFactory.newInstance();
-        assertNotNull(factory);
+        Assert.assertNotNull(factory);
         MessageBuilder builder = factory.newMessageBuilder();
         Message message = builder.newMessage();
-        assertNotNull(message);
+        Assert.assertNotNull(message);
     }
 
 }



Mime
View raw message