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 [3/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/io/MimeBoundaryInputStreamTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/MimeBoundaryInputStreamTest.java?rev=1426193&r1=1426192&r2=1426193&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/MimeBoundaryInputStreamTest.java (original)
+++ james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/MimeBoundaryInputStreamTest.java Thu Dec 27 13:23:54 2012
@@ -19,21 +19,18 @@
 
 package org.apache.james.mime4j.io;
 
+import org.apache.james.mime4j.util.ByteArrayBuffer;
+import org.junit.Assert;
+import org.junit.Test;
+
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 
-import org.apache.james.mime4j.io.BufferedLineReaderInputStream;
-import org.apache.james.mime4j.io.LineReaderInputStream;
-import org.apache.james.mime4j.io.MimeBoundaryInputStream;
-import org.apache.james.mime4j.util.ByteArrayBuffer;
-
-
-import junit.framework.TestCase;
-
-public class MimeBoundaryInputStreamTest extends TestCase {
+public class MimeBoundaryInputStreamTest {
 
+    @Test
     public void testBasicReading() throws IOException {
         String text = "Line 1\r\nLine 2\r\n--boundary\r\n" +
                 "Line 3\r\nLine 4\r\n--boundary--";
@@ -43,16 +40,17 @@ public class MimeBoundaryInputStreamTest
         BufferedLineReaderInputStream buffer = new BufferedLineReaderInputStream(bis, 4096);
 
         MimeBoundaryInputStream mime1 = new MimeBoundaryInputStream(buffer, "boundary");
-        assertEquals("Line 1\r\nLine 2", read(mime1, 5));
+        Assert.assertEquals("Line 1\r\nLine 2", read(mime1, 5));
 
-        assertFalse(mime1.isLastPart());
+        Assert.assertFalse(mime1.isLastPart());
 
         MimeBoundaryInputStream mime2 = new MimeBoundaryInputStream(buffer, "boundary");
-        assertEquals("Line 3\r\nLine 4", read(mime2, 5));
+        Assert.assertEquals("Line 3\r\nLine 4", read(mime2, 5));
 
-        assertTrue(mime2.isLastPart());
+        Assert.assertTrue(mime2.isLastPart());
     }
 
+    @Test
     public void testLenientLineDelimiterReading() throws IOException {
         String text = "Line 1\r\nLine 2\n--boundary\n" +
                 "Line 3\r\nLine 4\n--boundary--\n";
@@ -62,16 +60,17 @@ public class MimeBoundaryInputStreamTest
         BufferedLineReaderInputStream buffer = new BufferedLineReaderInputStream(bis, 4096);
 
         MimeBoundaryInputStream mime1 = new MimeBoundaryInputStream(buffer, "boundary");
-        assertEquals("Line 1\r\nLine 2", read(mime1, 5));
+        Assert.assertEquals("Line 1\r\nLine 2", read(mime1, 5));
 
-        assertFalse(mime1.isLastPart());
+        Assert.assertFalse(mime1.isLastPart());
 
         MimeBoundaryInputStream mime2 = new MimeBoundaryInputStream(buffer, "boundary");
-        assertEquals("Line 3\r\nLine 4", read(mime2, 5));
+        Assert.assertEquals("Line 3\r\nLine 4", read(mime2, 5));
 
-        assertTrue(mime2.isLastPart());
+        Assert.assertTrue(mime2.isLastPart());
     }
 
+    @Test
     public void testBasicReadingSmallBuffer1() throws IOException {
         String text = "yadayadayadayadayadayadayadayadayadayadayadayadayadayadayadayada\r\n--boundary\r\n" +
                 "blahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblah\r\n--boundary--";
@@ -81,18 +80,19 @@ public class MimeBoundaryInputStreamTest
         BufferedLineReaderInputStream buffer = new BufferedLineReaderInputStream(bis, 20);
 
         MimeBoundaryInputStream mime1 = new MimeBoundaryInputStream(buffer, "boundary");
-        assertEquals("yadayadayadayadayadayadayadayadayadayadayadayadayadayadayadayada",
+        Assert.assertEquals("yadayadayadayadayadayadayadayadayadayadayadayadayadayadayadayada",
                 read(mime1, 10));
 
-        assertFalse(mime1.isLastPart());
+        Assert.assertFalse(mime1.isLastPart());
 
         MimeBoundaryInputStream mime2 = new MimeBoundaryInputStream(buffer, "boundary");
-        assertEquals("blahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblah",
+        Assert.assertEquals("blahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblah",
                 read(mime2, 10));
 
-        assertTrue(mime2.isLastPart());
+        Assert.assertTrue(mime2.isLastPart());
     }
 
+    @Test
     public void testBasicReadingSmallBuffer2() throws IOException {
         String text = "yadayadayadayadayadayadayadayadayadayadayadayadayadayadayadayada\r\n--boundary\r\n" +
                 "blahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblah\r\n--boundary--";
@@ -103,18 +103,19 @@ public class MimeBoundaryInputStreamTest
 
         MimeBoundaryInputStream mime1 = new MimeBoundaryInputStream(buffer, "boundary");
 
-        assertEquals("yadayadayadayadayadayadayadayadayadayadayadayadayadayadayadayada",
+        Assert.assertEquals("yadayadayadayadayadayadayadayadayadayadayadayadayadayadayadayada",
                 read(mime1, 25));
 
-        assertFalse(mime1.isLastPart());
+        Assert.assertFalse(mime1.isLastPart());
 
         MimeBoundaryInputStream mime2 = new MimeBoundaryInputStream(buffer, "boundary");
-        assertEquals("blahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblah",
+        Assert.assertEquals("blahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblah",
                 read(mime2, 25));
 
-        assertTrue(mime2.isLastPart());
+        Assert.assertTrue(mime2.isLastPart());
     }
 
+    @Test
     public void testBasicReadingByOneByte() throws IOException {
         String text = "Line 1\r\nLine 2\r\n--boundary\r\n" +
                 "Line 3\r\nLine 4\r\n--boundary--";
@@ -124,20 +125,21 @@ public class MimeBoundaryInputStreamTest
         BufferedLineReaderInputStream buffer = new BufferedLineReaderInputStream(bis, 4096);
 
         MimeBoundaryInputStream mime1 = new MimeBoundaryInputStream(buffer, "boundary");
-        assertEquals("Line 1\r\nLine 2", readByOneByte(mime1));
+        Assert.assertEquals("Line 1\r\nLine 2", readByOneByte(mime1));
 
-        assertFalse(mime1.isLastPart());
+        Assert.assertFalse(mime1.isLastPart());
 
         MimeBoundaryInputStream mime2 = new MimeBoundaryInputStream(buffer, "boundary");
-        assertEquals("Line 3\r\nLine 4", readByOneByte(mime2));
+        Assert.assertEquals("Line 3\r\nLine 4", readByOneByte(mime2));
 
-        assertTrue(mime2.isLastPart());
+        Assert.assertTrue(mime2.isLastPart());
     }
 
     /**
      * Tests that a CRLF immediately preceding a boundary isn't included in
      * the stream.
      */
+    @Test
     public void testCRLFPrecedingBoundary() throws IOException {
         String text = "Line 1\r\nLine 2\r\n--boundary\r\n" +
                 "Line 3\r\nLine 4\r\n\r\n--boundary\r\n";
@@ -147,14 +149,14 @@ public class MimeBoundaryInputStreamTest
         BufferedLineReaderInputStream buffer = new BufferedLineReaderInputStream(bis, 4096);
 
         MimeBoundaryInputStream mime1 = new MimeBoundaryInputStream(buffer, "boundary");
-        assertEquals("Line 1\r\nLine 2", read(mime1, 5));
+        Assert.assertEquals("Line 1\r\nLine 2", read(mime1, 5));
 
-        assertFalse(mime1.isLastPart());
+        Assert.assertFalse(mime1.isLastPart());
 
         MimeBoundaryInputStream mime2 = new MimeBoundaryInputStream(buffer, "boundary");
-        assertEquals("Line 3\r\nLine 4\r\n", read(mime2, 5));
+        Assert.assertEquals("Line 3\r\nLine 4\r\n", read(mime2, 5));
 
-        assertFalse(mime2.isLastPart());
+        Assert.assertFalse(mime2.isLastPart());
     }
 
     private String readByOneByte(InputStream is) throws IOException {
@@ -181,6 +183,7 @@ public class MimeBoundaryInputStreamTest
     /**
      * Tests that a stream containing only a boundary is empty.
      */
+    @Test
     public void testImmediateBoundary() throws IOException {
         String text = "--boundary\r\n";
 
@@ -188,53 +191,56 @@ public class MimeBoundaryInputStreamTest
         BufferedLineReaderInputStream buffer = new BufferedLineReaderInputStream(bis, 4096);
 
         MimeBoundaryInputStream stream =
-            new MimeBoundaryInputStream(buffer, "boundary");
-        assertEquals(-1, stream.read());
+                new MimeBoundaryInputStream(buffer, "boundary");
+        Assert.assertEquals(-1, stream.read());
 
         text = "\r\n--boundary\r\n";
 
         bis = new ByteArrayInputStream(text.getBytes());
         buffer = new BufferedLineReaderInputStream(bis, 4096);
         stream =
-            new MimeBoundaryInputStream(buffer, "boundary");
-        assertEquals(-1, stream.read());
+                new MimeBoundaryInputStream(buffer, "boundary");
+        Assert.assertEquals(-1, stream.read());
     }
 
     /**
      * Tests that hasMoreParts behave as expected.
      */
+    @Test
     public void testHasMoreParts() throws IOException {
         String text = "--boundary--\r\n";
 
         ByteArrayInputStream bis = new ByteArrayInputStream(text.getBytes());
         BufferedLineReaderInputStream buffer = new BufferedLineReaderInputStream(bis, 4096);
         MimeBoundaryInputStream stream =
-            new MimeBoundaryInputStream(buffer, "boundary");
-        assertEquals(-1, stream.read());
-        assertTrue(stream.isLastPart());
+                new MimeBoundaryInputStream(buffer, "boundary");
+        Assert.assertEquals(-1, stream.read());
+        Assert.assertTrue(stream.isLastPart());
     }
 
     /**
      * Tests that a stream containing only a boundary is empty.
      */
+    @Test
     public void testPrefixIsBoundary() throws IOException {
         String text = "Line 1\r\n\r\n--boundary\r\n";
 
         ByteArrayInputStream bis = new ByteArrayInputStream(text.getBytes());
         BufferedLineReaderInputStream buffer = new BufferedLineReaderInputStream(bis, 4096);
         MimeBoundaryInputStream stream =
-            new MimeBoundaryInputStream(buffer, "boundary");
-        assertEquals("Line 1\r\n", read(stream, 100));
+                new MimeBoundaryInputStream(buffer, "boundary");
+        Assert.assertEquals("Line 1\r\n", read(stream, 100));
 
         text = "--boundary\r\n";
 
         bis = new ByteArrayInputStream(text.getBytes());
         buffer = new BufferedLineReaderInputStream(bis, 4096);
         stream = new MimeBoundaryInputStream(buffer, "boundary");
-        assertEquals(-1, stream.read());
+        Assert.assertEquals(-1, stream.read());
     }
 
 
+    @Test
     public void testBasicReadLine() throws Exception {
 
         String[] teststrs = new String[5];
@@ -268,12 +274,13 @@ public class MimeBoundaryInputStreamTest
             linebuf.clear();
             instream.readLine(linebuf);
             String s = new String(linebuf.toByteArray(), "US-ASCII");
-            assertEquals(teststr, s);
+            Assert.assertEquals(teststr, s);
         }
-        assertEquals(-1, instream.readLine(linebuf));
-        assertEquals(-1, instream.readLine(linebuf));
+        Assert.assertEquals(-1, instream.readLine(linebuf));
+        Assert.assertEquals(-1, instream.readLine(linebuf));
     }
 
+    @Test
     public void testReadEmptyLine() throws Exception {
 
         String teststr = "01234567890123456789\n\n\r\n\r\r\n\n\n\n\n\n--1234\r\n";
@@ -286,45 +293,45 @@ public class MimeBoundaryInputStreamTest
         linebuf.clear();
         instream.readLine(linebuf);
         String s = new String(linebuf.toByteArray(), "US-ASCII");
-        assertEquals("01234567890123456789\n", s);
+        Assert.assertEquals("01234567890123456789\n", s);
 
         linebuf.clear();
         instream.readLine(linebuf);
         s = new String(linebuf.toByteArray(), "US-ASCII");
-        assertEquals("\n", s);
+        Assert.assertEquals("\n", s);
 
         linebuf.clear();
         instream.readLine(linebuf);
         s = new String(linebuf.toByteArray(), "US-ASCII");
-        assertEquals("\r\n", s);
+        Assert.assertEquals("\r\n", s);
 
         linebuf.clear();
         instream.readLine(linebuf);
         s = new String(linebuf.toByteArray(), "US-ASCII");
-        assertEquals("\r\r\n", s);
+        Assert.assertEquals("\r\r\n", s);
 
         linebuf.clear();
         instream.readLine(linebuf);
         s = new String(linebuf.toByteArray(), "US-ASCII");
-        assertEquals("\n", s);
+        Assert.assertEquals("\n", s);
 
         linebuf.clear();
         instream.readLine(linebuf);
         s = new String(linebuf.toByteArray(), "US-ASCII");
-        assertEquals("\n", s);
+        Assert.assertEquals("\n", s);
 
         linebuf.clear();
         instream.readLine(linebuf);
         s = new String(linebuf.toByteArray(), "US-ASCII");
-        assertEquals("\n", s);
+        Assert.assertEquals("\n", s);
 
         linebuf.clear();
         instream.readLine(linebuf);
         s = new String(linebuf.toByteArray(), "US-ASCII");
-        assertEquals("\n", s);
+        Assert.assertEquals("\n", s);
 
-        assertEquals(-1, instream.readLine(linebuf));
-        assertEquals(-1, instream.readLine(linebuf));
+        Assert.assertEquals(-1, instream.readLine(linebuf));
+        Assert.assertEquals(-1, instream.readLine(linebuf));
     }
 
 }

Modified: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/PositionInputStreamTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/PositionInputStreamTest.java?rev=1426193&r1=1426192&r2=1426193&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/PositionInputStreamTest.java (original)
+++ james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/PositionInputStreamTest.java Thu Dec 27 13:23:54 2012
@@ -19,35 +19,37 @@
 
 package org.apache.james.mime4j.io;
 
+import org.junit.Assert;
+import org.junit.Test;
+
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 
-import junit.framework.TestCase;
-
-public class PositionInputStreamTest extends TestCase {
+public class PositionInputStreamTest {
 
+    @Test
     public void testPositionCounting() throws IOException {
-        byte[] data = new byte[] {'0', '1', '2', '3', '4', '5', '6'};
+        byte[] data = new byte[]{'0', '1', '2', '3', '4', '5', '6'};
         ByteArrayInputStream instream = new ByteArrayInputStream(data);
         PositionInputStream countingStream = new PositionInputStream(instream);
-        assertEquals(0, countingStream.getPosition());
-        assertTrue(countingStream.read() != -1);
-        assertEquals(1, countingStream.getPosition());
+        Assert.assertEquals(0, countingStream.getPosition());
+        Assert.assertTrue(countingStream.read() != -1);
+        Assert.assertEquals(1, countingStream.getPosition());
         byte[] tmp = new byte[3];
-        assertEquals(3, countingStream.read(tmp));
-        assertEquals(4, countingStream.getPosition());
-        assertEquals(2, countingStream.skip(2));
-        assertEquals(6, countingStream.getPosition());
-        assertTrue(countingStream.read() != -1);
-        assertEquals(7, countingStream.getPosition());
-        assertTrue(countingStream.read() == -1);
-        assertEquals(7, countingStream.getPosition());
-        assertTrue(countingStream.read() == -1);
-        assertEquals(7, countingStream.getPosition());
-        assertTrue(countingStream.read(tmp) == -1);
-        assertEquals(7, countingStream.getPosition());
-        assertTrue(countingStream.read(tmp) == -1);
-        assertEquals(7, countingStream.getPosition());
+        Assert.assertEquals(3, countingStream.read(tmp));
+        Assert.assertEquals(4, countingStream.getPosition());
+        Assert.assertEquals(2, countingStream.skip(2));
+        Assert.assertEquals(6, countingStream.getPosition());
+        Assert.assertTrue(countingStream.read() != -1);
+        Assert.assertEquals(7, countingStream.getPosition());
+        Assert.assertTrue(countingStream.read() == -1);
+        Assert.assertEquals(7, countingStream.getPosition());
+        Assert.assertTrue(countingStream.read() == -1);
+        Assert.assertEquals(7, countingStream.getPosition());
+        Assert.assertTrue(countingStream.read(tmp) == -1);
+        Assert.assertEquals(7, countingStream.getPosition());
+        Assert.assertTrue(countingStream.read(tmp) == -1);
+        Assert.assertEquals(7, countingStream.getPosition());
     }
 
 }

Modified: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/parser/MimeStreamParserExampleMessagesTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/parser/MimeStreamParserExampleMessagesTest.java?rev=1426193&r1=1426192&r2=1426193&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/parser/MimeStreamParserExampleMessagesTest.java (original)
+++ james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/parser/MimeStreamParserExampleMessagesTest.java Thu Dec 27 13:23:54 2012
@@ -19,6 +19,12 @@
 
 package org.apache.james.mime4j.parser;
 
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import org.apache.commons.io.IOUtils;
+import org.apache.james.mime4j.stream.MimeConfig;
+
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
@@ -32,14 +38,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.commons.io.IOUtils;
-import org.apache.james.mime4j.parser.MimeStreamParser;
-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
@@ -78,7 +76,7 @@ public class MimeStreamParserExampleMess
             String expected = IOUtils.toString(openStream, "ISO8859-1");
             assertEquals(expected, result);
         } catch (FileNotFoundException e) {
-            IOUtils.write(result, new FileOutputStream(xmlFileUrl.getPath()+".expected"));
+            IOUtils.write(result, new FileOutputStream(xmlFileUrl.getPath() + ".expected"));
             fail("Expected file created.");
         }
     }

Modified: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/parser/MimeStreamParserTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/parser/MimeStreamParserTest.java?rev=1426193&r1=1426192&r2=1426193&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/parser/MimeStreamParserTest.java (original)
+++ james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/parser/MimeStreamParserTest.java Thu Dec 27 13:23:54 2012
@@ -19,22 +19,21 @@
 
 package org.apache.james.mime4j.parser;
 
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.LinkedList;
-
-import junit.framework.TestCase;
-
-import org.apache.james.mime4j.parser.AbstractContentHandler;
-import org.apache.james.mime4j.parser.MimeStreamParser;
 import org.apache.james.mime4j.stream.BodyDescriptor;
 import org.apache.james.mime4j.stream.Field;
 import org.apache.james.mime4j.util.ByteSequence;
 import org.apache.james.mime4j.util.ContentUtil;
+import org.junit.Assert;
+import org.junit.Test;
 
-public class MimeStreamParserTest extends TestCase {
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.LinkedList;
 
+public class MimeStreamParserTest {
+
+    @Test
     public void testBoundaryInEpilogue() throws Exception {
         StringBuilder sb = new StringBuilder();
         sb.append("From: foo@bar.com\r\n");
@@ -78,9 +77,10 @@ public class MimeStreamParserTest extend
         });
         parser.parse(bais);
 
-        assertEquals(epilogue.toString(), actual.toString());
+        Assert.assertEquals(epilogue.toString(), actual.toString());
     }
 
+    @Test
     public void testParseOneLineFields() throws Exception {
         StringBuilder sb = new StringBuilder();
         final LinkedList<String> expected = new LinkedList<String>();
@@ -93,15 +93,16 @@ public class MimeStreamParserTest extend
         parser.setContentHandler(new AbstractContentHandler() {
             @Override
             public void field(Field field) {
-                assertEquals(expected.removeFirst(), decode(field.getRaw()));
+                Assert.assertEquals(expected.removeFirst(), decode(field.getRaw()));
             }
         });
 
         parser.parse(new ByteArrayInputStream(sb.toString().getBytes()));
 
-        assertEquals(0, expected.size());
+        Assert.assertEquals(0, expected.size());
     }
 
+    @Test
     public void testCRWithoutLFInHeader() throws Exception {
         /*
          * Test added because \r:s not followed by \n:s in the header would
@@ -110,29 +111,30 @@ public class MimeStreamParserTest extend
         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");
+                + "not\r\n\tfollowed by LF");
         sb.append(expected.getLast() + "\r\n");
 
         MimeStreamParser parser = new MimeStreamParser();
         parser.setContentHandler(new AbstractContentHandler() {
             @Override
             public void field(Field field) {
-                assertEquals(expected.removeFirst(), decode(field.getRaw()));
+                Assert.assertEquals(expected.removeFirst(), decode(field.getRaw()));
             }
         });
 
         parser.parse(new ByteArrayInputStream(sb.toString().getBytes()));
 
-        assertEquals(0, expected.size());
+        Assert.assertEquals(0, expected.size());
     }
 
+    @Test
     public void testParseMultiLineFields() throws Exception {
         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");
+                + "\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() + "\r\n");
         expected.add("Subject: A folded subject\r\n Line 2\r\n\tLine 3");
         sb.append(expected.getLast() + "\r\n");
@@ -141,15 +143,16 @@ public class MimeStreamParserTest extend
         parser.setContentHandler(new AbstractContentHandler() {
             @Override
             public void field(Field field) {
-                assertEquals(expected.removeFirst(), decode(field.getRaw()));
+                Assert.assertEquals(expected.removeFirst(), decode(field.getRaw()));
             }
         });
 
         parser.parse(new ByteArrayInputStream(sb.toString().getBytes()));
 
-        assertEquals(0, expected.size());
+        Assert.assertEquals(0, expected.size());
     }
 
+    @Test
     public void testStop() throws Exception {
         final MimeStreamParser parser = new MimeStreamParser();
         TestHandler handler = new TestHandler() {
@@ -162,32 +165,33 @@ public class MimeStreamParserTest extend
         parser.setContentHandler(handler);
 
         String msg = "Subject: Yada yada\r\n"
-                   + "From: foo@bar.com\r\n"
-                   + "\r\n"
-                   + "Line 1\r\n"
-                   + "Line 2\r\n";
+                + "From: foo@bar.com\r\n"
+                + "\r\n"
+                + "Line 1\r\n"
+                + "Line 2\r\n";
         String expected = "<message>\r\n"
-                        + "<header>\r\n"
-                        + "<field>\r\n"
-                        + "Subject: Yada yada"
-                        + "</field>\r\n"
-                        + "<field>\r\n"
-                        + "From: foo@bar.com"
-                        + "</field>\r\n"
-                        + "</header>\r\n"
-                        + "<body>\r\n"
-                        + "</body>\r\n"
-                        + "</message>\r\n";
+                + "<header>\r\n"
+                + "<field>\r\n"
+                + "Subject: Yada yada"
+                + "</field>\r\n"
+                + "<field>\r\n"
+                + "From: foo@bar.com"
+                + "</field>\r\n"
+                + "</header>\r\n"
+                + "<body>\r\n"
+                + "</body>\r\n"
+                + "</message>\r\n";
 
         parser.parse(new ByteArrayInputStream(msg.getBytes()));
         String result = handler.sb.toString();
 
-        assertEquals(expected, result);
+        Assert.assertEquals(expected, result);
     }
 
     /*
      * Tests that invalid fields are ignored.
      */
+    @Test
     public void testInvalidFields() throws Exception {
         StringBuilder sb = new StringBuilder();
         final LinkedList<String> expected = new LinkedList<String>();
@@ -202,18 +206,19 @@ public class MimeStreamParserTest extend
         parser.setContentHandler(new AbstractContentHandler() {
             @Override
             public void field(Field field) {
-                assertEquals(expected.removeFirst(), decode(field.getRaw()));
+                Assert.assertEquals(expected.removeFirst(), decode(field.getRaw()));
             }
         });
 
         parser.parse(new ByteArrayInputStream(sb.toString().getBytes()));
 
-        assertEquals(0, expected.size());
+        Assert.assertEquals(0, expected.size());
     }
 
     /*
      * Tests that empty streams still generate the expected series of events.
      */
+    @Test
     public void testEmptyStream() throws Exception {
         final LinkedList<String> expected = new LinkedList<String>();
         expected.add("startMessage");
@@ -226,63 +231,64 @@ public class MimeStreamParserTest extend
         parser.setContentHandler(new AbstractContentHandler() {
             @Override
             public void body(BodyDescriptor bd, InputStream is) {
-                assertEquals(expected.removeFirst(), "body");
+                Assert.assertEquals(expected.removeFirst(), "body");
             }
 
             @Override
             public void endMultipart() {
-                fail("endMultipart shouldn't be called for empty stream");
+                Assert.fail("endMultipart shouldn't be called for empty stream");
             }
 
             @Override
             public void endBodyPart() {
-                fail("endBodyPart shouldn't be called for empty stream");
+                Assert.fail("endBodyPart shouldn't be called for empty stream");
             }
 
             @Override
             public void endHeader() {
-                assertEquals(expected.removeFirst(), "endHeader");
+                Assert.assertEquals(expected.removeFirst(), "endHeader");
             }
 
             @Override
             public void endMessage() {
-                assertEquals(expected.removeFirst(), "endMessage");
+                Assert.assertEquals(expected.removeFirst(), "endMessage");
             }
 
             @Override
             public void field(Field field) {
-                fail("field shouldn't be called for empty stream");
+                Assert.fail("field shouldn't be called for empty stream");
             }
 
             @Override
             public void startMultipart(BodyDescriptor bd) {
-                fail("startMultipart shouldn't be called for empty stream");
+                Assert.fail("startMultipart shouldn't be called for empty stream");
             }
 
             @Override
             public void startBodyPart() {
-                fail("startBodyPart shouldn't be called for empty stream");
+                Assert.fail("startBodyPart shouldn't be called for empty stream");
             }
 
             @Override
             public void startHeader() {
-                assertEquals(expected.removeFirst(), "startHeader");
+                Assert.assertEquals(expected.removeFirst(), "startHeader");
             }
 
             @Override
             public void startMessage() {
-                assertEquals(expected.removeFirst(), "startMessage");
+                Assert.assertEquals(expected.removeFirst(), "startMessage");
             }
         });
 
         parser.parse(new ByteArrayInputStream(new byte[0]));
 
-        assertEquals(0, expected.size());
+        Assert.assertEquals(0, expected.size());
     }
 
     /*
      * Tests parsing of empty headers.
      */
+    @Test
     public void testEmpyHeader() throws Exception {
         StringBuilder sb = new StringBuilder();
         sb.append("\r\n");
@@ -294,8 +300,9 @@ public class MimeStreamParserTest extend
         parser.setContentHandler(new AbstractContentHandler() {
             @Override
             public void field(Field field) {
-                fail("No fields should be reported");
+                Assert.fail("No fields should be reported");
             }
+
             @Override
             public void body(BodyDescriptor bd, InputStream is) throws IOException {
                 int b;
@@ -307,12 +314,13 @@ public class MimeStreamParserTest extend
 
         parser.parse(new ByteArrayInputStream(sb.toString().getBytes()));
 
-        assertEquals("The body is right here\r\n", body.toString());
+        Assert.assertEquals("The body is right here\r\n", body.toString());
     }
 
     /*
      * Tests parsing of empty body.
      */
+    @Test
     public void testEmptyBody() throws Exception {
         StringBuilder sb = new StringBuilder();
         final LinkedList<String> expected = new LinkedList<String>();
@@ -325,22 +333,24 @@ public class MimeStreamParserTest extend
         parser.setContentHandler(new AbstractContentHandler() {
             @Override
             public void field(Field field) {
-                assertEquals(expected.removeFirst(), decode(field.getRaw()));
+                Assert.assertEquals(expected.removeFirst(), decode(field.getRaw()));
             }
+
             @Override
             public void body(BodyDescriptor bd, InputStream is) throws IOException {
-                assertEquals(-1, is.read());
+                Assert.assertEquals(-1, is.read());
             }
         });
 
         parser.parse(new ByteArrayInputStream(sb.toString().getBytes()));
 
-        assertEquals(0, expected.size());
+        Assert.assertEquals(0, expected.size());
     }
 
     /*
      * Tests that invalid fields are ignored.
      */
+    @Test
     public void testPrematureEOFAfterFields() throws Exception {
         StringBuilder sb = new StringBuilder();
         final LinkedList<String> expected = new LinkedList<String>();
@@ -353,13 +363,13 @@ public class MimeStreamParserTest extend
         parser.setContentHandler(new AbstractContentHandler() {
             @Override
             public void field(Field field) {
-                assertEquals(expected.removeFirst(), decode(field.getRaw()));
+                Assert.assertEquals(expected.removeFirst(), decode(field.getRaw()));
             }
         });
 
         parser.parse(new ByteArrayInputStream(sb.toString().getBytes()));
 
-        assertEquals(0, expected.size());
+        Assert.assertEquals(0, expected.size());
 
         sb = new StringBuilder();
         expected.clear();
@@ -372,15 +382,16 @@ public class MimeStreamParserTest extend
         parser.setContentHandler(new AbstractContentHandler() {
             @Override
             public void field(Field field) {
-                assertEquals(expected.removeFirst(), decode(field.getRaw()));
+                Assert.assertEquals(expected.removeFirst(), decode(field.getRaw()));
             }
         });
 
         parser.parse(new ByteArrayInputStream(sb.toString().getBytes()));
 
-        assertEquals(0, expected.size());
+        Assert.assertEquals(0, expected.size());
     }
 
+    @Test
     public void testAutomaticContentDecoding() throws Exception {
         MimeStreamParser parser = new MimeStreamParser();
         parser.setContentDecoding(true);
@@ -388,35 +399,35 @@ public class MimeStreamParserTest extend
         parser.setContentHandler(handler);
 
         String msg = "Subject: Yada yada\r\n"
-                   + "From: foo@bar.com\r\n"
-                   + "Content-Type: application/octet-stream\r\n"
-                   + "Content-Transfer-Encoding: base64\r\n"
-                   + "\r\n"
-                   + "V2hvIGF0ZSBteSBjYWtlPwo=";
+                + "From: foo@bar.com\r\n"
+                + "Content-Type: application/octet-stream\r\n"
+                + "Content-Transfer-Encoding: base64\r\n"
+                + "\r\n"
+                + "V2hvIGF0ZSBteSBjYWtlPwo=";
         String expected = "<message>\r\n"
-                        + "<header>\r\n"
-                        + "<field>\r\n"
-                        + "Subject: Yada yada"
-                        + "</field>\r\n"
-                        + "<field>\r\n"
-                        + "From: foo@bar.com"
-                        + "</field>\r\n"
-                        + "<field>\r\n"
-                        + "Content-Type: application/octet-stream"
-                        + "</field>\r\n"
-                        + "<field>\r\n"
-                        + "Content-Transfer-Encoding: base64"
-                        + "</field>\r\n"
-                        + "</header>\r\n"
-                        + "<body>\r\n"
-                        + "Who ate my cake?\n"
-                        + "</body>\r\n"
-                        + "</message>\r\n";
+                + "<header>\r\n"
+                + "<field>\r\n"
+                + "Subject: Yada yada"
+                + "</field>\r\n"
+                + "<field>\r\n"
+                + "From: foo@bar.com"
+                + "</field>\r\n"
+                + "<field>\r\n"
+                + "Content-Type: application/octet-stream"
+                + "</field>\r\n"
+                + "<field>\r\n"
+                + "Content-Transfer-Encoding: base64"
+                + "</field>\r\n"
+                + "</header>\r\n"
+                + "<body>\r\n"
+                + "Who ate my cake?\n"
+                + "</body>\r\n"
+                + "</message>\r\n";
 
         parser.parse(new ByteArrayInputStream(msg.getBytes()));
         String result = handler.sb.toString();
 
-        assertEquals(expected, result);
+        Assert.assertEquals(expected, result);
     }
 
     protected String decode(ByteSequence byteSequence) {

Modified: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeTokenEmbeddedMessageTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeTokenEmbeddedMessageTest.java?rev=1426193&r1=1426192&r2=1426193&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeTokenEmbeddedMessageTest.java (original)
+++ james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeTokenEmbeddedMessageTest.java Thu Dec 27 13:23:54 2012
@@ -19,30 +19,27 @@
 
 package org.apache.james.mime4j.stream;
 
+import org.apache.james.mime4j.ExampleMail;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
 import java.io.ByteArrayInputStream;
 import java.io.InputStream;
 
-import junit.framework.TestCase;
-
-import org.apache.james.mime4j.ExampleMail;
-
-public class MimeTokenEmbeddedMessageTest extends TestCase {
+public class MimeTokenEmbeddedMessageTest {
 
     MimeTokenStream stream;
 
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
+    @Before
+    public void setUp() throws Exception {
         stream = new MimeTokenStream();
         InputStream in = new ByteArrayInputStream(ExampleMail.MIME_MULTIPART_EMBEDDED_MESSAGES_BYTES);
         stream.parse(in);
     }
 
-    @Override
-    protected void tearDown() throws Exception {
-        super.tearDown();
-    }
-
+    @Test
     public void testWhenRecurseShouldVisitInnerMailsAndInnerMultiparts() throws Exception {
         stream.setRecursionMode(RecursionMode.M_RECURSE);
 
@@ -126,6 +123,7 @@ public class MimeTokenEmbeddedMessageTes
     }
 
 
+    @Test
     public void testWhenFlatAtStartShouldIgnoreMultipartStructure() throws Exception {
         stream.setRecursionMode(RecursionMode.M_FLAT);
         nextIs(EntityState.T_START_HEADER);
@@ -143,6 +141,7 @@ public class MimeTokenEmbeddedMessageTes
         nextIs(EntityState.T_END_MESSAGE);
     }
 
+    @Test
     public void testWhenFlatShouldIgnoreInnerMailsAndInnerMultiparts() throws Exception {
         nextIs(EntityState.T_START_HEADER);
         nextIs(EntityState.T_FIELD);
@@ -200,15 +199,15 @@ public class MimeTokenEmbeddedMessageTes
     private void checkInputStream(String expected) throws Exception {
         InputStream inputStream = stream.getInputStream();
         int next = inputStream.read();
-        int i=0;
+        int i = 0;
         while (next != -1) {
-            assertEquals("@" + i, expected.charAt(i++), (char) next);
+            Assert.assertEquals("@" + i, expected.charAt(i++), (char) next);
             next = inputStream.read();
         }
-        assertEquals(expected.length(), i);
+        Assert.assertEquals(expected.length(), i);
     }
 
     private void nextIs(EntityState state) throws Exception {
-        assertEquals(MimeTokenStream.stateToString(state), MimeTokenStream.stateToString(stream.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(state), MimeTokenStream.stateToString(stream.next()));
     }
 }

Modified: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeTokenNoRecurseTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeTokenNoRecurseTest.java?rev=1426193&r1=1426192&r2=1426193&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeTokenNoRecurseTest.java (original)
+++ james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeTokenNoRecurseTest.java Thu Dec 27 13:23:54 2012
@@ -19,27 +19,29 @@
 
 package org.apache.james.mime4j.stream;
 
+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.InputStream;
 
-import junit.framework.TestCase;
-
-import org.apache.james.mime4j.util.CharsetUtil;
-
-public class MimeTokenNoRecurseTest extends TestCase {
+public class MimeTokenNoRecurseTest {
 
     private static final String INNER_MAIL = "From: Timothy Tayler <tim@example.org>\r\n" +
-                "To: Joshua Tetley <joshua@example.org>\r\n" +
-                "Date: Tue, 12 Feb 2008 17:34:09 +0000 (GMT)\r\n" +
-                "Subject: Multipart Without RFC822 Part\r\n" +
-                "Content-Type: multipart/mixed;boundary=42\r\n\r\n" +
-                "--42\r\n" +
-                "Content-Type:text/plain; charset=US-ASCII\r\n\r\n" +
-                "First part of this mail\r\n" +
-                "--42\r\n" +
-                "Content-Type:text/plain; charset=US-ASCII\r\n\r\n" +
-                "Second part of this mail\r\n" +
-                "--42--\r\n";
+            "To: Joshua Tetley <joshua@example.org>\r\n" +
+            "Date: Tue, 12 Feb 2008 17:34:09 +0000 (GMT)\r\n" +
+            "Subject: Multipart Without RFC822 Part\r\n" +
+            "Content-Type: multipart/mixed;boundary=42\r\n\r\n" +
+            "--42\r\n" +
+            "Content-Type:text/plain; charset=US-ASCII\r\n\r\n" +
+            "First part of this mail\r\n" +
+            "--42\r\n" +
+            "Content-Type:text/plain; charset=US-ASCII\r\n\r\n" +
+            "Second part of this mail\r\n" +
+            "--42--\r\n";
 
     private static final String MAIL_WITH_RFC822_PART = "MIME-Version: 1.0\r\n" +
             "From: Timothy Tayler <tim@example.org>\r\n" +
@@ -64,20 +66,19 @@ public class MimeTokenNoRecurseTest exte
 
     MimeTokenStream stream;
 
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
+    @Before
+    public void setUp() throws Exception {
         stream = new MimeTokenStream();
         byte[] bytes = CharsetUtil.US_ASCII.encode(MAIL_WITH_RFC822_PART).array();
         InputStream in = new ByteArrayInputStream(bytes);
         stream.parse(in);
     }
 
-    @Override
-    protected void tearDown() throws Exception {
-        super.tearDown();
+    @After
+    public void tearDown() throws Exception {
     }
 
+    @Test
     public void testWhenRecurseShouldRecurseInnerMail() throws Exception {
         stream.setRecursionMode(RecursionMode.M_RECURSE);
         nextIs(EntityState.T_START_HEADER);
@@ -119,6 +120,7 @@ public class MimeTokenNoRecurseTest exte
     }
 
 
+    @Test
     public void testWhenRecurseShouldTreatInnerMailAsAnyOtherPart() throws Exception {
         stream.setRecursionMode(RecursionMode.M_NO_RECURSE);
         nextIs(EntityState.T_START_HEADER);
@@ -141,6 +143,7 @@ public class MimeTokenNoRecurseTest exte
         nextIs(EntityState.T_END_MULTIPART);
     }
 
+    @Test
     public void testWhenNoRecurseInputStreamShouldContainInnerMail() throws Exception {
         stream.setRecursionMode(RecursionMode.M_NO_RECURSE);
         nextIs(EntityState.T_START_HEADER);
@@ -164,14 +167,15 @@ public class MimeTokenNoRecurseTest exte
         nextIs(EntityState.T_BODY);
         InputStream inputStream = stream.getInputStream();
         int next = inputStream.read();
-        int i=0;
+        int i = 0;
         while (next != -1) {
-            assertEquals("@" + i, INNER_MAIL.charAt(i++), (char) next);
+            Assert.assertEquals("@" + i, INNER_MAIL.charAt(i++), (char) next);
             next = inputStream.read();
         }
-        assertEquals(INNER_MAIL.length()-2, i);
+        Assert.assertEquals(INNER_MAIL.length() - 2, i);
     }
 
+    @Test
     public void testSetNoRecurseSoInputStreamShouldContainInnerMail() throws Exception {
         nextIs(EntityState.T_START_HEADER);
         nextIs(EntityState.T_FIELD);
@@ -195,12 +199,12 @@ public class MimeTokenNoRecurseTest exte
         nextIs(EntityState.T_BODY);
         InputStream inputStream = stream.getInputStream();
         int next = inputStream.read();
-        int i=0;
+        int i = 0;
         while (next != -1) {
-            assertEquals("@" + i, INNER_MAIL.charAt(i++), (char) next);
+            Assert.assertEquals("@" + i, INNER_MAIL.charAt(i++), (char) next);
             next = inputStream.read();
         }
-        assertEquals(INNER_MAIL.length()-2, i);
+        Assert.assertEquals(INNER_MAIL.length() - 2, i);
     }
 
     private void nextShouldBeStandardPart(boolean withHeader) throws Exception {
@@ -215,6 +219,6 @@ public class MimeTokenNoRecurseTest exte
     }
 
     private void nextIs(EntityState state) throws Exception {
-        assertEquals(MimeTokenStream.stateToString(state), MimeTokenStream.stateToString(stream.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(state), MimeTokenStream.stateToString(stream.next()));
     }
 }

Modified: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeTokenStreamBodyDescriptorTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeTokenStreamBodyDescriptorTest.java?rev=1426193&r1=1426192&r2=1426193&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeTokenStreamBodyDescriptorTest.java (original)
+++ james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeTokenStreamBodyDescriptorTest.java Thu Dec 27 13:23:54 2012
@@ -19,77 +19,74 @@
 
 package org.apache.james.mime4j.stream;
 
-import java.io.ByteArrayInputStream;
-
-import junit.framework.TestCase;
-
 import org.apache.james.mime4j.ExampleMail;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
 
-public class MimeTokenStreamBodyDescriptorTest extends TestCase {
+import java.io.ByteArrayInputStream;
+
+public class MimeTokenStreamBodyDescriptorTest {
 
     MimeTokenStream parser;
 
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
+    @Before
+    public void setUp() throws Exception {
         parser = new MimeTokenStream();
         parser.parse(new ByteArrayInputStream(ExampleMail.MIME_MULTIPART_ALTERNATIVE_BYTES));
     }
 
-    @Override
-    protected void tearDown() throws Exception {
-        super.tearDown();
-    }
-
+    @Test
     public void testShouldReturnValidDescriptorForPreamble() throws Exception {
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_START_HEADER), MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_FIELD), MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_FIELD), MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_FIELD), MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_FIELD), MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_FIELD), MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_END_HEADER), MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_START_MULTIPART), MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_PREAMBLE), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_START_HEADER), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_FIELD), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_FIELD), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_FIELD), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_FIELD), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_FIELD), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_END_HEADER), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_START_MULTIPART), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_PREAMBLE), MimeTokenStream.stateToString(parser.next()));
         BodyDescriptor descriptor = parser.getBodyDescriptor();
