FileDocCategorySizeDatePackage
ToProcessorTest.javaAPI DocApache James 2.3.13855Fri Jan 12 12:56:38 GMT 2007org.apache.james.transport.mailets

ToProcessorTest

public class ToProcessorTest extends TestCase
Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. *

Fields Summary
private MimeMessage
mockedMimeMessage
private org.apache.mailet.Mail
mockedMail
private org.apache.mailet.Mailet
mailet
private String
processor
private String
notice
Constructors Summary
public ToProcessorTest(String arg0)


         
        super(arg0);
    
Methods Summary
private voidsetNotice(java.lang.String notice)

        this.notice = notice;
    
private voidsetProcessor(java.lang.String processor)

        this.processor = processor;
    
private voidsetupMailet()

        mailet = new ToProcessor();
        MockMailetConfig mci = new MockMailetConfig("Test",
                new MockMailContext());
        if (processor != null) {
            mci.setProperty("processor", processor);
        }
        if (notice != null) {
            mci.setProperty("notice", notice);
        }
        mailet.init(mci);
    
private voidsetupMockedMail(javax.mail.internet.MimeMessage m)

        mockedMail = new MockMail();
        mockedMail.setMessage(m);
        mockedMail.setRecipients(Arrays.asList(new MailAddress[] {
                new MailAddress("test@james.apache.org"),
                new MailAddress("test2@james.apache.org") }));

    
public voidtestExceptionThrown()

        boolean exceptionThrown = false;
        setProcessor(null);
        setNotice("error in message");
        setupMockedMail(mockedMimeMessage);

        try {
            setupMailet();
            mailet.service(mockedMail);
        } catch (MessagingException m) {
            exceptionThrown = true;
        }
        assertTrue(exceptionThrown);
    
public voidtestValidToProcessor()

        setProcessor("error");
        setNotice("error in message");
        setupMockedMail(mockedMimeMessage);
        setupMailet();

        mailet.service(mockedMail);

        assertEquals(processor, mockedMail.getState());
        assertEquals(notice, mockedMail.getErrorMessage());