use of com.alibaba.nacos.api.selector.NoneSelector 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));
}
use of com.alibaba.nacos.api.selector.NoneSelector in project nacos by alibaba.
the class NamingMaintainService_ITCase method createAndUpdateService.
@Test
public void createAndUpdateService() throws NacosException {
String serviceName = randomDomainName();
// register service
Service preService = new Service();
preService.setName(serviceName);
preService.setGroupName(Constants.DEFAULT_GROUP);
preService.setProtectThreshold(1.0f);
Map<String, String> metadata = new HashMap<String, String>();
metadata.put(serviceName, "this is a register metadata");
preService.setMetadata(metadata);
ExpressionSelector selector = new ExpressionSelector();
selector.setExpression("CONSUMER.label.A=PROVIDER.label.A &CONSUMER.label.B=PROVIDER.label.B");
System.out.println("service info : " + preService);
namingMaintainService.createService(preService, selector);
Service remoteService = namingMaintainService.queryService(serviceName);
System.out.println("remote service info : " + remoteService);
Assert.assertEquals(preService.toString(), remoteService.toString());
// update service
Service nowService = new Service();
nowService.setName(serviceName);
nowService.setGroupName(Constants.DEFAULT_GROUP);
nowService.setProtectThreshold(1.0f);
metadata.clear();
metadata.put(serviceName, "this is a update metadata");
nowService.setMetadata(metadata);
namingMaintainService.updateService(nowService, new NoneSelector());
remoteService = namingMaintainService.queryService(serviceName);
System.out.println("remote service info : " + remoteService);
Assert.assertEquals(nowService.toString(), remoteService.toString());
}
use of com.alibaba.nacos.api.selector.NoneSelector in project nacos by alibaba.
the class NamingClientProxyDelegateTest method testCreateService.
@Test
public void testCreateService() 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 = new Service();
try {
delegate.createService(service, new NoneSelector());
} catch (Exception e) {
Assert.fail();
}
}
use of com.alibaba.nacos.api.selector.NoneSelector in project nacos by alibaba.
the class NamingGrpcClientProxyTest method testUpdateService.
@Test
public void testUpdateService() throws NacosException {
// TODO thrown.expect(UnsupportedOperationException.class);
Service service = new Service();
AbstractSelector selector = new NoneSelector();
client.updateService(service, selector);
}
use of com.alibaba.nacos.api.selector.NoneSelector in project nacos by alibaba.
the class NamingHttpClientProxyTest method testCreateService.
@Test
public void testCreateService() 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);
// when
clientProxy.createService(new Service(), new NoneSelector());
// then
verify(nacosRestTemplate, times(1)).exchangeForm(endsWith(UtilAndComs.nacosUrlService), any(), any(), any(), eq(HttpMethod.POST), any());
}
Aggregations