This is an automated email from the ASF dual-hosted git repository.
albumenj pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/master by this push:
new 0bcb02e [UT] Fix ut case for payload exceed (#7502)
0bcb02e is described below
commit 0bcb02e47bdee57000a5c03d81a9c4d38bd6b74f
Author: Albumen Kevin <[email protected]>
AuthorDate: Fri Apr 2 19:19:32 2021 +0800
[UT] Fix ut case for payload exceed (#7502)
* fix ut case for payload exceed
* fix ut case for payload exceed
* suite differ situation
---
.../org/apache/dubbo/remoting/codec/ExchangeCodecTest.java | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git
a/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/codec/ExchangeCodecTest.java
b/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/codec/ExchangeCodecTest.java
index 3cb2c66..d801c64 100644
---
a/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/codec/ExchangeCodecTest.java
+++
b/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/codec/ExchangeCodecTest.java
@@ -43,7 +43,6 @@ import java.util.HashMap;
import java.util.Map;
import static org.apache.dubbo.common.constants.CommonConstants.READONLY_EVENT;
-import static org.junit.jupiter.api.Assertions.fail;
/**
*
@@ -186,12 +185,19 @@ public class ExchangeCodecTest extends TelnetCodecTest {
public void test_Decode_Check_Payload() throws IOException {
byte[] header = new byte[]{MAGIC_HIGH, MAGIC_LOW, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1};
byte[] request = assemblyDataProtocol(header);
+
try {
- testDecode_assertEquals(request,
TelnetCodec.DecodeResult.NEED_MORE_INPUT);
- fail();
+ Channel channel = getServerSideChannel(url);
+ ChannelBuffer buffer = ChannelBuffers.wrappedBuffer(request);
+ Object obj = codec.decode(channel, buffer);
+
+ Assertions.assertTrue(obj instanceof Response);
+ Assertions.assertTrue(((Response)
obj).getErrorMessage().startsWith(
+ "Data length too large: " + Bytes.bytes2int(new byte[]{1,
1, 1, 1})));
} catch (IOException expected) {
Assertions.assertTrue(expected.getMessage().startsWith("Data
length too large: " + Bytes.bytes2int(new byte[]{1, 1, 1, 1})));
}
+
}
@Test