-        assertNotNull(descriptor);
-        assertEquals("1729", descriptor.getBoundary());
-        assertEquals( "multipart/alternative", descriptor.getMimeType());
+        Assert.assertNotNull(descriptor);
+        Assert.assertEquals("1729", descriptor.getBoundary());
+        Assert.assertEquals("multipart/alternative", descriptor.getMimeType());
     }
 
+    @Test
     public void testShouldReturnValidDescriptorForEpilogue() throws Exception {
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_START_HEADER), MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_FIELD), MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_FIELD), MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_FIELD), MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_FIELD), MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_FIELD), MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_END_HEADER), MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_START_MULTIPART), MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_PREAMBLE), MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_START_BODYPART), MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_START_HEADER), MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_FIELD), MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_END_HEADER), MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_BODY), MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_END_BODYPART), MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_START_BODYPART), MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_START_HEADER), MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_FIELD), MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_END_HEADER), MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_BODY), MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_END_BODYPART), MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_START_BODYPART), MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_START_HEADER), MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_FIELD), MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_END_HEADER), MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_BODY), MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_END_BODYPART), MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_EPILOGUE), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_START_HEADER), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_FIELD), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_FIELD), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_FIELD), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_FIELD), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_FIELD), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_END_HEADER), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_START_MULTIPART), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_PREAMBLE), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_START_BODYPART), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_START_HEADER), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_FIELD), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_END_HEADER), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_BODY), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_END_BODYPART), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_START_BODYPART), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_START_HEADER), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_FIELD), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_END_HEADER), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_BODY), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_END_BODYPART), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_START_BODYPART), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_START_HEADER), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_FIELD), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_END_HEADER), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_BODY), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_END_BODYPART), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_EPILOGUE), MimeTokenStream.stateToString(parser.next()));
 
         BodyDescriptor descriptor = parser.getBodyDescriptor();
