Search in sources :

Example 6 with MailetConfig

use of org.apache.mailet.MailetConfig in project nhin-d by DirectProject.

the class NHINDMailetTest method testInit.

/**
     * Test the init method.
     */
public void testInit() {
    final String endpointUrl = "http://www.endpoint.url/";
    DirectXdMailet mailet = new DirectXdMailet();
    Map<String, String> params = new HashMap<String, String>();
    params.put("EndpointURL", endpointUrl);
    MailetConfig mailetConfig = new MockMailetConfig(params, "MailetName");
    try {
        mailet.init(mailetConfig);
    } catch (MessagingException e) {
        fail("Test setup failed");
    }
    try {
        mailet.init();
        assertEquals("EndpointURL value does not match expected", endpointUrl, mailet.getEndpointUrl());
    } catch (MessagingException e) {
        fail("Exception thrown");
    }
    try {
        params.clear();
        params.put("EndpointURL", "");
        mailet.init();
        fail("Exception not thrown");
    } catch (MessagingException e) {
        assertTrue(true);
    }
    try {
        params.clear();
        mailet.init();
        fail("Exception not thrown");
    } catch (MessagingException e) {
        assertTrue(true);
    }
}
Also used : HashMap(java.util.HashMap) MessagingException(javax.mail.MessagingException) MockMailetConfig(org.nhind.testutils.MockMailetConfig) MailetConfig(org.apache.mailet.MailetConfig) MockMailetConfig(org.nhind.testutils.MockMailetConfig)

Aggregations

MailetConfig (org.apache.mailet.MailetConfig)6 HashMap (java.util.HashMap)4 Mailet (org.apache.mailet.Mailet)4 BaseTestPlan (org.nhindirect.gateway.testutils.BaseTestPlan)4 Map (java.util.Map)2 MessagingException (javax.mail.MessagingException)2 MimeMessage (javax.mail.internet.MimeMessage)2 Vector (java.util.Vector)1 MailAddress (org.apache.mailet.MailAddress)1 Anchor (org.nhind.config.Anchor)1 Certificate (org.nhind.config.Certificate)1 ConfigurationServiceProxy (org.nhind.config.ConfigurationServiceProxy)1 Domain (org.nhind.config.Domain)1 Setting (org.nhind.config.Setting)1 MockMailetConfig (org.nhind.testutils.MockMailetConfig)1 NHINDSecurityAndTrustMailet (org.nhindirect.gateway.smtp.james.mailet.NHINDSecurityAndTrustMailet)1 NHINDAddress (org.nhindirect.stagent.NHINDAddress)1