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/03/15 10:28:08 UTC

[incubator-plc4x] branch master updated (983dd5c -> 3750277)

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

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


    from 983dd5c  implement crc by using external library
     new b8df5f0  added test for digest util to prove that implementation works for lists
     new 3750277  improved failing test so we can better understand why it is failing

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../java/ads/protocol/Ads2SerialProtocolTest.java  | 39 ++++++++++++----------
 .../java/ads/protocol/util/DigestUtilTest.java     | 10 ++++++
 2 files changed, 31 insertions(+), 18 deletions(-)

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

[incubator-plc4x] 02/02: improved failing test so we can better understand why it is failing

Posted by sr...@apache.org.
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

commit 3750277f3e2f4e816d4191eaa8dadf882d47bf99
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Thu Mar 15 11:28:03 2018 +0100

    improved failing test so we can better understand why it is failing
---
 .../java/ads/protocol/Ads2SerialProtocolTest.java  | 39 ++++++++++++----------
 1 file changed, 21 insertions(+), 18 deletions(-)

diff --git a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/Ads2SerialProtocolTest.java b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/Ads2SerialProtocolTest.java
index 7949880..4a62eea 100644
--- a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/Ads2SerialProtocolTest.java
+++ b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/Ads2SerialProtocolTest.java
@@ -57,6 +57,9 @@ public class Ads2SerialProtocolTest {
     @Parameterized.Parameter(1)
     public String clazzName;
 
+    @Parameterized.Parameter(2)
+    public AmsPacket amsPacket;
+
     @Parameterized.Parameters(name = "{index} {1}")
     public static Collection<Object[]> data() {
         AmsNetId targetAmsNetId = AmsNetId.of("1.2.3.4.5.6");
@@ -68,20 +71,20 @@ public class Ads2SerialProtocolTest {
         return Stream.of(
             AdsAddDeviceNotificationRequest.of(
                 targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId,
-                IndexGroup.of(1), IndexOffset.of(1), Length.of(1), TransmissionMode.of(1), MaxDelay.of(1), CycleTime.of(1)).toAmsSerialFrame((byte) 0),
+                IndexGroup.of(1), IndexOffset.of(1), Length.of(1), TransmissionMode.of(1), MaxDelay.of(1), CycleTime.of(1)),
             AdsAddDeviceNotificationResponse.of(
                 targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId,
                 Result.of(0),
                 NotificationHandle.of(0)
-            ).toAmsSerialFrame((byte) 0),
+            ),
             AdsDeleteDeviceNotificationRequest.of(
                 targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId,
                 NotificationHandle.of(0)
-            ).toAmsSerialFrame((byte) 0),
+            ),
             AdsDeleteDeviceNotificationResponse.of(
                 targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId,
                 Result.of(0)
-            ).toAmsSerialFrame((byte) 0),
+            ),
             AdsDeviceNotificationRequest.of(
                 targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId,
                 Stamps.of(1),
@@ -92,10 +95,10 @@ public class Ads2SerialProtocolTest {
                             AdsNotificationSample.of(NotificationHandle.of(0), data))
                     )
                 )
-            ).toAmsSerialFrame((byte) 0),
+            ),
             AdsReadDeviceInfoRequest.of(
                 targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId
-            ).toAmsSerialFrame((byte) 0),
+            ),
             AdsReadDeviceInfoResponse.of(
                 targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId,
                 Result.of(0),
@@ -103,63 +106,63 @@ public class Ads2SerialProtocolTest {
                 MinorVersion.of((byte) 2),
                 Version.of(3),
                 Device.of("Random DeviceId")
-            ).toAmsSerialFrame((byte) 0),
+            ),
             AdsReadRequest.of(
                 targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId,
                 IndexGroup.of(0),
                 IndexOffset.of(0),
                 Length.of(1)
-            ).toAmsSerialFrame((byte) 0),
+            ),
             AdsReadResponse.of(
                 targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId,
                 Result.of(0),
                 data
-            ).toAmsSerialFrame((byte) 0),
+            ),
             AdsReadStateRequest.of(
                 targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId
-            ).toAmsSerialFrame((byte) 0),
+            ),
             AdsReadStateResponse.of(
                 targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId,
                 Result.of(0)
-            ).toAmsSerialFrame((byte) 0),
+            ),
             AdsReadWriteRequest.of(
                 targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId,
                 IndexGroup.of(0),
                 IndexOffset.of(0),
                 ReadLength.of(data.getCalculatedLength()),
                 data
-            ).toAmsSerialFrame((byte) 0),
+            ),
             AdsReadWriteResponse.of(
                 targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId,
                 Result.of(0),
                 data
-            ).toAmsSerialFrame((byte) 0),
+            ),
             AdsWriteControlRequest.of(
                 targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId,
                 AdsState.of(0xaffe),
                 DeviceState.of(0xaffe),
                 data
-            ).toAmsSerialFrame((byte) 0),
+            ),
             AdsWriteControlResponse.of(
                 targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId,
                 Result.of(0)
-            ).toAmsSerialFrame((byte) 0),
+            ),
             AdsWriteRequest.of(
                 targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId,
                 IndexGroup.of(0),
                 IndexOffset.of(0),
                 data
-            ).toAmsSerialFrame((byte) 0),
+            ),
             AdsWriteResponse.of(
                 targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId,
                 Result.of(0)
-            ).toAmsSerialFrame((byte) 0)
+            )
             /*,
             UnknownCommand.of(
                 targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, State.DEFAULT, invokeId,
                 Unpooled.wrappedBuffer(new byte[]{42})
             )*/
-        ).map(amstcpPacket -> new Object[]{amstcpPacket, amstcpPacket.getClass().getSimpleName()}).collect(Collectors.toList());
+        ).map(amsPacket -> new Object[]{amsPacket.toAmsSerialFrame((byte) 0), amsPacket.getClass().getSimpleName(), amsPacket}).collect(Collectors.toList());
     }
 
     @Before

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

[incubator-plc4x] 01/02: added test for digest util to prove that implementation works for lists

Posted by sr...@apache.org.
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

commit b8df5f07005e43383aea5ae9bdf791fc12910b0e
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Thu Mar 15 11:27:42 2018 +0100

    added test for digest util to prove that implementation works for lists
---
 .../apache/plc4x/java/ads/protocol/util/DigestUtilTest.java    | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/util/DigestUtilTest.java b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/util/DigestUtilTest.java
index f2b5917..73f3328 100644
--- a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/util/DigestUtilTest.java
+++ b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/util/DigestUtilTest.java
@@ -18,14 +18,24 @@
  */
 package org.apache.plc4x.java.ads.protocol.util;
 
+import io.netty.buffer.Unpooled;
 import org.apache.commons.lang3.StringUtils;
 import org.junit.Test;
 
 import java.util.stream.IntStream;
 
+import static org.junit.Assert.assertEquals;
+
 public class DigestUtilTest {
 
     @Test
+    public void sameCalculation() throws Exception {
+        assertEquals(
+            DigestUtil.calculateCrc16(new byte[]{47, 99}),
+            DigestUtil.calculateCrc16(() -> Unpooled.wrappedBuffer(new byte[]{47}), () -> Unpooled.wrappedBuffer(new byte[]{99})));
+    }
+
+    @Test
     public void displayValue() throws Exception {
         Object[] crcs = IntStream.range(0, 256)
             .map(value -> DigestUtil.calculateCrc16(new byte[]{(byte) value}))

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