You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by cd...@apache.org on 2019/01/21 13:14:31 UTC

[incubator-plc4x] branch develop updated: - Added a first Daffodil testcase for the cotp protocol

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

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


The following commit(s) were added to refs/heads/develop by this push:
     new cecf75e  - Added a first Daffodil testcase for the cotp protocol
cecf75e is described below

commit cecf75e1e16e26bccfe7ffc7889c48f65f35d187
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Mon Jan 21 14:14:25 2019 +0100

    - Added a first Daffodil testcase for the cotp protocol
---
 protocols/pom.xml                                  | 12 +++++-
 .../apache/plc4x/protocols/CotpProtocolTest.java   | 38 ++++++++++++++++++
 .../org/apache/plc4x/protocols/cotp-protocol.tdml  | 46 ++++++++++++++++++++++
 3 files changed, 95 insertions(+), 1 deletion(-)

diff --git a/protocols/pom.xml b/protocols/pom.xml
index af8745f..cf1dccb 100644
--- a/protocols/pom.xml
+++ b/protocols/pom.xml
@@ -34,7 +34,11 @@
 
   <build>
     <!-- This project should only contain the DFDL definitions for our protocols -->
-    <sourceDirectory>src/main/dfdl</sourceDirectory>
+    <resources>
+      <resource>
+        <directory>src/main/dfdl</directory>
+      </resource>
+    </resources>
   </build>
 
   <dependencies>
@@ -43,6 +47,12 @@
       <artifactId>daffodil-tdml_2.12</artifactId>
       <scope>test</scope>
     </dependency>
+
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-api</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
 
diff --git a/protocols/src/test/java/org/apache/plc4x/protocols/CotpProtocolTest.java b/protocols/src/test/java/org/apache/plc4x/protocols/CotpProtocolTest.java
new file mode 100644
index 0000000..a18d5bc
--- /dev/null
+++ b/protocols/src/test/java/org/apache/plc4x/protocols/CotpProtocolTest.java
@@ -0,0 +1,38 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+
+package org.apache.plc4x.protocols;
+
+import org.apache.daffodil.tdml.DFDLTestSuite;
+import org.apache.daffodil.tdml.Runner;
+import org.apache.daffodil.util.Misc;
+import org.junit.jupiter.api.Test;
+
+public class CotpProtocolTest {
+
+    private String cotpProtocolTestCases = "org/apache/plc4x/protocols/cotp-protocol.tdml";
+    private DFDLTestSuite testSuite = new DFDLTestSuite(Misc.getRequiredResource(cotpProtocolTestCases), true, true, false,
+        Runner.defaultRoundTripDefaultDefault(), Runner.defaultValidationDefaultDefault());
+
+    @Test
+    public void simpleS7Message() {
+        testSuite.runOneTest("cotpConnectResponseInTkptPacket", scala.Option.apply(null), false);
+    }
+
+}
diff --git a/protocols/src/test/resources/org/apache/plc4x/protocols/cotp-protocol.tdml b/protocols/src/test/resources/org/apache/plc4x/protocols/cotp-protocol.tdml
new file mode 100644
index 0000000..3b70a36
--- /dev/null
+++ b/protocols/src/test/resources/org/apache/plc4x/protocols/cotp-protocol.tdml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+  -->
+
+<testSuite suiteName="dpaext"
+           description="Sample tests to post externally"
+           xmlns="http://www.ibm.com/xmlns/dfdl/testData"
+           defaultRoundTrip="true">
+
+    <parserTestCase name="cotpConnectResponseInTkptPacket"
+                    root="root"
+                    model="../../../../../classes/org/apache/plc4x/protocols/tpkt-protocol.dfdl.xsd"
+                    description="Section 1.2 General number example,  What is DFDL - binary numbers">
+
+        <document><documentPart type="byte">0300001611D00001000200C00109C1020100C2020102</documentPart></document>
+        <infoset>
+            <dfdlInfoset>
+                <TpktMessage xmlns="http://plc4x.apache.org/tpkt">
+                    <magicByte>3</magicByte>
+                    <reserved>0</reserved>
+                    <length>22</length>
+                    <userData>11D00001000200C00109C1020100C2020102</userData>
+                </TpktMessage>
+            </dfdlInfoset>
+        </infoset>
+    </parserTestCase>
+
+</testSuite>
+
+