diff --git a/dubbo-common/src/test/java/org/apache/dubbo/common/config/configcenter/file/FileSystemDynamicConfigurationTest.java b/dubbo-common/src/test/java/org/apache/dubbo/common/config/configcenter/file/FileSystemDynamicConfigurationTest.java index 17ead90b00a..71401363505 100644 --- a/dubbo-common/src/test/java/org/apache/dubbo/common/config/configcenter/file/FileSystemDynamicConfigurationTest.java +++ b/dubbo-common/src/test/java/org/apache/dubbo/common/config/configcenter/file/FileSystemDynamicConfigurationTest.java @@ -19,6 +19,7 @@ import org.apache.dubbo.common.URL; import org.apache.commons.io.FileUtils; +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -49,12 +50,18 @@ public class FileSystemDynamicConfigurationTest { @BeforeEach public void init() { - String classPath = getClassPath(); - URL url = valueOf("dubbo://127.0.0.1:20880").addParameter(CONFIG_CENTER_DIR_PARAM_NAME, classPath + File.separator + "config-center"); + File rootDirectory = new File(getClassPath(), "config-center"); + rootDirectory.mkdirs(); + URL url = valueOf("dubbo://127.0.0.1:20880").addParameter(CONFIG_CENTER_DIR_PARAM_NAME, rootDirectory.getAbsolutePath()); configuration = new FileSystemDynamicConfiguration(url); deleteQuietly(configuration.getRootDirectory()); } + @AfterEach + public void destroy() throws Exception { + configuration.close(); + } + private String getClassPath() { return getClass().getProtectionDomain().getCodeSource().getLocation().getPath(); }