use of org.pentaho.platform.plugin.services.email.EmailService in project pentaho-platform by pentaho.
the class EmailResourceTest method setUp.
@Override
protected void setUp() throws Exception {
// Setup the temp email config file
mp = new MicroPlatform();
mp.defineInstance(IAuthorizationPolicy.class, new TestAuthorizationPolicy());
mp.start();
defaultConfigFile = File.createTempFile("email_config_", ".xml");
this.emailResource = new EmailResource(new EmailService(defaultConfigFile));
}
use of org.pentaho.platform.plugin.services.email.EmailService in project pentaho-platform by pentaho.
the class EmailResourceTest method testEmailConfig.
public void testEmailConfig() throws Exception {
try {
new EmailResource(null);
fail("Exception should be thrown when a null EmailService is provided");
} catch (IllegalArgumentException success) {
// ignore
}
try {
new EmailResource(new EmailService(new File(defaultConfigFile, "cannot.exist")));
fail("Exception should be thrown when an invalid EmailService is provided");
} catch (IllegalArgumentException success) {
// ignore
}
IEmailConfiguration emptyConfig = emailResource.getEmailConfig();
assertTrue(BLANK_CONFIG.equals(emptyConfig));
Response response = emailResource.setEmailConfig(new EmailConfiguration());
assertEquals(OK_STATUS, response.getStatus());
emptyConfig = emailResource.getEmailConfig();
assertTrue(BLANK_CONFIG.equals(emptyConfig));
final EmailConfiguration emailConfigOriginal = new EmailConfiguration(true, false, "test@pentaho.com", "Pentaho Scheduler", null, 36, "", true, "user", null, false, true);
response = emailResource.setEmailConfig(emailConfigOriginal);
assertEquals(OK_STATUS, response.getStatus());
final IEmailConfiguration emailConfigNew = emailResource.getEmailConfig();
assertTrue(emailConfigOriginal.equals(emailConfigNew));
}
Aggregations