本文整理汇总了Java中org.springframework.mail.MailSendException.printStackTrace方法的典型用法代码示例。如果您正苦于以下问题:Java MailSendException.printStackTrace方法的具体用法?Java MailSendException.printStackTrace怎么用?Java MailSendException.printStackTrace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.mail.MailSendException
的用法示例。
在下文中一共展示了MailSendException.printStackTrace方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: failedMailServerConnect
import org.springframework.mail.MailSendException; //导入方法依赖的package包/类
@Test
public void failedMailServerConnect() throws Exception {
MockJavaMailSender sender = new MockJavaMailSender();
sender.setHost(null);
sender.setUsername("username");
sender.setPassword("password");
SimpleMailMessage simpleMessage1 = new SimpleMailMessage();
try {
sender.send(simpleMessage1);
fail("Should have thrown MailSendException");
}
catch (MailSendException ex) {
// expected
ex.printStackTrace();
assertTrue(ex.getFailedMessages() != null);
assertEquals(1, ex.getFailedMessages().size());
assertSame(simpleMessage1, ex.getFailedMessages().keySet().iterator().next());
assertSame(ex.getCause(), ex.getFailedMessages().values().iterator().next());
}
}
示例2: failedMailServerClose
import org.springframework.mail.MailSendException; //导入方法依赖的package包/类
@Test
public void failedMailServerClose() throws Exception {
MockJavaMailSender sender = new MockJavaMailSender();
sender.setHost("");
sender.setUsername("username");
sender.setPassword("password");
SimpleMailMessage simpleMessage1 = new SimpleMailMessage();
try {
sender.send(simpleMessage1);
fail("Should have thrown MailSendException");
}
catch (MailSendException ex) {
// expected
ex.printStackTrace();
assertTrue(ex.getFailedMessages() != null);
assertEquals(0, ex.getFailedMessages().size());
}
}
示例3: testFailedMailServerConnect
import org.springframework.mail.MailSendException; //导入方法依赖的package包/类
public void testFailedMailServerConnect() throws Exception {
MockJavaMailSender sender = new MockJavaMailSender();
sender.setHost(null);
sender.setUsername("username");
sender.setPassword("password");
SimpleMailMessage simpleMessage1 = new SimpleMailMessage();
try {
sender.send(simpleMessage1);
fail("Should have thrown MailSendException");
}
catch (MailSendException ex) {
// expected
ex.printStackTrace();
assertTrue(ex.getFailedMessages() != null);
assertEquals(1, ex.getFailedMessages().size());
assertSame(simpleMessage1, ex.getFailedMessages().keySet().iterator().next());
assertSame(ex.getCause(), ex.getFailedMessages().values().iterator().next());
}
}
示例4: testFailedMailServerClose
import org.springframework.mail.MailSendException; //导入方法依赖的package包/类
public void testFailedMailServerClose() throws Exception {
MockJavaMailSender sender = new MockJavaMailSender();
sender.setHost("");
sender.setUsername("username");
sender.setPassword("password");
SimpleMailMessage simpleMessage1 = new SimpleMailMessage();
try {
sender.send(simpleMessage1);
fail("Should have thrown MailSendException");
}
catch (MailSendException ex) {
// expected
ex.printStackTrace();
assertTrue(ex.getFailedMessages() != null);
assertEquals(0, ex.getFailedMessages().size());
}
}
示例5: failedSimpleMessage
import org.springframework.mail.MailSendException; //导入方法依赖的package包/类
@Test
public void failedSimpleMessage() throws Exception {
MockJavaMailSender sender = new MockJavaMailSender();
sender.setHost("host");
sender.setUsername("username");
sender.setPassword("password");
SimpleMailMessage simpleMessage1 = new SimpleMailMessage();
simpleMessage1.setTo("[email protected]");
simpleMessage1.setSubject("fail");
SimpleMailMessage simpleMessage2 = new SimpleMailMessage();
simpleMessage2.setTo("[email protected]");
try {
sender.send(simpleMessage1, simpleMessage2);
}
catch (MailSendException ex) {
ex.printStackTrace();
assertEquals("host", sender.transport.getConnectedHost());
assertEquals("username", sender.transport.getConnectedUsername());
assertEquals("password", sender.transport.getConnectedPassword());
assertTrue(sender.transport.isCloseCalled());
assertEquals(1, sender.transport.getSentMessages().size());
assertEquals(new InternetAddress("[email protected]"), sender.transport.getSentMessage(0).getAllRecipients()[0]);
assertEquals(1, ex.getFailedMessages().size());
assertEquals(simpleMessage1, ex.getFailedMessages().keySet().iterator().next());
Object subEx = ex.getFailedMessages().values().iterator().next();
assertTrue(subEx instanceof MessagingException);
assertEquals("failed", ((MessagingException) subEx).getMessage());
}
}
示例6: fFailedMimeMessage
import org.springframework.mail.MailSendException; //导入方法依赖的package包/类
@Test
public void fFailedMimeMessage() throws Exception {
MockJavaMailSender sender = new MockJavaMailSender();
sender.setHost("host");
sender.setUsername("username");
sender.setPassword("password");
MimeMessage mimeMessage1 = sender.createMimeMessage();
mimeMessage1.setRecipient(Message.RecipientType.TO, new InternetAddress("[email protected]"));
mimeMessage1.setSubject("fail");
MimeMessage mimeMessage2 = sender.createMimeMessage();
mimeMessage2.setRecipient(Message.RecipientType.TO, new InternetAddress("[email protected]"));
try {
sender.send(mimeMessage1, mimeMessage2);
}
catch (MailSendException ex) {
ex.printStackTrace();
assertEquals("host", sender.transport.getConnectedHost());
assertEquals("username", sender.transport.getConnectedUsername());
assertEquals("password", sender.transport.getConnectedPassword());
assertTrue(sender.transport.isCloseCalled());
assertEquals(1, sender.transport.getSentMessages().size());
assertEquals(mimeMessage2, sender.transport.getSentMessage(0));
assertEquals(1, ex.getFailedMessages().size());
assertEquals(mimeMessage1, ex.getFailedMessages().keySet().iterator().next());
Object subEx = ex.getFailedMessages().values().iterator().next();
assertTrue(subEx instanceof MessagingException);
assertEquals("failed", ((MessagingException) subEx).getMessage());
}
}
示例7: testFailedSimpleMessage
import org.springframework.mail.MailSendException; //导入方法依赖的package包/类
public void testFailedSimpleMessage() throws Exception {
MockJavaMailSender sender = new MockJavaMailSender();
sender.setHost("host");
sender.setUsername("username");
sender.setPassword("password");
SimpleMailMessage simpleMessage1 = new SimpleMailMessage();
simpleMessage1.setTo("[email protected]");
simpleMessage1.setSubject("fail");
SimpleMailMessage simpleMessage2 = new SimpleMailMessage();
simpleMessage2.setTo("[email protected]");
try {
sender.send(new SimpleMailMessage[] {simpleMessage1, simpleMessage2});
}
catch (MailSendException ex) {
ex.printStackTrace();
assertEquals("host", sender.transport.getConnectedHost());
assertEquals("username", sender.transport.getConnectedUsername());
assertEquals("password", sender.transport.getConnectedPassword());
assertTrue(sender.transport.isCloseCalled());
assertEquals(1, sender.transport.getSentMessages().size());
assertEquals(new InternetAddress("[email protected]"), sender.transport.getSentMessage(0).getAllRecipients()[0]);
assertEquals(1, ex.getFailedMessages().size());
assertEquals(simpleMessage1, ex.getFailedMessages().keySet().iterator().next());
Object subEx = ex.getFailedMessages().values().iterator().next();
assertTrue(subEx instanceof MessagingException);
assertEquals("failed", ((MessagingException) subEx).getMessage());
}
}
示例8: testFailedMimeMessage
import org.springframework.mail.MailSendException; //导入方法依赖的package包/类
public void testFailedMimeMessage() throws Exception {
MockJavaMailSender sender = new MockJavaMailSender();
sender.setHost("host");
sender.setUsername("username");
sender.setPassword("password");
MimeMessage mimeMessage1 = sender.createMimeMessage();
mimeMessage1.setRecipient(Message.RecipientType.TO, new InternetAddress("[email protected]"));
mimeMessage1.setSubject("fail");
MimeMessage mimeMessage2 = sender.createMimeMessage();
mimeMessage2.setRecipient(Message.RecipientType.TO, new InternetAddress("[email protected]"));
try {
sender.send(new MimeMessage[] {mimeMessage1, mimeMessage2});
}
catch (MailSendException ex) {
ex.printStackTrace();
assertEquals("host", sender.transport.getConnectedHost());
assertEquals("username", sender.transport.getConnectedUsername());
assertEquals("password", sender.transport.getConnectedPassword());
assertTrue(sender.transport.isCloseCalled());
assertEquals(1, sender.transport.getSentMessages().size());
assertEquals(mimeMessage2, sender.transport.getSentMessage(0));
assertEquals(1, ex.getFailedMessages().size());
assertEquals(mimeMessage1, ex.getFailedMessages().keySet().iterator().next());
Object subEx = ex.getFailedMessages().values().iterator().next();
assertTrue(subEx instanceof MessagingException);
assertEquals("failed", ((MessagingException) subEx).getMessage());
}
}