Search in sources :

Example 1 with InstanceResponse

use of com.alibaba.nacos.api.naming.remote.response.InstanceResponse in project nacos by alibaba.

the class NamingGrpcClientProxyTest method setUp.

@Before
public void setUp() throws NacosException, NoSuchFieldException, IllegalAccessException {
    List<String> serverList = Stream.of(ORIGIN_SERVER, "anotherServer").collect(Collectors.toList());
    when(factory.getServerList()).thenReturn(serverList);
    when(factory.genNextServer()).thenReturn(ORIGIN_SERVER);
    prop = new Properties();
    client = new NamingGrpcClientProxy(NAMESPACE_ID, proxy, factory, prop, holder);
    Field rpcClientField = NamingGrpcClientProxy.class.getDeclaredField("rpcClient");
    rpcClientField.setAccessible(true);
    rpcClientField.set(client, this.rpcClient);
    response = new InstanceResponse();
    when(this.rpcClient.request(any())).thenReturn(response);
    instance = new Instance();
    instance.setServiceName(SERVICE_NAME);
    instance.setIp("1.1.1.1");
    instance.setPort(1111);
}
Also used : Field(java.lang.reflect.Field) Instance(com.alibaba.nacos.api.naming.pojo.Instance) InstanceResponse(com.alibaba.nacos.api.naming.remote.response.InstanceResponse) Properties(java.util.Properties) Before(org.junit.Before)

Aggregations

Instance (com.alibaba.nacos.api.naming.pojo.Instance)1 InstanceResponse (com.alibaba.nacos.api.naming.remote.response.InstanceResponse)1 Field (java.lang.reflect.Field)1 Properties (java.util.Properties)1 Before (org.junit.Before)1