Junit upgrade

pull/23/head
xueli.xue 4 years ago
parent 0998692790
commit 8ea3c39098

@ -34,7 +34,7 @@
<mysql-connector-java.version>8.0.22</mysql-connector-java.version>
<slf4j-api.version>1.7.30</slf4j-api.version>
<junit.version>4.13.1</junit.version>
<junit.version>5.7.0</junit.version>
<javax.annotation-api.version>1.3.2</javax.annotation-api.version>
<groovy.version>3.0.7</groovy.version>

@ -1,18 +1,12 @@
package com.xxl.job.admin.controller;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class AbstractSpringMvcTest {
@ -20,7 +14,7 @@ public class AbstractSpringMvcTest {
private WebApplicationContext applicationContext;
protected MockMvc mockMvc;
@Before
@BeforeEach
public void setup() {
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.applicationContext).build();
}

@ -1,8 +1,8 @@
package com.xxl.job.admin.controller;
import com.xxl.job.admin.service.LoginService;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.util.LinkedMultiValueMap;
@ -16,7 +16,7 @@ public class JobInfoControllerTest extends AbstractSpringMvcTest {
private Cookie cookie;
@Before
@BeforeEach
public void login() throws Exception {
MvcResult ret = mockMvc.perform(
post("/login")
@ -31,6 +31,7 @@ public class JobInfoControllerTest extends AbstractSpringMvcTest {
public void testAdd() throws Exception {
MultiValueMap<String, String> parameters = new LinkedMultiValueMap<String, String>();
parameters.add("jobGroup", "1");
parameters.add("triggerStatus", "-1");
MvcResult ret = mockMvc.perform(
post("/jobinfo/pageList")

@ -1,14 +1,12 @@
package com.xxl.job.admin.core.util;
import org.hamcrest.core.Is;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.util.HashMap;
import java.util.Map;
import static com.xxl.job.admin.core.util.JacksonUtil.writeValueAsString;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class JacksonUtilTest {
@ -23,7 +21,7 @@ public class JacksonUtilTest {
String json = writeValueAsString(map);
//then
assertThat(json, is("{\"aaa\":\"111\",\"bbb\":\"222\"}"));
assertEquals(json, "{\"aaa\":\"111\",\"bbb\":\"222\"}");
}
@Test
@ -35,8 +33,8 @@ public class JacksonUtilTest {
Map result = JacksonUtil.readValue(jsonString, Map.class);
//then
assertThat(result.get("aaa"), Is.<Object>is("111"));
assertThat(result.get("bbb"), Is.<Object>is("222"));
assertEquals(result.get("aaa"), "111");
assertEquals(result.get("bbb"),"222");
}
}

@ -1,16 +1,13 @@
package com.xxl.job.admin.dao;
import com.xxl.job.admin.core.model.XxlJobGroup;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class XxlJobGroupDaoTest {

@ -3,16 +3,13 @@ package com.xxl.job.admin.dao;
import com.xxl.job.admin.core.model.XxlJobInfo;
import com.xxl.job.admin.core.scheduler.MisfireStrategyEnum;
import com.xxl.job.admin.core.scheduler.ScheduleTypeEnum;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class XxlJobInfoDaoTest {

@ -1,16 +1,13 @@
package com.xxl.job.admin.dao;
import com.xxl.job.admin.core.model.XxlJobLog;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class XxlJobLogDaoTest {

@ -1,16 +1,13 @@
package com.xxl.job.admin.dao;
import com.xxl.job.admin.core.model.XxlJobLogGlue;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class XxlJobLogGlueDaoTest {

@ -1,17 +1,14 @@
package com.xxl.job.admin.dao;
import com.xxl.job.admin.core.model.XxlJobRegistry;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class XxlJobRegistryDaoTest {

@ -1,19 +1,14 @@
package com.xxl.job.admin.util;
import com.xxl.job.admin.core.util.I18nUtil;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit4.SpringRunner;
/**
* email util test
*
* @author xuxueli 2017-12-22 17:16:23
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class I18nUtilTest {

@ -7,12 +7,13 @@ import com.xxl.job.core.biz.model.RegistryParam;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.context.XxlJobContext;
import com.xxl.job.core.enums.RegistryConfig;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* admin api test
*
@ -37,7 +38,7 @@ public class AdminBizTest {
ReturnT<String> returnT = adminBiz.callback(callbackParamList);
Assert.assertTrue(returnT.getCode() == ReturnT.SUCCESS_CODE);
assertTrue(returnT.getCode() == ReturnT.SUCCESS_CODE);
}
/**
@ -52,7 +53,7 @@ public class AdminBizTest {
RegistryParam registryParam = new RegistryParam(RegistryConfig.RegistType.EXECUTOR.name(), "xxl-job-executor-example", "127.0.0.1:9999");
ReturnT<String> returnT = adminBiz.registry(registryParam);
Assert.assertTrue(returnT.getCode() == ReturnT.SUCCESS_CODE);
assertTrue(returnT.getCode() == ReturnT.SUCCESS_CODE);
}
/**
@ -67,7 +68,7 @@ public class AdminBizTest {
RegistryParam registryParam = new RegistryParam(RegistryConfig.RegistType.EXECUTOR.name(), "xxl-job-executor-example", "127.0.0.1:9999");
ReturnT<String> returnT = adminBiz.registryRemove(registryParam);
Assert.assertTrue(returnT.getCode() == ReturnT.SUCCESS_CODE);
assertTrue(returnT.getCode() == ReturnT.SUCCESS_CODE);
}

@ -5,8 +5,8 @@ import com.xxl.job.core.biz.client.ExecutorBizClient;
import com.xxl.job.core.biz.model.*;
import com.xxl.job.core.enums.ExecutorBlockStrategyEnum;
import com.xxl.job.core.glue.GlueTypeEnum;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
* executor api test
@ -26,10 +26,10 @@ public class ExecutorBizTest {
final ReturnT<String> retval = executorBiz.beat();
// Assert result
Assert.assertNotNull(retval);
Assert.assertNull(((ReturnT<String>) retval).getContent());
Assert.assertEquals(200, retval.getCode());
Assert.assertNull(retval.getMsg());
Assertions.assertNotNull(retval);
Assertions.assertNull(((ReturnT<String>) retval).getContent());
Assertions.assertEquals(200, retval.getCode());
Assertions.assertNull(retval.getMsg());
}
@Test
@ -42,10 +42,10 @@ public class ExecutorBizTest {
final ReturnT<String> retval = executorBiz.idleBeat(new IdleBeatParam(jobId));
// Assert result
Assert.assertNotNull(retval);
Assert.assertNull(((ReturnT<String>) retval).getContent());
Assert.assertEquals(500, retval.getCode());
Assert.assertEquals("job thread is running or has trigger queue.", retval.getMsg());
Assertions.assertNotNull(retval);
Assertions.assertNull(((ReturnT<String>) retval).getContent());
Assertions.assertEquals(500, retval.getCode());
Assertions.assertEquals("job thread is running or has trigger queue.", retval.getMsg());
}
@Test
@ -68,7 +68,7 @@ public class ExecutorBizTest {
final ReturnT<String> retval = executorBiz.run(triggerParam);
// Assert result
Assert.assertNotNull(retval);
Assertions.assertNotNull(retval);
}
@Test
@ -81,10 +81,10 @@ public class ExecutorBizTest {
final ReturnT<String> retval = executorBiz.kill(new KillParam(jobId));
// Assert result
Assert.assertNotNull(retval);
Assert.assertNull(((ReturnT<String>) retval).getContent());
Assert.assertEquals(200, retval.getCode());
Assert.assertNull(retval.getMsg());
Assertions.assertNotNull(retval);
Assertions.assertNull(((ReturnT<String>) retval).getContent());
Assertions.assertEquals(200, retval.getCode());
Assertions.assertNull(retval.getMsg());
}
@Test
@ -99,7 +99,7 @@ public class ExecutorBizTest {
final ReturnT<LogResult> retval = executorBiz.log(new LogParam(logDateTim, logId, fromLineNum));
// Assert result
Assert.assertNotNull(retval);
Assertions.assertNotNull(retval);
}
}

@ -58,8 +58,8 @@
</dependency>
<!-- junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>

@ -24,6 +24,13 @@
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j-api.version}</version>
</dependency>
<!-- junit -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<!-- xxl-job-core -->
<dependency>

@ -0,0 +1,12 @@
package com.xxl.job.executor.sample.frameless.test;
import org.junit.jupiter.api.Test;
public class FramelessApplicationTest {
@Test
public void test(){
System.out.println("111");
}
}

@ -1,17 +1,14 @@
package com.xxl.job.executor.test;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class XxlJobExecutorExampleBootApplicationTests {
@Test
public void test() {
System.out.println(11);
}
}
Loading…
Cancel
Save