use of org.apache.sling.commons.messaging.MessageService in project sling by apache.
the class SimpleMailServiceIT method sendWithoutAuthentication.
@Test
public void sendWithoutAuthentication() throws Exception {
final Dictionary<String, Object> properties = MailBuilderConfigurations.minimal();
createFactoryConfiguration(FACTORY_PID, properties);
final MessageService messageService = getService(MessageService.class);
final CompletableFuture<Result> future = messageService.send("simple test message", "recipient@example.net");
try {
future.get();
} catch (Exception e) {
logger.info(e.getMessage(), e);
assertTrue(ExceptionUtils.getRootCause(e) instanceof AuthenticationFailedException);
}
}
use of org.apache.sling.commons.messaging.MessageService in project sling by apache.
the class SimpleMailServiceIT method send.
@Test
public void send() throws Exception {
final Dictionary<String, Object> properties = MailBuilderConfigurations.full(wiser.getServer().getPort());
createFactoryConfiguration(FACTORY_PID, properties);
final MessageService messageService = getService(MessageService.class);
final CompletableFuture<Result> future = messageService.send("simple test message", "recipient@example.net");
final MailResult result = (MailResult) future.get();
final String message = new String(result.getMessage(), StandardCharsets.UTF_8);
// TODO assert
logger.info("message: {}", message);
}
use of org.apache.sling.commons.messaging.MessageService in project sling by apache.
the class SimpleMailServiceIT method sendWithData.
@Test
public void sendWithData() throws Exception {
final Dictionary<String, Object> properties = MailBuilderConfigurations.full(wiser.getServer().getPort());
createFactoryConfiguration(FACTORY_PID, properties);
final MessageService messageService = getService(MessageService.class);
final Map configuration = Collections.singletonMap("mail.subject", "Testing the Simple Mail Service with a custom subject");
final Map data = Collections.singletonMap("mail", configuration);
final CompletableFuture<Result> future = messageService.send("simple test message", "recipient@example.net", data);
final MailResult result = (MailResult) future.get();
final String message = new String(result.getMessage(), StandardCharsets.UTF_8);
// TODO assert
logger.info("message: {}", message);
}
Aggregations