本文整理汇总了Java中org.springframework.mail.MailParseException类的典型用法代码示例。如果您正苦于以下问题:Java MailParseException类的具体用法?Java MailParseException怎么用?Java MailParseException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MailParseException类属于org.springframework.mail包,在下文中一共展示了MailParseException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: javaMailSenderWithParseExceptionOnMimeMessagePreparator
import org.springframework.mail.MailParseException; //导入依赖的package包/类
@Test
public void javaMailSenderWithParseExceptionOnMimeMessagePreparator() {
MockJavaMailSender sender = new MockJavaMailSender();
MimeMessagePreparator preparator = new MimeMessagePreparator() {
@Override
public void prepare(MimeMessage mimeMessage) throws MessagingException {
mimeMessage.setFrom(new InternetAddress(""));
}
};
try {
sender.send(preparator);
}
catch (MailParseException ex) {
// expected
assertTrue(ex.getCause() instanceof AddressException);
}
}
示例2: testJavaMailSenderWithParseExceptionOnMimeMessagePreparator
import org.springframework.mail.MailParseException; //导入依赖的package包/类
public void testJavaMailSenderWithParseExceptionOnMimeMessagePreparator() {
MockJavaMailSender sender = new MockJavaMailSender();
MimeMessagePreparator preparator = new MimeMessagePreparator() {
@Override
public void prepare(MimeMessage mimeMessage) throws MessagingException {
mimeMessage.setFrom(new InternetAddress(""));
}
};
try {
sender.send(preparator);
}
catch (MailParseException ex) {
// expected
assertTrue(ex.getCause() instanceof AddressException);
}
}
示例3: testCreateMimeMessageWithExceptionInInputStream
import org.springframework.mail.MailParseException; //导入依赖的package包/类
@Test
public void testCreateMimeMessageWithExceptionInInputStream() throws Exception {
InputStream inputStream = mock(InputStream.class);
AmazonSimpleEmailService emailService = mock(AmazonSimpleEmailService.class);
JavaMailSender mailSender = new SimpleEmailServiceJavaMailSender(emailService);
IOException ioException = new IOException("error");
when(inputStream.read(ArgumentMatchers.any(byte[].class), ArgumentMatchers.anyInt(), ArgumentMatchers.anyInt())).thenThrow(ioException);
try {
mailSender.createMimeMessage(inputStream);
fail("MailPreparationException expected due to error while creating mail");
} catch (MailParseException e) {
assertTrue(e.getMessage().startsWith("Could not parse raw MIME content"));
assertSame(ioException, e.getCause().getCause());
}
}
示例4: createMimeMessage
import org.springframework.mail.MailParseException; //导入依赖的package包/类
@Override
public MimeMessage createMimeMessage(InputStream contentStream) throws MailException {
try {
return new MimeMessage(getSession(), contentStream);
}
catch (MessagingException ex) {
throw new MailParseException("Could not parse raw MIME content", ex);
}
}
示例5: setFrom
import org.springframework.mail.MailParseException; //导入依赖的package包/类
@Override
public void setFrom(String from) throws MailParseException {
try {
this.helper.setFrom(from);
}
catch (MessagingException ex) {
throw new MailParseException(ex);
}
}
示例6: setReplyTo
import org.springframework.mail.MailParseException; //导入依赖的package包/类
@Override
public void setReplyTo(String replyTo) throws MailParseException {
try {
this.helper.setReplyTo(replyTo);
}
catch (MessagingException ex) {
throw new MailParseException(ex);
}
}
示例7: setTo
import org.springframework.mail.MailParseException; //导入依赖的package包/类
@Override
public void setTo(String to) throws MailParseException {
try {
this.helper.setTo(to);
}
catch (MessagingException ex) {
throw new MailParseException(ex);
}
}
示例8: setCc
import org.springframework.mail.MailParseException; //导入依赖的package包/类
@Override
public void setCc(String cc) throws MailParseException {
try {
this.helper.setCc(cc);
}
catch (MessagingException ex) {
throw new MailParseException(ex);
}
}
示例9: setBcc
import org.springframework.mail.MailParseException; //导入依赖的package包/类
@Override
public void setBcc(String bcc) throws MailParseException {
try {
this.helper.setBcc(bcc);
}
catch (MessagingException ex) {
throw new MailParseException(ex);
}
}
示例10: setSentDate
import org.springframework.mail.MailParseException; //导入依赖的package包/类
@Override
public void setSentDate(Date sentDate) throws MailParseException {
try {
this.helper.setSentDate(sentDate);
}
catch (MessagingException ex) {
throw new MailParseException(ex);
}
}
示例11: setSubject
import org.springframework.mail.MailParseException; //导入依赖的package包/类
@Override
public void setSubject(String subject) throws MailParseException {
try {
this.helper.setSubject(subject);
}
catch (MessagingException ex) {
throw new MailParseException(ex);
}
}
示例12: setText
import org.springframework.mail.MailParseException; //导入依赖的package包/类
@Override
public void setText(String text) throws MailParseException {
try {
this.helper.setText(text);
}
catch (MessagingException ex) {
throw new MailParseException(ex);
}
}
示例13: createEmail
import org.springframework.mail.MailParseException; //导入依赖的package包/类
/**
* Process POST /emails requestphh
* Create an email with an email prepared
*
* @param emailPrepared email prepared
* @return response entity
*/
@Override
public ResponseEntity<Object> createEmail(@ApiParam(value = "Create an email", required = true) @RequestBody EmailPrepared emailPrepared) {
// Prepare an email with headers, template and parameters
EmailEntity entity = entity = toEmailEntity(emailPrepared);
URI location = null;
// Send the email
try {
emailService.sendHtmlEmail(toEmail(entity));
emailRepository.save(entity); // Save email in database
location = ServletUriComponentsBuilder
.fromCurrentRequest()
.path("/{id}")
.buildAndExpand(entity.getId())
.toUri();
// Update email's URL in database
entity.setUrl(location.toString());
emailRepository.save(entity);
} catch (MessagingException e) {
throw new MailParseException("Error mail", e);
}
return ResponseEntity.created(location).build();
}
示例14: createMimeMessage
import org.springframework.mail.MailParseException; //导入依赖的package包/类
@Override
public MimeMessage createMimeMessage(InputStream contentStream) throws MailException {
try {
return new MimeMessage(getSession(), contentStream);
}
catch (Exception ex) {
throw new MailParseException("Could not parse raw MIME content", ex);
}
}
示例15: javaMailSenderWithParseExceptionOnSimpleMessage
import org.springframework.mail.MailParseException; //导入依赖的package包/类
@Test
public void javaMailSenderWithParseExceptionOnSimpleMessage() {
MockJavaMailSender sender = new MockJavaMailSender();
SimpleMailMessage simpleMessage = new SimpleMailMessage();
simpleMessage.setFrom("");
try {
sender.send(simpleMessage);
}
catch (MailParseException ex) {
// expected
assertTrue(ex.getCause() instanceof AddressException);
}
}