测试用例package调整

master
xuxueli 7 years ago
parent 32213ae06b
commit 7a8937ddf4
  1. 3
      doc/XXL-JOB官方文档.md
  2. 5
      xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/PropertiesUtil.java
  3. 2
      xxl-job-admin/src/test/java/com/xxl/job/admin/controller/AbstractSpringMvcTest.java
  4. 22
      xxl-job-admin/src/test/java/com/xxl/job/admin/controller/IndexControllerTest.java
  5. 39
      xxl-job-admin/src/test/java/com/xxl/job/admin/controller/JobInfoControllerTest.java
  6. 2
      xxl-job-admin/src/test/java/com/xxl/job/admin/dao/XxlJobGroupDaoTest.java
  7. 156
      xxl-job-admin/src/test/java/com/xxl/job/admin/dao/XxlJobInfoDaoTest.java
  8. 2
      xxl-job-admin/src/test/java/com/xxl/job/admin/dao/XxlJobLogDaoTest.java
  9. 2
      xxl-job-admin/src/test/java/com/xxl/job/admin/dao/XxlJobLogGlueDaoTest.java
  10. 2
      xxl-job-admin/src/test/java/com/xxl/job/admin/dao/XxlJobRegistryDaoTest.java
  11. 2
      xxl-job-admin/src/test/java/com/xxl/job/admin/util/MailUtilTest.java
  12. 18
      xxl-job-admin/src/test/java/com/xxl/job/admin/util/PropertiesUtilTest.java
  13. 2
      xxl-job-admin/src/test/java/com/xxl/job/adminbiz/AdminBizTest.java

@ -834,7 +834,7 @@ echo "分片总数 total = $3"
调度中心API服务位置:com.xxl.job.core.biz.AdminBiz.java
调度中心API服务请求参考代码:com.xxl.job.dao.impl.AdminBizTest.java
调度中心API服务请求参考代码:com.xxl.job.adminbiz.AdminBizTest.java
### 5.12 执行器API服务
执行器提供了API服务,供调度中心选择使用,目前提供的API服务有:
@ -1097,6 +1097,7 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段
- 22、调度中心项目日志配置改为xml文件格式;
- 23、Log地址格式兼容,支持非"/"结尾路径配置;
- 24、底层系统日志级别规范调整,清理遗留代码;
- 25、建表SQL优化,支持同步创建制定编码的库和表;
### TODO LIST

@ -12,6 +12,7 @@ import java.util.Properties;
/**
* properties util
*
* @author xuxueli 2015-8-28 10:35:53
*/
public class PropertiesUtil {
@ -33,9 +34,5 @@ public class PropertiesUtil {
}
return null;
}
public static void main(String[] args) {
System.out.println(getString("xxl.job.login.username"));
}
}

