use of com.alibaba.nacos.api.naming.pojo.Service in project nacos by alibaba.
the class NacosNamingMaintainServiceTest method testUpdateService3.
@Test
public void testUpdateService3() throws NacosException {
// given
Service service = new Service();
AbstractSelector selector = new NoneSelector();
// when
nacosNamingMaintainService.updateService(service, selector);
// then
verify(serverProxy, times(1)).updateService(service, selector);
}
use of com.alibaba.nacos.api.naming.pojo.Service in project nacos by alibaba.
the class NamingClientProxyDelegateTest method testQueryService.
@Test
public void testQueryService() throws NacosException {
String ns = "ns1";
ServiceInfoHolder holder = Mockito.mock(ServiceInfoHolder.class);
Properties props = new Properties();
props.setProperty("serverAddr", "localhost");
InstancesChangeNotifier notifier = new InstancesChangeNotifier();
NamingClientProxyDelegate delegate = new NamingClientProxyDelegate(ns, holder, props, notifier);
Service service = delegate.queryService("a", "b");
Assert.assertNull(service);
}
use of com.alibaba.nacos.api.naming.pojo.Service in project nacos by alibaba.
the class NamingGrpcClientProxyTest method testCreateService.
@Test
public void testCreateService() throws Exception {
// TODO thrown.expect(UnsupportedOperationException.class);
Service service = new Service();
AbstractSelector selector = new NoneSelector();
client.createService(service, selector);
}
use of com.alibaba.nacos.api.naming.pojo.Service in project nacos by alibaba.
the class NamingHttpClientProxyTest method testUpdateService.
@Test
public void testUpdateService() throws Exception {
// given
NacosRestTemplate nacosRestTemplate = mock(NacosRestTemplate.class);
HttpRestResult<Object> a = new HttpRestResult<Object>();
a.setData("");
a.setCode(200);
when(nacosRestTemplate.exchangeForm(any(), any(), any(), any(), any(), any())).thenReturn(a);
SecurityProxy proxy = mock(SecurityProxy.class);
ServerListManager mgr = mock(ServerListManager.class);
when(mgr.getServerList()).thenReturn(Arrays.asList("localhost"));
Properties props = new Properties();
ServiceInfoHolder holder = mock(ServiceInfoHolder.class);
NamingHttpClientProxy clientProxy = new NamingHttpClientProxy("namespaceId", proxy, mgr, props, holder);
final Field nacosRestTemplateField = NamingHttpClientProxy.class.getDeclaredField("nacosRestTemplate");
nacosRestTemplateField.setAccessible(true);
nacosRestTemplateField.set(clientProxy, nacosRestTemplate);
String serviceName = "service1";
String groupName = "group1";
// when
clientProxy.updateService(new Service(), new NoneSelector());
// then
verify(nacosRestTemplate, times(1)).exchangeForm(endsWith(UtilAndComs.nacosUrlService), any(), any(), any(), eq(HttpMethod.PUT), any());
}
use of com.alibaba.nacos.api.naming.pojo.Service in project nacos by alibaba.
the class NamingMaintainService_ITCase method deleteService.
@Test
public void deleteService() throws NacosException {
String serviceName = randomDomainName();
Service preService = new Service();
preService.setName(serviceName);
System.out.println("service info : " + preService);
namingMaintainService.createService(preService, new NoneSelector());
Assert.assertTrue(namingMaintainService.deleteService(serviceName));
}
Aggregations