Search in sources :

Example 1 with MockMailetConfig

use of org.nhind.testutils.MockMailetConfig 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

HashMap (java.util.HashMap)1 MessagingException (javax.mail.MessagingException)1 MailetConfig (org.apache.mailet.MailetConfig)1 MockMailetConfig (org.nhind.testutils.MockMailetConfig)1