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 14:14:00 UTC
[incubator-plc4x] branch master updated: added type generator
function to Plc4XS7ProtocolTest
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 bd291ae added type generator function to Plc4XS7ProtocolTest
bd291ae is described below
commit bd291aee091e7668837983a1852a57b766cee6e2
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Thu Jul 26 16:13:57 2018 +0200
added type generator function to Plc4XS7ProtocolTest
---
.../plc4x/java/s7/netty/Plc4XS7ProtocolTest.java | 49 ++++++++++++++--------
1 file changed, 31 insertions(+), 18 deletions(-)
diff --git a/plc4j/protocols/s7/src/test/java/org/apache/plc4x/java/s7/netty/Plc4XS7ProtocolTest.java b/plc4j/protocols/s7/src/test/java/org/apache/plc4x/java/s7/netty/Plc4XS7ProtocolTest.java
index 4b2c6f7..b2eb489 100644
--- a/plc4j/protocols/s7/src/test/java/org/apache/plc4x/java/s7/netty/Plc4XS7ProtocolTest.java
+++ b/plc4j/protocols/s7/src/test/java/org/apache/plc4x/java/s7/netty/Plc4XS7ProtocolTest.java
@@ -38,42 +38,58 @@ import org.apache.plc4x.java.s7.netty.model.types.MessageType;
import org.apache.plc4x.java.s7.netty.model.types.ParameterType;
import org.apache.plc4x.test.FastTests;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
+import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.lang.reflect.Field;
+import java.math.BigInteger;
import java.util.*;
import java.util.function.Consumer;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
import static java.util.Collections.singletonList;
+import static org.apache.plc4x.java.base.protocol.Plc4XSupportedDataTypes.streamOfPlc4XSupportedDataTypes;
+import static org.hamcrest.Matchers.hasItem;
+import static org.hamcrest.Matchers.not;
import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
import static org.junit.Assert.assertThat;
+import static org.junit.Assume.assumeThat;
import static org.mockito.Mockito.*;
@SuppressWarnings("unchecked")
@RunWith(Parameterized.class)
public class Plc4XS7ProtocolTest extends NettyTestBase {
- private Class<?> type;
- private S7Address address;
-
private Plc4XS7Protocol SUT;
- @Parameterized.Parameters
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+ // TODO: implement these types
+ private List<String> notYetSupportedDataType = Stream.of(
+ Calendar.class,
+ GregorianCalendar.class,
+ Double.class,
+ BigInteger.class,
+ byte[].class,
+ Byte[].class
+ ).map(Class::getSimpleName).collect(Collectors.toList());
+
+ @Parameterized.Parameter
+ public Class<?> type;
+
+ @Parameterized.Parameter(1)
+ public S7Address address;
+
+ @Parameterized.Parameters(name = "{index} Type:{0} {1}")
public static Collection<Object[]> data() {
List<Object[]> arguments = new LinkedList<>();
// Build the cross product of all variables and address types.
- Arrays.asList(
- /*Boolean.class,
- Byte.class,
- Short.class,
- // TODO: enable once Calender in implemented
- //Calendar.class,
- Float.class,
- Integer.class,*/
- String.class)
+ streamOfPlc4XSupportedDataTypes()
.forEach(
aClass -> Arrays.asList(
mock(S7Address.class),
@@ -84,11 +100,6 @@ public class Plc4XS7ProtocolTest extends NettyTestBase {
return arguments;
}
- public Plc4XS7ProtocolTest(Class<?> type, S7Address address) {
- this.type = type;
- this.address = address;
- }
-
@Before
public void setUp() {
SUT = new Plc4XS7Protocol();
@@ -97,6 +108,7 @@ public class Plc4XS7ProtocolTest extends NettyTestBase {
@Test
@Category(FastTests.class)
public void encode() throws Exception {
+ assumeThat(type + " not yet implemented", notYetSupportedDataType, not(hasItem(type.getSimpleName())));
// TODO: finish me
// Read Request Tests
{
@@ -117,6 +129,7 @@ public class Plc4XS7ProtocolTest extends NettyTestBase {
@Test
@Category(FastTests.class)
public void decode() throws Exception {
+ assumeThat(type + " not yet implemented", notYetSupportedDataType, not(hasItem(type.getSimpleName())));
// Read Test
{
short fakeTpduReference = (short) 1;