更新 SMSServiceTest.java

pull/1/head
wangsiyuan 2023-12-06 16:45:13 +08:00
parent fa8595d030
commit 2d3d3aa676
1 changed files with 35 additions and 7 deletions

View File

@ -8,7 +8,8 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import static org.junit.jupiter.api.Assertions.*; import java.util.ArrayList;
import java.util.List;
@SpringBootTest @SpringBootTest
class SMSServiceTest { class SMSServiceTest {
@ -35,14 +36,41 @@ class SMSServiceTest {
"【宽带专区】回“9”\n" + "【宽带专区】回“9”\n" +
"【在线客服】若您有话费/流量疑问、业务咨询/退订等其他需求可联系在线文字客服,点击官方认证通道: https://dx.10086.cn/Q_HZBg \n" + "【在线客服】若您有话费/流量疑问、业务咨询/退订等其他需求可联系在线文字客服,点击官方认证通道: https://dx.10086.cn/Q_HZBg \n" +
"【为您推荐】尊敬的客户您好您有10元话费券待领取 http://dx.10086.cn/D/jEd1Jq ,点击查看话费使用详情: https://dx.10086.cn/38UvEQ 。。【中国移动】"; "【为您推荐】尊敬的客户您好您有10元话费券待领取 http://dx.10086.cn/D/jEd1Jq ,点击查看话费使用详情: https://dx.10086.cn/38UvEQ 。。【中国移动】";
String shortMsg = "【腾讯科技】尊敬的用户您的账号whj139****3736经人工客服核实已根据账号使用情况进行处理请重新登录即可。";
String superMsg = generateMsg();
String accessToken = "gKGCDSgWV82XbU0H"; String accessToken = "gKGCDSgWV82XbU0H";
SMSInfo smsInfo = new SMSInfo(); List<SMSInfo> smsInfoList = new ArrayList<>();
smsInfo.setSmsContent(message); for (int i = 0; i < 3; i++) {
smsInfo.setSmsNumber("11111"); SMSInfo smsInfo = new SMSInfo();
smsInfo.setSmsAcceptanceTime("11111"); smsInfo.setSmsNumber("12321");
smsInfo.setSmsAcceptanceTime("1123321");
smsInfoList.add(smsInfo);
}
ServerResponseEntity serverResponseEntity = smsService.getSMSInfo(accessToken,smsInfo); smsInfoList.get(0).setSmsContent(message);
logger.info(serverResponseEntity.toString()); smsInfoList.get(1).setSmsContent(shortMsg);
smsInfoList.get(2).setSmsContent(superMsg);
for (int i = 0; i < 3; i++) {
ServerResponseEntity serverResponseEntity = smsService.getSMSInfo(accessToken,smsInfoList.get(i));
logger.info(serverResponseEntity.toString());
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
} }
private String generateMsg() {
StringBuilder msg = new StringBuilder("这是一条超长消息用于测试。");
int size = msg.toString().getBytes(java.nio.charset.StandardCharsets.UTF_8).length;
while (size <= 2100) {
msg.append("这是一条超长消息用于测试。");
size = msg.toString().getBytes(java.nio.charset.StandardCharsets.UTF_8).length;
}
return msg.toString();
}
} }