update MsgPushTest
This commit is contained in:
@@ -4,16 +4,6 @@
|
||||
*/
|
||||
package com.jeesite.test;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.annotation.Rollback;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
|
||||
import com.jeesite.common.config.Global;
|
||||
import com.jeesite.common.lang.DateUtils;
|
||||
import com.jeesite.common.tests.BaseSpringContextTests;
|
||||
@@ -31,6 +21,15 @@ import com.jeesite.modules.msg.utils.MsgPushUtils;
|
||||
import com.jeesite.modules.sys.entity.User;
|
||||
import com.jeesite.modules.sys.service.UserService;
|
||||
import com.jeesite.modules.sys.utils.UserUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.annotation.Rollback;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 消息推送测试类
|
||||
@@ -57,10 +56,10 @@ public class MsgPushTest extends BaseSpringContextTests {
|
||||
}
|
||||
for (int i=0; i<1; i++){
|
||||
testPc();
|
||||
testApp();
|
||||
testSMS();
|
||||
testMail();
|
||||
testMailTpl();
|
||||
// testApp();
|
||||
// testSMS();
|
||||
// testMail();
|
||||
// testMailTpl();
|
||||
}
|
||||
for (int j=0; j<3; j++){
|
||||
testTaskPush();
|
||||
@@ -73,23 +72,25 @@ public class MsgPushTest extends BaseSpringContextTests {
|
||||
msgContent.setTitle("提示信息");
|
||||
msgContent.setContent("您有1条新的任务");
|
||||
msgContent.addButton("办理", "/a/task/execute?id=123");
|
||||
// 即时推送消息
|
||||
logger.info("即时推送消息");
|
||||
MsgPushUtils.push(msgContent, "BizKey", "BizType", "system");
|
||||
// 定时推送消息
|
||||
logger.info("定时推送消息");
|
||||
MsgPushUtils.push(msgContent, "BizKey", "BizType", "system", DateUtils.parseDate("2018-05-05 08:30"));
|
||||
// 合并推送消息
|
||||
logger.info("合并推送消息");
|
||||
MsgPushUtils.push(msgContent, "BizKey", "BizType", "system", new Date(), Global.YES);
|
||||
logger.info("读取消息");
|
||||
MsgPushUtils.readMsgByBiz("BizKey", "BizType", "system");
|
||||
}
|
||||
|
||||
public void testApp(){
|
||||
AppMsgContent msgContent = new AppMsgContent();
|
||||
msgContent.setTitle("提示信息");
|
||||
msgContent.setContent("您有1条新的任务");
|
||||
// 即时推送消息
|
||||
logger.info("即时推送消息");
|
||||
MsgPushUtils.push(msgContent, "BizKey", "BizType", "system");
|
||||
// 定时推送消息
|
||||
logger.info("定时推送消息");
|
||||
MsgPushUtils.push(msgContent, "BizKey", "BizType", "system", DateUtils.parseDate("2018-05-05 08:30"));
|
||||
// 合并推送消息
|
||||
logger.info("合并推送消息");
|
||||
MsgPushUtils.push(msgContent, "BizKey", "BizType", "system", new Date(), Global.YES);
|
||||
}
|
||||
|
||||
@@ -97,11 +98,11 @@ public class MsgPushTest extends BaseSpringContextTests {
|
||||
SmsMsgContent msgContent = new SmsMsgContent();
|
||||
msgContent.setTitle("提示信息");
|
||||
msgContent.setContent("您好,您的验证码是:123456(请勿透露给其他人)感谢您的使用。");
|
||||
// 即时推送消息
|
||||
logger.info("即时推送消息");
|
||||
MsgPushUtils.push(msgContent, "BizKey", "BizType", "system");
|
||||
// 定时推送消息
|
||||
logger.info("定时推送消息");
|
||||
MsgPushUtils.push(msgContent, "BizKey", "BizType", "system", DateUtils.parseDate("2018-05-05 08:30"));
|
||||
// 合并推送消息
|
||||
logger.info("合并推送消息");
|
||||
MsgPushUtils.push(msgContent, "BizKey", "BizType", "system", new Date(), Global.YES);
|
||||
}
|
||||
|
||||
@@ -109,11 +110,11 @@ public class MsgPushTest extends BaseSpringContextTests {
|
||||
EmailMsgContent msgContent = new EmailMsgContent();
|
||||
msgContent.setTitle("提示信息");
|
||||
msgContent.setContent("这是一条测试邮件内容");
|
||||
// 即时推送消息
|
||||
logger.info("即时推送消息");
|
||||
MsgPushUtils.push(msgContent, "BizKey", "BizType", "system");
|
||||
// 定时推送消息
|
||||
logger.info("定时推送消息");
|
||||
MsgPushUtils.push(msgContent, "BizKey", "BizType", "system", DateUtils.parseDate("2018-05-05 08:30"));
|
||||
// 合并推送消息
|
||||
logger.info("合并推送消息");
|
||||
MsgPushUtils.push(msgContent, "BizKey", "BizType", "system", new Date(), Global.YES);
|
||||
}
|
||||
|
||||
@@ -122,13 +123,13 @@ public class MsgPushTest extends BaseSpringContextTests {
|
||||
MsgTemplate msgTemplate = new MsgTemplate();
|
||||
msgTemplate.setTplKey("mail_send_test");
|
||||
List<MsgTemplate> tplList = msgTemplateService.findList(msgTemplate);
|
||||
if (tplList.size() == 0){
|
||||
if (tplList.isEmpty()){
|
||||
msgTemplate.setTplName("邮件提示信息");
|
||||
msgTemplate.setTplContent("你好,${keyword1},请于 ${keyword2},准时参加${keyword3}");
|
||||
msgTemplate.setTplType(MsgPush.TYPE_EMAIL);
|
||||
msgTemplateService.save(msgTemplate);
|
||||
}
|
||||
// 根据模板发送消息
|
||||
logger.info("根据模板发送消息");
|
||||
EmailMsgContent msgContent = new EmailMsgContent();
|
||||
msgContent.setTitle("邮件提示信息");
|
||||
msgContent.setTplKey("mail_send_test");
|
||||
|
||||
Reference in New Issue
Block a user