-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from linlinjava/master
合并
- Loading branch information
Showing
10 changed files
with
164 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 0 additions & 52 deletions
52
litemall-core/src/main/java/org/linlinjava/litemall/core/util/MailUtils.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,23 @@ | ||
|
||
#\u90AE\u4EF6\u53D1\u9001\u914D\u7F6E | ||
# 邮件发送配置 | ||
sprint.mail.enable=false | ||
spring.mail.host=smtp.exmail.qq.com | ||
spring.mail.username=[email protected] | ||
spring.mail.password= | ||
spring.mail.sendto=ex@qq.com | ||
spring.mail.username=xxxxxx | ||
spring.mail.password=xxxxxx | ||
spring.mail.sendto=example@qq.com | ||
|
||
#\u77ED\u4FE1\u53D1\u9001\u914D\u7F6E | ||
# 短信发送配置 | ||
spring.sms.enable=false | ||
spring.sms.appid= | ||
spring.sms.appkey= | ||
spring.sms.sign= | ||
spring.sms.appid=111111 | ||
spring.sms.appkey=xxxxxx | ||
spring.sms.sign=xxxxxx | ||
|
||
#\u77ED\u4FE1\u6A21\u7248\u6D88\u606F\u914D\u7F6E\uFF0C\u8BF7\u5728\u817E\u8BAF\u77ED\u4FE1\u5E73\u53F0\u914D\u7F6E\u597D\u5404\u4E2A\u901A\u77E5\u6D88\u606F\u7684\u6A21\u7248\uFF0C\u7136\u540E\u5C06\u6A21\u7248ID\u4E00\u4E00\u8D4B\u503C,LitemallNotifyService,NotifyType\u679A\u4E3E\u4E2D\u4E0E\u8FD9\u91CC\u4E00\u4E00\u5BF9\u5E94 | ||
spring.sms.template.pay.complated=156349 | ||
spring.sms.template.verificationcode=156433 | ||
# 短信模板消息配置 | ||
# 请在腾讯短信平台配置通知消息模板,然后这里设置不同短信模板ID | ||
# 请参考LitemallNotifyService.notifySMSTemplate | ||
spring.sms.template.paySucceed=111111 | ||
spring.sms.template.captcha=222222 | ||
|
||
#\u53D1\u9001\u7EBF\u7A0B\u6C60\u914D\u7F6E | ||
# 发送线程池配置 | ||
spring.notify.corePoolSize=5 | ||
spring.notify.maxPoolSize=100 | ||
spring.notify.queueCapacity=50 |
41 changes: 41 additions & 0 deletions
41
litemall-core/src/test/java/org/linlinjava/litemall/core/MailTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.linlinjava.litemall.core; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.linlinjava.litemall.core.notify.LitemallNotifyService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | ||
import org.springframework.test.context.web.WebAppConfiguration; | ||
|
||
/** | ||
* 测试邮件发送服务 | ||
* | ||
* 注意LitemallNotifyService采用异步线程操作 | ||
* 因此测试的时候需要睡眠一会儿,保证任务执行 | ||
* | ||
* 开发者需要确保: | ||
* 1. 在相应的邮件服务器设置正确notify.properties已经设置正确 | ||
* 2. 在相应的邮件服务器设置正确 | ||
*/ | ||
@WebAppConfiguration | ||
@RunWith(SpringJUnit4ClassRunner.class) | ||
@SpringBootTest | ||
public class MailTest { | ||
|
||
@Autowired | ||
private LitemallNotifyService litemallNotifyService; | ||
|
||
@Test | ||
public void testMail() { | ||
litemallNotifyService.notifyMailMessage("订单信息", "订单1111111已付款,请发货"); | ||
|
||
try { | ||
Thread.sleep(5000); | ||
} catch (InterruptedException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
|
||
} |
73 changes: 73 additions & 0 deletions
73
litemall-core/src/test/java/org/linlinjava/litemall/core/SmsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package org.linlinjava.litemall.core; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.linlinjava.litemall.core.notify.LitemallNotifyService; | ||
import org.linlinjava.litemall.core.notify.NotifyUtils; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | ||
import org.springframework.test.context.web.WebAppConfiguration; | ||
|
||
/** | ||
* 测试短信发送服务 | ||
* | ||
* 注意LitemallNotifyService采用异步线程操作 | ||
* 因此测试的时候需要睡眠一会儿,保证任务执行 | ||
* | ||
* 开发者需要确保: | ||
* 1. 在腾讯云短信平台设置短信签名和短信模板notify.properties已经设置正确 | ||
* 2. 在腾讯云短信平台设置短信签名和短信模板 | ||
* 3. 在当前测试类设置好正确的手机号码 | ||
*/ | ||
@WebAppConfiguration | ||
@RunWith(SpringJUnit4ClassRunner.class) | ||
@SpringBootTest | ||
public class SmsTest { | ||
|
||
@Autowired | ||
private LitemallNotifyService litemallNotifyService; | ||
|
||
// @Test | ||
public void testSingle() { | ||
String phone = "xxxxxxxxxxx"; | ||
// 这里的短信签名必须在短信管理平台内设置正确并且相符合 | ||
String msg = "【xxx】你的验证码为:123456,请与2分钟内填写,如非本人操作,请忽略本短信。"; | ||
litemallNotifyService.notifySMSMessage(phone, msg); | ||
|
||
try { | ||
Thread.sleep(5000); | ||
} catch (InterruptedException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
@Test | ||
public void testCaptcha() { | ||
String phone = "xxxxxxxxxxx"; | ||
String[] params = new String[] {"123456"}; | ||
|
||
litemallNotifyService.notifySMSTemplate(phone, NotifyUtils.NotifyType.CAPTCHA, params); | ||
|
||
try { | ||
Thread.sleep(5000); | ||
} catch (InterruptedException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
@Test | ||
public void testPaySucceed() { | ||
String phone = "xxxxxxxxxxx"; | ||
String[] params = new String[] {"123456"}; | ||
|
||
litemallNotifyService.notifySMSTemplate(phone, NotifyUtils.NotifyType.PAY_SUCCEED, params); | ||
|
||
try { | ||
Thread.sleep(5000); | ||
} catch (InterruptedException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters