Skip to content

Commit 3298816

Browse files
committed
feat:添加测试用例
添加了对于配置文件日志级别的修改测试
1 parent 4c1cb77 commit 3298816

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

dongtai-log/src/test/java/io.dongtai.log/IastPropertiesTest.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ public class IastPropertiesTest {
99
private final String oldLogPath = System.getProperty("dongtai.log.path");
1010
private final String LogLevel = System.getProperty("dongtai.log.level");
1111

12+
private final String switchSign = System.getProperty("dongtai.log");
13+
14+
15+
1216
@Before
1317
public void setUp() {
1418
clear();
@@ -26,12 +30,32 @@ public void tearDown() {
2630
if (LogLevel != null) {
2731
System.setProperty("dongtai.log.level", LogLevel);
2832
}
33+
if (switchSign != null) {
34+
System.setProperty("dongtai.log", switchSign);
35+
}
2936
}
3037

3138
private void clear() {
3239
System.clearProperty("java.io.tmpdir.dongtai");
3340
System.clearProperty("dongtai.log.path");
3441
System.clearProperty("dongtai.log.level");
42+
System.clearProperty("dongtai.log");
43+
}
44+
45+
46+
@Test
47+
public void isEnabledTest(){
48+
boolean enabled = IastProperties.isEnabled();
49+
//默认开启
50+
Assert.assertTrue("isEnabled:" + enabled, enabled);
51+
52+
53+
//修改为关闭
54+
System.setProperty("dongtai.log", "false");
55+
enabled = IastProperties.isEnabled();
56+
Assert.assertFalse("isEnabled:" + enabled,enabled);
57+
58+
3559
}
3660

3761
@Test

0 commit comments

Comments
 (0)