-        assertNotNull(descriptor);
-        assertEquals("1729", descriptor.getBoundary());
-        assertEquals( "multipart/alternative", descriptor.getMimeType());
+        Assert.assertNotNull(descriptor);
+        Assert.assertEquals("1729", descriptor.getBoundary());
+        Assert.assertEquals("multipart/alternative", descriptor.getMimeType());
     }
 }

Modified: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeTokenStreamReaderTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeTokenStreamReaderTest.java?rev=1426193&r1=1426192&r2=1426193&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeTokenStreamReaderTest.java (original)
+++ james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeTokenStreamReaderTest.java Thu Dec 27 13:23:54 2012
@@ -19,102 +19,104 @@
 
 package org.apache.james.mime4j.stream;
 
+import org.apache.commons.io.IOUtils;
+import org.apache.james.mime4j.ExampleMail;
+import org.apache.james.mime4j.MimeException;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.Reader;
 
-import junit.framework.TestCase;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.james.mime4j.ExampleMail;
-import org.apache.james.mime4j.MimeException;
-
-public class MimeTokenStreamReaderTest extends TestCase {
+public class MimeTokenStreamReaderTest {
 
     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();
-    }
-
+    @Test
     public void testShouldReadSimpleBody() throws Exception {
         byte[] bytes = ExampleMail.RFC822_SIMPLE_BYTES;
         String body = ExampleMail.RFC822_SIMPLE_BODY;
         checkSimpleMail(bytes, body, 4);
     }
 
+    @Test
     public void testShouldReadOnePartMimeASCIIBody() throws Exception {
         byte[] bytes = ExampleMail.ONE_PART_MIME_ASCII_BYTES;
         String body = ExampleMail.ONE_PART_MIME_ASCII_BODY;
         checkSimpleMail(bytes, body, 11);
     }
 
+    @Test
     public void testShouldReadOnePartMime8859Body() throws Exception {
         byte[] bytes = ExampleMail.ONE_PART_MIME_8859_BYTES;
         String body = ExampleMail.ONE_PART_MIME_8859_BODY;
         checkSimpleMail(bytes, body, 13);
     }
 
+    @Test
     public void testShouldReadOnePartMimeBase64ASCIIBody() throws Exception {
         byte[] bytes = ExampleMail.ONE_PART_MIME_BASE64_ASCII_BYTES;
         String body = ExampleMail.ONE_PART_MIME_BASE64_ASCII_BODY;
         checkSimpleMail(bytes, body, 11);
     }
 
+    @Test
     public void testShouldReadOnePartMimeBase64Latin1Body() throws Exception {
         byte[] bytes = ExampleMail.ONE_PART_MIME_BASE64_LATIN1_BYTES;
         String body = ExampleMail.ONE_PART_MIME_BASE64_LATIN1_BODY;
         checkSimpleMail(bytes, body, 11);
     }
 
+    @Test
     public void testShouldReadOnePartMimeQuotedPrintable() throws Exception {
         byte[] bytes = ExampleMail.ONE_PART_MIME_QUOTED_PRINTABLE_ASCII_BYTES;
         String body = ExampleMail.ONE_PART_MIME_QUOTED_PRINTABLE_ASCII_BODY;
         checkSimpleMail(bytes, body, 11);
     }
 
+    @Test
     public void testShouldReadPartBodies() throws IOException, MimeException {
         InputStream in = new ByteArrayInputStream(ExampleMail.MIME_MIXED_MULTIPART_VARIOUS_ENCODINGS_BYTES);
         parser.parse(in);
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_START_HEADER),MimeTokenStream.stateToString(parser.next()));
-        for (int i=0;i<5;i++) {
-            assertEquals(MimeTokenStream.stateToString(EntityState.T_FIELD),MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_START_HEADER), MimeTokenStream.stateToString(parser.next()));
+        for (int i = 0; i < 5; i++) {
+            Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_FIELD), MimeTokenStream.stateToString(parser.next()));
         }
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_END_HEADER),MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_START_MULTIPART),MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_PREAMBLE),MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_START_BODYPART),MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_START_HEADER),MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_FIELD),MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_FIELD),MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_END_HEADER),MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_BODY),MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_END_HEADER), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_START_MULTIPART), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_PREAMBLE), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_START_BODYPART), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_START_HEADER), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_FIELD), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_FIELD), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_END_HEADER), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_BODY), MimeTokenStream.stateToString(parser.next()));
         checkBody(ExampleMail.MIME_MIXED_MULTIPART_VARIOUS_ENCODINGS_7BIT);
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_END_BODYPART),MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_START_BODYPART),MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_START_HEADER),MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_FIELD),MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_FIELD),MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_END_HEADER),MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_BODY),MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_END_BODYPART), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_START_BODYPART), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_START_HEADER), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_FIELD), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_FIELD), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_END_HEADER), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_BODY), MimeTokenStream.stateToString(parser.next()));
         checkBody(ExampleMail.MIME_MIXED_MULTIPART_VARIOUS_ENCODINGS_QUOTED_PRINTABLE);
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_END_BODYPART),MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_START_BODYPART),MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_START_HEADER),MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_FIELD),MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_FIELD),MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_END_HEADER),MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_BODY),MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_END_BODYPART), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_START_BODYPART), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_START_HEADER), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_FIELD), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_FIELD), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_END_HEADER), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_BODY), MimeTokenStream.stateToString(parser.next()));
         checkBody(ExampleMail.MIME_MIXED_MULTIPART_VARIOUS_ENCODINGS_BASE64);
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_END_BODYPART),MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_END_BODYPART), MimeTokenStream.stateToString(parser.next()));
 
 
     }
