Package org.apache.mailet

Examples of org.apache.mailet.Mailet


    public void testFullQualifiedUsingFakeConfig() throws Exception {
        m_conf.add("none.existing.package"); // has to be here so the Loader won't choke
        setUpLoader();

        Mailet mailet = m_jamesMailetLoader.getMailet(MockMailet.class.getName(), null);
        assetIsMockMailet(mailet);
    }
View Full Code Here


    public void testStandardMailets() throws Exception {
        m_conf.addStandardPackages();
        setUpLoader();

        // use standard package
        Mailet mailetNull1 = m_jamesMailetLoader.getMailet(MockMailet.class.getSimpleName(), null);
        assetIsMockMailet(mailetNull1);

        // use full qualified package in parallel
        Mailet mailetNull2 = m_jamesMailetLoader.getMailet(MockMailet.class.getName(), null);
        assetIsMockMailet(mailetNull2);

    }
View Full Code Here

    private void checkTestMailet(String mailetName) throws MessagingException {
        // use standard package
        DefaultConfigurationBuilder configuration = new DefaultConfigurationBuilder();
        configuration.addProperty("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"));
View Full Code Here

        Iterator<List<MailetManagement>> it = mailets.values().iterator();
        while (it.hasNext()) {
            List<MailetManagement> mList = it.next();
            for (int i = 0; i < mList.size(); i++) {
                Mailet m = mList.get(i).getMailet();
                if (debugEnabled) {
                    logger.debug("Shutdown mailet " + m.getMailetInfo());
                }
                m.destroy();
            }
          
        }
       
        Iterator<List<MatcherManagement>> mit = matchers.values().iterator();    
        while (mit.hasNext()) {
            List<MatcherManagement> mList = mit.next();
            for (int i = 0; i < mList.size(); i++) {
                Matcher m = mList.get(i);
                if (debugEnabled) {
                    logger.debug("Shutdown matcher " + m.getMatcherInfo());
                }
                m.destroy();
            }
          
        }     
    }
View Full Code Here

    public void testFullQualifiedUsingFakeConfig() throws ConfigurationException, MessagingException {
        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);
    }
View Full Code Here

    public void testStandardMailets() throws ConfigurationException, MessagingException {
        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);

    }
View Full Code Here

    private void checkTestMailet(String mailetName) throws MessagingException {
        // 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"));
View Full Code Here

        recipientIs.init(new DummyMatcherConfig("rec1@domain.com"));
       
        Matcher all = new All();
        all.init(new DummyMatcherConfig(""));
       
        Mailet changeBody = new MyMailet();
        Mailet changeBody2 = new MyMailet();

        changeBody.init(mockMailetConfig);
        changeBody2.init(mockMailetConfig);
       
        Mailet dumpSystemErr = new DumpSystemErr();
        changeBody.init(mockMailetConfig);
       
        checkerMailet = new CheckerMailet();
        t.add(recipientIs,changeBody);
        t.add(all,changeBody);
View Full Code Here

        recipientIs.init(new DummyMatcherConfig("rec1@domain.com"));
       
        Matcher all = new All();
        all.init(new DummyMatcherConfig(""));
       
        Mailet dumpSystemErr = new DumpSystemErr();
       
        checkerMailet = new CheckerMailet();
        t.add(recipientIs,dumpSystemErr);
        t.add(all,dumpSystemErr);
        t.add(all,checkerMailet);
View Full Code Here

    }

    private String processAddFooter(String asciisource, String footer)
            throws MessagingException, IOException {
        Mailet mailet = new AddFooter();

        MockMailetConfig mci = new MockMailetConfig("Test",new MockMailContext());
        mci.setProperty("text",footer);

        mailet.init(mci);

        Mail mail = new MailImpl(new MimeMessage(Session
                .getDefaultInstance(new Properties()),
                new ByteArrayInputStream(asciisource.getBytes())));

        mailet.service(mail);

        ByteArrayOutputStream rawMessage = new ByteArrayOutputStream();
        mail.getMessage().writeTo(
                rawMessage,
                new String[] { "Bcc", "Content-Length", "Message-ID" });
View Full Code Here

TOP

Related Classes of org.apache.mailet.Mailet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.