Follow the unit test naming convertion: MethodName_StateUnderTest_ExpectedBehavior
diff --git a/remoting-core/remoting-impl/src/main/java/org/apache/rocketmq/remoting/impl/netty/handler/Encoder.java b/remoting-core/remoting-impl/src/main/java/org/apache/rocketmq/remoting/impl/netty/handler/Encoder.java
index 329f343..702e2b4 100644
--- a/remoting-core/remoting-impl/src/main/java/org/apache/rocketmq/remoting/impl/netty/handler/Encoder.java
+++ b/remoting-core/remoting-impl/src/main/java/org/apache/rocketmq/remoting/impl/netty/handler/Encoder.java
@@ -59,7 +59,7 @@
}
}
- public void encode(final RemotingCommand remotingCommand, final ByteBufferWrapper out) {
+ private void encode(final RemotingCommand remotingCommand, final ByteBufferWrapper out) {
CodecHelper.encodeCommand(remotingCommand, out);
}
}
diff --git a/remoting-core/remoting-impl/src/test/java/org/apache/rocketmq/remoting/common/ResponseFutureTest.java b/remoting-core/remoting-impl/src/test/java/org/apache/rocketmq/remoting/common/ResponseFutureTest.java
index 6292745..c8e1f25 100644
--- a/remoting-core/remoting-impl/src/test/java/org/apache/rocketmq/remoting/common/ResponseFutureTest.java
+++ b/remoting-core/remoting-impl/src/test/java/org/apache/rocketmq/remoting/common/ResponseFutureTest.java
@@ -32,7 +32,7 @@
private RemotingCommandFactoryImpl factory = new RemotingCommandFactoryImpl();
@Test
- public void executeAsyncHandler_WithSuccess() {
+ public void executeAsyncHandler_Success() {
final RemotingCommand reqCommand = factory.createRequest();
final RemotingCommand resCommand = factory.createResponse(reqCommand);
future = new ResponseFuture(1, 3000, new AsyncHandler() {
@@ -53,7 +53,7 @@
}
@Test
- public void executeAsyncHandler_WithFailure() {
+ public void executeAsyncHandler_Failure() {
final RemotingCommand reqCommand = factory.createRequest();
final RemotingCommand resCommand = factory.createResponse(reqCommand);
final Throwable exception = new RuntimeException("Test Exception");
@@ -77,7 +77,7 @@
}
@Test
- public void waitResponse_WithSuccess() {
+ public void waitResponse_Success() {
future = new ResponseFuture(1, 1000, null, null);
final RemotingCommand reqCommand = factory.createRequest();
final RemotingCommand resCommand = factory.createResponse(reqCommand);
@@ -97,7 +97,7 @@
}
@Test
- public void waitResponse_WithTimeout() {
+ public void waitResponse_Timeout() {
future = new ResponseFuture(1, 1000, null, null);
RemotingCommand response = future.waitResponse(10);
assertNull(response);
diff --git a/remoting-core/remoting-impl/src/test/java/org/apache/rocketmq/remoting/common/SemaphoreReleaseOnlyOnceTest.java b/remoting-core/remoting-impl/src/test/java/org/apache/rocketmq/remoting/common/SemaphoreReleaseOnlyOnceTest.java
index 312e3b7..b671662 100644
--- a/remoting-core/remoting-impl/src/test/java/org/apache/rocketmq/remoting/common/SemaphoreReleaseOnlyOnceTest.java
+++ b/remoting-core/remoting-impl/src/test/java/org/apache/rocketmq/remoting/common/SemaphoreReleaseOnlyOnceTest.java
@@ -26,7 +26,7 @@
public class SemaphoreReleaseOnlyOnceTest extends BaseTest {
@Test
- public void release() {
+ public void release_Success() {
Semaphore semaphore = new Semaphore(0);
final SemaphoreReleaseOnlyOnce once = new SemaphoreReleaseOnlyOnce(semaphore);
diff --git a/remoting-core/remoting-impl/src/test/java/org/apache/rocketmq/remoting/impl/command/CodecHelperTest.java b/remoting-core/remoting-impl/src/test/java/org/apache/rocketmq/remoting/impl/command/CodecHelperTest.java
index 7c1c037..c8bdeb9 100644
--- a/remoting-core/remoting-impl/src/test/java/org/apache/rocketmq/remoting/impl/command/CodecHelperTest.java
+++ b/remoting-core/remoting-impl/src/test/java/org/apache/rocketmq/remoting/impl/command/CodecHelperTest.java
@@ -36,7 +36,7 @@
public class CodecHelperTest extends BaseTest {
@Test
- public void encodeAndDecodeCommand() {
+ public void encodeAndDecodeCommand_Success() {
ByteBufferWrapper buffer = new NettyByteBufferWrapper(ByteBufAllocator.DEFAULT.heapBuffer());
RemotingCommand command = randomRemotingCommand();
CodecHelper.encodeCommand(command, buffer);
@@ -51,7 +51,7 @@
}
@Test
- public void encodeCommand_WithException() {
+ public void encodeCommand_LenOverLimit_ExceptionThrown() {
ByteBufferWrapper buffer = new NettyByteBufferWrapper(ByteBufAllocator.DEFAULT.heapBuffer());
RemotingCommand command = randomRemotingCommand();
@@ -96,7 +96,7 @@
}
@Test
- public void decodeCommand_WithException() {
+ public void decodeCommand_LenOverLimit_ExceptionThrown() {
ByteBufferWrapper buffer = new NettyByteBufferWrapper(ByteBufAllocator.DEFAULT.heapBuffer());
buffer.writeShort((short) 0);
diff --git a/remoting-core/remoting-impl/src/test/java/org/apache/rocketmq/remoting/impl/command/RemotingCommandFactoryImplTest.java b/remoting-core/remoting-impl/src/test/java/org/apache/rocketmq/remoting/impl/command/RemotingCommandFactoryImplTest.java
index aa6e9ee..c1274c6 100644
--- a/remoting-core/remoting-impl/src/test/java/org/apache/rocketmq/remoting/impl/command/RemotingCommandFactoryImplTest.java
+++ b/remoting-core/remoting-impl/src/test/java/org/apache/rocketmq/remoting/impl/command/RemotingCommandFactoryImplTest.java
@@ -28,7 +28,7 @@
private RemotingCommandFactory factory = new RemotingCommandFactoryImpl();
@Test
- public void createRequest() {
+ public void createRequest_Success() {
RemotingCommand request = factory.createRequest();
assertEquals(request.cmdCode(), 0);
@@ -42,7 +42,7 @@
}
@Test
- public void createResponse() {
+ public void createResponse_Success() {
RemotingCommand request = factory.createRequest();
request.cmdVersion((short) 123);
request.cmdCode((short) 100);
diff --git a/remoting-core/remoting-impl/src/test/java/org/apache/rocketmq/remoting/impl/command/RequestIdGeneratorTest.java b/remoting-core/remoting-impl/src/test/java/org/apache/rocketmq/remoting/impl/command/RequestIdGeneratorTest.java
index 75d0ff1..5686124 100644
--- a/remoting-core/remoting-impl/src/test/java/org/apache/rocketmq/remoting/impl/command/RequestIdGeneratorTest.java
+++ b/remoting-core/remoting-impl/src/test/java/org/apache/rocketmq/remoting/impl/command/RequestIdGeneratorTest.java
@@ -24,7 +24,7 @@
public class RequestIdGeneratorTest {
@Test
- public void incrementAndGet() {
+ public void incrementAndGet_Success() {
int numA = RequestIdGenerator.inst.incrementAndGet();
int numB = RequestIdGenerator.inst.incrementAndGet();
diff --git a/remoting-core/remoting-impl/src/test/java/org/apache/rocketmq/remoting/impl/netty/handler/DecoderTest.java b/remoting-core/remoting-impl/src/test/java/org/apache/rocketmq/remoting/impl/netty/handler/DecoderTest.java
index 3f81286..1fd8e4c 100644
--- a/remoting-core/remoting-impl/src/test/java/org/apache/rocketmq/remoting/impl/netty/handler/DecoderTest.java
+++ b/remoting-core/remoting-impl/src/test/java/org/apache/rocketmq/remoting/impl/netty/handler/DecoderTest.java
@@ -33,7 +33,7 @@
public class DecoderTest extends BaseTest {
@Test
- public void decode() {
+ public void decode_Success() {
EmbeddedChannel channel = new EmbeddedChannel(new Encoder(), new Decoder());
RemotingCommand request = randomRemotingCommand();
@@ -49,7 +49,7 @@
}
@Test
- public void decode_WithException() {
+ public void decode_WrongMagicCode_ChannelClosed() {
// Magic Code doesn't match
EmbeddedChannel channel = new EmbeddedChannel(new Decoder());
@@ -58,8 +58,13 @@
buf.retain();
flushChannelWithException(channel, buf);
+ }
- channel = new EmbeddedChannel(new Decoder());
+ @Test
+ public void decode_LenOverLimit_ChannelClosed() {
+ // Magic Code doesn't match
+ ByteBuf buf = ByteBufAllocator.DEFAULT.heapBuffer();
+ EmbeddedChannel channel = new EmbeddedChannel(new Decoder());
buf.resetReaderIndex();
buf.resetWriterIndex();
diff --git a/remoting-core/remoting-impl/src/test/java/org/apache/rocketmq/remoting/impl/netty/handler/EncoderTest.java b/remoting-core/remoting-impl/src/test/java/org/apache/rocketmq/remoting/impl/netty/handler/EncoderTest.java
index 15f89be..9a379e9 100644
--- a/remoting-core/remoting-impl/src/test/java/org/apache/rocketmq/remoting/impl/netty/handler/EncoderTest.java
+++ b/remoting-core/remoting-impl/src/test/java/org/apache/rocketmq/remoting/impl/netty/handler/EncoderTest.java
@@ -35,7 +35,7 @@
public class EncoderTest extends BaseTest {
@Test
- public void encode() {
+ public void encode_Success() {
EmbeddedChannel channel = new EmbeddedChannel(new Encoder());
RemotingCommand request = randomRemotingCommand();
@@ -54,7 +54,7 @@
@Test
- public void encode_WithException() {
+ public void encode_LenOverLimit_ChannelClosed() {
EmbeddedChannel channel = new EmbeddedChannel(new Encoder());
RemotingCommand request = randomRemotingCommand();
diff --git a/remoting-core/remoting-impl/src/test/java/org/apache/rocketmq/remoting/impl/netty/handler/ExceptionHandlerTest.java b/remoting-core/remoting-impl/src/test/java/org/apache/rocketmq/remoting/impl/netty/handler/ExceptionHandlerTest.java
index 9687d38..2a27c8b 100644
--- a/remoting-core/remoting-impl/src/test/java/org/apache/rocketmq/remoting/impl/netty/handler/ExceptionHandlerTest.java
+++ b/remoting-core/remoting-impl/src/test/java/org/apache/rocketmq/remoting/impl/netty/handler/ExceptionHandlerTest.java
@@ -36,7 +36,7 @@
public class ExceptionHandlerTest extends BaseTest {
@Test
- public void exceptionCaught_WithException() {
+ public void exceptionCaught_ExceptionThrown_ChannelClosed() {
EmbeddedChannel channel = new EmbeddedChannel();
ByteBuf buffer = ByteBufAllocator.DEFAULT.heapBuffer();
channel.pipeline().addLast(new ByteToMessageDecoder() {