You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by sr...@apache.org on 2018/02/17 16:22:52 UTC

[incubator-plc4x] branch master updated: replace explicit hexdump with implicit dump() of ByteReadable

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

sruehl pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-plc4x.git


The following commit(s) were added to refs/heads/master by this push:
     new d296b14  replace explicit hexdump with implicit dump() of ByteReadable
d296b14 is described below

commit d296b14f3c6836649fad9cdc9fa4fb4edfb97475
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Sat Feb 17 17:22:49 2018 +0100

    replace explicit hexdump with implicit dump() of ByteReadable
---
 .../org/apache/plc4x/java/ads/netty/ADSProtocolTest.java  |  9 +--------
 .../apache/plc4x/java/ads/netty/Plc4XADSProtocolTest.java | 15 ++-------------
 2 files changed, 3 insertions(+), 21 deletions(-)

diff --git a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/netty/ADSProtocolTest.java b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/netty/ADSProtocolTest.java
index 568a761..6f799f5 100644
--- a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/netty/ADSProtocolTest.java
+++ b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/netty/ADSProtocolTest.java
@@ -18,7 +18,6 @@
  */
 package org.apache.plc4x.java.ads.netty;
 
-import org.apache.commons.io.HexDump;
 import org.apache.plc4x.java.ads.api.commands.*;
 import org.apache.plc4x.java.ads.api.commands.types.*;
 import org.apache.plc4x.java.ads.api.generic.AMSTCPPacket;
@@ -32,7 +31,6 @@ import org.junit.runners.Parameterized;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.ByteArrayOutputStream;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -165,12 +163,7 @@ public class ADSProtocolTest {
     public void setUp() throws Exception {
         SUT = new ADSProtocol();
         byte[] bytes = amstcpPacket.getBytes();
-        LOGGER.info("amstcpPacket:\n{} has \n{}bytes", amstcpPacket, bytes.length);
-        try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
-            HexDump.dump(bytes, 0, byteArrayOutputStream, 0);
-            byteArrayOutputStream.flush();
-            LOGGER.info("HexDump:\n{}", byteArrayOutputStream);
-        }
+        LOGGER.info("amstcpPacket:\n{} has \n{}bytes\nHexDump:\n{}", amstcpPacket, bytes.length, amstcpPacket.dump());
     }
 
     @Test
diff --git a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/netty/Plc4XADSProtocolTest.java b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/netty/Plc4XADSProtocolTest.java
index c11e932..72ed38c 100644
--- a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/netty/Plc4XADSProtocolTest.java
+++ b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/netty/Plc4XADSProtocolTest.java
@@ -18,7 +18,6 @@
  */
 package org.apache.plc4x.java.ads.netty;
 
-import org.apache.commons.io.HexDump;
 import org.apache.commons.lang3.SerializationUtils;
 import org.apache.commons.lang3.tuple.ImmutablePair;
 import org.apache.plc4x.java.ads.api.commands.ADSReadResponse;
@@ -39,7 +38,6 @@ import org.junit.runners.Parameterized;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.ByteArrayOutputStream;
 import java.lang.reflect.Field;
 import java.lang.reflect.Modifier;
 import java.util.ArrayList;
@@ -116,12 +114,7 @@ public class Plc4XADSProtocolTest {
         ArrayList<Object> out = new ArrayList<>();
         SUT.encode(null, plcRequestContainer, out);
         assertThat(out, hasSize(1));
-        try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
-            byte[] bytes = ((AMSTCPPacket) out.get(0)).getByteBuf().array();
-            HexDump.dump(bytes, 0, byteArrayOutputStream, 0);
-            byteArrayOutputStream.flush();
-            LOGGER.info("{}\nHexDump:\n{}", amstcpPacket, byteArrayOutputStream);
-        }
+        LOGGER.info("{}\nHexDump:\n{}", amstcpPacket, amstcpPacket.dump());
     }
 
     @Test
@@ -131,11 +124,7 @@ public class Plc4XADSProtocolTest {
         assertThat(in, hasSize(1));
         syncInvoiceId();
         ArrayList<Object> out = new ArrayList<>();
-        try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
-            byte[] bytes = amstcpPacket.getByteBuf().array();
-            HexDump.dump(bytes, 0, byteArrayOutputStream, 0);
-            LOGGER.info("{}\nHexDump:\n{}", amstcpPacket, byteArrayOutputStream);
-        }
+        LOGGER.info("{}\nHexDump:\n{}", amstcpPacket, amstcpPacket.dump());
         SUT.decode(null, amstcpPacket, out);
         assertThat(out, hasSize(1));
         assertThat(out.get(0), instanceOf(PlcRequestContainer.class));

-- 
To stop receiving notification emails like this one, please contact
sruehl@apache.org.