1 19 20 21 package org.apache.james.transport.mailets; 22 23 import junit.framework.TestCase; 24 import org.apache.james.test.mock.mailet.MockMailContext; 25 import org.apache.james.test.mock.mailet.MockMailetConfig; 26 import org.apache.james.test.util.Util; 27 import org.apache.mailet.Mail; 28 import org.apache.mailet.Mailet; 29 30 import javax.mail.MessagingException ; 31 import javax.mail.internet.MimeMessage ; 32 import javax.mail.internet.ParseException ; 33 import java.io.UnsupportedEncodingException ; 34 35 public class RemoveAllMailAttributesTest extends TestCase { 36 37 private Mail mockedMail; 38 39 private Mailet mailet; 40 41 public RemoveAllMailAttributesTest(String arg0) 42 throws UnsupportedEncodingException { 43 super(arg0); 44 } 45 46 private void setupMockedMail(MimeMessage m) throws ParseException { 47 mockedMail = Util.createMockMail2Recipients(m); 48 mockedMail.setAttribute("org.apache.james.test.junit", "true"); 49 50 } 51 52 private void setupMailet() throws MessagingException { 53 mailet = new RemoveAllMailAttributes(); 54 MockMailetConfig mci = new MockMailetConfig("Test", 55 new MockMailContext()); 56 mailet.init(mci); 57 } 58 59 public void testRemoveAllMailAttributes() throws MessagingException { 61 setupMockedMail(null); 62 setupMailet(); 63 64 assertTrue(mockedMail.getAttributeNames().hasNext()); 66 67 mailet.service(mockedMail); 68 69 assertFalse(mockedMail.getAttributeNames().hasNext()); 71 } 72 73 } 74 | Popular Tags |