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;
|
package com.xxl.job.admin.controller;
|
||||||
|
|
||||||
import com.xxl.job.admin.core.model.XxlJobInfo;
|
import com.xxl.job.admin.controller.interceptor.PermissionInterceptor;
|
||||||
import org.codehaus.jackson.map.ObjectMapper;
|
import com.xxl.job.admin.core.util.PropertiesUtil;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.test.web.servlet.MvcResult;
|
import org.springframework.test.web.servlet.MvcResult;
|
||||||
|
import org.springframework.util.LinkedMultiValueMap;
|
||||||
|
import org.springframework.util.MultiValueMap;
|
||||||
|
|
||||||
import javax.servlet.http.Cookie;
|
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 {
|
public class JobInfoControllerTest extends AbstractSpringMvcTest {
|
||||||
Cookie cookie;
|
|
||||||
|
private Cookie cookie;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void login() throws Exception {
|
public void login() throws Exception {
|
||||||
MvcResult ret = mockMvc.perform(
|
MvcResult ret = mockMvc.perform(
|
||||||
post("/login")
|
post("/login")
|
||||||
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
|
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
|
||||||
.param("userName", "admin")
|
.param("userName", PropertiesUtil.getString("xxl.job.login.username"))
|
||||||
.param("password", "123456")
|
.param("password", PropertiesUtil.getString("xxl.job.login.password"))
|
||||||
).andReturn();
|
).andReturn();
|
||||||
cookie = ret.getResponse().getCookie("LOGIN_IDENTITY");
|
cookie = ret.getResponse().getCookie(PermissionInterceptor.LOGIN_IDENTITY_KEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAdd() throws Exception {
|
public void testAdd() throws Exception {
|
||||||
XxlJobInfo jobInfo = new XxlJobInfo();
|
MultiValueMap<String, String> parameters = new LinkedMultiValueMap<String, String>();
|
||||||
jobInfo.setJobGroup(1);
|
parameters.add("jobGroup", "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);
|
|
||||||
MvcResult ret = mockMvc.perform(
|
MvcResult ret = mockMvc.perform(
|
||||||
post("/jobinfo/add")
|
post("/jobinfo/pageList")
|
||||||
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
|
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
|
||||||
.content(jobInfoStr)
|
//.content(paramsJson)
|
||||||
|
.params(parameters)
|
||||||
.cookie(cookie)
|
.cookie(cookie)
|
||||||
).andReturn();
|
).andReturn();
|
||||||
|
|
||||||
System.out.println(ret.getResponse().getContentAsString());
|
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.core.model.XxlJobGroup;
|
||||||
import com.xxl.job.admin.dao.XxlJobGroupDao;
|
import com.xxl.job.admin.dao.XxlJobGroupDao;
|
@ -1,78 +1,78 @@
|
|||||||
package com.xxl.job.dao.impl;
|
package com.xxl.job.admin.dao;
|
||||||
|
|
||||||
import com.xxl.job.admin.core.model.XxlJobInfo;
|
import com.xxl.job.admin.core.model.XxlJobInfo;
|
||||||
import com.xxl.job.admin.dao.XxlJobInfoDao;
|
import com.xxl.job.admin.dao.XxlJobInfoDao;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@ContextConfiguration(locations = "classpath*:spring/applicationcontext-*.xml")
|
@ContextConfiguration(locations = "classpath*:spring/applicationcontext-*.xml")
|
||||||
public class XxlJobInfoTest {
|
public class XxlJobInfoDaoTest {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private XxlJobInfoDao xxlJobInfoDao;
|
private XxlJobInfoDao xxlJobInfoDao;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void pageList(){
|
public void pageList(){
|
||||||
List<XxlJobInfo> list = xxlJobInfoDao.pageList(0, 20, 0, null);
|
List<XxlJobInfo> list = xxlJobInfoDao.pageList(0, 20, 0, null);
|
||||||
int list_count = xxlJobInfoDao.pageListCount(0, 20, 0, null);
|
int list_count = xxlJobInfoDao.pageListCount(0, 20, 0, null);
|
||||||
|
|
||||||
System.out.println(list);
|
System.out.println(list);
|
||||||
System.out.println(list_count);
|
System.out.println(list_count);
|
||||||
|
|
||||||
List<XxlJobInfo> list2 = xxlJobInfoDao.getJobsByGroup(1);
|
List<XxlJobInfo> list2 = xxlJobInfoDao.getJobsByGroup(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void save_load(){
|
public void save_load(){
|
||||||
XxlJobInfo info = new XxlJobInfo();
|
XxlJobInfo info = new XxlJobInfo();
|
||||||
info.setJobGroup(1);
|
info.setJobGroup(1);
|
||||||
info.setJobCron("jobCron");
|
info.setJobCron("jobCron");
|
||||||
info.setJobDesc("desc");
|
info.setJobDesc("desc");
|
||||||
info.setAuthor("setAuthor");
|
info.setAuthor("setAuthor");
|
||||||
info.setAlarmEmail("setAlarmEmail");
|
info.setAlarmEmail("setAlarmEmail");
|
||||||
info.setExecutorRouteStrategy("setExecutorRouteStrategy");
|
info.setExecutorRouteStrategy("setExecutorRouteStrategy");
|
||||||
info.setExecutorHandler("setExecutorHandler");
|
info.setExecutorHandler("setExecutorHandler");
|
||||||
info.setExecutorParam("setExecutorParam");
|
info.setExecutorParam("setExecutorParam");
|
||||||
info.setExecutorBlockStrategy("setExecutorBlockStrategy");
|
info.setExecutorBlockStrategy("setExecutorBlockStrategy");
|
||||||
info.setExecutorFailStrategy("setExecutorFailStrategy");
|
info.setExecutorFailStrategy("setExecutorFailStrategy");
|
||||||
info.setGlueType("setGlueType");
|
info.setGlueType("setGlueType");
|
||||||
info.setGlueSource("setGlueSource");
|
info.setGlueSource("setGlueSource");
|
||||||
info.setGlueRemark("setGlueRemark");
|
info.setGlueRemark("setGlueRemark");
|
||||||
info.setChildJobKey("setChildJobKey");
|
info.setChildJobKey("setChildJobKey");
|
||||||
|
|
||||||
int count = xxlJobInfoDao.save(info);
|
int count = xxlJobInfoDao.save(info);
|
||||||
|
|
||||||
XxlJobInfo info2 = xxlJobInfoDao.loadById(info.getId());
|
XxlJobInfo info2 = xxlJobInfoDao.loadById(info.getId());
|
||||||
info2.setJobCron("jobCron2");
|
info2.setJobCron("jobCron2");
|
||||||
info2.setJobDesc("desc2");
|
info2.setJobDesc("desc2");
|
||||||
info2.setAuthor("setAuthor2");
|
info2.setAuthor("setAuthor2");
|
||||||
info2.setAlarmEmail("setAlarmEmail2");
|
info2.setAlarmEmail("setAlarmEmail2");
|
||||||
info2.setExecutorRouteStrategy("setExecutorRouteStrategy2");
|
info2.setExecutorRouteStrategy("setExecutorRouteStrategy2");
|
||||||
info2.setExecutorHandler("setExecutorHandler2");
|
info2.setExecutorHandler("setExecutorHandler2");
|
||||||
info2.setExecutorParam("setExecutorParam2");
|
info2.setExecutorParam("setExecutorParam2");
|
||||||
info2.setExecutorBlockStrategy("setExecutorBlockStrategy2");
|
info2.setExecutorBlockStrategy("setExecutorBlockStrategy2");
|
||||||
info2.setExecutorFailStrategy("setExecutorFailStrategy2");
|
info2.setExecutorFailStrategy("setExecutorFailStrategy2");
|
||||||
info2.setGlueType("setGlueType2");
|
info2.setGlueType("setGlueType2");
|
||||||
info2.setGlueSource("setGlueSource2");
|
info2.setGlueSource("setGlueSource2");
|
||||||
info2.setGlueRemark("setGlueRemark2");
|
info2.setGlueRemark("setGlueRemark2");
|
||||||
info2.setGlueUpdatetime(new Date());
|
info2.setGlueUpdatetime(new Date());
|
||||||
info2.setChildJobKey("setChildJobKey2");
|
info2.setChildJobKey("setChildJobKey2");
|
||||||
|
|
||||||
int item2 = xxlJobInfoDao.update(info2);
|
int item2 = xxlJobInfoDao.update(info2);
|
||||||
|
|
||||||
xxlJobInfoDao.delete(info2.getId());
|
xxlJobInfoDao.delete(info2.getId());
|
||||||
|
|
||||||
List<XxlJobInfo> list2 = xxlJobInfoDao.getJobsByGroup(1);
|
List<XxlJobInfo> list2 = xxlJobInfoDao.getJobsByGroup(1);
|
||||||
|
|
||||||
int ret3 = xxlJobInfoDao.findAllCount();
|
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.core.model.XxlJobLog;
|
||||||
import com.xxl.job.admin.dao.XxlJobLogDao;
|
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.core.model.XxlJobLogGlue;
|
||||||
import com.xxl.job.admin.dao.XxlJobLogGlueDao;
|
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.core.model.XxlJobRegistry;
|
||||||
import com.xxl.job.admin.dao.XxlJobRegistryDao;
|
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 com.xxl.job.admin.core.util.MailUtil;
|
||||||
import org.junit.Test;
|
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.AdminBiz;
|
||||||
import com.xxl.job.core.biz.model.RegistryParam;
|
import com.xxl.job.core.biz.model.RegistryParam;
|
Loading…
Reference in new issue