You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2022/04/13 01:37:19 UTC

[shardingsphere] branch master updated: Fix PacketCodecTest exception (#16781)

This is an automated email from the ASF dual-hosted git repository.

panjuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 92dec8573aa Fix PacketCodecTest exception (#16781)
92dec8573aa is described below

commit 92dec8573aa494df8f865fc608b1f9ac4291ba04
Author: Zhengqiang Duan <du...@apache.org>
AuthorDate: Wed Apr 13 09:37:12 2022 +0800

    Fix PacketCodecTest exception (#16781)
---
 .../org/apache/shardingsphere/db/protocol/codec/PacketCodecTest.java  | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-core/src/test/java/org/apache/shardingsphere/db/protocol/codec/PacketCodecTest.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-core/src/test/java/org/apache/shardingsphere/db/protocol/codec/PacketCodecTest.java
index 0b1eb344c4c..4ce5d983038 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-core/src/test/java/org/apache/shardingsphere/db/protocol/codec/PacketCodecTest.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-core/src/test/java/org/apache/shardingsphere/db/protocol/codec/PacketCodecTest.java
@@ -23,6 +23,7 @@ import org.apache.shardingsphere.db.protocol.packet.DatabasePacket;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.mockito.Answers;
 import org.mockito.Mock;
 import org.mockito.junit.MockitoJUnitRunner;
 
@@ -39,7 +40,7 @@ public final class PacketCodecTest {
     @Mock
     private DatabasePacketCodecEngine databasePacketCodecEngine;
     
-    @Mock
+    @Mock(answer = Answers.RETURNS_DEEP_STUBS)
     private ChannelHandlerContext context;
     
     @Mock
@@ -55,6 +56,7 @@ public final class PacketCodecTest {
     @Test
     public void assertDecodeWithValidHeader() {
         when(byteBuf.readableBytes()).thenReturn(1);
+        when(byteBuf.capacity()).thenReturn(1);
         when(databasePacketCodecEngine.isValidHeader(1)).thenReturn(true);
         packetCodec.decode(context, byteBuf, Collections.emptyList());
         verify(databasePacketCodecEngine).decode(context, byteBuf, Collections.emptyList());