|
|
|
@ -19,13 +19,9 @@ package com.alibaba.cloud.nacos.endpoint;
|
|
|
|
|
import static org.junit.Assert.assertEquals;
|
|
|
|
|
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.NONE;
|
|
|
|
|
|
|
|
|
|
import java.lang.reflect.InvocationHandler;
|
|
|
|
|
import java.lang.reflect.Method;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
import org.junit.Assert;
|
|
|
|
|
import org.junit.Test;
|
|
|
|
|
import org.junit.runner.RunWith;
|
|
|
|
|
import org.powermock.api.mockito.PowerMockito;
|
|
|
|
@ -68,17 +64,13 @@ public class NacosConfigEndpointTests {
|
|
|
|
|
|
|
|
|
|
Method method = PowerMockito.method(NacosConfigService.class, "getConfig",
|
|
|
|
|
String.class, String.class, long.class);
|
|
|
|
|
MethodProxy.proxy(method, new InvocationHandler() {
|
|
|
|
|
@Override
|
|
|
|
|
public Object invoke(Object proxy, Method method, Object[] args)
|
|
|
|
|
throws Throwable {
|
|
|
|
|
|
|
|
|
|
if ("test-name.properties".equals(args[0])
|
|
|
|
|
&& "DEFAULT_GROUP".equals(args[1])) {
|
|
|
|
|
return "user.name=hello\nuser.age=12";
|
|
|
|
|
}
|
|
|
|
|
return "";
|
|
|
|
|
MethodProxy.proxy(method, (proxy, method1, args) -> {
|
|
|
|
|
|
|
|
|
|
if ("test-name.properties".equals(args[0])
|
|
|
|
|
&& "DEFAULT_GROUP".equals(args[1])) {
|
|
|
|
|
return "user.name=hello\nuser.age=12";
|
|
|
|
|
}
|
|
|
|
|
return "";
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -107,18 +99,16 @@ public class NacosConfigEndpointTests {
|
|
|
|
|
Builder builder = new Builder();
|
|
|
|
|
|
|
|
|
|
NacosConfigHealthIndicator healthIndicator = new NacosConfigHealthIndicator(
|
|
|
|
|
properties, properties.configServiceInstance());
|
|
|
|
|
properties.configServiceInstance());
|
|
|
|
|
healthIndicator.doHealthCheck(builder);
|
|
|
|
|
|
|
|
|
|
Builder builder1 = new Builder();
|
|
|
|
|
List<String> dataIds = new ArrayList<>();
|
|
|
|
|
dataIds.add("test-name.properties");
|
|
|
|
|
builder1.up().withDetail("dataIds", dataIds);
|
|
|
|
|
builder1.up();
|
|
|
|
|
|
|
|
|
|
Assert.assertTrue(builder.build().equals(builder1.build()));
|
|
|
|
|
assertEquals(builder1.build(), builder.build());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ignoreE) {
|
|
|
|
|
catch (Exception ignore) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|