You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by st...@apache.org on 2017/01/22 12:12:22 UTC
[17/31] incubator-rocketmq git commit: Polish remoting module's UT
Polish remoting module's UT
Project: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/commit/b997c974
Tree: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/tree/b997c974
Diff: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/diff/b997c974
Branch: refs/heads/ROCKETMQ-54
Commit: b997c9743e155df8d330bad54479ac320e722a36
Parents: 63de56c
Author: vongosling <vo...@apache.org>
Authored: Fri Jan 20 19:01:29 2017 +0800
Committer: vongosling <vo...@apache.org>
Committed: Fri Jan 20 19:01:29 2017 +0800
----------------------------------------------------------------------
.../remoting/netty/NettyRemotingServer.java | 4 +-
.../remoting/protocol/RemotingCommand.java | 12 -
.../remoting/protocol/RocketMQSerializable.java | 11 +-
.../remoting/protocol/protocol.sevialize.txt | 21 --
.../rocketmq/remoting/protocol/protocol.txt | 21 --
.../org/apache/rocketmq/remoting/MixTest.java | 30 ---
.../apache/rocketmq/remoting/NettyRPCTest.java | 233 -------------------
.../rocketmq/remoting/RemotingServerTest.java | 158 +++++++++++++
.../protocol/RocketMQSerializableTest.java | 16 +-
.../rocketmq/subclass/TestSubClassAuto.java | 27 ---
10 files changed, 173 insertions(+), 360 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/b997c974/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingServer.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingServer.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingServer.java
index d21894b..6a6df37 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingServer.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingServer.java
@@ -131,8 +131,8 @@ public class NettyRemotingServer extends NettyRemotingAbstract implements Remoti
@Override
public void start() {
- this.defaultEventExecutorGroup = new DefaultEventExecutorGroup(//
- nettyServerConfig.getServerWorkerThreads(), //
+ this.defaultEventExecutorGroup = new DefaultEventExecutorGroup(
+ nettyServerConfig.getServerWorkerThreads(),
new ThreadFactory() {
private AtomicInteger threadIndex = new AtomicInteger(0);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/b997c974/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommand.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommand.java b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommand.java
index 99c13fb..4f017ad 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommand.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommand.java
@@ -69,9 +69,6 @@ public class RemotingCommand {
}
}
- /**
-
- */
private int code;
private LanguageCode language = LanguageCode.JAVA;
private int version = 0;
@@ -80,13 +77,9 @@ public class RemotingCommand {
private String remark;
private HashMap<String, String> extFields;
private transient CommandCustomHeader customHeader;
- /**
- */
private SerializeType serializeTypeCurrentRPC = serializeTypeConfigInThisServer;
- /**
- */
private transient byte[] body;
protected RemotingCommand() {
@@ -117,9 +110,6 @@ public class RemotingCommand {
return createResponseCommand(RemotingSysResponseCode.SYSTEM_ERROR, "not set any response code", classHeader);
}
- /**
-
- */
public static RemotingCommand createResponseCommand(int code, String remark, Class<? extends CommandCustomHeader> classHeader) {
RemotingCommand cmd = new RemotingCommand();
cmd.markResponseType();
@@ -411,9 +401,7 @@ public class RemotingCommand {
return encodeHeader(this.body != null ? this.body.length : 0);
}
- /**
- */
public ByteBuffer encodeHeader(final int bodyLength) {
// 1> header length size
int length = 4;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/b997c974/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RocketMQSerializable.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RocketMQSerializable.java b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RocketMQSerializable.java
index 86dab46..66119e0 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RocketMQSerializable.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RocketMQSerializable.java
@@ -42,10 +42,8 @@ public class RocketMQSerializable {
extLen = extFieldsBytes.length;
}
- // ################### cal total length
int totalLen = calTotalLen(remarkLen, extLen);
- // ################### content
ByteBuffer headerBuffer = ByteBuffer.allocate(totalLen);
// int code(~32767)
headerBuffer.putShort((short) cmd.getCode());
@@ -77,7 +75,6 @@ public class RocketMQSerializable {
public static byte[] mapSerialize(HashMap<String, String> map) {
// keySize+key+valSize+val
- // keySize+key+valSize+val
if (null == map || map.isEmpty())
return null;
@@ -174,10 +171,10 @@ public class RocketMQSerializable {
HashMap<String, String> map = new HashMap<String, String>();
ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
- short keySize = 0;
- byte[] keyContent = null;
- int valSize = 0;
- byte[] valContent = null;
+ short keySize;
+ byte[] keyContent;
+ int valSize;
+ byte[] valContent;
while (byteBuffer.hasRemaining()) {
keySize = byteBuffer.getShort();
keyContent = new byte[keySize];
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/b997c974/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/protocol.sevialize.txt
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/protocol.sevialize.txt b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/protocol.sevialize.txt
deleted file mode 100644
index 3dc5ba5..0000000
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/protocol.sevialize.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-# 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.
-
-//
-// Remoting protocol V0.1 draft
-//
-// protocol <length> <header length> <header data> <body data>
-// 1 2 3 4
-//
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/b997c974/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/protocol.txt
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/protocol.txt b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/protocol.txt
deleted file mode 100644
index 3dc5ba5..0000000
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/protocol.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-# 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.
-
-//
-// Remoting protocol V0.1 draft
-//
-// protocol <length> <header length> <header data> <body data>
-// 1 2 3 4
-//
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/b997c974/remoting/src/test/java/org/apache/rocketmq/remoting/MixTest.java
----------------------------------------------------------------------
diff --git a/remoting/src/test/java/org/apache/rocketmq/remoting/MixTest.java b/remoting/src/test/java/org/apache/rocketmq/remoting/MixTest.java
deleted file mode 100644
index 3c4dcfa..0000000
--- a/remoting/src/test/java/org/apache/rocketmq/remoting/MixTest.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * $Id: MixTest.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
- */
-package org.apache.rocketmq.remoting;
-
-import org.junit.Test;
-
-public class MixTest {
- @Test
- public void test_extFieldsValue() {
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/b997c974/remoting/src/test/java/org/apache/rocketmq/remoting/NettyRPCTest.java
----------------------------------------------------------------------
diff --git a/remoting/src/test/java/org/apache/rocketmq/remoting/NettyRPCTest.java b/remoting/src/test/java/org/apache/rocketmq/remoting/NettyRPCTest.java
deleted file mode 100644
index f9c83b6..0000000
--- a/remoting/src/test/java/org/apache/rocketmq/remoting/NettyRPCTest.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * $Id: NettyRPCTest.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
- */
-package org.apache.rocketmq.remoting;
-
-import io.netty.channel.ChannelHandlerContext;
-import java.util.concurrent.Executors;
-import org.apache.rocketmq.remoting.annotation.CFNullable;
-import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-import org.apache.rocketmq.remoting.exception.RemotingConnectException;
-import org.apache.rocketmq.remoting.exception.RemotingSendRequestException;
-import org.apache.rocketmq.remoting.exception.RemotingTimeoutException;
-import org.apache.rocketmq.remoting.exception.RemotingTooMuchRequestException;
-import org.apache.rocketmq.remoting.netty.NettyClientConfig;
-import org.apache.rocketmq.remoting.netty.NettyRemotingClient;
-import org.apache.rocketmq.remoting.netty.NettyRemotingServer;
-import org.apache.rocketmq.remoting.netty.NettyRequestProcessor;
-import org.apache.rocketmq.remoting.netty.NettyServerConfig;
-import org.apache.rocketmq.remoting.netty.ResponseFuture;
-import org.apache.rocketmq.remoting.protocol.RemotingCommand;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import static org.junit.Assert.assertTrue;
-
-public class NettyRPCTest {
- private static RemotingServer remotingServer;
- private static RemotingClient remotingClient;
-
- public static RemotingServer createRemotingServer() throws InterruptedException {
- NettyServerConfig config = new NettyServerConfig();
- RemotingServer remotingServer = new NettyRemotingServer(config);
- remotingServer.registerProcessor(0, new NettyRequestProcessor() {
- private int i = 0;
-
- @Override
- public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) {
- System.out.println("processRequest=" + request + " " + (i++));
- request.setRemark("hello, I am respponse " + ctx.channel().remoteAddress());
- return request;
- }
-
- @Override
- public boolean rejectRequest() {
- return false;
- }
- }, Executors.newCachedThreadPool());
- remotingServer.start();
- return remotingServer;
- }
-
- public static RemotingClient createRemotingClient() {
- NettyClientConfig config = new NettyClientConfig();
- RemotingClient client = new NettyRemotingClient(config);
- client.start();
- return client;
- }
-
- @BeforeClass
- public static void initialize() throws InterruptedException {
- remotingServer = createRemotingServer();
- remotingClient = createRemotingClient();
- }
-
- @AfterClass
- public static void destroy() {
- remotingClient.shutdown();
- remotingServer.shutdown();
- }
-
- @Test
- public void test_RPC_Sync() throws InterruptedException, RemotingConnectException,
- RemotingSendRequestException, RemotingTimeoutException {
-
- for (int i = 0; i < 100; i++) {
- TestRequestHeader requestHeader = new TestRequestHeader();
- requestHeader.setCount(i);
- requestHeader.setMessageTitle("HelloMessageTitle");
- RemotingCommand request = RemotingCommand.createRequestCommand(0, requestHeader);
- RemotingCommand response = remotingClient.invokeSync("localhost:8888", request, 1000 * 3000);
- System.out.println("invoke result = " + response);
- assertTrue(response != null);
- }
- }
-
- @Test
- public void test_RPC_Oneway() throws InterruptedException, RemotingConnectException,
- RemotingTimeoutException, RemotingTooMuchRequestException, RemotingSendRequestException {
-
- for (int i = 0; i < 100; i++) {
- RemotingCommand request = RemotingCommand.createRequestCommand(0, null);
- request.setRemark(String.valueOf(i));
- remotingClient.invokeOneway("localhost:8888", request, 1000 * 3);
- }
- }
-
- @Test
- public void test_RPC_Async() throws InterruptedException, RemotingConnectException,
- RemotingTimeoutException, RemotingTooMuchRequestException, RemotingSendRequestException {
-
- for (int i = 0; i < 100; i++) {
- RemotingCommand request = RemotingCommand.createRequestCommand(0, null);
- request.setRemark(String.valueOf(i));
- remotingClient.invokeAsync("localhost:8888", request, 1000 * 3, new InvokeCallback() {
- @Override
- public void operationComplete(ResponseFuture responseFuture) {
- System.out.println(responseFuture.getResponseCommand());
- }
- });
- }
- }
-
- @Test
- public void test_server_call_client() throws InterruptedException, RemotingConnectException,
- RemotingSendRequestException, RemotingTimeoutException {
-
- remotingServer.registerProcessor(0, new NettyRequestProcessor() {
- @Override
- public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) {
- try {
- return remotingServer.invokeSync(ctx.channel(), request, 1000 * 10);
- } catch (InterruptedException | RemotingSendRequestException | RemotingTimeoutException e) {
- e.printStackTrace();
- }
-
- return null;
- }
-
- @Override
- public boolean rejectRequest() {
- return false;
- }
- }, Executors.newCachedThreadPool());
-
- remotingClient.registerProcessor(0, new NettyRequestProcessor() {
- @Override
- public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) {
- System.out.println("client receive server request = " + request);
- request.setRemark("client remark");
- return request;
- }
-
- @Override
- public boolean rejectRequest() {
- return false;
- }
- }, Executors.newCachedThreadPool());
-
- for (int i = 0; i < 3; i++) {
- RemotingCommand request = RemotingCommand.createRequestCommand(0, null);
- RemotingCommand response = remotingClient.invokeSync("localhost:8888", request, 1000 * 3);
- System.out.println("invoke result = " + response);
- assertTrue(response != null);
- }
- }
-
-}
-
-class TestRequestHeader implements CommandCustomHeader {
- @CFNullable
- private Integer count;
-
- @CFNullable
- private String messageTitle;
-
- @Override
- public void checkFields() throws RemotingCommandException {
- }
-
- public Integer getCount() {
- return count;
- }
-
- public void setCount(Integer count) {
- this.count = count;
- }
-
- public String getMessageTitle() {
- return messageTitle;
- }
-
- public void setMessageTitle(String messageTitle) {
- this.messageTitle = messageTitle;
- }
-}
-
-class TestResponseHeader implements CommandCustomHeader {
- @CFNullable
- private Integer count;
-
- @CFNullable
- private String messageTitle;
-
- public Integer getCount() {
- return count;
- }
-
- public void setCount(Integer count) {
- this.count = count;
- }
-
- @Override
- public void checkFields() throws RemotingCommandException {
-
- }
-
- public String getMessageTitle() {
- return messageTitle;
- }
-
- public void setMessageTitle(String messageTitle) {
- this.messageTitle = messageTitle;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/b997c974/remoting/src/test/java/org/apache/rocketmq/remoting/RemotingServerTest.java
----------------------------------------------------------------------
diff --git a/remoting/src/test/java/org/apache/rocketmq/remoting/RemotingServerTest.java b/remoting/src/test/java/org/apache/rocketmq/remoting/RemotingServerTest.java
new file mode 100644
index 0000000..31c2647
--- /dev/null
+++ b/remoting/src/test/java/org/apache/rocketmq/remoting/RemotingServerTest.java
@@ -0,0 +1,158 @@
+/*
+ * 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.remoting;
+
+import io.netty.channel.ChannelHandlerContext;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.Executors;
+import org.apache.rocketmq.remoting.annotation.CFNullable;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+import org.apache.rocketmq.remoting.exception.RemotingConnectException;
+import org.apache.rocketmq.remoting.exception.RemotingSendRequestException;
+import org.apache.rocketmq.remoting.exception.RemotingTimeoutException;
+import org.apache.rocketmq.remoting.exception.RemotingTooMuchRequestException;
+import org.apache.rocketmq.remoting.netty.NettyClientConfig;
+import org.apache.rocketmq.remoting.netty.NettyRemotingClient;
+import org.apache.rocketmq.remoting.netty.NettyRemotingServer;
+import org.apache.rocketmq.remoting.netty.NettyRequestProcessor;
+import org.apache.rocketmq.remoting.netty.NettyServerConfig;
+import org.apache.rocketmq.remoting.netty.ResponseFuture;
+import org.apache.rocketmq.remoting.protocol.LanguageCode;
+import org.apache.rocketmq.remoting.protocol.RemotingCommand;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertTrue;
+
+public class RemotingServerTest {
+ private static RemotingServer remotingServer;
+ private static RemotingClient remotingClient;
+
+ public static RemotingServer createRemotingServer() throws InterruptedException {
+ NettyServerConfig config = new NettyServerConfig();
+ RemotingServer remotingServer = new NettyRemotingServer(config);
+ remotingServer.registerProcessor(0, new NettyRequestProcessor() {
+ @Override
+ public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) {
+ request.setRemark("Hi " + ctx.channel().remoteAddress());
+ return request;
+ }
+
+ @Override
+ public boolean rejectRequest() {
+ return false;
+ }
+ }, Executors.newCachedThreadPool());
+
+ remotingServer.start();
+
+ return remotingServer;
+ }
+
+ public static RemotingClient createRemotingClient() {
+ NettyClientConfig config = new NettyClientConfig();
+ RemotingClient client = new NettyRemotingClient(config);
+ client.start();
+ return client;
+ }
+
+ @BeforeClass
+ public static void setup() throws InterruptedException {
+ remotingServer = createRemotingServer();
+ remotingClient = createRemotingClient();
+ }
+
+ @AfterClass
+ public static void destroy() {
+ remotingClient.shutdown();
+ remotingServer.shutdown();
+ }
+
+ @Test
+ public void testInvokeSync() throws InterruptedException, RemotingConnectException,
+ RemotingSendRequestException, RemotingTimeoutException {
+ RequestHeader requestHeader = new RequestHeader();
+ requestHeader.setCount(1);
+ requestHeader.setMessageTitle("Welcome");
+ RemotingCommand request = RemotingCommand.createRequestCommand(0, requestHeader);
+ RemotingCommand response = remotingClient.invokeSync("localhost:8888", request, 1000 * 3);
+ assertTrue(response != null);
+ assertThat(response.getLanguage()).isEqualTo(LanguageCode.JAVA);
+ assertThat(response.getExtFields()).hasSize(2);
+
+ }
+
+ @Test
+ public void testInvokeOneway() throws InterruptedException, RemotingConnectException,
+ RemotingTimeoutException, RemotingTooMuchRequestException, RemotingSendRequestException {
+
+ RemotingCommand request = RemotingCommand.createRequestCommand(0, null);
+ request.setRemark("messi");
+ remotingClient.invokeOneway("localhost:8888", request, 1000 * 3);
+ }
+
+ @Test
+ public void testInvokeAsync() throws InterruptedException, RemotingConnectException,
+ RemotingTimeoutException, RemotingTooMuchRequestException, RemotingSendRequestException {
+
+ final CountDownLatch latch = new CountDownLatch(1);
+ RemotingCommand request = RemotingCommand.createRequestCommand(0, null);
+ request.setRemark("messi");
+ remotingClient.invokeAsync("localhost:8888", request, 1000 * 3, new InvokeCallback() {
+ @Override
+ public void operationComplete(ResponseFuture responseFuture) {
+ latch.countDown();
+ assertTrue(responseFuture != null);
+ assertThat(responseFuture.getResponseCommand().getLanguage()).isEqualTo(LanguageCode.JAVA);
+ assertThat(responseFuture.getResponseCommand().getExtFields()).hasSize(2);
+ }
+ });
+ latch.await();
+ }
+}
+
+class RequestHeader implements CommandCustomHeader {
+ @CFNullable
+ private Integer count;
+
+ @CFNullable
+ private String messageTitle;
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ }
+
+ public Integer getCount() {
+ return count;
+ }
+
+ public void setCount(Integer count) {
+ this.count = count;
+ }
+
+ public String getMessageTitle() {
+ return messageTitle;
+ }
+
+ public void setMessageTitle(String messageTitle) {
+ this.messageTitle = messageTitle;
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/b997c974/remoting/src/test/java/org/apache/rocketmq/remoting/protocol/RocketMQSerializableTest.java
----------------------------------------------------------------------
diff --git a/remoting/src/test/java/org/apache/rocketmq/remoting/protocol/RocketMQSerializableTest.java b/remoting/src/test/java/org/apache/rocketmq/remoting/protocol/RocketMQSerializableTest.java
index e49a0d7..f1db54f 100644
--- a/remoting/src/test/java/org/apache/rocketmq/remoting/protocol/RocketMQSerializableTest.java
+++ b/remoting/src/test/java/org/apache/rocketmq/remoting/protocol/RocketMQSerializableTest.java
@@ -26,9 +26,9 @@ public class RocketMQSerializableTest {
public void testRocketMQProtocolEncodeAndDecode_WithoutRemarkWithoutExtFields() {
System.setProperty(RemotingCommand.REMOTING_VERSION_KEY, "2333");
- int code = 103; //org.apache.rocketmq.common.protocol.RequestCode.REGISTER_BROKER
- RemotingCommand cmd = RemotingCommand.createRequestCommand(code,
- new SampleCommandCustomHeader());
+ //org.apache.rocketmq.common.protocol.RequestCode.REGISTER_BROKER
+ int code = 103;
+ RemotingCommand cmd = RemotingCommand.createRequestCommand(code, new SampleCommandCustomHeader());
cmd.setSerializeTypeCurrentRPC(SerializeType.ROCKETMQ);
byte[] result = RocketMQSerializable.rocketMQProtocolEncode(cmd);
@@ -57,7 +57,8 @@ public class RocketMQSerializableTest {
public void testRocketMQProtocolEncodeAndDecode_WithRemarkWithoutExtFields() {
System.setProperty(RemotingCommand.REMOTING_VERSION_KEY, "2333");
- int code = 103; //org.apache.rocketmq.common.protocol.RequestCode.REGISTER_BROKER
+ //org.apache.rocketmq.common.protocol.RequestCode.REGISTER_BROKER
+ int code = 103;
RemotingCommand cmd = RemotingCommand.createRequestCommand(code,
new SampleCommandCustomHeader());
cmd.setSerializeTypeCurrentRPC(SerializeType.ROCKETMQ);
@@ -94,7 +95,8 @@ public class RocketMQSerializableTest {
public void testRocketMQProtocolEncodeAndDecode_WithoutRemarkWithExtFields() {
System.setProperty(RemotingCommand.REMOTING_VERSION_KEY, "2333");
- int code = 103; //org.apache.rocketmq.common.protocol.RequestCode.REGISTER_BROKER
+ //org.apache.rocketmq.common.protocol.RequestCode.REGISTER_BROKER
+ int code = 103;
RemotingCommand cmd = RemotingCommand.createRequestCommand(code,
new SampleCommandCustomHeader());
cmd.setSerializeTypeCurrentRPC(SerializeType.ROCKETMQ);
@@ -129,7 +131,7 @@ public class RocketMQSerializableTest {
@Test
public void testIsBlank_NotBlank() {
- assertThat(RocketMQSerializable.isBlank("aeiou")).isFalse();
+ assertThat(RocketMQSerializable.isBlank("bar")).isFalse();
assertThat(RocketMQSerializable.isBlank(" A ")).isFalse();
}
@@ -146,6 +148,6 @@ public class RocketMQSerializableTest {
private int parseToInt(byte[] array, int index) {
return array[index] * 16777216 + array[++index] * 65536 + array[++index] * 256
- + array[++index];
+ + array[++index];
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/b997c974/remoting/src/test/java/org/apache/rocketmq/subclass/TestSubClassAuto.java
----------------------------------------------------------------------
diff --git a/remoting/src/test/java/org/apache/rocketmq/subclass/TestSubClassAuto.java b/remoting/src/test/java/org/apache/rocketmq/subclass/TestSubClassAuto.java
deleted file mode 100644
index b60ad0c..0000000
--- a/remoting/src/test/java/org/apache/rocketmq/subclass/TestSubClassAuto.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * 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.subclass;
-
-import org.junit.Test;
-
-public class TestSubClassAuto {
- @Test
- public void test_sub() {
-
- }
-}