KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > james > transport > mailets > NullTest


1 /****************************************************************
2  * Licensed to the Apache Software Foundation (ASF) under one *
3  * or more contributor license agreements. See the NOTICE file *
4  * distributed with this work for additional information *
5  * regarding copyright ownership. The ASF licenses this file *
6  * to you under the Apache License, Version 2.0 (the *
7  * "License"); you may not use this file except in compliance *
8  * with the License. You may obtain a copy of the License at *
9  * *
10  * http://www.apache.org/licenses/LICENSE-2.0 *
11  * *
12  * Unless required by applicable law or agreed to in writing, *
13  * software distributed under the License is distributed on an *
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
15  * KIND, either express or implied. See the License for the *
16  * specific language governing permissions and limitations *
17  * under the License. *
18  ****************************************************************/

19
20
21 package org.apache.james.transport.mailets;
22
23 import java.io.UnsupportedEncodingException JavaDoc;
24 import java.util.Arrays JavaDoc;
25
26 import javax.mail.MessagingException JavaDoc;
27 import javax.mail.internet.MimeMessage JavaDoc;
28 import javax.mail.internet.ParseException JavaDoc;
29
30 import junit.framework.TestCase;
31
32 import org.apache.james.test.mock.mailet.MockMail;
33 import org.apache.mailet.Mail;
34 import org.apache.mailet.MailAddress;
35 import org.apache.mailet.Mailet;
36
37 public class NullTest extends TestCase {
38
39     private MimeMessage JavaDoc mockedMimeMessage;
40
41     private Mail mockedMail;
42
43     private Mailet mailet;
44
45     private final String JavaDoc PROCESSOR = "ghost";
46
47     public NullTest(String JavaDoc arg0) throws UnsupportedEncodingException JavaDoc {
48         super(arg0);
49     }
50
51     private void setupMockedMail(MimeMessage JavaDoc m) throws ParseException JavaDoc {
52         mockedMail = new MockMail();
53         mockedMail.setMessage(m);
54         mockedMail.setRecipients(Arrays.asList(new MailAddress[] {
55                 new MailAddress("test@james.apache.org"),
56                 new MailAddress("test2@james.apache.org") }));
57
58     }
59
60     private void setupMailet() throws MessagingException JavaDoc {
61         mailet = new Null();
62     }
63
64     // test if the right state was set
65
public void testNullMailet() throws MessagingException JavaDoc {
66         setupMockedMail(mockedMimeMessage);
67         setupMailet();
68
69         mailet.service(mockedMail);
70
71         assertEquals(PROCESSOR, mockedMail.getState());
72     }
73
74 }
75
Popular Tags