|
|
@@ -0,0 +1,49 @@
|
|
|
+package seecoder.devcloud.web.service.user;
|
|
|
+
|
|
|
+import org.junit.Assert;
|
|
|
+import org.junit.jupiter.api.Test;
|
|
|
+import org.junit.runner.RunWith;
|
|
|
+import org.mybatis.spring.annotation.MapperScan;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.boot.test.context.SpringBootTest;
|
|
|
+import org.springframework.context.annotation.ComponentScan;
|
|
|
+import org.springframework.mail.javamail.JavaMailSender;
|
|
|
+import org.springframework.mail.javamail.MimeMessageHelper;
|
|
|
+import org.springframework.scheduling.annotation.EnableAsync;
|
|
|
+import org.springframework.test.context.junit4.SpringRunner;
|
|
|
+import seecoder.devcloud.common.exceptions.ServiceException;
|
|
|
+
|
|
|
+import javax.mail.MessagingException;
|
|
|
+import javax.mail.internet.MimeMessage;
|
|
|
+
|
|
|
+import java.util.concurrent.CompletableFuture;
|
|
|
+
|
|
|
+import static org.junit.jupiter.api.Assertions.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author PuHong Weng
|
|
|
+ * @date 2021/3/3
|
|
|
+ * @description:
|
|
|
+ */
|
|
|
+@RunWith(SpringRunner.class)
|
|
|
+@SpringBootTest
|
|
|
+@ComponentScan({"seecoder.devcloud.api","seecoder.devcloud.common","seecoder.devcloud.web"})
|
|
|
+@MapperScan(basePackages = {"seecoder.devcloud.web.dao"})
|
|
|
+class MailServiceTest {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ MailService mailService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ JavaMailSender javaMailSender;
|
|
|
+ @Test
|
|
|
+ void send() {
|
|
|
+ try {
|
|
|
+ CompletableFuture<Void> result = mailService.send( "你的课程作业","按时","2717718789@qq.com");
|
|
|
+ CompletableFuture.allOf(result).join();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ Assert.fail(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|