parent
32213ae06b
commit
7a8937ddf4
@ -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…
Reference in new issue