当前位置: 首页>>代码示例>>Java>>正文


Java MailParseException类代码示例

本文整理汇总了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);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:18,代码来源:JavaMailSenderTests.java

示例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);
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:17,代码来源:JavaMailSenderTests.java

示例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());
    }
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:20,代码来源:SimpleEmailServiceJavaMailSenderTest.java

示例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);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:JavaMailSenderImpl.java

示例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);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:MimeMailMessage.java

示例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);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:MimeMailMessage.java

示例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);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:MimeMailMessage.java

示例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);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:MimeMailMessage.java

示例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);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:MimeMailMessage.java

示例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);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:MimeMailMessage.java

示例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);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:MimeMailMessage.java

示例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);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:MimeMailMessage.java

示例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();
}
 
开发者ID:PestaKit,项目名称:microservice-email,代码行数:37,代码来源:EmailApiController.java

示例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);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:10,代码来源:JavaMailSenderImpl.java

示例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);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:14,代码来源:JavaMailSenderTests.java


注:本文中的org.springframework.mail.MailParseException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。