use of com.alibaba.nacos.api.remote.request.RequestMeta in project nacos by alibaba.
the class InstanceRequestHandlerTest method testHandle.
@Test
public void testHandle() throws NacosException {
InstanceRequest instanceRequest = new InstanceRequest();
instanceRequest.setType(NamingRemoteConstants.REGISTER_INSTANCE);
Instance instance = new Instance();
instanceRequest.setInstance(instance);
RequestMeta requestMeta = new RequestMeta();
instanceRequestHandler.handle(instanceRequest, requestMeta);
Mockito.verify(clientOperationService).registerInstance(Mockito.any(), Mockito.any(), Mockito.anyString());
instanceRequest.setType(NamingRemoteConstants.DE_REGISTER_INSTANCE);
instanceRequestHandler.handle(instanceRequest, requestMeta);
Mockito.verify(clientOperationService).deregisterInstance(Mockito.any(), Mockito.any(), Mockito.anyString());
instanceRequest.setType("xxx");
try {
instanceRequestHandler.handle(instanceRequest, requestMeta);
} catch (Exception e) {
Assert.assertEquals(((NacosException) e).getErrCode(), NacosException.INVALID_PARAM);
}
}
use of com.alibaba.nacos.api.remote.request.RequestMeta in project nacos by alibaba.
the class RemoteRequestAuthFilterTest method testFilter.
@Test
public void testFilter() {
Mockito.when(authConfigs.isAuthEnabled()).thenReturn(true);
Request healthCheckRequest = new HealthCheckRequest();
try {
Response healthCheckResponse = remoteRequestAuthFilter.filter(healthCheckRequest, new RequestMeta(), MockRequestHandler.class);
Assert.assertNull(healthCheckResponse);
} catch (NacosException e) {
e.printStackTrace();
Assert.fail(e.getMessage());
}
}
use of com.alibaba.nacos.api.remote.request.RequestMeta in project nacos by alibaba.
the class ConnectionManager method buildMeta.
private RequestMeta buildMeta() {
RequestMeta meta = new RequestMeta();
meta.setClientVersion(VersionUtils.getFullClientVersion());
meta.setClientIp(NetUtils.localIP());
return meta;
}
use of com.alibaba.nacos.api.remote.request.RequestMeta in project nacos by alibaba.
the class ConfigChangeClusterSyncRequestHandlerTest method testHandle.
@Test
public void testHandle() throws NacosException {
ConfigChangeClusterSyncRequest configChangeSyncRequest = new ConfigChangeClusterSyncRequest();
configChangeSyncRequest.setRequestId("");
configChangeSyncRequest.setDataId("dataId");
configChangeSyncRequest.setTag("tag");
configChangeSyncRequest.setLastModified(1L);
configChangeSyncRequest.setBeta(false);
RequestMeta meta = new RequestMeta();
meta.setClientIp("1.1.1.1");
ConfigChangeClusterSyncResponse configChangeClusterSyncResponse = configChangeClusterSyncRequestHandler.handle(configChangeSyncRequest, meta);
assertEquals(configChangeClusterSyncResponse.getResultCode(), ResponseCode.SUCCESS.getCode());
}
use of com.alibaba.nacos.api.remote.request.RequestMeta in project nacos by alibaba.
the class ConfigPublishRequestHandlerTest method testHandle.
@Test
public void testHandle() throws NacosException {
ConfigPublishRequest configPublishRequest = new ConfigPublishRequest();
configPublishRequest.setDataId("dataId");
configPublishRequest.setGroup("group");
configPublishRequest.setContent("content");
RequestMeta requestMeta = new RequestMeta();
requestMeta.setClientIp("127.0.0.1");
ConfigPublishResponse response = configPublishRequestHandler.handle(configPublishRequest, requestMeta);
Assert.assertEquals(ResponseCode.SUCCESS.getCode(), response.getResultCode());
}
Aggregations