mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
单元测试由Junit4变更为Junit5
This commit is contained in:
@@ -4,8 +4,8 @@ import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.setting.dialect.Props;
|
||||
import cn.hutool.setting.dialect.PropsUtil;
|
||||
import lombok.Data;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class Issue3008Test {
|
||||
|
||||
@@ -17,7 +17,7 @@ public class Issue3008Test {
|
||||
public void toBeanTest() {
|
||||
final Props props = PropsUtil.get("issue3008");
|
||||
final MyUser user = props.toBean(MyUser.class, "person");
|
||||
Assert.assertEquals("[LOL, KFC, COFFE]", ArrayUtil.toString(user.getHobby()));
|
||||
assertEquals("[LOL, KFC, COFFE]", ArrayUtil.toString(user.getHobby()));
|
||||
}
|
||||
|
||||
@Data
|
||||
|
@@ -12,8 +12,8 @@
|
||||
|
||||
package cn.hutool.setting;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class IssueI7G34ETest {
|
||||
|
||||
@@ -22,6 +22,6 @@ public class IssueI7G34ETest {
|
||||
final Setting setting = new Setting("test_with_bom.setting");
|
||||
final String s = setting.get("line1", "key1");
|
||||
|
||||
Assert.assertEquals("value1", s);
|
||||
assertEquals("value1", s);
|
||||
}
|
||||
}
|
||||
|
@@ -5,16 +5,17 @@ import cn.hutool.log.LogFactory;
|
||||
import cn.hutool.log.dialect.console.ConsoleLogFactory;
|
||||
import cn.hutool.setting.dialect.Props;
|
||||
import lombok.Data;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
* Setting单元测试
|
||||
*
|
||||
@@ -23,7 +24,7 @@ import java.util.Objects;
|
||||
*/
|
||||
public class PropsTest {
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void init() {
|
||||
LogFactory.setCurrentLogFactory(ConsoleLogFactory.class);
|
||||
}
|
||||
@@ -33,22 +34,22 @@ public class PropsTest {
|
||||
//noinspection MismatchedQueryAndUpdateOfCollection
|
||||
final Props props = new Props("test.properties");
|
||||
final String user = props.getProperty("user");
|
||||
Assert.assertEquals(user, "root");
|
||||
assertEquals(user, "root");
|
||||
|
||||
final String driver = props.getStr("driver");
|
||||
Assert.assertEquals(driver, "com.mysql.jdbc.Driver");
|
||||
assertEquals(driver, "com.mysql.jdbc.Driver");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void propTestForAbsPAth() {
|
||||
//noinspection MismatchedQueryAndUpdateOfCollection
|
||||
final Props props = new Props("d:/test.properties");
|
||||
final String user = props.getProperty("user");
|
||||
Assert.assertEquals(user, "root");
|
||||
assertEquals(user, "root");
|
||||
|
||||
final String driver = props.getStr("driver");
|
||||
Assert.assertEquals(driver, "com.mysql.jdbc.Driver");
|
||||
assertEquals(driver, "com.mysql.jdbc.Driver");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -56,19 +57,19 @@ public class PropsTest {
|
||||
final Props props = Props.getProp("to_bean_test.properties");
|
||||
|
||||
final ConfigProperties cfg = props.toBean(ConfigProperties.class, "mail");
|
||||
Assert.assertEquals("mailer@mail.com", cfg.getHost());
|
||||
Assert.assertEquals(9000, cfg.getPort());
|
||||
Assert.assertEquals("mailer@mail.com", cfg.getFrom());
|
||||
assertEquals("mailer@mail.com", cfg.getHost());
|
||||
assertEquals(9000, cfg.getPort());
|
||||
assertEquals("mailer@mail.com", cfg.getFrom());
|
||||
|
||||
Assert.assertEquals("john", cfg.getCredentials().getUsername());
|
||||
Assert.assertEquals("password", cfg.getCredentials().getPassword());
|
||||
Assert.assertEquals("SHA1", cfg.getCredentials().getAuthMethod());
|
||||
assertEquals("john", cfg.getCredentials().getUsername());
|
||||
assertEquals("password", cfg.getCredentials().getPassword());
|
||||
assertEquals("SHA1", cfg.getCredentials().getAuthMethod());
|
||||
|
||||
Assert.assertEquals("true", cfg.getAdditionalHeaders().get("redelivery"));
|
||||
Assert.assertEquals("true", cfg.getAdditionalHeaders().get("secure"));
|
||||
assertEquals("true", cfg.getAdditionalHeaders().get("redelivery"));
|
||||
assertEquals("true", cfg.getAdditionalHeaders().get("secure"));
|
||||
|
||||
Assert.assertEquals("admin@mail.com", cfg.getDefaultRecipients().get(0));
|
||||
Assert.assertEquals("owner@mail.com", cfg.getDefaultRecipients().get(1));
|
||||
assertEquals("admin@mail.com", cfg.getDefaultRecipients().get(0));
|
||||
assertEquals("owner@mail.com", cfg.getDefaultRecipients().get(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -82,11 +83,11 @@ public class PropsTest {
|
||||
configProp.setProperty("version", 3);
|
||||
final SystemConfig systemConfig = configProp.toBean(SystemConfig.class);
|
||||
|
||||
Assert.assertEquals(DateUtil.parse("2020-01-01"), systemConfig.getCreateTime());
|
||||
Assert.assertEquals(true, systemConfig.getIsInit());
|
||||
Assert.assertEquals("1", systemConfig.getStairPlan());
|
||||
Assert.assertEquals(new Integer(2), systemConfig.getStageNum());
|
||||
Assert.assertEquals("3", systemConfig.getVersion());
|
||||
assertEquals(DateUtil.parse("2020-01-01"), systemConfig.getCreateTime());
|
||||
assertEquals(true, systemConfig.getIsInit());
|
||||
assertEquals("1", systemConfig.getStairPlan());
|
||||
assertEquals(new Integer(2), systemConfig.getStageNum());
|
||||
assertEquals("3", systemConfig.getVersion());
|
||||
}
|
||||
|
||||
@Data
|
||||
|
@@ -1,8 +1,8 @@
|
||||
package cn.hutool.setting;
|
||||
|
||||
import cn.hutool.setting.dialect.PropsUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -11,12 +11,12 @@ public class PropsUtilTest {
|
||||
@Test
|
||||
public void getTest() {
|
||||
String driver = PropsUtil.get("test").getStr("driver");
|
||||
Assert.assertEquals("com.mysql.jdbc.Driver", driver);
|
||||
assertEquals("com.mysql.jdbc.Driver", driver);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getFirstFoundTest() {
|
||||
String driver = Objects.requireNonNull(PropsUtil.getFirstFound("test2", "test")).getStr("driver");
|
||||
Assert.assertEquals("com.mysql.jdbc.Driver", driver);
|
||||
assertEquals("com.mysql.jdbc.Driver", driver);
|
||||
}
|
||||
}
|
||||
|
@@ -1,9 +1,9 @@
|
||||
package cn.hutool.setting;
|
||||
|
||||
import cn.hutool.core.lang.Console;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Setting单元测试
|
||||
@@ -18,23 +18,23 @@ public class SettingTest {
|
||||
Setting setting = new Setting("test.setting", true);
|
||||
|
||||
String driver = setting.getByGroup("driver", "demo");
|
||||
Assert.assertEquals("com.mysql.jdbc.Driver", driver);
|
||||
assertEquals("com.mysql.jdbc.Driver", driver);
|
||||
|
||||
//本分组变量替换
|
||||
String user = setting.getByGroup("user", "demo");
|
||||
Assert.assertEquals("rootcom.mysql.jdbc.Driver", user);
|
||||
assertEquals("rootcom.mysql.jdbc.Driver", user);
|
||||
|
||||
//跨分组变量替换
|
||||
String user2 = setting.getByGroup("user2", "demo");
|
||||
Assert.assertEquals("rootcom.mysql.jdbc.Driver", user2);
|
||||
assertEquals("rootcom.mysql.jdbc.Driver", user2);
|
||||
|
||||
//默认值测试
|
||||
String value = setting.getStr("keyNotExist", "defaultTest");
|
||||
Assert.assertEquals("defaultTest", value);
|
||||
assertEquals("defaultTest", value);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void settingTestForAbsPath() {
|
||||
//noinspection MismatchedQueryAndUpdateOfCollection
|
||||
Setting setting = new Setting("d:\\excel-plugin\\other.setting", true);
|
||||
@@ -50,10 +50,10 @@ public class SettingTest {
|
||||
setting.setByGroup("user", "group3", "root3");
|
||||
setting.set("user", "root4");
|
||||
|
||||
Assert.assertEquals("root", setting.getByGroup("user", "group1"));
|
||||
Assert.assertEquals("root2", setting.getByGroup("user", "group2"));
|
||||
Assert.assertEquals("root3", setting.getByGroup("user", "group3"));
|
||||
Assert.assertEquals("root4", setting.get("user"));
|
||||
assertEquals("root", setting.getByGroup("user", "group1"));
|
||||
assertEquals("root2", setting.getByGroup("user", "group2"));
|
||||
assertEquals("root3", setting.getByGroup("user", "group3"));
|
||||
assertEquals("root4", setting.get("user"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,20 +1,20 @@
|
||||
package cn.hutool.setting;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class SettingUtilTest {
|
||||
|
||||
@Test
|
||||
public void getTest() {
|
||||
String driver = SettingUtil.get("test").get("demo", "driver");
|
||||
Assert.assertEquals("com.mysql.jdbc.Driver", driver);
|
||||
assertEquals("com.mysql.jdbc.Driver", driver);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTest2() {
|
||||
String driver = SettingUtil.get("example/example").get("demo", "key");
|
||||
Assert.assertEquals("value", driver);
|
||||
assertEquals("value", driver);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -22,6 +22,6 @@ public class SettingUtilTest {
|
||||
//noinspection ConstantConditions
|
||||
String driver = SettingUtil.getFirstFound("test2", "test")
|
||||
.get("demo", "driver");
|
||||
Assert.assertEquals("com.mysql.jdbc.Driver", driver);
|
||||
assertEquals("com.mysql.jdbc.Driver", driver);
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@ package cn.hutool.setting.yaml;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.lang.Dict;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -15,15 +15,15 @@ public class YamlUtilTest {
|
||||
public void loadByPathTest() {
|
||||
final Dict result = YamlUtil.loadByPath("test.yaml");
|
||||
|
||||
Assert.assertEquals("John", result.getStr("firstName"));
|
||||
assertEquals("John", result.getStr("firstName"));
|
||||
|
||||
final List<Integer> numbers = result.getByPath("contactDetails.number");
|
||||
Assert.assertEquals(123456789, (int) numbers.get(0));
|
||||
Assert.assertEquals(456786868, (int) numbers.get(1));
|
||||
assertEquals(123456789, (int) numbers.get(0));
|
||||
assertEquals(456786868, (int) numbers.get(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void dumpTest() {
|
||||
final Dict dict = Dict.create()
|
||||
.set("name", "hutool")
|
||||
|
Reference in New Issue
Block a user