diff --git a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/context/SecureChannel.java b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/context/SecureChannel.java index 6669230a013..507be1f28bd 100644 --- a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/context/SecureChannel.java +++ b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/context/SecureChannel.java @@ -792,14 +792,16 @@ public void onDiscoverOpenSecureChannel(ConversationContext context, O WriteBufferByteBased buffer = new WriteBufferByteBased(extObject.getLengthInBytes(), org.apache.plc4x.java.spi.generation.ByteOrder.LITTLE_ENDIAN); extObject.serialize(buffer); - OpcuaOpenRequest openRequest = new OpcuaOpenRequest(FINAL_CHUNK, + OpcuaOpenRequest openRequest = new OpcuaOpenRequest( + FINAL_CHUNK, 0, SECURITY_POLICY_NONE, NULL_BYTE_STRING, NULL_BYTE_STRING, transactionId, transactionId, - buffer.getBytes()); + buffer.getBytes() + ); Consumer requestConsumer = t -> context.sendRequest(new OpcuaAPU(openRequest)) .expectResponse(OpcuaAPU.class, REQUEST_TIMEOUT) @@ -1039,14 +1041,16 @@ private void keepAlive() { WriteBufferByteBased buffer = new WriteBufferByteBased(extObject.getLengthInBytes(), org.apache.plc4x.java.spi.generation.ByteOrder.LITTLE_ENDIAN); extObject.serialize(buffer); - OpcuaOpenRequest openRequest = new OpcuaOpenRequest(FINAL_CHUNK, + OpcuaOpenRequest openRequest = new OpcuaOpenRequest( + FINAL_CHUNK, 0, new PascalString(this.securityPolicy), this.publicCertificate, this.thumbprint, transactionId, transactionId, - buffer.getBytes()); + buffer.getBytes() + ); final OpcuaAPU apu; diff --git a/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/OpcuaPlcDriverTest.java b/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/OpcuaPlcDriverTest.java index 51ebbe2bc67..ad1a06bceb8 100644 --- a/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/OpcuaPlcDriverTest.java +++ b/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/OpcuaPlcDriverTest.java @@ -21,7 +21,6 @@ import io.vavr.collection.List; import org.apache.plc4x.java.DefaultPlcDriverManager; import org.apache.plc4x.java.api.PlcConnection; -import org.apache.plc4x.java.api.exceptions.PlcConnectionException; import org.apache.plc4x.java.api.messages.PlcReadRequest; import org.apache.plc4x.java.api.messages.PlcReadResponse; import org.apache.plc4x.java.api.messages.PlcWriteRequest; @@ -47,20 +46,6 @@ public class OpcuaPlcDriverTest { - @BeforeAll - static void setUp() { - assumeTrue(() -> { - String OS = System.getProperty("os.name").toLowerCase(); - if (OS.contains("nix") - || OS.contains("nux") - || OS.contains("aix")) { - return false; - } - - return true; - }, "somehow opcua doesn't run properly on linux"); - } - // Read only variables of milo example server of version 3.6 private static final String BOOL_IDENTIFIER_READ_WRITE = "ns=2;s=HelloWorld/ScalarTypes/Boolean"; private static final String BYTE_IDENTIFIER_READ_WRITE = "ns=2;s=HelloWorld/ScalarTypes/Byte"; @@ -123,10 +108,10 @@ static void setUp() { private final String discoveryValidParamTrue = "discovery=true"; private final String discoveryValidParamFalse = "discovery=false"; private final String discoveryCorruptedParamWrongValueNum = "discovery=1"; - private final String discoveryCorruptedParamWronName = "diskovery=false"; + private final String discoveryCorruptedParamWrongName = "diskovery=false"; final List discoveryParamValidSet = List.of(discoveryValidParamTrue, discoveryValidParamFalse); - List discoveryParamCorruptedSet = List.of(discoveryCorruptedParamWrongValueNum, discoveryCorruptedParamWronName); + List discoveryParamCorruptedSet = List.of(discoveryCorruptedParamWrongValueNum, discoveryCorruptedParamWrongName); private static ExampleServer exampleServer; @@ -153,79 +138,86 @@ public static void tearDown() throws Exception { } } - @Test - public void connectionNoParams() { - connectionStringValidSet.forEach(connectionString -> { - try { - PlcConnection opcuaConnection = new DefaultPlcDriverManager().getConnection(connectionString); - Condition is_connected = new Condition<>(PlcConnection::isConnected, "is connected"); - assertThat(opcuaConnection).is(is_connected); - opcuaConnection.close(); - assertThat(opcuaConnection).isNot(is_connected); - } catch (PlcConnectionException e) { - fail("Exception during connectionNoParams while connecting Test EXCEPTION: " + e.getMessage()); - } catch (Exception e) { - fail("Exception during connectionNoParams while closing Test EXCEPTION: " + e.getMessage()); - } - }); - } + @Nested + class ConnectionRelated { + @TestFactory + Stream connectionNoParams() { + return connectionStringValidSet.toStream() + .map(connectionString -> DynamicTest.dynamicTest(connectionString, () -> { + PlcConnection opcuaConnection = new DefaultPlcDriverManager().getConnection(connectionString); + Condition is_connected = new Condition<>(PlcConnection::isConnected, "is connected"); + assertThat(opcuaConnection).is(is_connected); + opcuaConnection.close(); + assertThat(opcuaConnection).isNot(is_connected); + })) + .map(DynamicNode.class::cast) + .toJavaStream(); + } - @Test - public void connectionWithDiscoveryParam() { - connectionStringValidSet.forEach(connectionAddress -> discoveryParamValidSet.forEach(discoveryParam -> { - String connectionString = connectionAddress + paramSectionDivider + discoveryParam; - try { - PlcConnection opcuaConnection = new DefaultPlcDriverManager().getConnection(connectionString); - Condition is_connected = new Condition<>(PlcConnection::isConnected, "is connected"); - assertThat(opcuaConnection).is(is_connected); - opcuaConnection.close(); - assertThat(opcuaConnection).isNot(is_connected); - } catch (PlcConnectionException e) { - fail("Exception during connectionWithDiscoveryParam while connecting Test EXCEPTION: " + e.getMessage()); - } catch (Exception e) { - fail("Exception during connectionWithDiscoveryParam while closing Test EXCEPTION: " + e.getMessage()); - } - })); + @TestFactory + Stream connectionWithDiscoveryParam() throws Exception { + return connectionStringValidSet.toStream() + .map(connectionAddress -> DynamicContainer.dynamicContainer(connectionAddress, () -> + discoveryParamValidSet.toStream().map(discoveryParam -> DynamicTest.dynamicTest(discoveryParam, () -> { + String connectionString = connectionAddress + paramSectionDivider + discoveryParam; + PlcConnection opcuaConnection = new DefaultPlcDriverManager().getConnection(connectionString); + Condition is_connected = new Condition<>(PlcConnection::isConnected, "is connected"); + assertThat(opcuaConnection).is(is_connected); + opcuaConnection.close(); + assertThat(opcuaConnection).isNot(is_connected); + })) + .map(DynamicNode.class::cast) + .iterator())) + .map(DynamicNode.class::cast) + .toJavaStream(); + } } - @Test - public void readVariables() { - try { + @Nested + class readWrite { + + @BeforeEach + public void testForLinux() { + checkForLinux(); // TODO: seems those do not run on linux + } + + @Test + public void readVariables() throws Exception { PlcConnection opcuaConnection = new DefaultPlcDriverManager().getConnection(tcpConnectionAddress); Condition is_connected = new Condition<>(PlcConnection::isConnected, "is connected"); assertThat(opcuaConnection).is(is_connected); - PlcReadRequest.Builder builder = opcuaConnection.readRequestBuilder(); - builder.addTagAddress("Bool", BOOL_IDENTIFIER_READ_WRITE); - builder.addTagAddress("Byte", BYTE_IDENTIFIER_READ_WRITE); - builder.addTagAddress("Double", DOUBLE_IDENTIFIER_READ_WRITE); - builder.addTagAddress("Float", FLOAT_IDENTIFIER_READ_WRITE); - builder.addTagAddress("Int16", INT16_IDENTIFIER_READ_WRITE); - builder.addTagAddress("Int32", INT32_IDENTIFIER_READ_WRITE); - builder.addTagAddress("Int64", INT64_IDENTIFIER_READ_WRITE); - builder.addTagAddress("Integer", INTEGER_IDENTIFIER_READ_WRITE); - builder.addTagAddress("SByte", SBYTE_IDENTIFIER_READ_WRITE); - builder.addTagAddress("String", STRING_IDENTIFIER_READ_WRITE); - builder.addTagAddress("UInt16", UINT16_IDENTIFIER_READ_WRITE); - builder.addTagAddress("UInt32", UINT32_IDENTIFIER_READ_WRITE); - builder.addTagAddress("UInt64", UINT64_IDENTIFIER_READ_WRITE); - builder.addTagAddress("UInteger", UINTEGER_IDENTIFIER_READ_WRITE); - - builder.addTagAddress("BoolArray", BOOL_ARRAY_IDENTIFIER); - //builder.addTagAddress("ByteStringArray", BYTE_STRING_ARRAY_IDENTIFIER); - builder.addTagAddress("ByteArray", BYTE_ARRAY_IDENTIFIER); - builder.addTagAddress("DoubleArray", DOUBLE_ARRAY_IDENTIFIER); - builder.addTagAddress("FloatArray", FLOAT_ARRAY_IDENTIFIER); - builder.addTagAddress("Int16Array", INT16_ARRAY_IDENTIFIER); - builder.addTagAddress("Int32Array", INT32_ARRAY_IDENTIFIER); - builder.addTagAddress("Int64Array", INT64_ARRAY_IDENTIFIER); - builder.addTagAddress("SByteArray", SBYTE_ARRAY_IDENTIFIER); - builder.addTagAddress("StringArray", STRING_ARRAY_IDENTIFIER); - builder.addTagAddress("UInt16Array", UINT16_ARRAY_IDENTIFIER); - builder.addTagAddress("UInt32Array", UINT32_ARRAY_IDENTIFIER); - builder.addTagAddress("UInt64Array", UINT64_ARRAY_IDENTIFIER); - - builder.addTagAddress("DoesNotExists", DOES_NOT_EXIST_IDENTIFIER_READ_WRITE); + PlcReadRequest.Builder builder = opcuaConnection.readRequestBuilder() + .addTagAddress("Bool", BOOL_IDENTIFIER_READ_WRITE) + .addTagAddress("Byte", BYTE_IDENTIFIER_READ_WRITE) + .addTagAddress("Double", DOUBLE_IDENTIFIER_READ_WRITE) + .addTagAddress("Float", FLOAT_IDENTIFIER_READ_WRITE) + .addTagAddress("Int16", INT16_IDENTIFIER_READ_WRITE) + .addTagAddress("Int32", INT32_IDENTIFIER_READ_WRITE) + .addTagAddress("Int64", INT64_IDENTIFIER_READ_WRITE) + .addTagAddress("Integer", INTEGER_IDENTIFIER_READ_WRITE) + .addTagAddress("SByte", SBYTE_IDENTIFIER_READ_WRITE) + .addTagAddress("String", STRING_IDENTIFIER_READ_WRITE) + .addTagAddress("UInt16", UINT16_IDENTIFIER_READ_WRITE) + .addTagAddress("UInt32", UINT32_IDENTIFIER_READ_WRITE) + .addTagAddress("UInt64", UINT64_IDENTIFIER_READ_WRITE) + .addTagAddress("UInteger", UINTEGER_IDENTIFIER_READ_WRITE) + + .addTagAddress("BoolArray", BOOL_ARRAY_IDENTIFIER) + //.addTagAddress("ByteStringArray", BYTE_STRING_ARRAY_IDENTIFIER); + .addTagAddress("ByteArray", BYTE_ARRAY_IDENTIFIER) + .addTagAddress("DoubleArray", DOUBLE_ARRAY_IDENTIFIER) + .addTagAddress("FloatArray", FLOAT_ARRAY_IDENTIFIER) + .addTagAddress("Int16Array", INT16_ARRAY_IDENTIFIER) + .addTagAddress("Int32Array", INT32_ARRAY_IDENTIFIER) + .addTagAddress("Int64Array", INT64_ARRAY_IDENTIFIER) + .addTagAddress("SByteArray", SBYTE_ARRAY_IDENTIFIER) + .addTagAddress("StringArray", STRING_ARRAY_IDENTIFIER) + .addTagAddress("UInt16Array", UINT16_ARRAY_IDENTIFIER) + .addTagAddress("UInt32Array", UINT32_ARRAY_IDENTIFIER) + .addTagAddress("UInt64Array", UINT64_ARRAY_IDENTIFIER) + + .addTagAddress("DoesNotExists", DOES_NOT_EXIST_IDENTIFIER_READ_WRITE); PlcReadRequest request = builder.build(); PlcReadResponse response = request.execute().get(); @@ -259,93 +251,95 @@ public void readVariables() { assertThat(response.getResponseCode("DoesNotExists")).isEqualTo(PlcResponseCode.NOT_FOUND); + opcuaConnection.close(); + assertThat(opcuaConnection.isConnected()).isFalse(); + } + + @Test + public void writeVariables() throws Exception { + + PlcConnection opcuaConnection = new DefaultPlcDriverManager().getConnection(tcpConnectionAddress); + Condition is_connected = new Condition<>(PlcConnection::isConnected, "is connected"); + assertThat(opcuaConnection).is(is_connected); + + PlcWriteRequest.Builder builder = opcuaConnection.writeRequestBuilder() + .addTagAddress("Bool", BOOL_IDENTIFIER_READ_WRITE, true) + .addTagAddress("Byte", BYTE_IDENTIFIER_READ_WRITE + ";BYTE", (short) 3) + .addTagAddress("Double", DOUBLE_IDENTIFIER_READ_WRITE, 0.5d) + .addTagAddress("Float", FLOAT_IDENTIFIER_READ_WRITE, 0.5f) + //.addTagAddress("Int16", INT16_IDENTIFIER_READ_WRITE + "", (short) 1) + .addTagAddress("Int32", INT32_IDENTIFIER_READ_WRITE, 42) + .addTagAddress("Int64", INT64_IDENTIFIER_READ_WRITE, 42L) + .addTagAddress("Integer", INTEGER_IDENTIFIER_READ_WRITE, 42) + .addTagAddress("SByte", SBYTE_IDENTIFIER_READ_WRITE + ";SINT", -127) + .addTagAddress("String", STRING_IDENTIFIER_READ_WRITE, "Helllo Toddy!") + .addTagAddress("UInt16", UINT16_IDENTIFIER_READ_WRITE + ";UINT", 65535) + .addTagAddress("UInt32", UINT32_IDENTIFIER_READ_WRITE + ";UDINT", 101010101L) + .addTagAddress("UInt64", UINT64_IDENTIFIER_READ_WRITE + ";ULINT", new BigInteger("1337")) + .addTagAddress("UInteger", UINTEGER_IDENTIFIER_READ_WRITE + ";UDINT", 102020202L) + + + .addTagAddress("BooleanArray", BOOL_ARRAY_IDENTIFIER, (Object[]) new Boolean[]{true, true, true, true, true}) + .addTagAddress("ByteArray", BYTE_ARRAY_IDENTIFIER + ";BYTE", (Object[]) new Short[]{1, 100, 100, 255, 123}) + .addTagAddress("DoubleArray", DOUBLE_ARRAY_IDENTIFIER, (Object[]) new Double[]{1.0, 2.0, 3.0, 4.0, 5.0}) + .addTagAddress("FloatArray", FLOAT_ARRAY_IDENTIFIER, (Object[]) new Float[]{1.0F, 2.0F, 3.0F, 4.0F, 5.0F}) + .addTagAddress("Int16Array", INT16_ARRAY_IDENTIFIER, (Object[]) new Short[]{1, 2, 3, 4, 5}) + .addTagAddress("Int32Array", INT32_ARRAY_IDENTIFIER, (Object[]) new Integer[]{1, 2, 3, 4, 5}) + .addTagAddress("Int64Array", INT64_ARRAY_IDENTIFIER, (Object[]) new Long[]{1L, 2L, 3L, 4L, 5L}) + .addTagAddress("IntegerArray", INT32_ARRAY_IDENTIFIER, (Object[]) new Integer[]{1, 2, 3, 4, 5}) + .addTagAddress("SByteArray", SBYTE_ARRAY_IDENTIFIER, (Object[]) new Byte[]{1, 2, 3, 4, 5}) + .addTagAddress("StringArray", STRING_ARRAY_IDENTIFIER, (Object[]) new String[]{"1", "2", "3", "4", "5"}) + .addTagAddress("UInt16Array", UINT16_ARRAY_IDENTIFIER + ";UINT", (Object[]) new Short[]{1, 2, 3, 4, 5}) + .addTagAddress("UInt32Array", UINT32_ARRAY_IDENTIFIER + ";UDINT", (Object[]) new Integer[]{1, 2, 3, 4, 5}) + .addTagAddress("UInt64Array", UINT64_ARRAY_IDENTIFIER + ";ULINT", (Object[]) new Long[]{1L, 2L, 3L, 4L, 5L}) + + .addTagAddress("DoesNotExists", DOES_NOT_EXIST_IDENTIFIER_READ_WRITE, "11"); + + PlcWriteRequest request = builder.build(); + PlcWriteResponse response = request.execute().get(); + + List.of( + "Bool", + "Byte", + "Double", + "Float", + "Int16", + "Int32", + "Int64", + "Integer", + "SByte", + "String", + "UInt16", + "UInt32", + "UInt64", + "UInteger", + "BooleanArray", + "ByteArray", + "DoubleArray", + "FloatArray", + "Int16Array", + "Int32Array", + "Int64Array", + "IntegerArray", + "SByteArray", + "StringArray", + "UInt16Array", + "UInt32Array", + "UInt64Array" + ).forEach(s -> { + assertThat(response.getResponseCode(s)).withFailMessage(s + "is not ok").isEqualTo(PlcResponseCode.OK); + }); + assertThat(response.getResponseCode("DoesNotExists")).isEqualTo(PlcResponseCode.OK); + opcuaConnection.close(); assert !opcuaConnection.isConnected(); - } catch (Exception e) { - fail("Exception during readVariables Test EXCEPTION: " + e.getMessage()); } - } - @Test - public void writeVariables() throws Exception { - PlcConnection opcuaConnection = new DefaultPlcDriverManager().getConnection(tcpConnectionAddress); - Condition is_connected = new Condition<>(PlcConnection::isConnected, "is connected"); - assertThat(opcuaConnection).is(is_connected); - - PlcWriteRequest.Builder builder = opcuaConnection.writeRequestBuilder(); - builder.addTagAddress("Bool", BOOL_IDENTIFIER_READ_WRITE, true); - builder.addTagAddress("Byte", BYTE_IDENTIFIER_READ_WRITE + ";BYTE", (short) 3); - builder.addTagAddress("Double", DOUBLE_IDENTIFIER_READ_WRITE, 0.5d); - builder.addTagAddress("Float", FLOAT_IDENTIFIER_READ_WRITE, 0.5f); - //builder.addTagAddress("Int16", INT16_IDENTIFIER_READ_WRITE + "", (short) 1); - builder.addTagAddress("Int32", INT32_IDENTIFIER_READ_WRITE, 42); - builder.addTagAddress("Int64", INT64_IDENTIFIER_READ_WRITE, 42L); - builder.addTagAddress("Integer", INTEGER_IDENTIFIER_READ_WRITE, 42); - builder.addTagAddress("SByte", SBYTE_IDENTIFIER_READ_WRITE + ";SINT", -127); - builder.addTagAddress("String", STRING_IDENTIFIER_READ_WRITE, "Helllo Toddy!"); - builder.addTagAddress("UInt16", UINT16_IDENTIFIER_READ_WRITE + ";UINT", 65535); - builder.addTagAddress("UInt32", UINT32_IDENTIFIER_READ_WRITE + ";UDINT", 101010101L); - builder.addTagAddress("UInt64", UINT64_IDENTIFIER_READ_WRITE + ";ULINT", new BigInteger("1337")); - builder.addTagAddress("UInteger", UINTEGER_IDENTIFIER_READ_WRITE + ";UDINT", 102020202L); - - - builder.addTagAddress("BooleanArray", BOOL_ARRAY_IDENTIFIER, new Boolean[]{true, true, true, true, true}); - builder.addTagAddress("ByteArray", BYTE_ARRAY_IDENTIFIER + ";BYTE", new Short[]{1, 100, 100, 255, 123}); - builder.addTagAddress("DoubleArray", DOUBLE_ARRAY_IDENTIFIER, new Double[]{1.0, 2.0, 3.0, 4.0, 5.0}); - builder.addTagAddress("FloatArray", FLOAT_ARRAY_IDENTIFIER, new Float[]{1.0F, 2.0F, 3.0F, 4.0F, 5.0F}); - builder.addTagAddress("Int16Array", INT16_ARRAY_IDENTIFIER, new Short[]{1, 2, 3, 4, 5}); - builder.addTagAddress("Int32Array", INT32_ARRAY_IDENTIFIER, new Integer[]{1, 2, 3, 4, 5}); - builder.addTagAddress("Int64Array", INT64_ARRAY_IDENTIFIER, new Long[]{1L, 2L, 3L, 4L, 5L}); - builder.addTagAddress("IntegerArray", INT32_ARRAY_IDENTIFIER, new Integer[]{1, 2, 3, 4, 5}); - builder.addTagAddress("SByteArray", SBYTE_ARRAY_IDENTIFIER, new Byte[]{1, 2, 3, 4, 5}); - builder.addTagAddress("StringArray", STRING_ARRAY_IDENTIFIER, new String[]{"1", "2", "3", "4", "5"}); - builder.addTagAddress("UInt16Array", UINT16_ARRAY_IDENTIFIER + ";UINT", new Short[]{1, 2, 3, 4, 5}); - builder.addTagAddress("UInt32Array", UINT32_ARRAY_IDENTIFIER + ";UDINT", new Integer[]{1, 2, 3, 4, 5}); - builder.addTagAddress("UInt64Array", UINT64_ARRAY_IDENTIFIER + ";ULINT", new Long[]{1L, 2L, 3L, 4L, 5L}); - - builder.addTagAddress("DoesNotExists", DOES_NOT_EXIST_IDENTIFIER_READ_WRITE, "11"); - - PlcWriteRequest request = builder.build(); - PlcWriteResponse response = request.execute().get(); - - assertThat(response.getResponseCode("Bool")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("Byte")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("Double")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("Float")).isEqualTo(PlcResponseCode.OK); - //assertThat(response.getResponseCode("Int16")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("Int32")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("Int64")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("Integer")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("SByte")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("String")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("UInt16")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("UInt32")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("UInt64")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("UInteger")).isEqualTo(PlcResponseCode.OK); - - assertThat(response.getResponseCode("BooleanArray")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("ByteArray")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("DoubleArray")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("FloatArray")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("Int16Array")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("Int32Array")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("Int64Array")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("IntegerArray")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("SByteArray")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("StringArray")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("UInt16Array")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("UInt32Array")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("UInt64Array")).isEqualTo(PlcResponseCode.OK); - - assertThat(response.getResponseCode("DoesNotExists")).isEqualTo(PlcResponseCode.NOT_FOUND); - - opcuaConnection.close(); - assert !opcuaConnection.isConnected(); } + @Test public void testOpcuaAddressPattern() { - assertThat(":tcp://localhost").matches(INET_ADDRESS_PATTERN); assertThat(":tcp://localhost:3131").matches(INET_ADDRESS_PATTERN); assertThat(":tcp://www.google.de").matches(INET_ADDRESS_PATTERN); @@ -367,7 +361,6 @@ public void testOpcuaAddressPattern() { assertThat("opcua:tcp://127.0.0.1?discovery=false").matches(URI_PATTERN); assertThat("opcua:tcp://opcua.demo-this.com:51210/UA/SampleServer?discovery=false").matches(URI_PATTERN); - } /* @@ -488,4 +481,12 @@ Stream testConnectionStringPattern() throws Exception { ); } + static void checkForLinux() { + assumeTrue(() -> { + String OS = System.getProperty("os.name").toLowerCase(); + return !OS.contains("nix") + && !OS.contains("nux") + && !OS.contains("aix"); + }, "somehow opcua doesn't run properly on linux"); + } }