Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ java_library(
"@maven//:commons_validator_commons_validator",
"@maven//:com_github_luben_zstd_jni",
"@maven//:org_lz4_lz4_java",
"@maven//:com_alibaba_fastjson",
"@maven//:com_alibaba_fastjson2_fastjson2",
"@maven//:io_netty_netty_all",
"@maven//:io_opentracing_opentracing_api",
"@maven//:commons_collections_commons_collections",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package org.apache.rocketmq.client.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson2.JSON;
import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package org.apache.rocketmq.client.impl.factory;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson2.JSON;
import io.netty.channel.Channel;
import java.util.Collections;
import java.util.HashMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package org.apache.rocketmq.client.producer;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson2.JSON;
import org.apache.rocketmq.common.message.MessageQueue;

public class SendResult {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.apache.rocketmq.client.impl;

import com.alibaba.fastjson2.JSON;
import org.apache.rocketmq.client.ClientConfig;
import org.apache.rocketmq.client.consumer.AckCallback;
import org.apache.rocketmq.client.consumer.AckResult;
Expand All @@ -34,6 +35,7 @@
import org.apache.rocketmq.client.producer.SendCallback;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.client.producer.SendStatus;
import org.apache.rocketmq.common.CheckRocksdbCqWriteResult;
import org.apache.rocketmq.common.MixAll;
import org.apache.rocketmq.common.ObjectCreator;
import org.apache.rocketmq.common.Pair;
Expand Down Expand Up @@ -2148,6 +2150,22 @@ public NettyClientConfig getNettyClientConfig() {
}
}

@Test
public void testCheckRocksdbCqWriteProgress() throws Exception {
RemotingCommand response = RemotingCommand.createResponseCommand(ResponseCode.SUCCESS, "Success");
CheckRocksdbCqWriteResult expectedResult = new CheckRocksdbCqWriteResult();
expectedResult.setCheckStatus(CheckRocksdbCqWriteResult.CheckStatus.CHECK_OK.getValue());
response.setBody(JSON.toJSONString(expectedResult).getBytes());

when(remotingClient.invokeSync(any(String.class), any(RemotingCommand.class), any(Long.class)))
.thenReturn(response);

CheckRocksdbCqWriteResult result = mqClientAPI.checkRocksdbCqWriteProgress(
"brokerAddr", "testTopic", 12345L, 3000L);

assertEquals(CheckRocksdbCqWriteResult.CheckStatus.CHECK_OK.getValue(), result.getCheckStatus());
}

private Properties createProperties() {
Properties result = new Properties();
result.put("key", "value");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.rocketmq.client.producer;

import com.alibaba.fastjson2.JSON;
import org.apache.rocketmq.common.message.MessageQueue;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class SendResultTest {

@Test
public void testEncoderSendResultToJson() {
SendResult sendResult = new SendResult();
sendResult.setSendStatus(SendStatus.SEND_OK);
sendResult.setMsgId("12345");
sendResult.setQueueOffset(100L);
MessageQueue messageQueue = new MessageQueue("TestTopic", "BrokerA", 1);
sendResult.setMessageQueue(messageQueue);

String json = SendResult.encoderSendResultToJson(sendResult);

SendResult decodedResult = JSON.parseObject(json, SendResult.class);
assertEquals(sendResult.getSendStatus(), decodedResult.getSendStatus());
assertEquals(sendResult.getMsgId(), decodedResult.getMsgId());
assertEquals(sendResult.getQueueOffset(), decodedResult.getQueueOffset());
assertEquals(sendResult.getMessageQueue(), decodedResult.getMessageQueue());
}

@Test
public void testDecoderSendResultFromJson() {
String json = "{\"sendStatus\":\"SEND_OK\",\"msgId\":\"12345\",\"queueOffset\":100,\"messageQueue\":{\"topic\":\"TestTopic\",\"brokerName\":\"BrokerA\",\"queueId\":1}}";

SendResult sendResult = SendResult.decoderSendResultFromJson(json);

assertEquals(SendStatus.SEND_OK, sendResult.getSendStatus());
assertEquals("12345", sendResult.getMsgId());
assertEquals(100L, sendResult.getQueueOffset());
assertEquals("TestTopic", sendResult.getMessageQueue().getTopic());
assertEquals("BrokerA", sendResult.getMessageQueue().getBrokerName());
assertEquals(1, sendResult.getMessageQueue().getQueueId());
}
}
Loading