@ -14,6 +14,7 @@ import org.springframework.web.context.WebApplicationContext;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath*:spring/*.xml"})
public class AbstractSpringMvcTest {
@Autowired
private WebApplicationContext applicationContext;
protected MockMvc mockMvc;
@ -22,4 +23,5 @@ public class AbstractSpringMvcTest {
public void setup() {
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.applicationContext).build();
}
}

@ -1,22 +0,0 @@
package com.xxl.job.admin.controller;
import org.junit.Test;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MvcResult;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
public class IndexControllerTest extends AbstractSpringMvcTest {
@Test
public void testLogin() throws Exception {
MvcResult ret = mockMvc.perform(
post("/login")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.param("userName", "admin")
.param("password", "123456")
).andReturn();
System.out.println(ret.getResponse().getContentAsString());
}
}

@ -1,52 +1,47 @@
package com.xxl.job.admin.controller;
import com.xxl.job.admin.core.model.XxlJobInfo;
import org.codehaus.jackson.map.ObjectMapper;
import com.xxl.job.admin.controller.interceptor.PermissionInterceptor;
import com.xxl.job.admin.core.util.PropertiesUtil;
import org.junit.Before;
import org.junit.Test;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import javax.servlet.http.Cookie;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
public class JobInfoControllerTest extends AbstractSpringMvcTest {
Cookie cookie;
private Cookie cookie;
@Before
public void login() throws Exception {
MvcResult ret = mockMvc.perform(
post("/login")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.param("userName", "admin")
.param("password", "123456")
.param("userName", PropertiesUtil.getString("xxl.job.login.username"))
.param("password", PropertiesUtil.getString("xxl.job.login.password"))
).andReturn();
cookie = ret.getResponse().getCookie("LOGIN_IDENTITY");
cookie = ret.getResponse().getCookie(PermissionInterceptor.LOGIN_IDENTITY_KEY);
}
@Test
public void testAdd() throws Exception {
XxlJobInfo jobInfo = new XxlJobInfo();
jobInfo.setJobGroup(1);
jobInfo.setJobDesc("autoEnquiryStatisPerWeek");
jobInfo.setExecutorRouteStrategy("FIRST");
jobInfo.setJobCron("0 0 1 ? * MON");
jobInfo.setGlueType("BEAN");
jobInfo.setExecutorHandler("AutoEnquriy");
jobInfo.setExecutorBlockStrategy("SERIAL_EXECUTION");
jobInfo.setExecutorFailStrategy("FAIL_ALARM");
jobInfo.setAuthor("listening");
ObjectMapper mapper = new ObjectMapper();
String jobInfoStr = mapper.writeValueAsString(jobInfo);
MultiValueMap<String, String> parameters = new LinkedMultiValueMap<String, String>();
parameters.add("jobGroup", "1");
MvcResult ret = mockMvc.perform(
post("/jobinfo/add")
post("/jobinfo/pageList")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.content(jobInfoStr)
//.content(paramsJson)
.params(parameters)
.cookie(cookie)
).andReturn();
System.out.println(ret.getResponse().getContentAsString());
}
}

@ -1,4 +1,4 @@
package com.xxl.job.dao.impl;
package com.xxl.job.admin.dao;
import com.xxl.job.admin.core.model.XxlJobGroup;
import com.xxl.job.admin.dao.XxlJobGroupDao;

@ -1,78 +1,78 @@
package com.xxl.job.dao.impl;
import com.xxl.job.admin.core.model.XxlJobInfo;
import com.xxl.job.admin.dao.XxlJobInfoDao;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath*:spring/applicationcontext-*.xml")
public class XxlJobInfoTest {
@Resource
private XxlJobInfoDao xxlJobInfoDao;
@Test
public void pageList(){
List<XxlJobInfo> list = xxlJobInfoDao.pageList(0, 20, 0, null);
int list_count = xxlJobInfoDao.pageListCount(0, 20, 0, null);
System.out.println(list);
System.out.println(list_count);
List<XxlJobInfo> list2 = xxlJobInfoDao.getJobsByGroup(1);
}
@Test
public void save_load(){
XxlJobInfo info = new XxlJobInfo();
info.setJobGroup(1);
info.setJobCron("jobCron");
info.setJobDesc("desc");
info.setAuthor("setAuthor");
info.setAlarmEmail("setAlarmEmail");
info.setExecutorRouteStrategy("setExecutorRouteStrategy");
info.setExecutorHandler("setExecutorHandler");
info.setExecutorParam("setExecutorParam");
info.setExecutorBlockStrategy("setExecutorBlockStrategy");
info.setExecutorFailStrategy("setExecutorFailStrategy");
info.setGlueType("setGlueType");
info.setGlueSource("setGlueSource");
info.setGlueRemark("setGlueRemark");
info.setChildJobKey("setChildJobKey");
int count = xxlJobInfoDao.save(info);
XxlJobInfo info2 = xxlJobInfoDao.loadById(info.getId());
info2.setJobCron("jobCron2");
info2.setJobDesc("desc2");
info2.setAuthor("setAuthor2");
info2.setAlarmEmail("setAlarmEmail2");
info2.setExecutorRouteStrategy("setExecutorRouteStrategy2");
info2.setExecutorHandler("setExecutorHandler2");
info2.setExecutorParam("setExecutorParam2");
info2.setExecutorBlockStrategy("setExecutorBlockStrategy2");
info2.setExecutorFailStrategy("setExecutorFailStrategy2");
info2.setGlueType("setGlueType2");
info2.setGlueSource("setGlueSource2");
info2.setGlueRemark("setGlueRemark2");
info2.setGlueUpdatetime(new Date());
info2.setChildJobKey("setChildJobKey2");
int item2 = xxlJobInfoDao.update(info2);
xxlJobInfoDao.delete(info2.getId());
List<XxlJobInfo> list2 = xxlJobInfoDao.getJobsByGroup(1);
int ret3 = xxlJobInfoDao.findAllCount();
}
}
package com.xxl.job.admin.dao;
import com.xxl.job.admin.core.model.XxlJobInfo;
import com.xxl.job.admin.dao.XxlJobInfoDao;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath*:spring/applicationcontext-*.xml")
public class XxlJobInfoDaoTest {
@Resource
private XxlJobInfoDao xxlJobInfoDao;
@Test
public void pageList(){
List<XxlJobInfo> list = xxlJobInfoDao.pageList(0, 20, 0, null);
int list_count = xxlJobInfoDao.pageListCount(0, 20, 0, null);
System.out.println(list);
System.out.println(list_count);
List<XxlJobInfo> list2 = xxlJobInfoDao.getJobsByGroup(1);
}
@Test
public void save_load(){
XxlJobInfo info = new XxlJobInfo();
info.setJobGroup(1);
info.setJobCron("jobCron");
info.setJobDesc("desc");
info.setAuthor("setAuthor");
info.setAlarmEmail("setAlarmEmail");
info.setExecutorRouteStrategy("setExecutorRouteStrategy");
info.setExecutorHandler("setExecutorHandler");
info.setExecutorParam("setExecutorParam");
info.setExecutorBlockStrategy("setExecutorBlockStrategy");
info.setExecutorFailStrategy("setExecutorFailStrategy");
info.setGlueType("setGlueType");
info.setGlueSource("setGlueSource");
info.setGlueRemark("setGlueRemark");
info.setChildJobKey("setChildJobKey");
int count = xxlJobInfoDao.save(info);
XxlJobInfo info2 = xxlJobInfoDao.loadById(info.getId());
info2.setJobCron("jobCron2");
info2.setJobDesc("desc2");
info2.setAuthor("setAuthor2");
info2.setAlarmEmail("setAlarmEmail2");
info2.setExecutorRouteStrategy("setExecutorRouteStrategy2");
info2.setExecutorHandler("setExecutorHandler2");
info2.setExecutorParam("setExecutorParam2");
info2.setExecutorBlockStrategy("setExecutorBlockStrategy2");
info2.setExecutorFailStrategy("setExecutorFailStrategy2");
info2.setGlueType("setGlueType2");
info2.setGlueSource("setGlueSource2");
info2.setGlueRemark("setGlueRemark2");
info2.setGlueUpdatetime(new Date());
info2.setChildJobKey("setChildJobKey2");
int item2 = xxlJobInfoDao.update(info2);
xxlJobInfoDao.delete(info2.getId());
List<XxlJobInfo> list2 = xxlJobInfoDao.getJobsByGroup(1);
int ret3 = xxlJobInfoDao.findAllCount();
}
}

@ -1,4 +1,4 @@
package com.xxl.job.dao.impl;
package com.xxl.job.admin.dao;
import com.xxl.job.admin.core.model.XxlJobLog;
import com.xxl.job.admin.dao.XxlJobLogDao;

@ -1,4 +1,4 @@
package com.xxl.job.dao.impl;
package com.xxl.job.admin.dao;
import com.xxl.job.admin.core.model.XxlJobLogGlue;
import com.xxl.job.admin.dao.XxlJobLogGlueDao;

@ -1,4 +1,4 @@
package com.xxl.job.dao.impl;
package com.xxl.job.admin.dao;
import com.xxl.job.admin.core.model.XxlJobRegistry;
import com.xxl.job.admin.dao.XxlJobRegistryDao;

@ -1,4 +1,4 @@
package com.xxl.job.dao.impl;
package com.xxl.job.admin.util;
import com.xxl.job.admin.core.util.MailUtil;
import org.junit.Test;

@ -0,0 +1,18 @@
package com.xxl.job.admin.util;
import com.xxl.job.admin.core.util.PropertiesUtil;
import org.junit.Test;
/**
* prop util test
*
* @author xuxueli 2017-12-25 15:17:36
*/
public class PropertiesUtilTest {
@Test
public void registryTest() throws Exception {
System.out.println(PropertiesUtil.getString("xxl.job.login.username"));
}
}

@ -1,4 +1,4 @@
package com.xxl.job.dao.impl;
package com.xxl.job.adminbiz;
import com.xxl.job.core.biz.AdminBiz;
import com.xxl.job.core.biz.model.RegistryParam;
Loading…
Cancel
Save