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/11/08 09:11:56 UTC
[incubator-plc4x] branch master updated: [plc4j-ads] migrate
disabled encoder/decoder tests to spock moved report properties to
driver-bases-test
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 c30f6c9 [plc4j-ads] migrate disabled encoder/decoder tests to spock moved report properties to driver-bases-test
c30f6c9 is described below
commit c30f6c93e3e5c1fcf9b1f552ad950700eb736014
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Thu Nov 8 10:10:59 2018 +0100
[plc4j-ads] migrate disabled encoder/decoder tests to spock
moved report properties to driver-bases-test
---
.gitignore | 2 +
plc4j/protocols/ads/pom.xml | 14 ++-
.../ads/protocol/util/LittleEndianDecoder.java | 7 +-
.../ads/protocol/util/LittleEndianEncoder.java | 3 +-
.../protocol/util/LittleEndianDecoderSpec.groovy | 99 ++++++++++++++++++++
.../protocol/util/LittleEndianEncoderSpec.groovy | 53 +++++++++++
.../ads/protocol/util/LittleEndianDecoderTest.java | 100 ---------------------
.../ads/protocol/util/LittleEndianEncoderTest.java | 75 ----------------
...spockframework.report.IReportCreator.properties | 0
9 files changed, 171 insertions(+), 182 deletions(-)
diff --git a/.gitignore b/.gitignore
index 6c2f13d..0842fd3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -77,3 +77,5 @@ local.properties
# Emacs backup files
*~
.scannerwork
+
+spock-reports
\ No newline at end of file
diff --git a/plc4j/protocols/ads/pom.xml b/plc4j/protocols/ads/pom.xml
index 0fdef5a..b0737ab 100644
--- a/plc4j/protocols/ads/pom.xml
+++ b/plc4j/protocols/ads/pom.xml
@@ -17,7 +17,8 @@
limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -119,6 +120,17 @@
<version>0.2.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.spockframework</groupId>
+ <artifactId>spock-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.athaydes</groupId>
+ <artifactId>spock-reports</artifactId>
+ <version>1.6.1</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/protocol/util/LittleEndianDecoder.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/protocol/util/LittleEndianDecoder.java
index 4bd92d3..fb77f44 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/protocol/util/LittleEndianDecoder.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/protocol/util/LittleEndianDecoder.java
@@ -23,6 +23,7 @@ import io.netty.buffer.Unpooled;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.NotImplementedException;
import org.apache.plc4x.java.ads.model.AdsDataType;
+import org.apache.plc4x.java.api.exceptions.PlcUnsupportedDataTypeException;
import org.apache.plc4x.java.base.messages.items.*;
import java.io.ByteArrayOutputStream;
@@ -339,11 +340,9 @@ public class LittleEndianDecoder {
case SUB_RANGE_DATA_TYPE: {
throw new NotImplementedException("not implemented yet " + adsDataType);
}
- case UNKNOWN: {
- throw new NotImplementedException("not implemented yet " + adsDataType);
- }
+ case UNKNOWN:
default:
- throw new IllegalArgumentException("Unsupported adsDataType " + adsDataType);
+ throw new PlcUnsupportedDataTypeException("Unsupported adsDataType " + adsDataType);
}
}
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/protocol/util/LittleEndianEncoder.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/protocol/util/LittleEndianEncoder.java
index 272d451..573032b 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/protocol/util/LittleEndianEncoder.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/protocol/util/LittleEndianEncoder.java
@@ -103,8 +103,7 @@ public class LittleEndianEncoder {
return stringStream
.map(s -> s.getBytes(Charset.defaultCharset()))
// TODO: this 0 termination is from s7 but might be completly wrong in ads. Guess its a terminator
- .map(bytes -> ArrayUtils.add(bytes, (byte) 0x0))
- .map(bytes -> Arrays.copyOf(bytes, adsDataType.getTargetByteSize()));
+ .map(bytes -> ArrayUtils.add(bytes, (byte) 0x0));
}
private static Stream<byte[]> encodeByteArray(AdsDataType adsDataType, Stream<byte[]> byteArrayStream) {
diff --git a/plc4j/protocols/ads/src/test/groovy/org/apache/plc4x/java/ads/protocol/util/LittleEndianDecoderSpec.groovy b/plc4j/protocols/ads/src/test/groovy/org/apache/plc4x/java/ads/protocol/util/LittleEndianDecoderSpec.groovy
new file mode 100644
index 0000000..8be2518
--- /dev/null
+++ b/plc4j/protocols/ads/src/test/groovy/org/apache/plc4x/java/ads/protocol/util/LittleEndianDecoderSpec.groovy
@@ -0,0 +1,99 @@
+/*
+ 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.java.ads.protocol.util
+
+import org.apache.plc4x.java.ads.model.AdsDataType
+import org.apache.plc4x.java.api.exceptions.PlcProtocolException
+import org.apache.plc4x.java.api.exceptions.PlcUnsupportedDataTypeException
+import spock.lang.Ignore
+import spock.lang.Specification
+import spock.lang.Unroll
+
+import static org.apache.plc4x.java.ads.model.AdsDataType.*
+
+class LittleEndianDecoderSpec extends Specification {
+ @Unroll
+ def "decode of #adsdt.name() using get#retrievalType.simpleName [#expectedValues]"(AdsDataType adsdt, def retrievalType, def expectedValues, def rawData) {
+ when:
+ def fieldItem = LittleEndianDecoder.decodeData(adsdt, rawData)
+
+ and:
+ def data = []
+ (0..fieldItem.numberOfValues - 1).forEach({ index ->
+ data << fieldItem."get${retrievalType.simpleName}"(index)
+ })
+
+ then:
+ assert data == expectedValues
+ where:
+ adsdt | retrievalType | expectedValues | rawData
+ BIT | Boolean | [true, false] | [0x1, 0x0] as byte[]
+ BIT | Byte | [1, 0] | [0x1, 0x0] as byte[]
+ BIT | Short | [1] | [0x1] as byte[]
+ BIT | Short | [1] | [0x1] as byte[]
+ BIT | Short | [1, 0] | [0x1, 0x0] as byte[]
+
+ INT | Byte | [1] | [0x1, 0x0] as byte[]
+ INT | Short | [1] | [0x1, 0x0] as byte[]
+ INT | Short | [256] | [0x0, 0x1] as byte[]
+ INT | Short | [256, 256] | [0x0, 0x1, 0x0, 0x1] as byte[]
+ INT | Integer | [1] | [0x1, 0x0] as byte[]
+ INT | Integer | [256] | [0x0, 0x1] as byte[]
+ INT | Integer | [256, 256] | [0x0, 0x1, 0x0, 0x1] as byte[]
+ INT | Float | [1.0f] | [0x1, 0x0] as byte[]
+ INT | Float | [256f] | [0x0, 0x1] as byte[]
+ INT | Float | [256f, 256f] | [0x0, 0x1, 0x0, 0x1] as byte[]
+ INT | Double | [1d] | [0x1, 0x0] as byte[]
+ INT | Double | [256d] | [0x0, 0x1] as byte[]
+ INT | Double | [256d, 256d] | [0x0, 0x1, 0x0, 0x1] as byte[]
+
+ INT32 | Integer | [16777216] | [0x0, 0x0, 0x0, 0x1] as byte[]
+ INT32 | Integer | [16777216, 16777216] | [0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1] as byte[]
+
+ REAL | Float | [1.4E-45f] | [0x1, 0x0, 0x0, 0x0] as byte[]
+ REAL | Float | [2.3509887E-38f] | [0x0, 0x0, 0x0, 0x1] as byte[]
+ REAL | Float | [2.3509887E-38f, 2.3509887E-38f] | [0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1] as byte[]
+
+ LREAL | Double | [4.9E-324] | [0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0] as byte[]
+ LREAL | Double | [7.2911220195563975E-304] | [0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1] as byte[]
+ LREAL | Double | [7.2911220195563975E-304, 7.2911220195563975E-304] | [0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1] as byte[]
+
+ STRING | String | ["plc4x"] | [0x70, 0x6c, 0x63, 0x34, 0x78, 0x0] as byte[]
+ STRING | String | ["plc4xplc4x"] | [0x70, 0x6c, 0x63, 0x34, 0x78, 0x70, 0x6c, 0x63, 0x34, 0x78, 0x0] as byte[]
+ STRING | String | ["plc4x", "plc4x"] | [0x70, 0x6c, 0x63, 0x34, 0x78, 0x0, 0x70, 0x6c, 0x63, 0x34, 0x78, 0x0] as byte[]
+ }
+
+ @Ignore("Needs finishing")
+ def "failure test with string"() {
+ when:
+ LittleEndianDecoder.decodeData(STRING, [0x01] as byte[])
+
+ then:
+ thrown PlcProtocolException
+ }
+
+ def "failure test with unsupported data type"() {
+ when:
+ LittleEndianDecoder.decodeData(UNKNOWN, new byte[10])
+
+ then:
+ thrown PlcUnsupportedDataTypeException
+ }
+}
diff --git a/plc4j/protocols/ads/src/test/groovy/org/apache/plc4x/java/ads/protocol/util/LittleEndianEncoderSpec.groovy b/plc4j/protocols/ads/src/test/groovy/org/apache/plc4x/java/ads/protocol/util/LittleEndianEncoderSpec.groovy
new file mode 100644
index 0000000..56a02b6
--- /dev/null
+++ b/plc4j/protocols/ads/src/test/groovy/org/apache/plc4x/java/ads/protocol/util/LittleEndianEncoderSpec.groovy
@@ -0,0 +1,53 @@
+/*
+ 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.java.ads.protocol.util
+
+import org.apache.plc4x.java.ads.model.AdsDataType
+import spock.lang.Specification
+import spock.lang.Unroll
+
+import static org.apache.plc4x.java.ads.model.AdsDataType.*
+
+class LittleEndianEncoderSpec extends Specification {
+ @Unroll
+ def "encode of #adsdt.name() using #values"(AdsDataType adsdt, def expectedBytes, def values) {
+ when:
+ def bytes = LittleEndianEncoder.encodeData(adsdt, *values)
+
+ then:
+ assert expectedBytes == bytes
+ where:
+ adsdt | expectedBytes | values
+ SINT | [0x01, 0x00, 0x01, 0x00] as byte[] | [true, false, true, false]
+
+ SINT | [0x12, 0x03, 0x05, 0x7f] as byte[] | [0x12, 0x03, 0x05, 0x7f] as byte[]
+ INT | [0x1, 0x00] as byte[] | [1] as short[]
+ INT | [0x0e, 0x00, 0x50, 0x00] as byte[] | [14, 80] as short[]
+ INT32 | [0x5a, 0x0a, 0x00, 0x00] as byte[] | [2650]
+ INT32 | [0x5a, 0x0a, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00] as byte[] | [2650, 80]
+ REAL | [0xc3, 0xf5, 0x48, 0x40] as byte[] | [3.14f]
+ REAL | [0xc3, 0xf5, 0x48, 0x40, 0x14, 0xae, 0x07, 0x40] as byte[] | [3.14f, 2.12f]
+ LREAL | [0x1F, 0x85, 0xEB, 0x51, 0xB8, 0x1E, 0x09, 0x40] as byte[] | [3.14d]
+ LREAL | [0x1F, 0x85, 0xEB, 0x51, 0xB8, 0x1E, 0x09, 0x40, 0xF6, 0x28, 0x5C, 0x8F, 0xC2, 0xF5, 0x00, 0x40] as byte[] | [3.14d, 2.12d]
+ STRING | [0x70, 0x6c, 0x63, 0x34, 0x78, 0x00] as byte[] | ["plc4x"]
+ STRING | [0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x21, 0x00] as byte[] | ["HelloWorld!"]
+ STRING | [0x70, 0x6c, 0x63, 0x34, 0x78, 0x00, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x21, 0x00] as byte[] | ["plc4x", "HelloWorld!"]
+ }
+}
diff --git a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/util/LittleEndianDecoderTest.java b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/util/LittleEndianDecoderTest.java
deleted file mode 100644
index 1edaf37..0000000
--- a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/util/LittleEndianDecoderTest.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- 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.java.ads.protocol.util;
-
-import org.apache.commons.lang3.reflect.MethodUtils;
-import org.apache.plc4x.java.ads.model.AdsDataType;
-import org.apache.plc4x.java.api.exceptions.PlcProtocolException;
-import org.apache.plc4x.java.api.exceptions.PlcUnsupportedDataTypeException;
-import org.apache.plc4x.java.base.messages.items.BaseDefaultFieldItem;
-import org.junit.jupiter.api.Disabled;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.Arguments;
-import org.junit.jupiter.params.provider.MethodSource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.lang.reflect.Method;
-import java.util.*;
-import java.util.stream.Stream;
-
-import static java.util.Arrays.asList;
-import static java.util.Collections.singletonList;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-
-@Disabled("needs finishing")
-public class LittleEndianDecoderTest {
-
- private static Logger LOG = LoggerFactory.getLogger(LittleEndianDecoderTest.class);
-
- @ParameterizedTest
- @MethodSource("createAdsDataTypePears")
- public void decodeData(AdsDataType adsDataType, Collection expectedTypes, Class<?> clazz, byte[] adsData) throws Exception {
- BaseDefaultFieldItem<?> fieldItem = LittleEndianDecoder.decodeData(adsDataType, adsData);
-
- Method getterMethod = MethodUtils.getAccessibleMethod(BaseDefaultFieldItem.class, "get" + clazz.getSimpleName(), int.class);
- LOG.info("Using {} to map", getterMethod);
-
- List<? super Object> actualTypes = new LinkedList<>();
- for (int i = 0; i < fieldItem.getNumberOfValues(); i++) {
- actualTypes.add(getterMethod.invoke(fieldItem, i));
- }
- assertEquals(expectedTypes, actualTypes);
- }
-
- @Test
- public void negativeTest() {
- assertThrows(PlcProtocolException.class, () -> LittleEndianDecoder.decodeData(AdsDataType.STRING, new byte[]{0x01}));
- assertThrows(PlcUnsupportedDataTypeException.class, () -> LittleEndianDecoder.decodeData(AdsDataType.UNKNOWN, new byte[10]));
- }
-
- private static Stream<Arguments> createAdsDataTypePears() {
- Calendar calendar1 = Calendar.getInstance();
- calendar1.setTime(new Date(-11644473600000L));
- Calendar calendar0x0001 = Calendar.getInstance();
- calendar0x0001.setTime(new Date(-4438714196208L));
-
- return Arrays.stream(AdsDataType.values())
- .filter(adsDataType -> adsDataType != AdsDataType.UNKNOWN)
- .flatMap(adsDataType -> Stream.of(
- Arguments.of(asList(true, false), Boolean.class, new byte[]{0x1, 0x0}),
- Arguments.of(asList((byte) 0x1, (byte) 0x0), Byte.class, new byte[]{0x1, 0x0}),
- Arguments.of(singletonList((short) 1), Short.class, new byte[]{0x1}),
- Arguments.of(singletonList((short) 256), Short.class, new byte[]{0x0, 0x1}),
- Arguments.of(asList((short) 256, (short) 256), Short.class, new byte[]{0x0, 0x1, 0x0, 0x1}),
- Arguments.of(singletonList(1), Integer.class, new byte[]{0x1}),
- Arguments.of(singletonList(16777216), Integer.class, new byte[]{0x0, 0x0, 0x0, 0x1}),
- Arguments.of(asList(16777216, 16777216), Integer.class, new byte[]{0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1}),
- Arguments.of(singletonList(1.4E-45f), Float.class, new byte[]{0x1}),
- Arguments.of(singletonList(2.3509887E-38f), Float.class, new byte[]{0x0, 0x0, 0x0, 0x1}),
- Arguments.of(asList(2.3509887E-38f, 2.3509887E-38f), Float.class, new byte[]{0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1}),
- Arguments.of(singletonList(4.9E-324), Double.class, new byte[]{0x1}),
- Arguments.of(singletonList(7.2911220195563975E-304), Double.class, new byte[]{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1}),
- Arguments.of(asList(7.2911220195563975E-304, 7.2911220195563975E-304), Double.class, new byte[]{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1}),
- Arguments.of(singletonList(calendar1), Calendar.class, new byte[]{0x1}),
- Arguments.of(singletonList(calendar0x0001), Calendar.class, new byte[]{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1}),
- Arguments.of(asList(calendar0x0001, calendar0x0001), Calendar.class, new byte[]{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1}),
- Arguments.of(singletonList("plc4x"), String.class, new byte[]{0x70, 0x6c, 0x63, 0x34, 0x78, 0x0}),
- Arguments.of(singletonList("plc4xplc4x"), String.class, new byte[]{0x70, 0x6c, 0x63, 0x34, 0x78, 0x70, 0x6c, 0x63, 0x34, 0x78, 0x0}),
- Arguments.of(asList("plc4x", "plc4x"), String.class, new byte[]{0x70, 0x6c, 0x63, 0x34, 0x78, 0x0, 0x70, 0x6c, 0x63, 0x34, 0x78, 0x0})
- ).map(arguments -> Arguments.of(adsDataType, arguments.get()[0], arguments.get()[1], arguments.get()[2])));
- }
-}
\ No newline at end of file
diff --git a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/util/LittleEndianEncoderTest.java b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/util/LittleEndianEncoderTest.java
deleted file mode 100644
index 86d4249..0000000
--- a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/util/LittleEndianEncoderTest.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- 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.java.ads.protocol.util;
-
-import org.apache.plc4x.java.ads.model.AdsDataType;
-import org.apache.plc4x.java.api.exceptions.PlcUnsupportedDataTypeException;
-import org.junit.jupiter.api.Disabled;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.Arguments;
-import org.junit.jupiter.params.provider.MethodSource;
-
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.stream.Stream;
-
-import static org.apache.plc4x.java.base.util.Assert.assertByteEquals;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-
-@Disabled("needs finishing")
-public class LittleEndianEncoderTest {
-
- @ParameterizedTest
- @MethodSource("createAdsDataTypePears")
- public void decodeData(AdsDataType adsDataType, byte[] expectedData, Class<?> clazz, Object[] values) throws Exception {
- assertByteEquals(expectedData, LittleEndianEncoder.encodeData(adsDataType, values));
- }
-
- @Test
- public void negativeTest() {
- assertThrows(PlcUnsupportedDataTypeException.class, () -> LittleEndianEncoder.encodeData(AdsDataType.UNKNOWN, ""));
- }
-
- private static Stream<Arguments> createAdsDataTypePears() {
- Calendar calendar1 = Calendar.getInstance();
- //calendar1.set(2003, Calendar.DECEMBER, 23, 13, 3, 0);
- calendar1.setTime(new Date(1072180980436L));
-
- return Arrays.stream(AdsDataType.values())
- .filter(adsDataType -> adsDataType != AdsDataType.UNKNOWN)
- .flatMap(adsDataType -> Stream.of(
- Arguments.of(new byte[]{0x01, 0x00, 0x01, 0x00}, Boolean.class, new Object[]{true, false, true, false}),
- Arguments.of(new byte[]{0x12, 0x03, 0x05, 0x7f}, Byte.class, new Object[]{(byte) 0x12, (byte) 0x03, (byte) 0x05, (byte) 0x7f}),
- Arguments.of(new byte[]{0x1, 0x00}, Short.class, new Object[]{(short) 1}),
- Arguments.of(new byte[]{0x0e, 0x00, 0x50, 0x00}, Short.class, new Object[]{(short) 14, (short) 80}),
- Arguments.of(new byte[]{0x5a, 0x0a, 0x00, 0x00}, Integer.class, new Object[]{2650}),
- Arguments.of(new byte[]{0x5a, 0x0a, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00}, Integer.class, new Object[]{2650, 80}),
- Arguments.of(new byte[]{(byte) 0xc3, (byte) 0xf5, 0x48, 0x40}, Float.class, new Object[]{3.14f}),
- Arguments.of(new byte[]{(byte) 0xc3, (byte) 0xf5, 0x48, 0x40, 0x14, (byte) 0xae, 0x07, 0x40}, Float.class, new Object[]{3.14f, 2.12f}),
- Arguments.of(new byte[]{0x1F, (byte) 0x85, (byte) 0xEB, 0x51, (byte) 0xB8, 0x1E, 0x09, 0x40}, Double.class, new Object[]{3.14}),
- Arguments.of(new byte[]{0x1F, (byte) 0x85, (byte) 0xEB, 0x51, (byte) 0xB8, 0x1E, 0x09, 0x40, (byte) 0xF6, 0x28, 0x5C, (byte) 0x8F, (byte) 0xC2, (byte) 0xF5, 0x00, 0x40}, Double.class, new Object[]{3.14, 2.12}),
- Arguments.of(new byte[]{(byte) 0x40, (byte) 0x79, (byte) 0xFB, (byte) 0xB5, (byte) 0x4C, (byte) 0xC9, (byte) 0xC3, (byte) 0x01}, Calendar.class, new Object[]{calendar1}),
- Arguments.of(new byte[]{0x70, 0x6c, 0x63, 0x34, 0x78, 0x00}, String.class, new Object[]{"plc4x"}),
- Arguments.of(new byte[]{0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x21, 0x00}, String.class, new Object[]{"HelloWorld!"}),
- Arguments.of(new byte[]{0x70, 0x6c, 0x63, 0x34, 0x78, 0x00, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x21, 0x00}, String.class, new Object[]{"plc4x", "HelloWorld!"})
- ).map(arguments -> Arguments.of(adsDataType, arguments.get()[0], arguments.get()[1], arguments.get()[2])));
- }
-}
\ No newline at end of file
diff --git a/plc4j/protocols/s7/src/test/resources/META-INF/services/com.athaydes.spockframework.report.IReportCreator.properties b/plc4j/protocols/driver-bases/test/src/main/resources/META-INF/services/com.athaydes.spockframework.report.IReportCreator.properties
similarity index 100%
rename from plc4j/protocols/s7/src/test/resources/META-INF/services/com.athaydes.spockframework.report.IReportCreator.properties
rename to plc4j/protocols/driver-bases/test/src/main/resources/META-INF/services/com.athaydes.spockframework.report.IReportCreator.properties