Search in sources :

Example 6 with GetKVConfigResponseHeader

use of org.apache.rocketmq.common.protocol.header.namesrv.GetKVConfigResponseHeader in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class DefaultRequestProcessorTest method testProcessRequest_GetKVConfigReturnNotNull.

@Test
public void testProcessRequest_GetKVConfigReturnNotNull() throws RemotingCommandException {
    namesrvController.getKvConfigManager().putKVConfig("namespace", "key", "value");
    GetKVConfigRequestHeader header = new GetKVConfigRequestHeader();
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_KV_CONFIG, header);
    request.addExtField("namespace", "namespace");
    request.addExtField("key", "key");
    RemotingCommand response = defaultRequestProcessor.processRequest(null, request);
    assertThat(response.getCode()).isEqualTo(ResponseCode.SUCCESS);
    assertThat(response.getRemark()).isNull();
    GetKVConfigResponseHeader responseHeader = (GetKVConfigResponseHeader) response.readCustomHeader();
    assertThat(responseHeader.getValue()).isEqualTo("value");
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) GetKVConfigRequestHeader(org.apache.rocketmq.common.protocol.header.namesrv.GetKVConfigRequestHeader) GetKVConfigResponseHeader(org.apache.rocketmq.common.protocol.header.namesrv.GetKVConfigResponseHeader) Test(org.junit.Test)

Example 7 with GetKVConfigResponseHeader

use of org.apache.rocketmq.common.protocol.header.namesrv.GetKVConfigResponseHeader in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class DefaultRequestProcessorTest method testProcessRequest_GetKVConfigReturnNull.

@Test
public void testProcessRequest_GetKVConfigReturnNull() throws RemotingCommandException {
    GetKVConfigRequestHeader header = new GetKVConfigRequestHeader();
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_KV_CONFIG, header);
    request.addExtField("namespace", "namespace");
    request.addExtField("key", "key");
    RemotingCommand response = defaultRequestProcessor.processRequest(null, request);
    assertThat(response.getCode()).isEqualTo(ResponseCode.QUERY_NOT_FOUND);
    assertThat(response.getRemark()).isEqualTo("No config item, Namespace: namespace Key: key");
    GetKVConfigResponseHeader responseHeader = (GetKVConfigResponseHeader) response.readCustomHeader();
    assertThat(responseHeader.getValue()).isNull();
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) GetKVConfigRequestHeader(org.apache.rocketmq.common.protocol.header.namesrv.GetKVConfigRequestHeader) GetKVConfigResponseHeader(org.apache.rocketmq.common.protocol.header.namesrv.GetKVConfigResponseHeader) Test(org.junit.Test)

Example 8 with GetKVConfigResponseHeader

use of org.apache.rocketmq.common.protocol.header.namesrv.GetKVConfigResponseHeader in project rocketmq by apache.

the class DefaultRequestProcessorTest method testProcessRequest_GetKVConfigReturnNotNull.

@Test
public void testProcessRequest_GetKVConfigReturnNotNull() throws RemotingCommandException {
    namesrvController.getKvConfigManager().putKVConfig("namespace", "key", "value");
    GetKVConfigRequestHeader header = new GetKVConfigRequestHeader();
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_KV_CONFIG, header);
    request.addExtField("namespace", "namespace");
    request.addExtField("key", "key");
    RemotingCommand response = defaultRequestProcessor.processRequest(null, request);
    assertThat(response.getCode()).isEqualTo(ResponseCode.SUCCESS);
    assertThat(response.getRemark()).isNull();
    GetKVConfigResponseHeader responseHeader = (GetKVConfigResponseHeader) response.readCustomHeader();
    assertThat(responseHeader.getValue()).isEqualTo("value");
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) GetKVConfigRequestHeader(org.apache.rocketmq.common.protocol.header.namesrv.GetKVConfigRequestHeader) GetKVConfigResponseHeader(org.apache.rocketmq.common.protocol.header.namesrv.GetKVConfigResponseHeader) Test(org.junit.Test)

Aggregations

GetKVConfigRequestHeader (org.apache.rocketmq.common.protocol.header.namesrv.GetKVConfigRequestHeader)8 GetKVConfigResponseHeader (org.apache.rocketmq.common.protocol.header.namesrv.GetKVConfigResponseHeader)8 RemotingCommand (org.apache.rocketmq.remoting.protocol.RemotingCommand)8 Test (org.junit.Test)4 MQClientException (org.apache.rocketmq.client.exception.MQClientException)2