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 16:00:38 UTC
[incubator-plc4x] branch develop updated: - Simplified the way
test-suites are defined
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 7c843a2 - Simplified the way test-suites are defined
7c843a2 is described below
commit 7c843a2e50beae952f72debcbf0a2636b32b1fa9
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Mon Jan 21 17:00:34 2019 +0100
- Simplified the way test-suites are defined
---
...ProtocolTest.java => AbstractProtocolTest.java} | 49 ++++++++++------------
.../apache/plc4x/protocols/TpktProtocolTest.java | 40 +++---------------
2 files changed, 29 insertions(+), 60 deletions(-)
diff --git a/protocols/src/test/java/org/apache/plc4x/protocols/TpktProtocolTest.java b/protocols/src/test/java/org/apache/plc4x/protocols/AbstractProtocolTest.java
similarity index 51%
copy from protocols/src/test/java/org/apache/plc4x/protocols/TpktProtocolTest.java
copy to protocols/src/test/java/org/apache/plc4x/protocols/AbstractProtocolTest.java
index c34132d..704937d 100644
--- a/protocols/src/test/java/org/apache/plc4x/protocols/TpktProtocolTest.java
+++ b/protocols/src/test/java/org/apache/plc4x/protocols/AbstractProtocolTest.java
@@ -22,38 +22,35 @@ 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.BeforeEach;
-import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.DynamicTest;
+import org.junit.jupiter.api.TestFactory;
+import scala.collection.Iterator;
-public class TpktProtocolTest {
+import java.util.LinkedList;
+import java.util.List;
- private DFDLTestSuite testSuite;
+public abstract class AbstractProtocolTest {
- @BeforeEach
- public void setup() {
- String tpktProtocolTestCases = "org/apache/plc4x/protocols/tpkt-protocol.tdml";
- testSuite = new DFDLTestSuite(Misc.getRequiredResource(tpktProtocolTestCases), true, true, false,
- Runner.defaultRoundTripDefaultDefault(), Runner.defaultValidationDefaultDefault());
- }
-
- @Test
- public void tpktPacketContainingCotpConnectResponse() {
- testSuite.runOneTest("tpktPacketContainingCotpConnectResponse", scala.Option.apply(null), false);
- }
+ private final String testsuiteName;
- @Test
- public void invalidMagicByte() {
- testSuite.runOneTest("invalidMagicByte", scala.Option.apply(null), false);
+ public AbstractProtocolTest(String testsuiteName) {
+ this.testsuiteName = testsuiteName;
}
- @Test
- public void tooShortPayload() {
- testSuite.runOneTest("tooShortPayload", scala.Option.apply(null), false);
- }
-
- @Test
- public void tooLongPayload() {
- testSuite.runOneTest("tooLongPayload", scala.Option.apply(null), false);
+ @TestFactory
+ public List<DynamicTest> getTestsuiteTests() {
+ DFDLTestSuite testSuite = new DFDLTestSuite(Misc.getRequiredResource(testsuiteName), true, true, false,
+ Runner.defaultRoundTripDefaultDefault(), Runner.defaultValidationDefaultDefault());
+ List<DynamicTest> dynamicTests = new LinkedList<>();
+ Iterator<String> iterator = testSuite.testCaseMap().keySet().iterator();
+ while(iterator.hasNext()) {
+ String testcaseName = iterator.next();
+ DynamicTest test = DynamicTest.dynamicTest(testcaseName, () ->
+ testSuite.runOneTest(testcaseName, scala.Option.apply(null), false)
+ );
+ dynamicTests.add(test);
+ }
+ return dynamicTests;
}
}
diff --git a/protocols/src/test/java/org/apache/plc4x/protocols/TpktProtocolTest.java b/protocols/src/test/java/org/apache/plc4x/protocols/TpktProtocolTest.java
index c34132d..f67dbb1 100644
--- a/protocols/src/test/java/org/apache/plc4x/protocols/TpktProtocolTest.java
+++ b/protocols/src/test/java/org/apache/plc4x/protocols/TpktProtocolTest.java
@@ -19,41 +19,13 @@
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.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-public class TpktProtocolTest {
-
- private DFDLTestSuite testSuite;
-
- @BeforeEach
- public void setup() {
- String tpktProtocolTestCases = "org/apache/plc4x/protocols/tpkt-protocol.tdml";
- testSuite = new DFDLTestSuite(Misc.getRequiredResource(tpktProtocolTestCases), true, true, false,
- Runner.defaultRoundTripDefaultDefault(), Runner.defaultValidationDefaultDefault());
- }
-
- @Test
- public void tpktPacketContainingCotpConnectResponse() {
- testSuite.runOneTest("tpktPacketContainingCotpConnectResponse", scala.Option.apply(null), false);
- }
-
- @Test
- public void invalidMagicByte() {
- testSuite.runOneTest("invalidMagicByte", scala.Option.apply(null), false);
- }
-
- @Test
- public void tooShortPayload() {
- testSuite.runOneTest("tooShortPayload", scala.Option.apply(null), false);
- }
+/**
+ * Executes all tests for the ISO on TCP / TPKT protocol.
+ */
+public class TpktProtocolTest extends AbstractProtocolTest {
- @Test
- public void tooLongPayload() {
- testSuite.runOneTest("tooLongPayload", scala.Option.apply(null), false);
+ public TpktProtocolTest() {
+ super("org/apache/plc4x/protocols/tpkt-protocol.tdml");
}
}