From 312c3397222a3a31590ef1983a85855a26104bf9 Mon Sep 17 00:00:00 2001 From: Wenjun Ruan Date: Fri, 13 Oct 2023 16:43:54 +0800 Subject: [PATCH] Delete File generated by UT (#15022) --- .../dolphinscheduler/common/utils/FileUtilsTest.java | 6 ++++++ .../dao/utils/TaskCacheUtilsTest.java | 12 ++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/FileUtilsTest.java b/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/FileUtilsTest.java index b47ae692f6..faa99e2a32 100644 --- a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/FileUtilsTest.java +++ b/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/FileUtilsTest.java @@ -22,6 +22,7 @@ import static org.apache.dolphinscheduler.common.constants.DateConstants.YYYYMMD import java.io.FileInputStream; import java.io.FileNotFoundException; +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -128,4 +129,9 @@ public class FileUtilsTest { () -> FileUtils.getFileChecksum(dirPath)); } + @AfterEach + public void tearDown() { + FileUtils.deleteFile("test"); + } + } diff --git a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/utils/TaskCacheUtilsTest.java b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/utils/TaskCacheUtilsTest.java index 1b6329b3a6..49d5a87bb6 100644 --- a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/utils/TaskCacheUtilsTest.java +++ b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/utils/TaskCacheUtilsTest.java @@ -17,8 +17,6 @@ package org.apache.dolphinscheduler.dao.utils; -import static org.apache.dolphinscheduler.common.constants.Constants.CRC_SUFFIX; - import org.apache.dolphinscheduler.common.enums.Flag; import org.apache.dolphinscheduler.common.utils.FileUtils; import org.apache.dolphinscheduler.dao.entity.TaskInstance; @@ -36,6 +34,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -182,8 +181,8 @@ class TaskCacheUtilsTest { @Test void testReplaceWithCheckSum() { String content = "abcdefg"; - String filePath = "test/testFile.txt"; - FileUtils.writeContent2File(content, filePath + CRC_SUFFIX); + String filePath = "test/testFile.txt.crc"; + FileUtils.writeContent2File(content, filePath); Property property = new Property(); property.setProp("f1"); @@ -197,4 +196,9 @@ class TaskCacheUtilsTest { String crc = TaskCacheUtils.getValCheckSum(property, taskExecutionContext, storageOperate); Assertions.assertEquals(crc, content); } + + @AfterEach + public void tearDown() { + FileUtils.deleteFile("test"); + } }