Skip to content

Commit

Permalink
[ISSUE alibaba#11967] Can not aquire the specific config
Browse files Browse the repository at this point in the history
  • Loading branch information
syshenyao authored and yao.shen@hstong.com committed May 6, 2024
1 parent 478bf23 commit 5228a88
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
package com.alibaba.nacos.config.server.service.dump.disk;

import junit.framework.TestCase;
import org.junit.After;
import org.junit.Before;

import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
Expand All @@ -25,10 +28,23 @@

public class ConfigRawDiskServiceTest extends TestCase {

private String cachedOsName;

@Before
public void setUp() throws Exception {
cachedOsName = System.getProperty("os.name");
}

@After
public void tearDown() throws Exception {
System.setProperty("os.name", cachedOsName);
}

/**
* 测试获取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");
Expand All @@ -49,6 +65,7 @@ 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");
Expand All @@ -73,6 +90,7 @@ 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");
Expand Down

0 comments on commit 5228a88

Please sign in to comment.