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/07/26 11:47:58 UTC
[incubator-plc4x] branch master updated: added byte[] and Byte[] to
supported data types 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 11db5b9 added byte[] and Byte[] to supported data types test
11db5b9 is described below
commit 11db5b9a592d3a3ae9fc21bde77e9fb6250b11d1
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Thu Jul 26 13:47:55 2018 +0200
added byte[] and Byte[] to supported data types test
---
.../plc4x/java/ads/protocol/Plc4x2AdsProtocolTest.java | 14 ++++++++++++++
.../plc4x/java/base/protocol/Plc4XSupportedDataTypes.java | 7 +++++--
.../plc4x/java/modbus/netty/Plc4XModbusProtocolTest.java | 4 +++-
3 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/Plc4x2AdsProtocolTest.java b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/Plc4x2AdsProtocolTest.java
index 5dc4558..4c5384e 100644
--- a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/Plc4x2AdsProtocolTest.java
+++ b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/Plc4x2AdsProtocolTest.java
@@ -34,7 +34,9 @@ import org.apache.plc4x.java.api.messages.*;
import org.apache.plc4x.java.api.messages.items.ReadResponseItem;
import org.apache.plc4x.java.api.messages.items.ResponseItem;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.slf4j.Logger;
@@ -45,6 +47,7 @@ import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Collection;
import java.util.GregorianCalendar;
+import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
@@ -55,6 +58,7 @@ import static org.apache.plc4x.java.base.protocol.Plc4XSupportedDataTypes.defaul
import static org.apache.plc4x.java.base.protocol.Plc4XSupportedDataTypes.streamOfLittleEndianDataTypePairs;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
+import static org.junit.Assume.assumeThat;
@RunWith(Parameterized.class)
public class Plc4x2AdsProtocolTest {
@@ -62,6 +66,14 @@ public class Plc4x2AdsProtocolTest {
private Plc4x2AdsProtocol SUT;
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+ // TODO: implement these types
+ private List<String> notYetSupportedDataType = Stream.of(
+ byte[].class,
+ Byte[].class
+ ).map(Class::getSimpleName).collect(Collectors.toList());
+
@Parameterized.Parameter
public String payloadClazzName;
@@ -121,6 +133,7 @@ public class Plc4x2AdsProtocolTest {
@Test
public void encode() throws Exception {
+ assumeThat(payloadClazzName + " not yet implemented", notYetSupportedDataType, not(hasItem(payloadClazzName)));
ArrayList<Object> out = new ArrayList<>();
SUT.encode(null, plcRequestContainer, out);
assertThat(out, hasSize(1));
@@ -152,6 +165,7 @@ public class Plc4x2AdsProtocolTest {
@Test
public void decode() throws Exception {
+ assumeThat(payloadClazzName + " not yet implemented", notYetSupportedDataType, not(hasItem(payloadClazzName)));
ArrayList<Object> in = new ArrayList<>();
SUT.encode(null, plcRequestContainer, in);
assertThat(in, hasSize(1));
diff --git a/plc4j/protocols/driver-bases/test/src/main/java/org/apache/plc4x/java/base/protocol/Plc4XSupportedDataTypes.java b/plc4j/protocols/driver-bases/test/src/main/java/org/apache/plc4x/java/base/protocol/Plc4XSupportedDataTypes.java
index 3585d94..4cf0e61 100644
--- a/plc4j/protocols/driver-bases/test/src/main/java/org/apache/plc4x/java/base/protocol/Plc4XSupportedDataTypes.java
+++ b/plc4j/protocols/driver-bases/test/src/main/java/org/apache/plc4x/java/base/protocol/Plc4XSupportedDataTypes.java
@@ -49,6 +49,8 @@ public class Plc4XSupportedDataTypes {
littleEndianMap.put(Calendar.class, ImmutablePair.of(calenderInstance, new byte[]{0x0, (byte) 0x80, 0x3E, 0x15, (byte) 0xAB, 0x47, (byte) 0xFC, 0x28}));
littleEndianMap.put(GregorianCalendar.class, littleEndianMap.get(Calendar.class));
littleEndianMap.put(String.class, ImmutablePair.of(String.valueOf("Hello World!"), new byte[]{0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x21, 0x00}));
+ littleEndianMap.put(byte[].class, ImmutablePair.of(new byte[]{0x1, 0x2, 0x3, 0x4}, new byte[]{0x1, 0x2, 0x3, 0x4}));
+ littleEndianMap.put(Byte[].class, ImmutablePair.of(new byte[]{0x1, 0x2, 0x3, 0x4}, new byte[]{0x1, 0x2, 0x3, 0x4}));
bigEndianMap = new HashMap<>();
littleEndianMap.forEach((clazz, pair) -> {
Serializable serializable = pair.getLeft();
@@ -68,14 +70,15 @@ public class Plc4XSupportedDataTypes {
return Stream.of(
Boolean.class,
Byte.class,
- // TODO: add byte[]
Short.class,
Float.class,
Integer.class,
Double.class,
BigInteger.class,
Calendar.class,
- String.class
+ String.class,
+ byte[].class,
+ Byte[].class
);
}
diff --git a/plc4j/protocols/modbus/src/test/java/org/apache/plc4x/java/modbus/netty/Plc4XModbusProtocolTest.java b/plc4j/protocols/modbus/src/test/java/org/apache/plc4x/java/modbus/netty/Plc4XModbusProtocolTest.java
index 0a40696..2cb5a06 100644
--- a/plc4j/protocols/modbus/src/test/java/org/apache/plc4x/java/modbus/netty/Plc4XModbusProtocolTest.java
+++ b/plc4j/protocols/modbus/src/test/java/org/apache/plc4x/java/modbus/netty/Plc4XModbusProtocolTest.java
@@ -72,7 +72,9 @@ public class Plc4XModbusProtocolTest {
GregorianCalendar.class,
Float.class,
Double.class,
- String.class
+ String.class,
+ byte[].class,
+ Byte[].class
).map(Class::getSimpleName).collect(Collectors.toList());
@Parameterized.Parameter