You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by jm...@apache.org on 2018/01/04 05:19:21 UTC
[incubator-plc4x] 02/05: stop RTE when passing empty or null
messages
This is an automated email from the ASF dual-hosted git repository.
jmclean pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-plc4x.git
commit ce7f0c880cf453705f144ea259a062e25075f726
Author: Justin Mclean <jm...@apache.org>
AuthorDate: Thu Jan 4 16:15:57 2018 +1100
stop RTE when passing empty or null messages
---
.../plc4x/java/isotp/netty/IsoTPProtocolTest.java | 30 ++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/plc4j/protocols/s7/src/test/java/org/apache/plc4x/java/isotp/netty/IsoTPProtocolTest.java b/plc4j/protocols/s7/src/test/java/org/apache/plc4x/java/isotp/netty/IsoTPProtocolTest.java
index 524be72..a536bd4 100644
--- a/plc4j/protocols/s7/src/test/java/org/apache/plc4x/java/isotp/netty/IsoTPProtocolTest.java
+++ b/plc4j/protocols/s7/src/test/java/org/apache/plc4x/java/isotp/netty/IsoTPProtocolTest.java
@@ -364,4 +364,34 @@ public class IsoTPProtocolTest extends NettyTestBase {
assertTrue(errorTpdu.getParameters().isEmpty(), "Message contains paramaters");
}
+ @Test
+ @Tag("fast")
+ public void encodeNullRequest() throws Exception {
+ ChannelHandlerContext ctx = new MockChannelHandlerContext();
+ ByteBuf buf = Unpooled.buffer();
+ ConnectionRequestTpdu tpdu = null;
+ ArrayList<Object> out = new ArrayList<>();
+
+ isoTPProtocol.encode(ctx, tpdu, out);
+ assertTrue(out.size() == 0, "Message decoded when null passed");
+
+ isoTPProtocol.encode(ctx, null, out);
+ assertTrue(out.size() == 0, "Message decoded when null passed");
+ }
+
+
+ @Test
+ @Tag("fast")
+ public void decodeNull() throws Exception {
+ ChannelHandlerContext ctx = new MockChannelHandlerContext();
+ ByteBuf buf = Unpooled.buffer();
+ ArrayList<Object> out = new ArrayList<>();
+ IsoOnTcpMessage in = new IsoOnTcpMessage(buf);
+
+ isoTPProtocol.decode(ctx, in, out);
+ assertTrue(out.size() == 0, "Message decoded when blank message passed");
+
+ isoTPProtocol.decode(ctx, null, out);
+ assertTrue(out.size() == 0, "Message decoded when blank message passed");
+ }
}
--
To stop receiving notification emails like this one, please contact
"commits@plc4x.apache.org" <co...@plc4x.apache.org>.