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 [5/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/dom/src/test/java/org/apache/james/mime4j/dom/MessageTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageTest.java?rev=1426193&r1=1426192&r2=1426193&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageTest.java (original)
+++ james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageTest.java Thu Dec 27 13:23:54 2012
@@ -19,24 +19,7 @@
 
 package org.apache.james.mime4j.dom;
 
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-import java.util.TimeZone;
-
-import junit.framework.TestCase;
-
 import org.apache.commons.io.IOUtils;
-import org.apache.james.mime4j.dom.Header;
-import org.apache.james.mime4j.dom.Message;
-import org.apache.james.mime4j.dom.Multipart;
-import org.apache.james.mime4j.dom.SingleBody;
 import org.apache.james.mime4j.dom.address.Group;
 import org.apache.james.mime4j.dom.address.Mailbox;
 import org.apache.james.mime4j.dom.field.FieldName;
@@ -44,20 +27,34 @@ import org.apache.james.mime4j.dom.field
 import org.apache.james.mime4j.field.DefaultFieldParser;
 import org.apache.james.mime4j.field.address.AddressBuilder;
 import org.apache.james.mime4j.message.BodyPart;
-import org.apache.james.mime4j.message.HeaderImpl;
-import org.apache.james.mime4j.message.MessageImpl;
 import org.apache.james.mime4j.message.DefaultMessageBuilder;
 import org.apache.james.mime4j.message.DefaultMessageWriter;
+import org.apache.james.mime4j.message.HeaderImpl;
+import org.apache.james.mime4j.message.MessageImpl;
 import org.apache.james.mime4j.message.MultipartImpl;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+import java.util.TimeZone;
 
-public class MessageTest extends TestCase {
+public class MessageTest {
     private Header headerTextPlain = null;
     private Header headerMessageRFC822 = null;
     private Header headerEmpty = null;
     private Header headerMultipartMixed = null;
     private Header headerMultipartDigest = null;
 
-    @Override
+    @Before
     public void setUp() throws Exception {
         headerTextPlain = new HeaderImpl();
         headerMessageRFC822 = new HeaderImpl();
@@ -75,6 +72,7 @@ public class MessageTest extends TestCas
                 DefaultFieldParser.parse("Content-Type: multipart/digest; boundary=foo"));
     }
 
+    @Test
     public void testGetMimeType() {
         MessageImpl parent = null;
         MessageImpl child = null;
@@ -84,13 +82,13 @@ public class MessageTest extends TestCas
         child.setParent(parent);
         parent.setHeader(headerMultipartDigest);
         child.setHeader(headerEmpty);
-        assertEquals("multipart/digest, empty", "message/rfc822",
+        Assert.assertEquals("multipart/digest, empty", "message/rfc822",
                 child.getMimeType());
         child.setHeader(headerTextPlain);
-        assertEquals("multipart/digest, text/plain", "text/plain",
+        Assert.assertEquals("multipart/digest, text/plain", "text/plain",
                 child.getMimeType());
         child.setHeader(headerMessageRFC822);
-        assertEquals("multipart/digest, message/rfc822", "message/rfc822",
+        Assert.assertEquals("multipart/digest, message/rfc822", "message/rfc822",
                 child.getMimeType());
 
         parent = new MessageImpl();
@@ -98,41 +96,43 @@ public class MessageTest extends TestCas
         child.setParent(parent);
         parent.setHeader(headerMultipartMixed);
         child.setHeader(headerEmpty);
-        assertEquals("multipart/mixed, empty", "text/plain",
+        Assert.assertEquals("multipart/mixed, empty", "text/plain",
                 child.getMimeType());
         child.setHeader(headerTextPlain);
-        assertEquals("multipart/mixed, text/plain", "text/plain",
+        Assert.assertEquals("multipart/mixed, text/plain", "text/plain",
                 child.getMimeType());
         child.setHeader(headerMessageRFC822);
-        assertEquals("multipart/mixed, message/rfc822", "message/rfc822",
+        Assert.assertEquals("multipart/mixed, message/rfc822", "message/rfc822",
                 child.getMimeType());
 
         child = new MessageImpl();
         child.setHeader(headerEmpty);
-        assertEquals("null, empty", "text/plain", child.getMimeType());
+        Assert.assertEquals("null, empty", "text/plain", child.getMimeType());
         child.setHeader(headerTextPlain);
-        assertEquals("null, text/plain", "text/plain", child.getMimeType());
+        Assert.assertEquals("null, text/plain", "text/plain", child.getMimeType());
         child.setHeader(headerMessageRFC822);
-        assertEquals("null, message/rfc822", "message/rfc822",
+        Assert.assertEquals("null, message/rfc822", "message/rfc822",
                 child.getMimeType());
     }
 
+    @Test
     public void testIsMultipart() {
         MessageImpl m = new MessageImpl();
 
         m.setHeader(headerEmpty);
-        assertTrue("empty", !m.isMultipart());
+        Assert.assertTrue("empty", !m.isMultipart());
 
         m.setHeader(headerTextPlain);
-        assertTrue("text/plain", !m.isMultipart());
+        Assert.assertTrue("text/plain", !m.isMultipart());
 
         m.setHeader(headerMultipartDigest);
-        assertTrue("multipart/digest", m.isMultipart());
+        Assert.assertTrue("multipart/digest", m.isMultipart());
 
         m.setHeader(headerMultipartMixed);
-        assertTrue("multipart/mixed", m.isMultipart());
+        Assert.assertTrue("multipart/mixed", m.isMultipart());
     }
 
+    @Test
     public void testWriteTo() throws Exception {
         byte[] inputByte = getRawMessageAsByteArray();
 
@@ -149,11 +149,12 @@ public class MessageTest extends TestCas
         int b = -1;
         int i = 0;
         while ((b = output.read()) != -1) {
-            assertEquals("same byte", b, inputByte[i]);
+            Assert.assertEquals("same byte", b, inputByte[i]);
             i++;
         }
     }
 
+    @Test
     public void testAddHeaderWriteTo() throws Exception {
         String headerName = "testheader";
         String headerValue = "testvalue";
@@ -167,7 +168,7 @@ public class MessageTest extends TestCas
         Message m = builder.parseMessage(new ByteArrayInputStream(inputByte));
         m.getHeader().addField(DefaultFieldParser.parse(testheader));
 
-        assertEquals("header added", m.getHeader().getField(headerName)
+        Assert.assertEquals("header added", m.getHeader().getField(headerName)
                 .getBody(), headerValue);
 
         ByteArrayOutputStream out = new ByteArrayOutputStream();
@@ -176,121 +177,132 @@ public class MessageTest extends TestCas
                 new InputStreamReader(new ByteArrayInputStream(out
                         .toByteArray())))));
 
-        assertTrue("header added", lines.contains(testheader));
+        Assert.assertTrue("header added", lines.contains(testheader));
     }
 
+    @Test
     public void testMimeVersion() throws Exception {
         MessageImpl m = new MessageImpl();
-        assertNotNull(m.getHeader());
+        Assert.assertNotNull(m.getHeader());
         MimeVersionField field = (MimeVersionField) m.getHeader().getField(FieldName.MIME_VERSION);
-        assertNotNull(field);
-        assertEquals(1, field.getMajorVersion());
-        assertEquals(0, field.getMinorVersion());
+        Assert.assertNotNull(field);
+        Assert.assertEquals(1, field.getMajorVersion());
+        Assert.assertEquals(0, field.getMinorVersion());
     }
 
+    @Test
     public void testGetMessageId() throws Exception {
         MessageImpl m = new MessageImpl();
-        assertNull(m.getMessageId());
+        Assert.assertNull(m.getMessageId());
 
         String id = "<msg17@localhost>";
         Header header = new HeaderImpl();
         header.setField(DefaultFieldParser.parse("Message-ID: " + id));
         m.setHeader(header);
-        assertEquals(id, m.getMessageId());
+        Assert.assertEquals(id, m.getMessageId());
     }
 
+    @Test
     public void testCreateMessageId() throws Exception {
         MessageImpl m = new MessageImpl();
         m.createMessageId("hostname");
 
         String id = m.getMessageId();
-        assertNotNull(id);
-        assertTrue(id.startsWith("<Mime4j."));
-        assertTrue(id.endsWith("@hostname>"));
+        Assert.assertNotNull(id);
+        Assert.assertTrue(id.startsWith("<Mime4j."));
+        Assert.assertTrue(id.endsWith("@hostname>"));
     }
 
+    @Test
     public void testGetSubject() throws Exception {
         MessageImpl m = new MessageImpl();
-        assertNull(m.getSubject());
+        Assert.assertNull(m.getSubject());
 
         String subject = "testing 1 2";
         Header header = new HeaderImpl();
         header.setField(DefaultFieldParser.parse("Subject: " + subject));
         m.setHeader(header);
-        assertEquals(subject, m.getSubject());
+        Assert.assertEquals(subject, m.getSubject());
 
         header.setField(DefaultFieldParser.parse("Subject: =?windows-1252?Q?99_=80?="));
-        assertEquals("99 \u20ac", m.getSubject());
+        Assert.assertEquals("99 \u20ac", m.getSubject());
     }
 
+    @Test
     public void testSetSubject() throws Exception {
         MessageImpl m = new MessageImpl();
 
         m.setSubject("Semmelbr\366sel");
-        assertEquals("Semmelbr\366sel", m.getSubject());
-        assertEquals("=?ISO-8859-1?Q?Semmelbr=F6sel?=", m.getHeader().getField(
+        Assert.assertEquals("Semmelbr\366sel", m.getSubject());
+        Assert.assertEquals("=?ISO-8859-1?Q?Semmelbr=F6sel?=", m.getHeader().getField(
                 "Subject").getBody());
 
         m.setSubject(null);
-        assertNull(m.getHeader().getField("Subject"));
+        Assert.assertNull(m.getHeader().getField("Subject"));
     }
 
+    @Test
     public void testGetDate() throws Exception {
         MessageImpl m = new MessageImpl();
-        assertNull(m.getDate());
+        Assert.assertNull(m.getDate());
 
         Header header = new HeaderImpl();
         header.setField(DefaultFieldParser.parse("Date: Thu, 1 Jan 1970 05:30:00 +0530"));
         m.setHeader(header);
 
-        assertEquals(new Date(0), m.getDate());
+        Assert.assertEquals(new Date(0), m.getDate());
     }
 
+    @Test
     public void testSetDate() throws Exception {
         MessageImpl m = new MessageImpl();
 
         m.setDate(new Date(86400000), TimeZone.getTimeZone("GMT"));
-        assertEquals(new Date(86400000), m.getDate());
-        assertEquals("Fri, 2 Jan 1970 00:00:00 +0000", m.getHeader().getField(
+        Assert.assertEquals(new Date(86400000), m.getDate());
+        Assert.assertEquals("Fri, 2 Jan 1970 00:00:00 +0000", m.getHeader().getField(
                 "Date").getBody());
 
         m.setDate(null);
-        assertNull(m.getHeader().getField("Date"));
+        Assert.assertNull(m.getHeader().getField("Date"));
     }
 
+    @Test
     public void testGetSender() throws Exception {
         MessageImpl m = new MessageImpl();
-        assertNull(m.getSender());
+        Assert.assertNull(m.getSender());
 
         Header header = new HeaderImpl();
         header.setField(DefaultFieldParser.parse("Sender: john.doe@example.net"));
         m.setHeader(header);
 
-        assertEquals("john.doe@example.net", m.getSender().getAddress());
+        Assert.assertEquals("john.doe@example.net", m.getSender().getAddress());
     }
 
+    @Test
     public void testSetSender() throws Exception {
         MessageImpl m = new MessageImpl();
 
         m.setSender(AddressBuilder.DEFAULT.parseMailbox("john.doe@example.net"));
-        assertEquals("john.doe@example.net", m.getHeader().getField("Sender")
+        Assert.assertEquals("john.doe@example.net", m.getHeader().getField("Sender")
                 .getBody());
 
         m.setSender(null);
-        assertNull(m.getHeader().getField("Sender"));
+        Assert.assertNull(m.getHeader().getField("Sender"));
     }
 
+    @Test
     public void testGetFrom() throws Exception {
         MessageImpl m = new MessageImpl();
-        assertNull(m.getFrom());
+        Assert.assertNull(m.getFrom());
 
         Header header = new HeaderImpl();
         header.setField(DefaultFieldParser.parse("From: john.doe@example.net"));
         m.setHeader(header);
 
-        assertEquals("john.doe@example.net", m.getFrom().get(0).getAddress());
+        Assert.assertEquals("john.doe@example.net", m.getFrom().get(0).getAddress());
     }
 
+    @Test
     public void testSetFrom() throws Exception {
         MessageImpl m = new MessageImpl();
 
@@ -298,33 +310,35 @@ public class MessageTest extends TestCas
         Mailbox mailbox2 = AddressBuilder.DEFAULT.parseMailbox("jane.doe@example.net");
 
         m.setFrom(mailbox1);
-        assertEquals("john.doe@example.net", m.getHeader().getField("From")
+        Assert.assertEquals("john.doe@example.net", m.getHeader().getField("From")
                 .getBody());
 
         m.setFrom(mailbox1, mailbox2);
-        assertEquals("john.doe@example.net, jane.doe@example.net", m
+        Assert.assertEquals("john.doe@example.net, jane.doe@example.net", m
                 .getHeader().getField("From").getBody());
 
         m.setFrom(Arrays.asList(mailbox1, mailbox2));
-        assertEquals("john.doe@example.net, jane.doe@example.net", m
+        Assert.assertEquals("john.doe@example.net, jane.doe@example.net", m
                 .getHeader().getField("From").getBody());
 
         m.setFrom((Mailbox) null);
-        assertNull(m.getHeader().getField("From"));
+        Assert.assertNull(m.getHeader().getField("From"));
     }
 
+    @Test
     public void testGetTo() throws Exception {
         MessageImpl m = new MessageImpl();
-        assertNull(m.getTo());
+        Assert.assertNull(m.getTo());
 
         Header header = new HeaderImpl();
         header.setField(DefaultFieldParser.parse("To: john.doe@example.net"));
         m.setHeader(header);
 
-        assertEquals("john.doe@example.net", ((Mailbox) m.getTo().get(0))
+        Assert.assertEquals("john.doe@example.net", ((Mailbox) m.getTo().get(0))
                 .getAddress());
     }
 
+    @Test
     public void testSetTo() throws Exception {
         MessageImpl m = new MessageImpl();
 
@@ -334,35 +348,37 @@ public class MessageTest extends TestCas
         Mailbox mailbox3 = AddressBuilder.DEFAULT.parseMailbox("Mary Smith <mary@example.net>");
 
         m.setTo(group);
-        assertEquals("Does: john.doe@example.net, jane.doe@example.net;", m
+        Assert.assertEquals("Does: john.doe@example.net, jane.doe@example.net;", m
                 .getHeader().getField("To").getBody());
 
         m.setTo(group, mailbox3);
-        assertEquals("Does: john.doe@example.net, jane.doe@example.net;, "
+        Assert.assertEquals("Does: john.doe@example.net, jane.doe@example.net;, "
                 + "Mary Smith <mary@example.net>", m.getHeader().getField("To")
                 .getBody());
 
         m.setTo(Arrays.asList(group, mailbox3));
-        assertEquals("Does: john.doe@example.net, jane.doe@example.net;, "
+        Assert.assertEquals("Does: john.doe@example.net, jane.doe@example.net;, "
                 + "Mary Smith <mary@example.net>", m.getHeader().getField("To")
                 .getBody());
 
         m.setTo((Mailbox) null);
-        assertNull(m.getHeader().getField("To"));
+        Assert.assertNull(m.getHeader().getField("To"));
     }
 
+    @Test
     public void testGetCc() throws Exception {
         MessageImpl m = new MessageImpl();
-        assertNull(m.getCc());
+        Assert.assertNull(m.getCc());
 
         Header header = new HeaderImpl();
         header.setField(DefaultFieldParser.parse("Cc: john.doe@example.net"));
         m.setHeader(header);
 
-        assertEquals("john.doe@example.net", ((Mailbox) m.getCc().get(0))
+        Assert.assertEquals("john.doe@example.net", ((Mailbox) m.getCc().get(0))
                 .getAddress());
     }
 
+    @Test
     public void testSetCc() throws Exception {
         MessageImpl m = new MessageImpl();
 
@@ -372,35 +388,37 @@ public class MessageTest extends TestCas
         Mailbox mailbox3 = AddressBuilder.DEFAULT.parseMailbox("Mary Smith <mary@example.net>");
 
         m.setCc(group);
-        assertEquals("Does: john.doe@example.net, jane.doe@example.net;", m
+        Assert.assertEquals("Does: john.doe@example.net, jane.doe@example.net;", m
                 .getHeader().getField("Cc").getBody());
 
         m.setCc(group, mailbox3);
-        assertEquals("Does: john.doe@example.net, jane.doe@example.net;, "
+        Assert.assertEquals("Does: john.doe@example.net, jane.doe@example.net;, "
                 + "Mary Smith <mary@example.net>", m.getHeader().getField("Cc")
                 .getBody());
 
         m.setCc(Arrays.asList(group, mailbox3));
-        assertEquals("Does: john.doe@example.net, jane.doe@example.net;, "
+        Assert.assertEquals("Does: john.doe@example.net, jane.doe@example.net;, "
                 + "Mary Smith <mary@example.net>", m.getHeader().getField("Cc")
                 .getBody());
 
         m.setCc((Mailbox) null);
-        assertNull(m.getHeader().getField("Cc"));
+        Assert.assertNull(m.getHeader().getField("Cc"));
     }
 
+    @Test
     public void testGetBcc() throws Exception {
         MessageImpl m = new MessageImpl();
-        assertNull(m.getBcc());
+        Assert.assertNull(m.getBcc());
 
         Header header = new HeaderImpl();
         header.setField(DefaultFieldParser.parse("Bcc: john.doe@example.net"));
         m.setHeader(header);
 
-        assertEquals("john.doe@example.net", ((Mailbox) m.getBcc().get(0))
+        Assert.assertEquals("john.doe@example.net", ((Mailbox) m.getBcc().get(0))
                 .getAddress());
     }
 
+    @Test
     public void testSetBcc() throws Exception {
         MessageImpl m = new MessageImpl();
 
@@ -410,35 +428,37 @@ public class MessageTest extends TestCas
         Mailbox mailbox3 = AddressBuilder.DEFAULT.parseMailbox("Mary Smith <mary@example.net>");
 
         m.setBcc(group);
-        assertEquals("Does: john.doe@example.net, jane.doe@example.net;", m
+        Assert.assertEquals("Does: john.doe@example.net, jane.doe@example.net;", m
                 .getHeader().getField("Bcc").getBody());
 
         m.setBcc(group, mailbox3);
-        assertEquals("Does: john.doe@example.net, jane.doe@example.net;, "
+        Assert.assertEquals("Does: john.doe@example.net, jane.doe@example.net;, "
                 + "Mary Smith <mary@example.net>", m.getHeader()
                 .getField("Bcc").getBody());
 
         m.setBcc(Arrays.asList(group, mailbox3));
-        assertEquals("Does: john.doe@example.net, jane.doe@example.net;, "
+        Assert.assertEquals("Does: john.doe@example.net, jane.doe@example.net;, "
                 + "Mary Smith <mary@example.net>", m.getHeader()
                 .getField("Bcc").getBody());
 
         m.setBcc((Mailbox) null);
-        assertNull(m.getHeader().getField("Bcc"));
+        Assert.assertNull(m.getHeader().getField("Bcc"));
     }
 
+    @Test
     public void testGetReplyTo() throws Exception {
         MessageImpl m = new MessageImpl();
-        assertNull(m.getReplyTo());
+        Assert.assertNull(m.getReplyTo());
 
         Header header = new HeaderImpl();
         header.setField(DefaultFieldParser.parse("Reply-To: john.doe@example.net"));
         m.setHeader(header);
 
-        assertEquals("john.doe@example.net", ((Mailbox) m.getReplyTo().get(0))
+        Assert.assertEquals("john.doe@example.net", ((Mailbox) m.getReplyTo().get(0))
                 .getAddress());
     }
 
+    @Test
     public void testSetReplyTo() throws Exception {
         MessageImpl m = new MessageImpl();
 
@@ -448,23 +468,24 @@ public class MessageTest extends TestCas
         Mailbox mailbox3 = AddressBuilder.DEFAULT.parseMailbox("Mary Smith <mary@example.net>");
 
         m.setReplyTo(group);
-        assertEquals("Does: john.doe@example.net, jane.doe@example.net;", m
+        Assert.assertEquals("Does: john.doe@example.net, jane.doe@example.net;", m
                 .getHeader().getField("Reply-To").getBody());
 
         m.setReplyTo(group, mailbox3);
-        assertEquals("Does: john.doe@example.net, jane.doe@example.net;, "
+        Assert.assertEquals("Does: john.doe@example.net, jane.doe@example.net;, "
                 + "Mary Smith <mary@example.net>", m.getHeader().getField(
                 "Reply-To").getBody());
 
         m.setReplyTo(Arrays.asList(group, mailbox3));
-        assertEquals("Does: john.doe@example.net, jane.doe@example.net;, "
+        Assert.assertEquals("Does: john.doe@example.net, jane.doe@example.net;, "
                 + "Mary Smith <mary@example.net>", m.getHeader().getField(
                 "Reply-To").getBody());
 
         m.setReplyTo((Mailbox) null);
-        assertNull(m.getHeader().getField("Reply-To"));
+        Assert.assertNull(m.getHeader().getField("Reply-To"));
     }
 
+    @Test
     public void testDisposeGetsPropagatedToBody() throws Exception {
         DummyBody body1 = new DummyBody();
         BodyPart part1 = new BodyPart();
@@ -484,13 +505,13 @@ public class MessageTest extends TestCas
         m.setHeader(headerMultipartMixed);
         m.setBody(mp);
 
-        assertFalse(body1.disposed);
-        assertFalse(body2.disposed);
+        Assert.assertFalse(body1.disposed);
+        Assert.assertFalse(body2.disposed);
 
         m.dispose();
 
-        assertTrue(body1.disposed);
-        assertTrue(body2.disposed);
+        Assert.assertTrue(body1.disposed);
+        Assert.assertTrue(body2.disposed);
     }
 
     private byte[] getRawMessageAsByteArray() {

Modified: james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageWriteToTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageWriteToTest.java?rev=1426193&r1=1426192&r2=1426193&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageWriteToTest.java (original)
+++ james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageWriteToTest.java Thu Dec 27 13:23:54 2012
@@ -19,30 +19,23 @@
 
 package org.apache.james.mime4j.dom;
 
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-
 import org.apache.james.mime4j.ExampleMail;
 import org.apache.james.mime4j.message.DefaultMessageBuilder;
 import org.apache.james.mime4j.message.DefaultMessageWriter;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
 
-import junit.framework.TestCase;
-
-public class MessageWriteToTest extends TestCase {
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-    }
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 
-    @Override
-    protected void tearDown() throws Exception {
-        super.tearDown();
-    }
+public class MessageWriteToTest {
 
+    @Test
     public void testSimpleMail() throws Exception {
         Message message = createMessage(ExampleMail.RFC822_SIMPLE_BYTES);
-        assertFalse("Not multipart", message.isMultipart());
+        Assert.assertFalse("Not multipart", message.isMultipart());
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         DefaultMessageWriter writer = new DefaultMessageWriter();
         writer.writeMessage(message, out);
@@ -51,35 +44,38 @@ public class MessageWriteToTest extends 
 
     private void assertEquals(byte[] expected, byte[] actual) {
         StringBuilder buffer = new StringBuilder(expected.length);
-        assertEquals(new String(expected), new String(actual));
-        assertEquals(expected.length, actual.length);
+        Assert.assertEquals(new String(expected), new String(actual));
+        Assert.assertEquals(expected.length, actual.length);
         for (int i = 0; i < actual.length; i++) {
-            buffer.append((char)actual[i]);
-            assertEquals("Mismatch@" + i, expected[i], actual[i]);
+            buffer.append((char) actual[i]);
+            Assert.assertEquals("Mismatch@" + i, expected[i], actual[i]);
         }
     }
 
+    @Test
     public void testBinaryAttachment() throws Exception {
         Message message = createMessage(ExampleMail.MULTIPART_WITH_BINARY_ATTACHMENTS_BYTES);
-        assertTrue("Is multipart", message.isMultipart());
+        Assert.assertTrue("Is multipart", message.isMultipart());
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         DefaultMessageWriter writer = new DefaultMessageWriter();
         writer.writeMessage(message, out);
         assertEquals(ExampleMail.MULTIPART_WITH_BINARY_ATTACHMENTS_BYTES, out.toByteArray());
     }
 
+    @Test
     public void testBinaryAttachmentNoPreamble() throws Exception {
         Message message = createMessage(ExampleMail.MULTIPART_WITH_BINARY_ATTACHMENTS_NOPREAMBLE_BYTES);
-        assertTrue("Is multipart", message.isMultipart());
+        Assert.assertTrue("Is multipart", message.isMultipart());
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         DefaultMessageWriter writer = new DefaultMessageWriter();
         writer.writeMessage(message, out);
         assertEquals(ExampleMail.MULTIPART_WITH_BINARY_ATTACHMENTS_NOPREAMBLE_BYTES, out.toByteArray());
     }
 
+    @Test
     public void testBinaryAttachmentPreambleEpilogue() throws Exception {
         Message message = createMessage(ExampleMail.MULTIPART_WITH_BINARY_ATTACHMENTS_PREAMBLE_EPILOGUE_BYTES);
-        assertTrue("Is multipart", message.isMultipart());
+        Assert.assertTrue("Is multipart", message.isMultipart());
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         DefaultMessageWriter writer = new DefaultMessageWriter();
         writer.writeMessage(message, out);

Modified: james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MimeBuilderCopyTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MimeBuilderCopyTest.java?rev=1426193&r1=1426192&r2=1426193&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MimeBuilderCopyTest.java (original)
+++ james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MimeBuilderCopyTest.java Thu Dec 27 13:23:54 2012
@@ -19,26 +19,23 @@
 
 package org.apache.james.mime4j.dom;
 
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.james.mime4j.dom.Body;
-import org.apache.james.mime4j.dom.Entity;
-import org.apache.james.mime4j.dom.Header;
-import org.apache.james.mime4j.dom.Multipart;
 import org.apache.james.mime4j.field.DefaultFieldParser;
 import org.apache.james.mime4j.message.BasicBodyFactory;
 import org.apache.james.mime4j.message.BodyPart;
+import org.apache.james.mime4j.message.DefaultMessageBuilder;
 import org.apache.james.mime4j.message.HeaderImpl;
 import org.apache.james.mime4j.message.MessageImpl;
-import org.apache.james.mime4j.message.DefaultMessageBuilder;
 import org.apache.james.mime4j.message.MultipartImpl;
 import org.apache.james.mime4j.stream.Field;
+import org.junit.Assert;
+import org.junit.Test;
 
-import junit.framework.TestCase;
+import java.util.Arrays;
+import java.util.List;
 
-public class MimeBuilderCopyTest extends TestCase {
+public class MimeBuilderCopyTest {
 
+    @Test
     public void testCopyMessage() throws Exception {
         MessageImpl parent = new MessageImpl();
         Header header = new HeaderImpl();
@@ -52,28 +49,30 @@ public class MimeBuilderCopyTest extends
         DefaultMessageBuilder builder = new DefaultMessageBuilder();
         Message copy = builder.copy(original);
 
-        assertNotNull(copy.getHeader());
-        assertNotSame(header, copy.getHeader());
+        Assert.assertNotNull(copy.getHeader());
+        Assert.assertNotSame(header, copy.getHeader());
 
-        assertNotNull(copy.getBody());
-        assertNotSame(body, copy.getBody());
+        Assert.assertNotNull(copy.getBody());
+        Assert.assertNotSame(body, copy.getBody());
 
-        assertSame(copy, copy.getBody().getParent());
+        Assert.assertSame(copy, copy.getBody().getParent());
 
-        assertNull(copy.getParent());
+        Assert.assertNull(copy.getParent());
     }
 
+    @Test
     public void testCopyEmptyBodyPart() throws Exception {
         BodyPart original = new BodyPart();
 
         DefaultMessageBuilder builder = new DefaultMessageBuilder();
         BodyPart copy = builder.copy(original);
 
-        assertNull(copy.getHeader());
-        assertNull(copy.getBody());
-        assertNull(copy.getParent());
+        Assert.assertNull(copy.getHeader());
+        Assert.assertNull(copy.getBody());
+        Assert.assertNull(copy.getParent());
     }
 
+    @Test
     public void testCopyBodyPart() throws Exception {
         MessageImpl parent = new MessageImpl();
         Header header = new HeaderImpl();
@@ -87,30 +86,32 @@ public class MimeBuilderCopyTest extends
         DefaultMessageBuilder builder = new DefaultMessageBuilder();
         BodyPart copy = builder.copy(original);
 
-        assertNotNull(copy.getHeader());
-        assertNotSame(header, copy.getHeader());
+        Assert.assertNotNull(copy.getHeader());
+        Assert.assertNotSame(header, copy.getHeader());
 
-        assertNotNull(copy.getBody());
-        assertNotSame(body, copy.getBody());
+        Assert.assertNotNull(copy.getBody());
+        Assert.assertNotSame(body, copy.getBody());
 
-        assertSame(copy, copy.getBody().getParent());
+        Assert.assertSame(copy, copy.getBody().getParent());
 
-        assertNull(copy.getParent());
+        Assert.assertNull(copy.getParent());
     }
 
+    @Test
     public void testCopyEmptyMultipart() throws Exception {
         Multipart original = new MultipartImpl("mixed");
 
         DefaultMessageBuilder builder = new DefaultMessageBuilder();
         Multipart copy = builder.copy(original);
 
-        assertSame(original.getPreamble(), copy.getPreamble());
-        assertSame(original.getEpilogue(), copy.getEpilogue());
-        assertSame(original.getSubType(), copy.getSubType());
-        assertTrue(copy.getBodyParts().isEmpty());
-        assertNull(copy.getParent());
+        Assert.assertSame(original.getPreamble(), copy.getPreamble());
+        Assert.assertSame(original.getEpilogue(), copy.getEpilogue());
+        Assert.assertSame(original.getSubType(), copy.getSubType());
+        Assert.assertTrue(copy.getBodyParts().isEmpty());
+        Assert.assertNull(copy.getParent());
     }
 
+    @Test
     public void testCopyMultipart() throws Exception {
         MessageImpl parent = new MessageImpl();
         BodyPart bodyPart = new BodyPart();
@@ -124,19 +125,20 @@ public class MimeBuilderCopyTest extends
         DefaultMessageBuilder builder = new DefaultMessageBuilder();
         Multipart copy = builder.copy(original);
 
-        assertSame(original.getPreamble(), copy.getPreamble());
-        assertSame(original.getEpilogue(), copy.getEpilogue());
-        assertSame(original.getSubType(), copy.getSubType());
-        assertEquals(1, copy.getBodyParts().size());
-        assertNull(copy.getParent());
+        Assert.assertSame(original.getPreamble(), copy.getPreamble());
+        Assert.assertSame(original.getEpilogue(), copy.getEpilogue());
+        Assert.assertSame(original.getSubType(), copy.getSubType());
+        Assert.assertEquals(1, copy.getBodyParts().size());
+        Assert.assertNull(copy.getParent());
 
         Entity bodyPartCopy = copy.getBodyParts().iterator().next();
-        assertNotSame(bodyPart, bodyPartCopy);
+        Assert.assertNotSame(bodyPart, bodyPartCopy);
 
-        assertSame(parent, bodyPart.getParent());
-        assertNull(bodyPartCopy.getParent());
+        Assert.assertSame(parent, bodyPart.getParent());
+        Assert.assertNull(bodyPartCopy.getParent());
     }
 
+    @Test
     public void testCopyMultipartMessage() throws Exception {
         BodyPart bodyPart1 = new BodyPart();
         BodyPart bodyPart2 = new BodyPart();
@@ -157,15 +159,16 @@ public class MimeBuilderCopyTest extends
         Entity bodyPartCopy1 = bodyParts.get(0);
         Entity bodyPartCopy2 = bodyParts.get(1);
 
-        assertNotSame(bodyPart1, bodyPartCopy1);
-        assertEquals(original, bodyPart1.getParent());
-        assertEquals(copy, bodyPartCopy1.getParent());
-
-        assertNotSame(bodyPart2, bodyPartCopy2);
-        assertEquals(original, bodyPart2.getParent());
-        assertEquals(copy, bodyPartCopy2.getParent());
+        Assert.assertNotSame(bodyPart1, bodyPartCopy1);
+        Assert.assertEquals(original, bodyPart1.getParent());
+        Assert.assertEquals(copy, bodyPartCopy1.getParent());
+
+        Assert.assertNotSame(bodyPart2, bodyPartCopy2);
+        Assert.assertEquals(original, bodyPart2.getParent());
+        Assert.assertEquals(copy, bodyPartCopy2.getParent());
     }
 
+    @Test
     public void testCopyHeader() throws Exception {
         Field f1 = DefaultFieldParser.parse("name1: value1");
         Field f2 = DefaultFieldParser.parse("name2: value");
@@ -180,16 +183,16 @@ public class MimeBuilderCopyTest extends
         Header copy = builder.copy(original);
 
         // copy must have same fields as original
-        assertEquals(Arrays.asList(f1, f2, f3), copy.getFields());
-        assertEquals(Arrays.asList(f1, f3), copy.getFields("name1"));
+        Assert.assertEquals(Arrays.asList(f1, f2, f3), copy.getFields());
+        Assert.assertEquals(Arrays.asList(f1, f3), copy.getFields("name1"));
 
         // modify original
         original.removeFields("name1");
-        assertEquals(Arrays.asList(f2), original.getFields());
+        Assert.assertEquals(Arrays.asList(f2), original.getFields());
 
         // copy may not be affected
-        assertEquals(Arrays.asList(f1, f2, f3), copy.getFields());
-        assertEquals(Arrays.asList(f1, f3), copy.getFields("name1"));
+        Assert.assertEquals(Arrays.asList(f1, f2, f3), copy.getFields());
+        Assert.assertEquals(Arrays.asList(f1, f3), copy.getFields("name1"));
     }
 
 }

Modified: james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MultipartFormTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MultipartFormTest.java?rev=1426193&r1=1426192&r2=1426193&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MultipartFormTest.java (original)
+++ james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MultipartFormTest.java Thu Dec 27 13:23:54 2012
@@ -19,22 +19,21 @@
 
 package org.apache.james.mime4j.dom;
 
-import java.io.ByteArrayOutputStream;
-
-import junit.framework.TestCase;
-
-import org.apache.james.mime4j.dom.Header;
-import org.apache.james.mime4j.dom.Multipart;
 import org.apache.james.mime4j.field.DefaultFieldParser;
 import org.apache.james.mime4j.message.BasicBodyFactory;
 import org.apache.james.mime4j.message.BodyPart;
+import org.apache.james.mime4j.message.DefaultMessageWriter;
 import org.apache.james.mime4j.message.HeaderImpl;
 import org.apache.james.mime4j.message.MessageImpl;
-import org.apache.james.mime4j.message.DefaultMessageWriter;
 import org.apache.james.mime4j.message.MultipartImpl;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.io.ByteArrayOutputStream;
 
-public class MultipartFormTest extends TestCase {
+public class MultipartFormTest {
 
+    @Test
     public void testMultipartFormContent() throws Exception {
         BasicBodyFactory bodyFactory = new BasicBodyFactory();
 
@@ -72,20 +71,20 @@ public class MultipartFormTest extends T
         out.close();
 
         String expected = "--foo\r\n" +
-            "Content-Type: text/plain\r\n" +
-            "\r\n" +
-            "this stuff\r\n" +
-            "--foo\r\n" +
-            "Content-Type: text/plain\r\n" +
-            "\r\n" +
-            "that stuff\r\n" +
-            "--foo\r\n" +
-            "Content-Type: text/plain\r\n" +
-            "\r\n" +
-            "all kind of stuff\r\n" +
-            "--foo--\r\n";
+                "Content-Type: text/plain\r\n" +
+                "\r\n" +
+                "this stuff\r\n" +
+                "--foo\r\n" +
+                "Content-Type: text/plain\r\n" +
+                "\r\n" +
+                "that stuff\r\n" +
+                "--foo\r\n" +
+                "Content-Type: text/plain\r\n" +
+                "\r\n" +
+                "all kind of stuff\r\n" +
+                "--foo--\r\n";
         String s = out.toString("US-ASCII");
-        assertEquals(expected, s);
+        Assert.assertEquals(expected, s);
     }
 
 }

Modified: james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/ContentTypeFieldTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/ContentTypeFieldTest.java?rev=1426193&r1=1426192&r2=1426193&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/ContentTypeFieldTest.java (original)
+++ james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/ContentTypeFieldTest.java Thu Dec 27 13:23:54 2012
@@ -21,15 +21,14 @@ package org.apache.james.mime4j.field;
 
 import org.apache.james.mime4j.MimeException;
 import org.apache.james.mime4j.dom.field.ContentTypeField;
-import org.apache.james.mime4j.field.ContentTypeFieldImpl;
 import org.apache.james.mime4j.stream.RawField;
 import org.apache.james.mime4j.stream.RawFieldParser;
 import org.apache.james.mime4j.util.ByteSequence;
 import org.apache.james.mime4j.util.ContentUtil;
+import org.junit.Assert;
+import org.junit.Test;
 
-import junit.framework.TestCase;
-
-public class ContentTypeFieldTest extends TestCase {
+public class ContentTypeFieldTest {
 
     static ContentTypeField parse(final String s) throws MimeException {
         ByteSequence raw = ContentUtil.encode(s);
@@ -37,69 +36,75 @@ public class ContentTypeFieldTest extend
         return ContentTypeFieldImpl.PARSER.parse(rawField, null);
     }
 
-    public void testMimeTypeWithSemiColonNoParams() throws Exception  {
+    @Test
+    public void testMimeTypeWithSemiColonNoParams() throws Exception {
         ContentTypeField f = parse("Content-Type: text/html;");
-        assertEquals("text/html", f.getMimeType());
+        Assert.assertEquals("text/html", f.getMimeType());
     }
 
+    @Test
     public void testGetMimeType() throws Exception {
         ContentTypeField f = parse("Content-Type: text/PLAIN");
-        assertEquals("text/plain", f.getMimeType());
+        Assert.assertEquals("text/plain", f.getMimeType());
 
         f = parse("content-type:   TeXt / html   ");
-        assertEquals("text/html", f.getMimeType());
+        Assert.assertEquals("text/html", f.getMimeType());
 
         f = parse("CONTENT-TYPE:   x-app/yada ;"
-                                                    + "  param = yada");
-        assertEquals("x-app/yada", f.getMimeType());
+                + "  param = yada");
+        Assert.assertEquals("x-app/yada", f.getMimeType());
 
         f = parse("CONTENT-TYPE:   yada");
-        assertEquals(null, f.getMimeType());
+        Assert.assertEquals(null, f.getMimeType());
     }
 
+    @Test
     public void testGetMimeTypeStatic() throws Exception {
-        ContentTypeField child = parse("Content-Type: child/type");;
+        ContentTypeField child = parse("Content-Type: child/type");
+        ;
         ContentTypeField parent = parse("Content-Type: parent/type");
 
-        assertEquals("child/type", ContentTypeFieldImpl.getMimeType(child, parent));
+        Assert.assertEquals("child/type", ContentTypeFieldImpl.getMimeType(child, parent));
 
         child = null;
         parent = parse("Content-Type: parent/type");
-        assertEquals("text/plain", ContentTypeFieldImpl.getMimeType(child, parent));
+        Assert.assertEquals("text/plain", ContentTypeFieldImpl.getMimeType(child, parent));
         parent = parse("Content-Type: multipart/digest");
-        assertEquals("message/rfc822", ContentTypeFieldImpl.getMimeType(child, parent));
+        Assert.assertEquals("message/rfc822", ContentTypeFieldImpl.getMimeType(child, parent));
 
         child = parse("Content-Type:");
         parent = parse("Content-Type: parent/type");
-        assertEquals("text/plain", ContentTypeFieldImpl.getMimeType(child, parent));
+        Assert.assertEquals("text/plain", ContentTypeFieldImpl.getMimeType(child, parent));
         parent = parse("Content-Type: multipart/digest");
-        assertEquals("message/rfc822", ContentTypeFieldImpl.getMimeType(child, parent));
+        Assert.assertEquals("message/rfc822", ContentTypeFieldImpl.getMimeType(child, parent));
     }
 
+    @Test
     public void testGetCharsetStatic() throws Exception {
         ContentTypeField f = parse("Content-Type: some/type; charset=iso8859-1");
-        assertEquals("iso8859-1", ContentTypeFieldImpl.getCharset(f));
+        Assert.assertEquals("iso8859-1", ContentTypeFieldImpl.getCharset(f));
 
         f = parse("Content-Type: some/type;");
-        assertEquals("us-ascii", ContentTypeFieldImpl.getCharset(f));
+        Assert.assertEquals("us-ascii", ContentTypeFieldImpl.getCharset(f));
     }
 
+    @Test
     public void testGetParameter() throws Exception {
         ContentTypeField f = parse("CONTENT-TYPE:   text / html ;"
-                                                + "  boundary=yada yada");
-        assertEquals("yada", f.getParameter("boundary"));
+                + "  boundary=yada yada");
+        Assert.assertEquals("yada", f.getParameter("boundary"));
 
         f = parse("Content-Type: x-app/yada;"
-                                                + "  boUNdarY= \"ya:\\\"*da\"; "
-                                                + "\tcharset\t =  us-ascii");
-        assertEquals("ya:\"*da", f.getParameter("boundary"));
-        assertEquals("us-ascii", f.getParameter("charset"));
+                + "  boUNdarY= \"ya:\\\"*da\"; "
+                + "\tcharset\t =  us-ascii");
+        Assert.assertEquals("ya:\"*da", f.getParameter("boundary"));
+        Assert.assertEquals("us-ascii", f.getParameter("charset"));
 
         f = parse("Content-Type: x-app/yada;  "
-                            + "boUNdarY= \"ya \\\"\\\"\tda \\\"\"; "
-                            + "\tcharset\t =  \"\\\"hepp\\\"  =us\t-ascii\"");
-        assertEquals("ya \"\"\tda \"", f.getParameter("boundary"));
-        assertEquals("\"hepp\"  =us\t-ascii", f.getParameter("charset"));
+                + "boUNdarY= \"ya \\\"\\\"\tda \\\"\"; "
+                + "\tcharset\t =  \"\\\"hepp\\\"  =us\t-ascii\"");
+        Assert.assertEquals("ya \"\"\tda \"", f.getParameter("boundary"));
+        Assert.assertEquals("\"hepp\"  =us\t-ascii", f.getParameter("charset"));
     }
 
 }

Modified: james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/FieldsTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/FieldsTest.java?rev=1426193&r1=1426192&r2=1426193&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/FieldsTest.java (original)
+++ james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/FieldsTest.java Thu Dec 27 13:23:54 2012
@@ -19,15 +19,6 @@
 
 package org.apache.james.mime4j.field;
 
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.TimeZone;
-
-import junit.framework.TestCase;
-
 import org.apache.james.mime4j.dom.address.Group;
 import org.apache.james.mime4j.dom.address.Mailbox;
 import org.apache.james.mime4j.dom.field.AddressListField;
@@ -37,231 +28,259 @@ import org.apache.james.mime4j.dom.field
 import org.apache.james.mime4j.dom.field.DateTimeField;
 import org.apache.james.mime4j.dom.field.MailboxField;
 import org.apache.james.mime4j.dom.field.MailboxListField;
-import org.apache.james.mime4j.field.Fields;
 import org.apache.james.mime4j.field.address.AddressBuilder;
 import org.apache.james.mime4j.stream.Field;
 import org.apache.james.mime4j.util.ByteSequence;
 import org.apache.james.mime4j.util.ContentUtil;
 import org.apache.james.mime4j.util.MimeUtil;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.TimeZone;
 
-public class FieldsTest extends TestCase {
+public class FieldsTest {
 
+    @Test
     public void testContentTypeString() throws Exception {
         ContentTypeField field = Fields.contentType("multipart/mixed; "
                 + "boundary=\"-=Part.0.37877968dd4f6595.11eccf0271c"
                 + ".2dce5678cbc933d5=-\"");
-        assertTrue(field.isValidField());
+        Assert.assertTrue(field.isValidField());
 
         String expectedRaw = "Content-Type: multipart/mixed;\r\n "
                 + "boundary=\"-=Part.0.37877968dd4f6595.11eccf0271c"
                 + ".2dce5678cbc933d5=-\"";
-        assertEquals(expectedRaw, decode(field));
+        Assert.assertEquals(expectedRaw, decode(field));
     }
 
+    @Test
     public void testContentTypeStringParameters() throws Exception {
         Map<String, String> parameters = new HashMap<String, String>();
         parameters.put("boundary",
                 "-=Part.0.37877968dd4f6595.11eccf0271c.2dce5678cbc933d5=-");
         ContentTypeField field = Fields.contentType("multipart/mixed",
                 parameters);
-        assertTrue(field.isValidField());
+        Assert.assertTrue(field.isValidField());
 
         String expectedRaw = "Content-Type: multipart/mixed;\r\n "
                 + "boundary=\"-=Part.0.37877968dd4f6595.11eccf0271c"
                 + ".2dce5678cbc933d5=-\"";
-        assertEquals(expectedRaw, decode(field));
+        Assert.assertEquals(expectedRaw, decode(field));
     }
 
+    @Test
     public void testContentTypeStringParametersWithSpaces() throws Exception {
         Map<String, String> parameters = new HashMap<String, String>();
         parameters.put("param", "value with space chars");
         ContentTypeField field = Fields.contentType("multipart/mixed",
                 parameters);
-        assertTrue(field.isValidField());
+        Assert.assertTrue(field.isValidField());
 
         String expectedRaw = "Content-Type: multipart/mixed; "
                 + "param=\"value with space chars\"";
-        assertEquals(expectedRaw, decode(field));
+        Assert.assertEquals(expectedRaw, decode(field));
     }
 
+    @Test
     public void testContentTypeStringNullParameters() throws Exception {
         ContentTypeField field = Fields.contentType("text/plain", null);
-        assertTrue(field.isValidField());
+        Assert.assertTrue(field.isValidField());
 
         String expectedRaw = "Content-Type: text/plain";
-        assertEquals(expectedRaw, decode(field));
+        Assert.assertEquals(expectedRaw, decode(field));
     }
 
+    @Test
     public void testInvalidContentType() throws Exception {
         ContentTypeField field = Fields.contentType("multipart/mixed; "
                 + "boundary=-=Part.0.37877968dd4f6595.11eccf0271c"
                 + ".2dce5678cbc933d5=-");
-        assertFalse(field.isValidField());
+        Assert.assertFalse(field.isValidField());
 
-        assertEquals("multipart/mixed", field.getMimeType());
+        Assert.assertEquals("multipart/mixed", field.getMimeType());
     }
 
+    @Test
     public void testContentTransferEncoding() throws Exception {
         ContentTransferEncodingField field = Fields
                 .contentTransferEncoding("base64");
-        assertTrue(field.isValidField());
+        Assert.assertTrue(field.isValidField());
 
-        assertEquals("Content-Transfer-Encoding: base64",
+        Assert.assertEquals("Content-Transfer-Encoding: base64",
                 decode(field));
     }
 
+    @Test
     public void testContentDispositionString() throws Exception {
         ContentDispositionField field = Fields.contentDisposition("inline; "
                 + "filename=\"testing 1 2.dat\"; size=12345; "
                 + "creation-date=\"Thu, 1 Jan 1970 00:00:00 +0000\"");
-        assertTrue(field.isValidField());
+        Assert.assertTrue(field.isValidField());
 
         String expectedRaw = "Content-Disposition: inline; filename="
                 + "\"testing 1 2.dat\"; size=12345;\r\n creation-date="
                 + "\"Thu, 1 Jan 1970 00:00:00 +0000\"";
-        assertEquals(expectedRaw, decode(field));
+        Assert.assertEquals(expectedRaw, decode(field));
     }
 
+    @Test
     public void testContentDispositionStringParameters() throws Exception {
         Map<String, String> parameters = new HashMap<String, String>();
         parameters.put("creation-date", MimeUtil.formatDate(new Date(0),
                 TimeZone.getTimeZone("GMT")));
         ContentDispositionField field = Fields.contentDisposition("attachment",
                 parameters);
-        assertTrue(field.isValidField());
+        Assert.assertTrue(field.isValidField());
 
         String expectedRaw = "Content-Disposition: attachment; "
                 + "creation-date=\"Thu, 1 Jan 1970 00:00:00\r\n +0000\"";
-        assertEquals(expectedRaw, decode(field));
+        Assert.assertEquals(expectedRaw, decode(field));
 
-        assertEquals(new Date(0), field.getCreationDate());
+        Assert.assertEquals(new Date(0), field.getCreationDate());
     }
 
+    @Test
     public void testContentDispositionStringNullParameters() throws Exception {
         ContentDispositionField field = Fields.contentDisposition("inline",
                 (Map<String, String>) null);
-        assertTrue(field.isValidField());
+        Assert.assertTrue(field.isValidField());
 
         String expectedRaw = "Content-Disposition: inline";
-        assertEquals(expectedRaw, decode(field));
+        Assert.assertEquals(expectedRaw, decode(field));
     }
 
+    @Test
     public void testContentDispositionFilename() throws Exception {
         ContentDispositionField field = Fields.contentDisposition("attachment",
                 "some file.dat");
-        assertTrue(field.isValidField());
+        Assert.assertTrue(field.isValidField());
 
-        assertEquals("attachment", field.getDispositionType());
-        assertEquals("some file.dat", field.getFilename());
+        Assert.assertEquals("attachment", field.getDispositionType());
+        Assert.assertEquals("some file.dat", field.getFilename());
     }
 
+    @Test
     public void testContentDispositionFilenameSize() throws Exception {
         ContentDispositionField field = Fields.contentDisposition("attachment",
                 "some file.dat", 300);
-        assertTrue(field.isValidField());
+        Assert.assertTrue(field.isValidField());
 
-        assertEquals("attachment", field.getDispositionType());
-        assertEquals("some file.dat", field.getFilename());
-        assertEquals(300, field.getSize());
+        Assert.assertEquals("attachment", field.getDispositionType());
+        Assert.assertEquals("some file.dat", field.getFilename());
+        Assert.assertEquals(300, field.getSize());
     }
 
+    @Test
     public void testContentDispositionFilenameSizeDate() throws Exception {
         ContentDispositionField field = Fields.contentDisposition("attachment",
                 "some file.dat", 300, new Date(1000), new Date(2000), new Date(
-                        3000));
-        assertTrue(field.isValidField());
+                3000));
+        Assert.assertTrue(field.isValidField());
 
-        assertEquals("attachment", field.getDispositionType());
-        assertEquals("some file.dat", field.getFilename());
-        assertEquals(300, field.getSize());
-        assertEquals(new Date(1000), field.getCreationDate());
-        assertEquals(new Date(2000), field.getModificationDate());
-        assertEquals(new Date(3000), field.getReadDate());
+        Assert.assertEquals("attachment", field.getDispositionType());
+        Assert.assertEquals("some file.dat", field.getFilename());
+        Assert.assertEquals(300, field.getSize());
+        Assert.assertEquals(new Date(1000), field.getCreationDate());
+        Assert.assertEquals(new Date(2000), field.getModificationDate());
+        Assert.assertEquals(new Date(3000), field.getReadDate());
     }
 
+    @Test
     public void testInvalidContentDisposition() throws Exception {
         ContentDispositionField field = Fields.contentDisposition("inline; "
                 + "filename=some file.dat");
-        assertFalse(field.isValidField());
+        Assert.assertFalse(field.isValidField());
 
-        assertEquals("inline", field.getDispositionType());
+        Assert.assertEquals("inline", field.getDispositionType());
     }
 
+    @Test
     public void testDateStringDateTimeZone() throws Exception {
         DateTimeField field = Fields.date("Date", new Date(0), TimeZone
                 .getTimeZone("GMT"));
-        assertTrue(field.isValidField());
+        Assert.assertTrue(field.isValidField());
 
-        assertEquals("Date: Thu, 1 Jan 1970 00:00:00 +0000", decode(field
-                ));
-        assertEquals(new Date(0), field.getDate());
+        Assert.assertEquals("Date: Thu, 1 Jan 1970 00:00:00 +0000", decode(field
+        ));
+        Assert.assertEquals(new Date(0), field.getDate());
 
         field = Fields.date("Resent-Date", new Date(0), TimeZone
                 .getTimeZone("GMT+1"));
-        assertTrue(field.isValidField());
+        Assert.assertTrue(field.isValidField());
 
-        assertEquals("Resent-Date: Thu, 1 Jan 1970 01:00:00 +0100",
+        Assert.assertEquals("Resent-Date: Thu, 1 Jan 1970 01:00:00 +0100",
                 decode(field));
-        assertEquals(new Date(0), field.getDate());
+        Assert.assertEquals(new Date(0), field.getDate());
     }
 
+    @Test
     public void testDateDST() throws Exception {
         long millis = 1216221153000l;
         DateTimeField field = Fields.date("Date", new Date(millis), TimeZone
                 .getTimeZone("CET"));
-        assertTrue(field.isValidField());
+        Assert.assertTrue(field.isValidField());
 
-        assertEquals("Date: Wed, 16 Jul 2008 17:12:33 +0200", decode(field
-                ));
-        assertEquals(new Date(millis), field.getDate());
+        Assert.assertEquals("Date: Wed, 16 Jul 2008 17:12:33 +0200", decode(field
+        ));
+        Assert.assertEquals(new Date(millis), field.getDate());
     }
 
+    @Test
     public void testMessageId() throws Exception {
         Field messageId = Fields.messageId("acme.org");
 
         String raw = decode(messageId);
-        assertTrue(raw.startsWith("Message-ID: <Mime4j."));
-        assertTrue(raw.endsWith("@acme.org>"));
+        Assert.assertTrue(raw.startsWith("Message-ID: <Mime4j."));
+        Assert.assertTrue(raw.endsWith("@acme.org>"));
     }
 
+    @Test
     public void testSubject() throws Exception {
-        assertEquals("Subject: ", decode(Fields.subject("")));
-        assertEquals("Subject: test", decode(Fields.subject("test")));
-        assertEquals("Subject: =?ISO-8859-1?Q?Sm=F8rebr=F8d?=", decode(Fields
+        Assert.assertEquals("Subject: ", decode(Fields.subject("")));
+        Assert.assertEquals("Subject: test", decode(Fields.subject("test")));
+        Assert.assertEquals("Subject: =?ISO-8859-1?Q?Sm=F8rebr=F8d?=", decode(Fields
                 .subject("Sm\370rebr\370d")));
 
         String seventyEight = "12345678901234567890123456789012345678901234567890123456789012345678";
-        assertEquals("Subject:\r\n " + seventyEight, decode(Fields.subject(
+        Assert.assertEquals("Subject:\r\n " + seventyEight, decode(Fields.subject(
                 seventyEight)));
 
         String seventyNine = seventyEight + "9";
         String expected = "Subject: =?US-ASCII?Q?1234567890123456789012345678901234?="
                 + "\r\n =?US-ASCII?Q?56789012345678901234567890123456789?=";
-        assertEquals(expected, decode(Fields.subject(seventyNine)));
+        Assert.assertEquals(expected, decode(Fields.subject(seventyNine)));
     }
 
+    @Test
     public void testSender() throws Exception {
         MailboxField field = Fields.sender(AddressBuilder.DEFAULT
                 .parseMailbox("JD <john.doe@acme.org>"));
-        assertEquals("Sender: JD <john.doe@acme.org>", decode(field));
+        Assert.assertEquals("Sender: JD <john.doe@acme.org>", decode(field));
     }
 
+    @Test
     public void testFrom() throws Exception {
         Mailbox mailbox1 = AddressBuilder.DEFAULT.parseMailbox("JD <john.doe@acme.org>");
         Mailbox mailbox2 = AddressBuilder.DEFAULT.parseMailbox("Mary Smith <mary@example.net>");
 
         MailboxListField field = Fields.from(mailbox1);
-        assertEquals("From: JD <john.doe@acme.org>", decode(field));
+        Assert.assertEquals("From: JD <john.doe@acme.org>", decode(field));
 
         field = Fields.from(mailbox1, mailbox2);
-        assertEquals("From: JD <john.doe@acme.org>, "
+        Assert.assertEquals("From: JD <john.doe@acme.org>, "
                 + "Mary Smith <mary@example.net>", decode(field));
 
         field = Fields.from(Arrays.asList(mailbox1, mailbox2));
-        assertEquals("From: JD <john.doe@acme.org>, "
+        Assert.assertEquals("From: JD <john.doe@acme.org>, "
                 + "Mary Smith <mary@example.net>", decode(field));
     }
 
+    @Test
     public void testTo() throws Exception {
         Mailbox mailbox1 = AddressBuilder.DEFAULT.parseMailbox("JD <john.doe@acme.org>");
         Mailbox mailbox2 = AddressBuilder.DEFAULT.parseMailbox("jane.doe@example.org");
@@ -269,20 +288,21 @@ public class FieldsTest extends TestCase
         Group group = new Group("The Does", mailbox1, mailbox2);
 
         AddressListField field = Fields.to(group);
-        assertEquals("To: The Does: JD <john.doe@acme.org>, "
+        Assert.assertEquals("To: The Does: JD <john.doe@acme.org>, "
                 + "jane.doe@example.org;", decode(field));
 
         field = Fields.to(group, mailbox3);
-        assertEquals("To: The Does: JD <john.doe@acme.org>, "
+        Assert.assertEquals("To: The Does: JD <john.doe@acme.org>, "
                 + "jane.doe@example.org;, Mary Smith\r\n <mary@example.net>",
                 decode(field));
 
         field = Fields.to(Arrays.asList(group, mailbox3));
-        assertEquals("To: The Does: JD <john.doe@acme.org>, "
+        Assert.assertEquals("To: The Does: JD <john.doe@acme.org>, "
                 + "jane.doe@example.org;, Mary Smith\r\n <mary@example.net>",
                 decode(field));
     }
 
+    @Test
     public void testCc() throws Exception {
         Mailbox mailbox1 = AddressBuilder.DEFAULT.parseMailbox("JD <john.doe@acme.org>");
         Mailbox mailbox2 = AddressBuilder.DEFAULT.parseMailbox("jane.doe@example.org");
@@ -290,20 +310,21 @@ public class FieldsTest extends TestCase
         Group group = new Group("The Does", mailbox1, mailbox2);
 
         AddressListField field = Fields.cc(group);
-        assertEquals("Cc: The Does: JD <john.doe@acme.org>, "
+        Assert.assertEquals("Cc: The Does: JD <john.doe@acme.org>, "
                 + "jane.doe@example.org;", decode(field));
 
         field = Fields.cc(group, mailbox3);
-        assertEquals("Cc: The Does: JD <john.doe@acme.org>, "
+        Assert.assertEquals("Cc: The Does: JD <john.doe@acme.org>, "
                 + "jane.doe@example.org;, Mary Smith\r\n <mary@example.net>",
                 decode(field));
 
         field = Fields.cc(Arrays.asList(group, mailbox3));
-        assertEquals("Cc: The Does: JD <john.doe@acme.org>, "
+        Assert.assertEquals("Cc: The Does: JD <john.doe@acme.org>, "
                 + "jane.doe@example.org;, Mary Smith\r\n <mary@example.net>",
                 decode(field));
     }
 
+    @Test
     public void testBcc() throws Exception {
         Mailbox mailbox1 = AddressBuilder.DEFAULT.parseMailbox("JD <john.doe@acme.org>");
         Mailbox mailbox2 = AddressBuilder.DEFAULT.parseMailbox("jane.doe@example.org");
@@ -311,20 +332,21 @@ public class FieldsTest extends TestCase
         Group group = new Group("The Does", mailbox1, mailbox2);
 
         AddressListField field = Fields.bcc(group);
-        assertEquals("Bcc: The Does: JD <john.doe@acme.org>, "
+        Assert.assertEquals("Bcc: The Does: JD <john.doe@acme.org>, "
                 + "jane.doe@example.org;", decode(field));
 
         field = Fields.bcc(group, mailbox3);
-        assertEquals("Bcc: The Does: JD <john.doe@acme.org>, "
+        Assert.assertEquals("Bcc: The Does: JD <john.doe@acme.org>, "
                 + "jane.doe@example.org;, Mary Smith\r\n <mary@example.net>",
                 decode(field));
 
         field = Fields.bcc(Arrays.asList(group, mailbox3));
-        assertEquals("Bcc: The Does: JD <john.doe@acme.org>, "
+        Assert.assertEquals("Bcc: The Does: JD <john.doe@acme.org>, "
                 + "jane.doe@example.org;, Mary Smith\r\n <mary@example.net>",
                 decode(field));
     }
 
+    @Test
     public void testReplyTo() throws Exception {
         Mailbox mailbox1 = AddressBuilder.DEFAULT.parseMailbox("JD <john.doe@acme.org>");
         Mailbox mailbox2 = AddressBuilder.DEFAULT.parseMailbox("jane.doe@example.org");
@@ -332,36 +354,39 @@ public class FieldsTest extends TestCase
         Group group = new Group("The Does", mailbox1, mailbox2);
 
         AddressListField field = Fields.replyTo(group);
-        assertEquals("Reply-To: The Does: JD <john.doe@acme.org>, "
+        Assert.assertEquals("Reply-To: The Does: JD <john.doe@acme.org>, "
                 + "jane.doe@example.org;", decode(field));
 
         field = Fields.replyTo(group, mailbox3);
-        assertEquals("Reply-To: The Does: JD <john.doe@acme.org>, "
+        Assert.assertEquals("Reply-To: The Does: JD <john.doe@acme.org>, "
                 + "jane.doe@example.org;, Mary\r\n Smith <mary@example.net>",
                 decode(field));
 
         field = Fields.replyTo(Arrays.asList(group, mailbox3));
-        assertEquals("Reply-To: The Does: JD <john.doe@acme.org>, "
+        Assert.assertEquals("Reply-To: The Does: JD <john.doe@acme.org>, "
                 + "jane.doe@example.org;, Mary\r\n Smith <mary@example.net>",
                 decode(field));
     }
 
+    @Test
     public void testMailbox() throws Exception {
         MailboxField field = Fields.mailbox("Resent-Sender", AddressBuilder.DEFAULT
                 .parseMailbox("JD <john.doe@acme.org>"));
-        assertEquals("Resent-Sender: JD <john.doe@acme.org>", decode(field));
+        Assert.assertEquals("Resent-Sender: JD <john.doe@acme.org>", decode(field));
     }
 
+    @Test
     public void testMailboxList() throws Exception {
         Mailbox mailbox1 = AddressBuilder.DEFAULT.parseMailbox("JD <john.doe@acme.org>");
         Mailbox mailbox2 = AddressBuilder.DEFAULT.parseMailbox("Mary Smith <mary@example.net>");
 
         MailboxListField field = Fields.mailboxList("Resent-From", Arrays
                 .asList(mailbox1, mailbox2));
-        assertEquals("Resent-From: JD <john.doe@acme.org>, "
+        Assert.assertEquals("Resent-From: JD <john.doe@acme.org>, "
                 + "Mary Smith <mary@example.net>", decode(field));
     }
 
+    @Test
     public void testAddressList() throws Exception {
         Mailbox mailbox1 = AddressBuilder.DEFAULT.parseMailbox("JD <john.doe@acme.org>");
         Mailbox mailbox2 = AddressBuilder.DEFAULT.parseMailbox("jane.doe@example.org");
@@ -370,15 +395,16 @@ public class FieldsTest extends TestCase
 
         AddressListField field = Fields.addressList("Resent-To", Arrays.asList(
                 group, mailbox3));
-        assertEquals("Resent-To: The Does: JD <john.doe@acme.org>, "
+        Assert.assertEquals("Resent-To: The Does: JD <john.doe@acme.org>, "
                 + "jane.doe@example.org;, Mary\r\n Smith <mary@example.net>",
                 decode(field));
     }
 
+    @Test
     public void testInvalidFieldName() throws Exception {
         try {
             Fields.date("invalid field name", new Date());
-            fail();
+            Assert.fail();
         } catch (IllegalArgumentException expected) {
         }
     }

Modified: james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/LenientContentDispositionFieldTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/LenientContentDispositionFieldTest.java?rev=1426193&r1=1426192&r2=1426193&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/LenientContentDispositionFieldTest.java (original)
+++ james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/LenientContentDispositionFieldTest.java Thu Dec 27 13:23:54 2012
@@ -19,18 +19,18 @@
 
 package org.apache.james.mime4j.field;
 
-import java.util.Date;
-
-import junit.framework.TestCase;
-
 import org.apache.james.mime4j.MimeException;
 import org.apache.james.mime4j.dom.field.ContentDispositionField;
 import org.apache.james.mime4j.stream.RawField;
 import org.apache.james.mime4j.stream.RawFieldParser;
 import org.apache.james.mime4j.util.ByteSequence;
 import org.apache.james.mime4j.util.ContentUtil;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.Date;
 
-public class LenientContentDispositionFieldTest extends TestCase {
+public class LenientContentDispositionFieldTest {
 
     static ContentDispositionField parse(final String s) throws MimeException {
         ByteSequence raw = ContentUtil.encode(s);
@@ -38,131 +38,140 @@ public class LenientContentDispositionFi
         return ContentDispositionFieldLenientImpl.PARSER.parse(rawField, null);
     }
 
+    @Test
     public void testDispositionTypeWithSemiColonNoParams() throws Exception {
         ContentDispositionField f = parse("Content-Disposition: inline;");
-        assertEquals("inline", f.getDispositionType());
+        Assert.assertEquals("inline", f.getDispositionType());
     }
 
+    @Test
     public void testGetDispositionType() throws Exception {
         ContentDispositionField f = parse("Content-Disposition: attachment");
-        assertEquals("attachment", f.getDispositionType());
+        Assert.assertEquals("attachment", f.getDispositionType());
 
         f = parse("content-disposition:   InLiNe   ");
-        assertEquals("inline", f.getDispositionType());
+        Assert.assertEquals("inline", f.getDispositionType());
 
         f = parse("CONTENT-DISPOSITION:   x-yada ;" + "  param = yada");
-        assertEquals("x-yada", f.getDispositionType());
+        Assert.assertEquals("x-yada", f.getDispositionType());
 
         f = parse("CONTENT-DISPOSITION:   ");
-        assertEquals("", f.getDispositionType());
+        Assert.assertEquals("", f.getDispositionType());
     }
 
+    @Test
     public void testGetParameter() throws Exception {
         ContentDispositionField f = parse("CONTENT-DISPOSITION:   inline ;"
-                        + "  filename=yada yada");
-        assertEquals("yada yada", f.getParameter("filename"));
+                + "  filename=yada yada");
+        Assert.assertEquals("yada yada", f.getParameter("filename"));
 
         f = parse("Content-Disposition: x-yada;"
-                        + "  fileNAme= \"ya:\\\"*da\"; " + "\tSIZE\t =  1234");
-        assertEquals("ya:\"*da", f.getParameter("filename"));
-        assertEquals("1234", f.getParameter("size"));
+                + "  fileNAme= \"ya:\\\"*da\"; " + "\tSIZE\t =  1234");
+        Assert.assertEquals("ya:\"*da", f.getParameter("filename"));
+        Assert.assertEquals("1234", f.getParameter("size"));
 
         f = parse("Content-Disposition: x-yada;  "
-                        + "fileNAme= \"ya \\\"\\\"\tda \\\"\"; "
-                        + "\tx-Yada\t =  \"\\\"hepp\\\"  =us\t-ascii\"");
-        assertEquals("ya \"\"\tda \"", f.getParameter("filename"));
-        assertEquals("\"hepp\"  =us\t-ascii", f.getParameter("x-yada"));
+                + "fileNAme= \"ya \\\"\\\"\tda \\\"\"; "
+                + "\tx-Yada\t =  \"\\\"hepp\\\"  =us\t-ascii\"");
+        Assert.assertEquals("ya \"\"\tda \"", f.getParameter("filename"));
+        Assert.assertEquals("\"hepp\"  =us\t-ascii", f.getParameter("x-yada"));
     }
 
+    @Test
     public void testIsDispositionType() throws Exception {
         ContentDispositionField f = parse("Content-Disposition:INline");
-        assertTrue(f.isDispositionType("InLiNe"));
-        assertFalse(f.isDispositionType("NiLiNe"));
-        assertTrue(f.isInline());
-        assertFalse(f.isAttachment());
+        Assert.assertTrue(f.isDispositionType("InLiNe"));
+        Assert.assertFalse(f.isDispositionType("NiLiNe"));
+        Assert.assertTrue(f.isInline());
+        Assert.assertFalse(f.isAttachment());
 
         f = parse("Content-Disposition: attachment");
-        assertTrue(f.isDispositionType("ATTACHMENT"));
-        assertFalse(f.isInline());
-        assertTrue(f.isAttachment());
+        Assert.assertTrue(f.isDispositionType("ATTACHMENT"));
+        Assert.assertFalse(f.isInline());
+        Assert.assertTrue(f.isAttachment());
 
         f = parse("Content-Disposition: x-something");
-        assertTrue(f.isDispositionType("x-SomeThing"));
-        assertFalse(f.isInline());
-        assertFalse(f.isAttachment());
+        Assert.assertTrue(f.isDispositionType("x-SomeThing"));
+        Assert.assertFalse(f.isInline());
+        Assert.assertFalse(f.isAttachment());
     }
 
+    @Test
     public void testGetFilename() throws Exception {
         ContentDispositionField f = parse("Content-Disposition: inline; filename=yada.txt");
-        assertEquals("yada.txt", f.getFilename());
+        Assert.assertEquals("yada.txt", f.getFilename());
 
         f = parse("Content-Disposition: inline; filename=yada yada.txt");
-        assertEquals("yada yada.txt", f.getFilename());
+        Assert.assertEquals("yada yada.txt", f.getFilename());
 
         f = parse("Content-Disposition: inline; filename=\"yada yada.txt\"");
-        assertEquals("yada yada.txt", f.getFilename());
+        Assert.assertEquals("yada yada.txt", f.getFilename());
 
         f = parse("Content-Disposition: inline");
-        assertNull(f.getFilename());
+        Assert.assertNull(f.getFilename());
     }
 
+    @Test
     public void testGetCreationDate() throws Exception {
         ContentDispositionField f = parse("Content-Disposition: inline; "
-                        + "creation-date=\"Tue, 01 Jan 1970 00:00:00 +0000\"");
-        assertEquals(new Date(0), f.getCreationDate());
+                + "creation-date=\"Tue, 01 Jan 1970 00:00:00 +0000\"");
+        Assert.assertEquals(new Date(0), f.getCreationDate());
 
         f = parse("Content-Disposition: inline; "
-                        + "creation-date=Tue, 01 Jan 1970 00:00:00 +0000");
-        assertEquals(new Date(0), f.getCreationDate());
+                + "creation-date=Tue, 01 Jan 1970 00:00:00 +0000");
+        Assert.assertEquals(new Date(0), f.getCreationDate());
 
         f = parse("Content-Disposition: attachment");
-        assertNull(f.getCreationDate());
+        Assert.assertNull(f.getCreationDate());
     }
 
+    @Test
     public void testGetModificationDate() throws Exception {
         ContentDispositionField f = parse("Content-Disposition: inline; "
-                        + "modification-date=\"Tue, 01 Jan 1970 00:00:00 +0000\"");
-        assertEquals(new Date(0), f.getModificationDate());
+                + "modification-date=\"Tue, 01 Jan 1970 00:00:00 +0000\"");
+        Assert.assertEquals(new Date(0), f.getModificationDate());
 
         f = parse("Content-Disposition: inline; "
-                        + "modification-date=\"Wed, 12 Feb 1997 16:29:51 -0500\"");
-        assertEquals(new Date(855782991000l), f.getModificationDate());
+                + "modification-date=\"Wed, 12 Feb 1997 16:29:51 -0500\"");
+        Assert.assertEquals(new Date(855782991000l), f.getModificationDate());
 
         f = parse("Content-Disposition: inline; "
-                        + "modification-date=yesterday");
-        assertNull(f.getModificationDate());
+                + "modification-date=yesterday");
+        Assert.assertNull(f.getModificationDate());
 
         f = parse("Content-Disposition: attachment");
-        assertNull(f.getModificationDate());
+        Assert.assertNull(f.getModificationDate());
     }
 
+    @Test
     public void testGetReadDate() throws Exception {
         ContentDispositionField f = parse("Content-Disposition: inline; "
-                        + "read-date=\"Tue, 01 Jan 1970 00:00:00 +0000\"");
-        assertEquals(new Date(0), f.getReadDate());
+                + "read-date=\"Tue, 01 Jan 1970 00:00:00 +0000\"");
+        Assert.assertEquals(new Date(0), f.getReadDate());
 
         f = parse("Content-Disposition: inline; read-date=");
-        assertNull(f.getReadDate());
+        Assert.assertNull(f.getReadDate());
 
         f = parse("Content-Disposition: attachment");
-        assertNull(f.getReadDate());
+        Assert.assertNull(f.getReadDate());
     }
 
+    @Test
     public void testGetSize() throws Exception {
         ContentDispositionField f = parse("Content-Disposition: attachment; size=0");
-        assertEquals(0, f.getSize());
+        Assert.assertEquals(0, f.getSize());
 
         f = parse("Content-Disposition: attachment; size=matters");
-        assertEquals(-1, f.getSize());
+        Assert.assertEquals(-1, f.getSize());
 
         f = parse("Content-Disposition: attachment");
-        assertEquals(-1, f.getSize());
+        Assert.assertEquals(-1, f.getSize());
 
         f = parse("Content-Disposition: attachment; size=-12");
-        assertEquals(-1, f.getSize());
+        Assert.assertEquals(-1, f.getSize());
 
         f = parse("Content-Disposition: attachment; size=12");
-        assertEquals(12, f.getSize());
+        Assert.assertEquals(12, f.getSize());
     }
 
 }

Modified: james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/LenientContentLanguageFieldTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/LenientContentLanguageFieldTest.java?rev=1426193&r1=1426192&r2=1426193&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/LenientContentLanguageFieldTest.java (original)
+++ james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/LenientContentLanguageFieldTest.java Thu Dec 27 13:23:54 2012
@@ -19,18 +19,18 @@
 
 package org.apache.james.mime4j.field;
 
-import java.util.List;
-
 import org.apache.james.mime4j.MimeException;
 import org.apache.james.mime4j.dom.field.ContentLanguageField;
 import org.apache.james.mime4j.stream.RawField;
 import org.apache.james.mime4j.stream.RawFieldParser;
 import org.apache.james.mime4j.util.ByteSequence;
 import org.apache.james.mime4j.util.ContentUtil;
+import org.junit.Assert;
+import org.junit.Test;
 
-import junit.framework.TestCase;
+import java.util.List;
 
-public class LenientContentLanguageFieldTest extends TestCase {
+public class LenientContentLanguageFieldTest {
 
     static ContentLanguageField parse(final String s) throws MimeException {
         ByteSequence raw = ContentUtil.encode(s);
@@ -38,47 +38,52 @@ public class LenientContentLanguageField
         return ContentLanguageFieldLenientImpl.PARSER.parse(rawField, null);
     }
 
+    @Test
     public void testGetLanguage() throws Exception {
         ContentLanguageField f = parse("Content-Language: en, de");
         List<String> langs = f.getLanguages();
-        assertNotNull(langs);
-        assertEquals(2, langs.size());
-        assertEquals("en", langs.get(0));
-        assertEquals("de", langs.get(1));
+        Assert.assertNotNull(langs);
+        Assert.assertEquals(2, langs.size());
+        Assert.assertEquals("en", langs.get(0));
+        Assert.assertEquals("de", langs.get(1));
     }
 
+    @Test
     public void testGetLanguageEmpty() throws Exception {
         ContentLanguageField f = parse("Content-Language: ");
         List<String> langs = f.getLanguages();
-        assertNotNull(langs);
-        assertEquals(0, langs.size());
+        Assert.assertNotNull(langs);
+        Assert.assertEquals(0, langs.size());
     }
 
+    @Test
     public void testGetLanguageWithComments() throws Exception {
         ContentLanguageField f = parse("Content-Language: en (yada yada), (blah blah)de");
         List<String> langs = f.getLanguages();
-        assertNotNull(langs);
-        assertEquals(2, langs.size());
-        assertEquals("en", langs.get(0));
-        assertEquals("de", langs.get(1));
+        Assert.assertNotNull(langs);
+        Assert.assertEquals(2, langs.size());
+        Assert.assertEquals("en", langs.get(0));
+        Assert.assertEquals("de", langs.get(1));
     }
 
+    @Test
     public void testGetLanguageWithUnderscore() throws Exception {
         ContentLanguageField f = parse("Content-Language: en, en_GB (Great Britain)");
         List<String> langs = f.getLanguages();
-        assertNotNull(langs);
-        assertEquals(2, langs.size());
-        assertEquals("en", langs.get(0));
-        assertEquals("en_GB", langs.get(1));
+        Assert.assertNotNull(langs);
+        Assert.assertEquals(2, langs.size());
+        Assert.assertEquals("en", langs.get(0));
+        Assert.assertEquals("en_GB", langs.get(1));
     }
 
+    @Test
     public void testGetLanguageWithEmptyElement() throws Exception {
         ContentLanguageField f = parse("Content-Language: en,, de,");
         List<String> langs = f.getLanguages();
-        assertNotNull(langs);
-        assertEquals(2, langs.size());
-        assertEquals("en", langs.get(0));
-        assertEquals("de", langs.get(1));
+        Assert.assertNotNull(langs);
+        Assert.assertEquals(2, langs.size());
+        Assert.assertEquals("en", langs.get(0));
+        Assert.assertEquals("de", langs.get(1));
     }
 
 }

Modified: james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/LenientContentLocationFieldTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/LenientContentLocationFieldTest.java?rev=1426193&r1=1426192&r2=1426193&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/LenientContentLocationFieldTest.java (original)
+++ james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/LenientContentLocationFieldTest.java Thu Dec 27 13:23:54 2012
@@ -25,10 +25,10 @@ import org.apache.james.mime4j.stream.Ra
 import org.apache.james.mime4j.stream.RawFieldParser;
 import org.apache.james.mime4j.util.ByteSequence;
 import org.apache.james.mime4j.util.ContentUtil;
+import org.junit.Assert;
+import org.junit.Test;
 
-import junit.framework.TestCase;
-
-public class LenientContentLocationFieldTest extends TestCase {
+public class LenientContentLocationFieldTest {
 
     static ContentLocationField parse(final String s) throws MimeException {
         ByteSequence raw = ContentUtil.encode(s);
@@ -36,28 +36,32 @@ public class LenientContentLocationField
         return ContentLocationFieldLenientImpl.PARSER.parse(rawField, null);
     }
 
+    @Test
     public void testGetSimpleLocation() throws Exception {
         ContentLocationField f = parse("Content-Location: stuff");
         String location = f.getLocation();
-        assertEquals("stuff", location);
+        Assert.assertEquals("stuff", location);
     }
 
+    @Test
     public void testGetQuotedLocation() throws Exception {
         ContentLocationField f = parse("Content-Location: \" stuff \"");
         String location = f.getLocation();
-        assertEquals("stuff", location);
+        Assert.assertEquals("stuff", location);
     }
 
+    @Test
     public void testGetLocationWithBlanks() throws Exception {
         ContentLocationField f = parse("Content-Location: this / that \t/what not");
         String location = f.getLocation();
-        assertEquals("this/that/whatnot", location);
+        Assert.assertEquals("this/that/whatnot", location);
     }
 
+    @Test
     public void testGetLocationWithCommens() throws Exception {
         ContentLocationField f = parse("Content-Location: this(blah) / that (yada) /what not");
         String location = f.getLocation();
-        assertEquals("this/that/whatnot", location);
+        Assert.assertEquals("this/that/whatnot", location);
     }
 
 }

Modified: james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/LenientContentTypeFieldTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/LenientContentTypeFieldTest.java?rev=1426193&r1=1426192&r2=1426193&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/LenientContentTypeFieldTest.java (original)
+++ james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/LenientContentTypeFieldTest.java Thu Dec 27 13:23:54 2012
@@ -25,10 +25,10 @@ import org.apache.james.mime4j.stream.Ra
 import org.apache.james.mime4j.stream.RawFieldParser;
 import org.apache.james.mime4j.util.ByteSequence;
 import org.apache.james.mime4j.util.ContentUtil;
+import org.junit.Assert;
+import org.junit.Test;
 
-import junit.framework.TestCase;
-
-public class LenientContentTypeFieldTest extends TestCase {
+public class LenientContentTypeFieldTest {
 
     static ContentTypeField parse(final String s) throws MimeException {
         ByteSequence raw = ContentUtil.encode(s);
@@ -36,55 +36,60 @@ public class LenientContentTypeFieldTest
         return ContentTypeFieldLenientImpl.PARSER.parse(rawField, null);
     }
 
-    public void testMimeTypeWithSemiColonNoParams() throws Exception  {
+    @Test
+    public void testMimeTypeWithSemiColonNoParams() throws Exception {
         ContentTypeField f = parse("Content-Type: text/html;");
-        assertEquals("text/html", f.getMimeType());
+        Assert.assertEquals("text/html", f.getMimeType());
     }
 
-    public void testMimeTypeWithMultipleSemiColon() throws Exception  {
+    @Test
+    public void testMimeTypeWithMultipleSemiColon() throws Exception {
         ContentTypeField f = parse("Content-Type: text/html;;;");
-        assertEquals("text/html", f.getMimeType());
-        assertEquals(1, f.getParameters().size());
+        Assert.assertEquals("text/html", f.getMimeType());
+        Assert.assertEquals(1, f.getParameters().size());
     }
 
-    public void testMimeTypeWithNonameParam() throws Exception  {
+    @Test
+    public void testMimeTypeWithNonameParam() throws Exception {
         ContentTypeField f = parse("Content-Type: text/html;=stuff");
-        assertEquals("text/html", f.getMimeType());
-        assertEquals(1, f.getParameters().size());
-        assertEquals("stuff", f.getParameter(""));
+        Assert.assertEquals("text/html", f.getMimeType());
+        Assert.assertEquals(1, f.getParameters().size());
+        Assert.assertEquals("stuff", f.getParameter(""));
     }
 
+    @Test
     public void testGetMimeType() throws Exception {
         ContentTypeField f = parse("Content-Type: text/PLAIN");
-        assertEquals("text/plain", f.getMimeType());
+        Assert.assertEquals("text/plain", f.getMimeType());
 
         f = parse("content-type:   TeXt / html   ");
-        assertEquals("text/html", f.getMimeType());
+        Assert.assertEquals("text/html", f.getMimeType());
 
         f = parse("CONTENT-TYPE:   x-app/yada ;"
-                                                    + "  param = yada");
-        assertEquals("x-app/yada", f.getMimeType());
+                + "  param = yada");
+        Assert.assertEquals("x-app/yada", f.getMimeType());
 
         f = parse("CONTENT-TYPE:   yada");
-        assertEquals(null, f.getMimeType());
+        Assert.assertEquals(null, f.getMimeType());
     }
 
+    @Test
     public void testGetParameter() throws Exception {
         ContentTypeField f = parse("CONTENT-TYPE:   text / html ;"
-                                                + "  boundary=yada yada");
-        assertEquals("yada yada", f.getParameter("boundary"));
+                + "  boundary=yada yada");
+        Assert.assertEquals("yada yada", f.getParameter("boundary"));
 
         f = parse("Content-Type: x-app/yada;"
-                                                + "  boUNdarY= \"ya:\\\"*da\"; "
-                                                + "\tcharset\t =  us-ascii");
-        assertEquals("ya:\"*da", f.getParameter("boundary"));
-        assertEquals("us-ascii", f.getParameter("charset"));
+                + "  boUNdarY= \"ya:\\\"*da\"; "
+                + "\tcharset\t =  us-ascii");
+        Assert.assertEquals("ya:\"*da", f.getParameter("boundary"));
+        Assert.assertEquals("us-ascii", f.getParameter("charset"));
 
         f = parse("Content-Type: x-app/yada;  "
-                            + "boUNdarY= \"ya \\\"\\\"\tda \\\"\"; "
-                            + "\tcharset\t =  \"\\\"hepp\\\"  =us\t-ascii\"");
-        assertEquals("ya \"\"\tda \"", f.getParameter("boundary"));
-        assertEquals("\"hepp\"  =us\t-ascii", f.getParameter("charset"));
+                + "boUNdarY= \"ya \\\"\\\"\tda \\\"\"; "
+                + "\tcharset\t =  \"\\\"hepp\\\"  =us\t-ascii\"");
+        Assert.assertEquals("ya \"\"\tda \"", f.getParameter("boundary"));
+        Assert.assertEquals("\"hepp\"  =us\t-ascii", f.getParameter("charset"));
     }
 
 }



Mime
View raw message