- 添加 aliyun 短信发送服务
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package cn.iocoder.mall.admin.client;
|
||||
|
||||
import cn.iocoder.mall.admin.SystemApplicationTest;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* 阿里云 短信 test
|
||||
*
|
||||
* @author Sin
|
||||
* @time 2019/5/26 10:08 AM
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = SystemApplicationTest.class)
|
||||
public class SmsAliYunClientTest {
|
||||
|
||||
@Autowired
|
||||
private SmsAliYunClient smsAliYunClient;
|
||||
|
||||
@Test
|
||||
public void singleSendTest() {
|
||||
String sign = "阿里云短信测试专用";
|
||||
String mobile = "13302926050";
|
||||
String templateCode = "SMS_137110043";
|
||||
String template = "验证码#code#,您正在进行身份验证,打死不要告诉别人哦!";
|
||||
smsAliYunClient.singleSend(mobile, sign, templateCode,
|
||||
template, ImmutableMap.of("code", "8888"));
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,6 @@
|
||||
package cn.iocoder.mall.admin.client;
|
||||
|
||||
import cn.iocoder.mall.admin.SystemApplicationTest;
|
||||
import com.aliyuncs.CommonRequest;
|
||||
import com.aliyuncs.CommonResponse;
|
||||
import com.aliyuncs.DefaultAcsClient;
|
||||
import com.aliyuncs.IAcsClient;
|
||||
import com.aliyuncs.exceptions.ClientException;
|
||||
import com.aliyuncs.exceptions.ServerException;
|
||||
import com.aliyuncs.http.MethodType;
|
||||
import com.aliyuncs.profile.DefaultProfile;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import org.assertj.core.util.Lists;
|
||||
import org.junit.Before;
|
||||
@@ -18,8 +10,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 短信 sms client test
|
||||
*
|
||||
@@ -44,13 +34,15 @@ public class SmsYunPianClientTest {
|
||||
public void sendMobileTest() {
|
||||
String mobile = "13302926050";
|
||||
String template = "您的验证码是#code#,打死也不告诉别人哦。";
|
||||
smsYunPianClient.singleSend(mobile, sign, template, ImmutableMap.of("code", "1111"));
|
||||
smsYunPianClient.singleSend(mobile, sign, null,
|
||||
template, ImmutableMap.of("code", "1111"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void batchSendTest() {
|
||||
String mobile = "13302926050";
|
||||
String template = "您的验证码是#code#,打死也不告诉别人哦。";
|
||||
smsYunPianClient.batchSend(Lists.newArrayList(mobile), sign, template, ImmutableMap.of("code", "2222"));
|
||||
smsYunPianClient.batchSend(Lists.newArrayList(mobile), sign, null,
|
||||
template, ImmutableMap.of("code", "2222"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@ public class SmsServiceImplTest {
|
||||
|
||||
@Test
|
||||
public void createSignTest() {
|
||||
smsService.createSign("悦跑运动", SmsPlatformEnum.YunPian.getValue());
|
||||
|
||||
// smsService.createSign("悦跑运动", SmsPlatformEnum.YunPian.getValue());
|
||||
smsService.createSign("登录确认验证码", SmsPlatformEnum.AliYun.getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -50,7 +50,6 @@ public class SmsServiceImplTest {
|
||||
Assert.assertTrue("更新不成功!", smsSignBO.getSign().equals(newSign));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void deletedSignTest() {
|
||||
smsService.deleteSign(3);
|
||||
@@ -61,23 +60,28 @@ public class SmsServiceImplTest {
|
||||
|
||||
@Test
|
||||
public void createTemplateTest() {
|
||||
String template = "您的验证码是#code#,打死也不告诉别人哦。";
|
||||
smsService.createTemplate(3, template,
|
||||
SmsPlatformEnum.YunPian.getValue(),
|
||||
Integer sign = 4;
|
||||
String templateCode = "SMS_137110043";
|
||||
String template = "验证码#code#,您正在登录,若非本人操作,请勿泄露。";
|
||||
smsService.createTemplate(
|
||||
sign,
|
||||
templateCode,
|
||||
template,
|
||||
SmsPlatformEnum.AliYun.getValue(),
|
||||
SmsTypeEnum.VERIFICATION_CODE.getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void singleSendTest() {
|
||||
String mobile = "13302926050";
|
||||
Integer templateId = 5;
|
||||
Integer templateId = 7;
|
||||
smsService.singleSend(mobile, templateId, ImmutableMap.of("code", "8888"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void batchSendTest() {
|
||||
String mobile = "13302926050";
|
||||
Integer templateId = 5;
|
||||
Integer templateId = 7;
|
||||
smsService.batchSend(Lists.newArrayList(mobile), templateId, ImmutableMap.of("code", "8888"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user