1 19 20 21 package org.apache.james.transport.matchers; 22 23 import junit.framework.TestCase; 24 import org.apache.james.test.mock.javaxmail.MockMimeMessage; 25 import org.apache.james.test.mock.mailet.MockMail; 26 import org.apache.james.test.mock.mailet.MockMailContext; 27 import org.apache.james.test.mock.mailet.MockMatcherConfig; 28 import org.apache.james.test.util.Util; 29 import org.apache.mailet.Matcher; 30 31 import javax.mail.MessagingException ; 32 import javax.mail.internet.MimeMessage ; 33 import java.io.UnsupportedEncodingException ; 34 35 public abstract class AbstractSubjectIsTest extends TestCase { 36 37 protected MockMail mockedMail; 38 39 protected Matcher matcher; 40 41 private String subject = null; 42 43 private MockMimeMessage mockedMimeMessage; 44 45 public AbstractSubjectIsTest(String arg0) 46 throws UnsupportedEncodingException { 47 super(arg0); 48 } 49 50 protected void setSubject(String subject) { 51 this.subject = subject; 52 } 53 54 protected void setupMockedMail(MimeMessage m) { 55 mockedMail = new MockMail(); 56 mockedMail.setMessage(m); 57 58 } 59 60 protected void setupMockedMimeMessage() throws MessagingException { 61 mockedMimeMessage = Util.createMimeMessage("test", "test"); 62 mockedMimeMessage.setSubject(subject); 63 } 64 65 protected void setupMatcher() throws MessagingException { 66 matcher = createMatcher(); 67 MockMatcherConfig mci = new MockMatcherConfig(getConfigOption() 68 + getSubjectName(), new MockMailContext()); 69 matcher.init(mci); 70 } 71 72 protected void setupAll() throws MessagingException { 73 setupMockedMimeMessage(); 74 setupMockedMail(mockedMimeMessage); 75 setupMatcher(); 76 } 77 78 protected abstract String getConfigOption(); 79 80 protected abstract String getSubjectName(); 81 82 protected abstract Matcher createMatcher(); 83 } 84 | Popular Tags |