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 2022/03/01 11:07:46 UTC

[plc4x] branch develop updated: test(protocols/c-bus): move tests to nested test

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

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


The following commit(s) were added to refs/heads/develop by this push:
     new dc5ceda  test(protocols/c-bus): move tests to nested test
dc5ceda is described below

commit dc5ceda7f6a4007d4d6d819d2b38f229d809bf40
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Tue Mar 1 12:07:39 2022 +0100

    test(protocols/c-bus): move tests to nested test
---
 .../apache/plc4x/java/cbus/RandomPackagesTest.java | 148 +++++++++++----------
 1 file changed, 76 insertions(+), 72 deletions(-)

diff --git a/plc4j/drivers/c-bus/src/test/java/org/apache/plc4x/java/cbus/RandomPackagesTest.java b/plc4j/drivers/c-bus/src/test/java/org/apache/plc4x/java/cbus/RandomPackagesTest.java
index 98f67a6..a35b769 100644
--- a/plc4j/drivers/c-bus/src/test/java/org/apache/plc4x/java/cbus/RandomPackagesTest.java
+++ b/plc4j/drivers/c-bus/src/test/java/org/apache/plc4x/java/cbus/RandomPackagesTest.java
@@ -22,6 +22,7 @@ import org.apache.commons.codec.binary.Hex;
 import org.apache.plc4x.java.cbus.readwrite.CBusCommand;
 import org.apache.plc4x.java.spi.generation.ReadBufferByteBased;
 import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Nested;
 import org.junit.jupiter.api.Test;
 
 import static org.assertj.core.api.Assertions.assertThat;
