list,
i'm looking at the test coverage and in particular the classes which are
tested below 85%.
i came across the MailEngine. there are these two methods:
/**
* Send a simple message based on a Velocity template.
* @param msg the message to populate
* @param templateName the Velocity template to use (relative to
classpath)
* @param model a map containing key/value pairs
*/
public void sendMessage(SimpleMailMessage msg, String templateName,
Map model) {
String result = null;
try {
result =
VelocityEngineUtils.mergeTemplateIntoString(velocityEngine,
templateName, model);
} catch (VelocityException e) {
e.printStackTrace();
log.error(e.getMessage());
}
msg.setText(result);
send(msg);
}
/**
* Send a simple message with pre-populated values.
* @param msg the message to send
* @throws org.springframework.mail.MailException when SMTP server
is down
*/
public void send(SimpleMailMessage msg) throws MailException {
try {
mailSender.send(msg);
} catch (MailException ex) {
log.error(ex.getMessage());
throw ex;
}
}
i wonder in both methods, what is the use of the catching part?
with send (the last one) it only adds a logging (which will be done
where ever the thrown exception is caught.
and in the first one there will be send an empty message....
in the test case i added this line:
// a null from should work
mailEngine.sendMessage(new String[] {
"[email protected]"
}, null, cpResource, emailBody, emailSubject, ATTACHMENT_NAME);
so the null for from is tested too
should i make a jira with phatch??
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]