diff --git a/config/src/test/java/com/alibaba/nacos/config/server/service/dump/disk/ConfigRawDiskServiceTest.java b/config/src/test/java/com/alibaba/nacos/config/server/service/dump/disk/ConfigRawDiskServiceTest.java index 70271b6b68c..ab2c8f71bdf 100644 --- a/config/src/test/java/com/alibaba/nacos/config/server/service/dump/disk/ConfigRawDiskServiceTest.java +++ b/config/src/test/java/com/alibaba/nacos/config/server/service/dump/disk/ConfigRawDiskServiceTest.java @@ -33,6 +33,7 @@ public class ConfigRawDiskServiceTest extends TestCase { @Before public void setUp() throws Exception { cachedOsName = System.getProperty("os.name"); + System.setProperty("os.name", "window"); } @After @@ -41,10 +42,9 @@ public void tearDown() throws Exception { } /** - * 测试获取beta文件路径. + * 测试获取文件路径. */ public void testTargetFile() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { - System.setProperty("os.name", "window"); Method method = ConfigRawDiskService.class.getDeclaredMethod("targetFile", String.class, String.class, String.class); method.setAccessible(true); File result = (File) method.invoke(null, "aaaa\\dsaknkf", "aaaa/dsaknkf", "aaaa:dsaknkf"); @@ -65,7 +65,6 @@ public void testTargetFile() throws NoSuchMethodException, IllegalAccessExceptio * 测试获取beta文件路径. */ public void testTargetBetaFile() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { - System.setProperty("os.name", "window"); Method method = ConfigRawDiskService.class.getDeclaredMethod("targetBetaFile", String.class, String.class, String.class); method.setAccessible(true); File result = (File) method.invoke(null, "aaaa\\dsaknkf", "aaaa/dsaknkf", "aaaa:dsaknkf"); @@ -90,7 +89,6 @@ public void testTargetBetaFile() throws NoSuchMethodException, IllegalAccessExce * @throws InvocationTargetException 目标异常 */ public void testTargetTagFile() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { - System.setProperty("os.name", "window"); Method method = ConfigRawDiskService.class.getDeclaredMethod("targetTagFile", String.class, String.class, String.class, String.class); method.setAccessible(true); File result = (File) method.invoke(null, "aaaa\\dsaknkf", "aaaa/dsaknkf", "aaaa:dsaknkf", "aaaadsaknkf");