FileDocCategorySizeDatePackage
JamesMailetLoaderTest.javaAPI DocApache James 2.3.15213Fri Jan 12 12:56:36 GMT 2007org.apache.james.transport

JamesMailetLoaderTest

public class JamesMailetLoaderTest 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 JamesMailetLoader
m_jamesMailetLoader
private JamesMailetLoaderConfiguration
m_conf
Constructors Summary
Methods Summary
private voidassetIsNullMailet(org.apache.mailet.Mailet mailet)

        assertNotNull("Null mailet loaded", mailet);
        assertTrue("Null mailet is expected class", mailet instanceof org.apache.james.transport.mailets.Null);
    
private voidcheckTestMailet(java.lang.String mailetName)

        // use standard package
        DefaultConfiguration configuration = new DefaultConfiguration("mailetLoaderTest");
        configuration.addChild(Util.getValuedConfiguration("testMailetKey", "testMailetValue"));

        Mailet mailet = m_jamesMailetLoader.getMailet(mailetName, configuration);
        assertTrue("MailetLoaderTestMailet mailet is expected class", mailet instanceof MailetLoaderTestMailet);
        MailetLoaderTestMailet mailetLoaderTestMailet = ((MailetLoaderTestMailet) mailet);
        assertTrue("init was called by loader", mailetLoaderTestMailet.assertInitCalled());
        MailetConfig mailetConfig = mailetLoaderTestMailet.getMailetConfig();
        assertEquals("init was called w/ right config", "testMailetValue", mailetConfig.getInitParameter("testMailetKey"));
    
private voidsetUpLoader()

        m_conf.init();
        m_jamesMailetLoader.configure(m_conf);
    
public voidtestFullQualifiedUsingFakeConfig()

        m_conf.add("none.existing.package"); // has to be here so the Loader won't choke
        setUpLoader();

        Mailet mailet = m_jamesMailetLoader.getMailet("org.apache.james.transport.mailets.Null", null);
        assetIsNullMailet(mailet);
    
public voidtestStandardMailets()

        m_conf.addStandardPackages();
        setUpLoader();

        // use standard package
        Mailet mailetNull1 = m_jamesMailetLoader.getMailet("Null", null);
        assetIsNullMailet(mailetNull1);

        // use full qualified package in parallel
        Mailet mailetNull2 = m_jamesMailetLoader.getMailet("org.apache.james.transport.mailets.Null", null);
        assetIsNullMailet(mailetNull2);

    
public voidtestTestMailets()

        m_conf.addStandardPackages();
        setUpLoader();

        checkTestMailet("MailetLoaderTestMailet");
        
        checkTestMailet("MailetLoaderTestSMIMEMailet");

    
public voidtestUsingEmtpyConfig()

        setUpLoader();