@@ -122,18 +124,18 @@ public class MimeTokenStreamReaderTest e
     private void checkSimpleMail(byte[] bytes, String body, int fields) throws IOException, MimeException {
         InputStream in = new ByteArrayInputStream(bytes);
         parser.parse(in);
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_START_HEADER),MimeTokenStream.stateToString(parser.next()));
-        for (int i=0;i<fields;i++) {
-            assertEquals(MimeTokenStream.stateToString(EntityState.T_FIELD),MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_START_HEADER), MimeTokenStream.stateToString(parser.next()));
+        for (int i = 0; i < fields; i++) {
+            Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_FIELD), MimeTokenStream.stateToString(parser.next()));
         }
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_END_HEADER),MimeTokenStream.stateToString(parser.next()));
-        assertEquals(MimeTokenStream.stateToString(EntityState.T_BODY),MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_END_HEADER), MimeTokenStream.stateToString(parser.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(EntityState.T_BODY), MimeTokenStream.stateToString(parser.next()));
         checkBody(body);
     }
 
     private void checkBody(String body) throws IOException {
         Reader reader = parser.getReader();
-        assertNotNull(reader);
-        assertEquals(body, IOUtils.toString(reader));
+        Assert.assertNotNull(reader);
+        Assert.assertEquals(body, IOUtils.toString(reader));
     }
 }