@@ -31,85 +32,88 @@ public class RandomPackagesTest {
 
     static final String BACKSLASH = "5C";
 
-    // 4.2.9.1
-    @Test
-    void pointToPointCommand1() throws Exception {
-        byte[] bytes = Hex.decodeHex(BACKSLASH + "0603002102D4");
-        ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
-        CBusCommand cBusCommand = CBusCommand.staticParse(readBufferByteBased, false);
-        assertThat(cBusCommand)
-            .isNotNull();
-    }
+    // from: https://updates.clipsal.com/ClipsalSoftwareDownload/DL/downloads/OpenCBus/Serial%20Interface%20User%20Guide.pdf
+    @Nested
+    class ReferenceDocumentationTest {
+        // 4.2.9.1
+        @Test
+        void pointToPointCommand1() throws Exception {
+            byte[] bytes = Hex.decodeHex(BACKSLASH + "0603002102D4");
+            ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
+            CBusCommand cBusCommand = CBusCommand.staticParse(readBufferByteBased, false);
+            assertThat(cBusCommand)
+                .isNotNull();
+        }
 
-    // 4.2.9.1
-    @Test
-    void pointToPointCommand2() throws Exception {
-        byte[] bytes = Hex.decodeHex(BACKSLASH + "06420903210289");
-        ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
-        CBusCommand cBusCommand = CBusCommand.staticParse(readBufferByteBased, false);
-        assertThat(cBusCommand)
-            .isNotNull();
-    }
+        // 4.2.9.1
+        @Test
+        void pointToPointCommand2() throws Exception {
+            byte[] bytes = Hex.decodeHex(BACKSLASH + "06420903210289");
+            ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
+            CBusCommand cBusCommand = CBusCommand.staticParse(readBufferByteBased, false);
+            assertThat(cBusCommand)
+                .isNotNull();
+        }
 
-    // 4.2.9.2
-    @Test
-    void pointToMultiPointCommand1() throws Exception {
-        byte[] bytes = Hex.decodeHex(BACKSLASH + "0538000108BA");
-        ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
-        CBusCommand cBusCommand = CBusCommand.staticParse(readBufferByteBased, false);
-        assertThat(cBusCommand)
-            .isNotNull();
-    }
+        // 4.2.9.2
+        @Test
+        void pointToMultiPointCommand1() throws Exception {
+            byte[] bytes = Hex.decodeHex(BACKSLASH + "0538000108BA");
+            ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
+            CBusCommand cBusCommand = CBusCommand.staticParse(readBufferByteBased, false);
+            assertThat(cBusCommand)
+                .isNotNull();
+        }
 
-    // 4.2.9.2
-    @Test
-    void pointToMultiPointCommand2() throws Exception {
-        byte[] bytes = Hex.decodeHex(BACKSLASH + "05FF007A38004A");
-        ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
-        CBusCommand cBusCommand = CBusCommand.staticParse(readBufferByteBased, false);
-        assertThat(cBusCommand)
-            .isNotNull();
-    }
+        // 4.2.9.2
+        @Test
+        void pointToMultiPointCommand2() throws Exception {
+            byte[] bytes = Hex.decodeHex(BACKSLASH + "05FF007A38004A");
+            ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
+            CBusCommand cBusCommand = CBusCommand.staticParse(readBufferByteBased, false);
+            assertThat(cBusCommand)
+                .isNotNull();
+        }
 
-    // 4.2.9.3
-    @Test
-    void pointToPointToMultiPointCommand2() throws Exception {
-        byte[] bytes = Hex.decodeHex(BACKSLASH + "03420938010871");
-        ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
-        CBusCommand cBusCommand = CBusCommand.staticParse(readBufferByteBased, false);
-        assertThat(cBusCommand)
-            .isNotNull();
-    }
+        // 4.2.9.3
+        @Test
+        void pointToPointToMultiPointCommand2() throws Exception {
+            byte[] bytes = Hex.decodeHex(BACKSLASH + "03420938010871");
+            ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
+            CBusCommand cBusCommand = CBusCommand.staticParse(readBufferByteBased, false);
+            assertThat(cBusCommand)
+                .isNotNull();
+        }
 
-    // 4.3.3.1
-    @Test
-    void calReply1() throws Exception {
-        byte[] bytes = Hex.decodeHex(BACKSLASH + "0605002102");
-        ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
-        CBusCommand cBusCommand = CBusCommand.staticParse(readBufferByteBased, false);
-        assertThat(cBusCommand)
-            .isNotNull();
-    }
+        // 4.3.3.1
+        @Test
+        void calReply1() throws Exception {
+            byte[] bytes = Hex.decodeHex(BACKSLASH + "0605002102");
+            ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
+            CBusCommand cBusCommand = CBusCommand.staticParse(readBufferByteBased, false);
+            assertThat(cBusCommand)
+                .isNotNull();
+        }
 
-    // 4.3.3.1
-    @Test
-    void calReply2() throws Exception {
-        byte[] bytes = Hex.decodeHex(BACKSLASH + "86059300890231E22E363620207F");
-        ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
-        CBusCommand cBusCommand = CBusCommand.staticParse(readBufferByteBased, false);
-        assertThat(cBusCommand)
-            .isNotNull();
-    }
+        // 4.3.3.1
+        @Test
+        void calReply2() throws Exception {
+            byte[] bytes = Hex.decodeHex(BACKSLASH + "86059300890231E22E363620207F");
+            ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
+            CBusCommand cBusCommand = CBusCommand.staticParse(readBufferByteBased, false);
+            assertThat(cBusCommand)
+                .isNotNull();
+        }
 
-    // 4.3.3.2
-    @Test
-    void monitoredSal() throws Exception {
-        byte[] bytes = Hex.decodeHex(BACKSLASH + "0503380079083F");
-        ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
-        CBusCommand cBusCommand = CBusCommand.staticParse(readBufferByteBased, false);
-        assertThat(cBusCommand)
-            .isNotNull();
+        // 4.3.3.2
+        @Test
+        void monitoredSal() throws Exception {
+            byte[] bytes = Hex.decodeHex(BACKSLASH + "0503380079083F");
+            ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
+            CBusCommand cBusCommand = CBusCommand.staticParse(readBufferByteBased, false);
+            assertThat(cBusCommand)
+                .isNotNull();
+        }
     }
 
-
 }