mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
单元测试由Junit4变更为Junit5
This commit is contained in:
parent
69e278c787
commit
b427440274
@ -1,9 +1,11 @@
|
|||||||
package cn.hutool.cron.pattern;
|
package cn.hutool.cron.pattern;
|
||||||
|
|
||||||
import cn.hutool.cron.CronException;
|
import cn.hutool.cron.CronException;
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
public class CronPatternBuilderTest {
|
public class CronPatternBuilderTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -32,13 +34,15 @@ public class CronPatternBuilderTest {
|
|||||||
assertEquals("* * 2-9 * * *", build);
|
assertEquals("* * 2-9 * * *", build);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = CronException.class)
|
@Test
|
||||||
public void buildRangeErrorTest(){
|
public void buildRangeErrorTest(){
|
||||||
String build = CronPatternBuilder.of()
|
assertThrows(CronException.class, () -> {
|
||||||
|
String build = CronPatternBuilder.of()
|
||||||
.set(Part.SECOND, "*")
|
.set(Part.SECOND, "*")
|
||||||
// 55无效值
|
// 55无效值
|
||||||
.setRange(Part.HOUR, 2, 55)
|
.setRange(Part.HOUR, 2, 55)
|
||||||
.build();
|
.build();
|
||||||
assertEquals("* * 2-9 * * *", build);
|
assertEquals("* * 2-9 * * *", build);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,11 @@ package cn.hutool.cron.pattern;
|
|||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.cron.CronException;
|
import cn.hutool.cron.CronException;
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 定时任务单元测试类
|
* 定时任务单元测试类
|
||||||
*
|
*
|
||||||
@ -159,10 +161,12 @@ public class CronPatternTest {
|
|||||||
assertMatch(pattern, "2017-12-02 23:59:59");
|
assertMatch(pattern, "2017-12-02 23:59:59");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = CronException.class)
|
@Test
|
||||||
public void rangeYearTest() {
|
public void rangeYearTest() {
|
||||||
// year的范围是1970~2099年,超出报错
|
assertThrows(CronException.class, () -> {
|
||||||
CronPattern.of("0/1 * * * 1/1 ? 2020-2120");
|
// year的范围是1970~2099年,超出报错
|
||||||
|
CronPattern.of("0/1 * * * 1/1 ? 2020-2120");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5,7 +5,7 @@ import org.junit.jupiter.api.Test;
|
|||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
public class Issue3685Test {
|
public class Issue3685Test {
|
||||||
@Test
|
@Test
|
||||||
|
@ -7,7 +7,6 @@ import cn.hutool.core.net.NetUtil;
|
|||||||
import cn.hutool.core.net.url.UrlBuilder;
|
import cn.hutool.core.net.url.UrlBuilder;
|
||||||
import cn.hutool.core.util.CharsetUtil;
|
import cn.hutool.core.util.CharsetUtil;
|
||||||
import cn.hutool.core.util.ReUtil;
|
import cn.hutool.core.util.ReUtil;
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
|
||||||
import org.junit.jupiter.api.Disabled;
|
import org.junit.jupiter.api.Disabled;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
@ -16,6 +15,8 @@ import java.util.LinkedHashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
public class HttpUtilTest {
|
public class HttpUtilTest {
|
||||||
|
|
||||||
|
|
||||||
@ -392,10 +393,10 @@ public class HttpUtilTest {
|
|||||||
|
|
||||||
final String resp = HttpUtil.createPost(String.format("http://localhost:%s/formEncoded", port))
|
final String resp = HttpUtil.createPost(String.format("http://localhost:%s/formEncoded", port))
|
||||||
.form("test", test).execute().body();
|
.form("test", test).execute().body();
|
||||||
assertEquals("Form请求参数解码", test, resp);
|
assertEquals(test, resp);
|
||||||
|
|
||||||
final String urlGet = UrlBuilder.of(String.format("http://localhost:%s/urlEncoded", port)).addQuery("test", test).build();
|
final String urlGet = UrlBuilder.of(String.format("http://localhost:%s/urlEncoded", port)).addQuery("test", test).build();
|
||||||
final String resp2 = HttpUtil.createGet(urlGet).execute().body();
|
final String resp2 = HttpUtil.createGet(urlGet).execute().body();
|
||||||
assertEquals("QueryString请求参数编码", test, resp2);
|
assertEquals(test, resp2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,8 +58,8 @@ public class JWTTest {
|
|||||||
.setPayload("admin", true)
|
.setPayload("admin", true)
|
||||||
.setSigner(JWTSignerUtil.none());
|
.setSigner(JWTSignerUtil.none());
|
||||||
|
|
||||||
final String rightToken = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9." +
|
final String rightToken = "eyJ0eXAiOiJKV1QiLCJhbGciOiJub25lIn0." +
|
||||||
"eyJzdWIiOiIxMjM0NTY3ODkwIiwiYWRtaW4iOnRydWUsIm5hbWUiOiJsb29seSJ9.";
|
"eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6Imxvb2x5IiwiYWRtaW4iOnRydWV9.";
|
||||||
|
|
||||||
final String token = jwt.sign();
|
final String token = jwt.sign();
|
||||||
assertEquals(rightToken, token);
|
assertEquals(rightToken, token);
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package cn.hutool.jwt;
|
package cn.hutool.jwt;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
public class JWTUtilTest {
|
public class JWTUtilTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -43,10 +44,12 @@ public class JWTUtilTest {
|
|||||||
assertEquals(true, jwt.getPayload("admin"));
|
assertEquals(true, jwt.getPayload("admin"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void parseNullTest(){
|
public void parseNullTest(){
|
||||||
// https://gitee.com/dromara/hutool/issues/I5OCQB
|
assertThrows(IllegalArgumentException.class, () -> {
|
||||||
JWTUtil.parseToken(null);
|
// https://gitee.com/dromara/hutool/issues/I5OCQB
|
||||||
|
JWTUtil.parseToken(null);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user