Search in sources :

Example 1 with RequestMeta

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);
    }
}
Also used : Instance(com.alibaba.nacos.api.naming.pojo.Instance) RequestMeta(com.alibaba.nacos.api.remote.request.RequestMeta) InstanceRequest(com.alibaba.nacos.api.naming.remote.request.InstanceRequest) NacosException(com.alibaba.nacos.api.exception.NacosException) NacosException(com.alibaba.nacos.api.exception.NacosException) Test(org.junit.Test)

Example 2 with RequestMeta

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());
    }
}
Also used : Response(com.alibaba.nacos.api.remote.response.Response) RequestMeta(com.alibaba.nacos.api.remote.request.RequestMeta) HealthCheckRequest(com.alibaba.nacos.api.remote.request.HealthCheckRequest) Request(com.alibaba.nacos.api.remote.request.Request) HealthCheckRequest(com.alibaba.nacos.api.remote.request.HealthCheckRequest) NacosException(com.alibaba.nacos.api.exception.NacosException) Test(org.junit.Test)

Example 3 with RequestMeta

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;
}
Also used : RequestMeta(com.alibaba.nacos.api.remote.request.RequestMeta)

Example 4 with RequestMeta

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());
}
Also used : ConfigChangeClusterSyncRequest(com.alibaba.nacos.api.config.remote.request.cluster.ConfigChangeClusterSyncRequest) RequestMeta(com.alibaba.nacos.api.remote.request.RequestMeta) ConfigChangeClusterSyncResponse(com.alibaba.nacos.api.config.remote.response.cluster.ConfigChangeClusterSyncResponse) Test(org.junit.Test)

Example 5 with RequestMeta

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());
}
Also used : ConfigPublishRequest(com.alibaba.nacos.api.config.remote.request.ConfigPublishRequest) ConfigPublishResponse(com.alibaba.nacos.api.config.remote.response.ConfigPublishResponse) RequestMeta(com.alibaba.nacos.api.remote.request.RequestMeta) Test(org.junit.Test)

Aggregations

RequestMeta (com.alibaba.nacos.api.remote.request.RequestMeta)26 Test (org.junit.Test)20 NacosException (com.alibaba.nacos.api.exception.NacosException)10 Payload (com.alibaba.nacos.api.grpc.auto.Payload)8 StreamObserver (io.grpc.stub.StreamObserver)7 Response (com.alibaba.nacos.api.remote.response.Response)6 InstanceRequest (com.alibaba.nacos.api.naming.remote.request.InstanceRequest)5 ErrorResponse (com.alibaba.nacos.api.remote.response.ErrorResponse)5 Instance (com.alibaba.nacos.api.naming.pojo.Instance)3 ServerCheckRequest (com.alibaba.nacos.api.remote.request.ServerCheckRequest)3 ServerLoaderInfoResponse (com.alibaba.nacos.api.remote.response.ServerLoaderInfoResponse)3 ConfigQueryRequest (com.alibaba.nacos.api.config.remote.request.ConfigQueryRequest)2 ConfigQueryResponse (com.alibaba.nacos.api.config.remote.response.ConfigQueryResponse)2 ServiceInfo (com.alibaba.nacos.api.naming.pojo.ServiceInfo)2 RequestCallBack (com.alibaba.nacos.api.remote.RequestCallBack)2 HealthCheckRequest (com.alibaba.nacos.api.remote.request.HealthCheckRequest)2 Request (com.alibaba.nacos.api.remote.request.Request)2 ServerLoaderInfoRequest (com.alibaba.nacos.api.remote.request.ServerLoaderInfoRequest)2 ServerReloadRequest (com.alibaba.nacos.api.remote.request.ServerReloadRequest)2 ServerCheckResponse (com.alibaba.nacos.api.remote.response.ServerCheckResponse)2