MailSession mailSession = new MailSession();
mailSession.create();
Session session = null;
try
{
session = mailSession.getSession();
}
catch (NamingException e)
{
assert false;
// Naming exception can't occur if we aren't getting the Session from
// JNDI
}
assert DEFAULT_HOST.equals(session.getProperty("mail.smtp.host"));
int port = 0;
try
{
port = Integer.parseInt(session.getProperty("mail.smtp.port"));
}
catch (NumberFormatException e)
{
assert false;
}
assert port == DEFAULT_PORT;
assert "smtp".equals(session.getProperty("mail.transport.protocol"));
SMTPTransport transport = null;
try
{
assert session.getTransport() instanceof SMTPTransport;
transport = (SMTPTransport) session.getTransport();
}
catch (NoSuchProviderException e)
{
assert false;
}
assert !session.getDebug();
assert transport.getStartTLS();
}