mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
单元测试由Junit4变更为Junit5
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
<logback.version>1.4.14</logback.version>
|
||||
<log4j.version>1.2.17</log4j.version>
|
||||
<log4j2.version>2.20.0</log4j2.version>
|
||||
<commons-logging.version>1.3.0</commons-logging.version>
|
||||
<commons-logging.version>1.3.3</commons-logging.version>
|
||||
<tinylog.version>1.3.6</tinylog.version>
|
||||
<tinylog2.version>2.7.0</tinylog2.version>
|
||||
<!-- 此处固定3.4.x,支持到jdk8 -->
|
||||
|
@@ -11,7 +11,7 @@ import cn.hutool.log.dialect.log4j2.Log4j2LogFactory;
|
||||
import cn.hutool.log.dialect.slf4j.Slf4jLogFactory;
|
||||
import cn.hutool.log.dialect.tinylog.TinyLog2Factory;
|
||||
import cn.hutool.log.dialect.tinylog.TinyLogFactory;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* 日志门面单元测试
|
||||
@@ -19,15 +19,15 @@ import org.junit.Test;
|
||||
*
|
||||
*/
|
||||
public class CustomLogTest {
|
||||
|
||||
|
||||
private static final String LINE = "----------------------------------------------------------------------";
|
||||
|
||||
|
||||
@Test
|
||||
public void consoleLogTest(){
|
||||
LogFactory factory = new ConsoleLogFactory();
|
||||
LogFactory.setCurrentLogFactory(factory);
|
||||
Log log = LogFactory.get();
|
||||
|
||||
|
||||
log.info("This is custom '{}' log\n{}", factory.getName(), LINE);
|
||||
}
|
||||
|
||||
@@ -40,24 +40,24 @@ public class CustomLogTest {
|
||||
log.info(null);
|
||||
log.info((String)null);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void commonsLogTest(){
|
||||
LogFactory factory = new ApacheCommonsLogFactory();
|
||||
LogFactory.setCurrentLogFactory(factory);
|
||||
Log log = LogFactory.get();
|
||||
|
||||
|
||||
log.info(null);
|
||||
log.info((String)null);
|
||||
log.info("This is custom '{}' log\n{}", factory.getName(), LINE);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void tinyLogTest(){
|
||||
LogFactory factory = new TinyLogFactory();
|
||||
LogFactory.setCurrentLogFactory(factory);
|
||||
Log log = LogFactory.get();
|
||||
|
||||
|
||||
log.info(null);
|
||||
log.info((String)null);
|
||||
log.info("This is custom '{}' log\n{}", factory.getName(), LINE);
|
||||
@@ -73,7 +73,7 @@ public class CustomLogTest {
|
||||
log.info((String)null);
|
||||
log.info("This is custom '{}' log\n{}", factory.getName(), LINE);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void log4j2LogTest(){
|
||||
LogFactory factory = new Log4j2LogFactory();
|
||||
@@ -86,47 +86,47 @@ public class CustomLogTest {
|
||||
log.info((String)null);
|
||||
log.info("This is custom '{}' log\n{}", factory.getName(), LINE);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void log4jLogTest(){
|
||||
LogFactory factory = new Log4jLogFactory();
|
||||
LogFactory.setCurrentLogFactory(factory);
|
||||
Log log = LogFactory.get();
|
||||
|
||||
|
||||
log.info(null);
|
||||
log.info((String)null);
|
||||
log.info("This is custom '{}' log\n{}", factory.getName(), LINE);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void jbossLogTest(){
|
||||
LogFactory factory = new JbossLogFactory();
|
||||
LogFactory.setCurrentLogFactory(factory);
|
||||
Log log = LogFactory.get();
|
||||
|
||||
|
||||
log.info(null);
|
||||
log.info((String)null);
|
||||
log.info("This is custom '{}' log\n{}", factory.getName(), LINE);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void jdkLogTest(){
|
||||
LogFactory factory = new JdkLogFactory();
|
||||
LogFactory.setCurrentLogFactory(factory);
|
||||
Log log = LogFactory.get();
|
||||
|
||||
|
||||
log.info(null);
|
||||
log.info((String)null);
|
||||
log.info("This is custom '{}' log\n{}", factory.getName(), LINE);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void slf4jTest(){
|
||||
LogFactory factory = new Slf4jLogFactory(false);
|
||||
LogFactory.setCurrentLogFactory(factory);
|
||||
Log log = LogFactory.get();
|
||||
|
||||
|
||||
log.info(null);
|
||||
log.info((String)null);
|
||||
log.info("This is custom '{}' log\n{}", factory.getName(), LINE);
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package cn.hutool.log.test;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import cn.hutool.log.Log;
|
||||
import cn.hutool.log.LogFactory;
|
||||
@@ -13,25 +13,25 @@ import cn.hutool.log.level.Level;
|
||||
*
|
||||
*/
|
||||
public class LogTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void logTest(){
|
||||
Log log = LogFactory.get();
|
||||
|
||||
|
||||
// 自动选择日志实现
|
||||
log.debug("This is {} log", Level.DEBUG);
|
||||
log.info("This is {} log", Level.INFO);
|
||||
log.warn("This is {} log", Level.WARN);
|
||||
|
||||
|
||||
// Exception e = new Exception("test Exception");
|
||||
// log.error(e, "This is {} log", Level.ERROR);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 兼容slf4j日志消息格式测试,即第二个参数是异常对象时正常输出异常信息
|
||||
*/
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void logWithExceptionTest() {
|
||||
Log log = LogFactory.get();
|
||||
Exception e = new Exception("test Exception");
|
||||
|
@@ -3,7 +3,7 @@ package cn.hutool.log.test;
|
||||
import cn.hutool.log.Log;
|
||||
import cn.hutool.log.LogFactory;
|
||||
import cn.hutool.log.dialect.logtube.LogTubeLogFactory;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class LogTubeTest {
|
||||
|
||||
|
@@ -4,7 +4,7 @@ import cn.hutool.log.LogFactory;
|
||||
import cn.hutool.log.StaticLog;
|
||||
import cn.hutool.log.dialect.console.ConsoleColorLogFactory;
|
||||
import cn.hutool.log.dialect.console.ConsoleLogFactory;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class StaticLogTest {
|
||||
@Test
|
||||
|
Reference in New Issue
Block a user