Modified: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeTokenStreamTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeTokenStreamTest.java?rev=1426193&r1=1426192&r2=1426193&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeTokenStreamTest.java (original)
+++ james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeTokenStreamTest.java Thu Dec 27 13:23:54 2012
@@ -19,21 +19,23 @@
 
 package org.apache.james.mime4j.stream;
 
-import java.io.ByteArrayInputStream;
-
-import junit.framework.TestCase;
-
 import org.apache.james.mime4j.ExampleMail;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.ByteArrayInputStream;
 
-public class MimeTokenStreamTest extends TestCase {
+public class MimeTokenStreamTest {
 
     MimeTokenStream stream;
 
-    @Override
+    @Before
     public void setUp() throws Exception {
         stream = new MimeTokenStream();
     }
 
+    @Test
     public void testSetRecursionModeBeforeParse() throws Exception {
         stream.setRecursionMode(RecursionMode.M_NO_RECURSE);
         stream.parse(new ByteArrayInputStream(ExampleMail.MAIL_WITH_RFC822_PART_BYTES));
@@ -77,6 +79,6 @@ public class MimeTokenStreamTest extends
     }
 
     private void checkNextIs(EntityState expected) throws Exception {
-        assertEquals(MimeTokenStream.stateToString(expected), MimeTokenStream.stateToString(stream.next()));
+        Assert.assertEquals(MimeTokenStream.stateToString(expected), MimeTokenStream.stateToString(stream.next()));
     }
 }

Modified: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MultipartStreamTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MultipartStreamTest.java?rev=1426193&r1=1426192&r2=1426193&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MultipartStreamTest.java (original)
+++ james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MultipartStreamTest.java Thu Dec 27 13:23:54 2012
@@ -19,28 +19,30 @@
 
 package org.apache.james.mime4j.stream;
 
+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.io.InputStream;
 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;
-
-public class MultipartStreamTest extends TestCase {
+public class MultipartStreamTest {
 
     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";
+            "--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";
     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,37 +51,36 @@ public class MultipartStreamTest 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" +
-    "Content-Type: text/plain; charset=US-ASCII\r\n\r\n" +
-    "Custard!" +
-    "\r\n" +
-    "--42--\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" +
+            "Content-Type: text/plain; charset=US-ASCII\r\n\r\n" +
+            "Custard!" +
+            "\r\n" +
+            "--42--\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 testShouldSupplyInputStreamForSimpleBody() throws Exception {
         parser.parse(new ByteArrayInputStream(US_ASCII.encode(MESSAGE).array()));
         checkState(EntityState.T_START_HEADER);
@@ -91,10 +92,11 @@ public class MultipartStreamTest extends
         checkState(EntityState.T_END_HEADER);
         checkState(EntityState.T_START_MULTIPART);
         InputStream out = parser.getInputStream();
-        assertEquals(BODY, IOUtils.toString(out, "us-ascii"));
+        Assert.assertEquals(BODY, IOUtils.toString(out, "us-ascii"));
         checkState(EntityState.T_END_MULTIPART);
     }
 
+    @Test
     public void testInputStreamShouldReadOnlyMessage() throws Exception {
         parser.parse(new ByteArrayInputStream(US_ASCII.encode(COMPLEX_MESSAGE).array()));
         checkState(EntityState.T_START_HEADER);
@@ -126,7 +128,7 @@ public class MultipartStreamTest extends
         checkState(EntityState.T_END_HEADER);
         checkState(EntityState.T_START_MULTIPART);
         InputStream out = parser.getInputStream();
-        assertEquals(BODY, IOUtils.toString(out, "us-ascii"));
+        Assert.assertEquals(BODY, IOUtils.toString(out, "us-ascii"));
         checkState(EntityState.T_END_MULTIPART);
         checkState(EntityState.T_END_MESSAGE);
         checkState(EntityState.T_END_BODYPART);
@@ -142,6 +144,6 @@ public class MultipartStreamTest 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()));
     }
 }



Mime
View raw message