75 lines
3.7 KiB
Java
75 lines
3.7 KiB
Java
package com.kimgo.wepush.service;
|
||
|
||
import com.kimgo.wepush.model.SMSInfo;
|
||
import com.kimgo.wepush.response.ServerResponseEntity;
|
||
import org.junit.jupiter.api.Test;
|
||
import org.slf4j.Logger;
|
||
import org.slf4j.LoggerFactory;
|
||
import org.springframework.beans.factory.annotation.Autowired;
|
||
import org.springframework.boot.test.context.SpringBootTest;
|
||
|
||
import java.util.ArrayList;
|
||
import java.util.List;
|
||
|
||
@SpringBootTest
|
||
class SMSServiceTest {
|
||
private final Logger logger = LoggerFactory.getLogger(SMSServiceTest.class);
|
||
@Autowired
|
||
private SMSService smsService;
|
||
public void testMessageSize(){
|
||
String message = "【话费剩余】\n" +
|
||
"您所在的家庭账户本月通信费87.90元,余额20.91元,其中本机本月累计消费87.90元(由家庭账户统一支付),家庭成员13541758298本月费用0.00元,家庭成员20935981572本月费用0.00元。新爱家58共享话费58.00元,当前剩余0.00元,\n" +
|
||
"【流量查询】\n" +
|
||
"国内通用流量共15.00GB,当前可使用14.95GB。回CXLL查明细。\n" +
|
||
"【套餐剩余】\n" +
|
||
"移动68套餐基本通话优惠分钟数余200分钟。\n" +
|
||
"发送“0000”到“10086”,订购业务清清楚楚,一键退订轻轻松松。\n" +
|
||
"【已开业务】回“1”\n" +
|
||
"【流量超市】回“2”\n" +
|
||
"【消费情况】回“3”\n" +
|
||
"【20元/月→4GB国内流量】回“4”\n" +
|
||
"【30元/月→10GB国内流量】回“5”\n" +
|
||
"【60元/月→30GB国内流量】回“6”\n" +
|
||
"【7天流量包】回“7”\n" +
|
||
"【19.9元/月→5GB国内流量+视频会员】回“8”\n" +
|
||
"【宽带专区】回“9”\n" +
|
||
"【在线客服】若您有话费/流量疑问、业务咨询/退订等其他需求可联系在线文字客服,点击官方认证通道: https://dx.10086.cn/Q_HZBg \n" +
|
||
"【为您推荐】尊敬的客户,您好!您有10元话费券待领取: http://dx.10086.cn/D/jEd1Jq ,点击查看话费使用详情: https://dx.10086.cn/38UvEQ 。。【中国移动】";
|
||
String shortMsg = "【腾讯科技】尊敬的用户,您的账号whj139****3736,经人工客服核实,已根据账号使用情况进行处理,请重新登录即可。";
|
||
String superMsg = generateMsg();
|
||
|
||
String accessToken = "gKGCDSgWV82XbU0H";
|
||
List<SMSInfo> smsInfoList = new ArrayList<>();
|
||
for (int i = 0; i < 3; i++) {
|
||
SMSInfo smsInfo = new SMSInfo();
|
||
smsInfo.setSmsNumber("12321");
|
||
smsInfo.setSmsAcceptanceTime("1123321");
|
||
smsInfoList.add(smsInfo);
|
||
}
|
||
|
||
smsInfoList.get(0).setSmsContent(message);
|
||
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();
|
||
}
|
||
|
||
} |