This is an automated email from the ASF dual-hosted git repository.

hutcheb pushed a commit to branch fix/PLC4X-303
in repository https://gitbox.apache.org/repos/asf/plc4x.git


The following commit(s) were added to refs/heads/fix/PLC4X-303 by this push:
     new 7a88e51  Cleaned up xml test suite for opcua
7a88e51 is described below

commit 7a88e51ebef3903f860ce2088ccc113cd5079abe
Author: hutcheb <[email protected]>
AuthorDate: Wed Nov 10 04:45:17 2021 +1000

    Cleaned up xml test suite for opcua
    
    Improved error handling when resolving hostname
---
 .../plc4x/java/opcua/context/SecureChannel.java    |  6 +--
 .../java/opcua/protocol/OpcuaProtocolLogic.java    |  2 +-
 protocols/opcua/src/main/xslt/opc-manual.xsl       | 10 ++--
 .../resources/protocols/opcua/DriverTestsuite.xml  | 62 ++--------------------
 4 files changed, 14 insertions(+), 66 deletions(-)

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 6e58b3a..bb35c90 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
@@ -174,7 +174,8 @@ public class SecureChannel {
             this.endpoints.add(address.getHostName());
             this.endpoints.add(address.getCanonicalHostName());
         } catch (UnknownHostException e) {
-            e.printStackTrace();
+            LOGGER.warn("Unable to resolve host name. Using original host from 
connection string which may cause issues connecting to server");
+            this.endpoints.add(this.configuration.getHost());
         }
     }
 
@@ -261,14 +262,13 @@ public class SecureChannel {
             DEFAULT_MAX_MESSAGE_SIZE,
             DEFAULT_MAX_CHUNK_COUNT,
             this.endpoint);
-        System.out.print(hello.toString());
+
         Consumer<Integer> requestConsumer = t -> {
             context.sendRequest(new OpcuaAPU(hello))
                 .expectResponse(OpcuaAPU.class, REQUEST_TIMEOUT)
                 .check(p -> p.getMessage() instanceof OpcuaAcknowledgeResponse)
                 .unwrap(p -> (OpcuaAcknowledgeResponse) p.getMessage())
                 .handle(opcuaAcknowledgeResponse -> {
-                    System.out.print(opcuaAcknowledgeResponse.toString());
                     sendBufferSize = 
Math.min(opcuaAcknowledgeResponse.getReceiveBufferSize(), 
DEFAULT_SEND_BUFFER_SIZE);
                     maxMessageSize = 
Math.min(opcuaAcknowledgeResponse.getMaxMessageSize(), 
DEFAULT_MAX_MESSAGE_SIZE);
                     onConnectOpenSecureChannel(context, 
opcuaAcknowledgeResponse);
diff --git 
a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/protocol/OpcuaProtocolLogic.java
 
b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/protocol/OpcuaProtocolLogic.java
index e7c2d78..ae07434 100644
--- 
a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/protocol/OpcuaProtocolLogic.java
+++ 
b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/protocol/OpcuaProtocolLogic.java
@@ -425,7 +425,7 @@ public class OpcuaProtocolLogic extends 
Plc4xProtocolBase<OpcuaAPU> implements H
                     ByteStringArray[] array = ((VariantByteString) 
variant).getValue();
                     for (int k = 0; k < array.length; k++) {
                         int length = array[k].getValue().length;
-                        Short[] tmpValue = new Short[length];
+                        Byte[] tmpValue = new Byte[length];
                         for (int i = 0; i < length; i++) {
                             tmpValue[i] = array[k].getValue()[i];
                         }
diff --git a/protocols/opcua/src/main/xslt/opc-manual.xsl 
b/protocols/opcua/src/main/xslt/opc-manual.xsl
index c2e6957..eaff6f2 100644
--- a/protocols/opcua/src/main/xslt/opc-manual.xsl
+++ b/protocols/opcua/src/main/xslt/opc-manual.xsl
@@ -90,7 +90,7 @@
             [simple          PascalByteString   
'receiverCertificateThumbprint']
             [simple          int 32             'sequenceNumber']
             [simple          int 32             'requestId']
-            [array           int 8              'message' count 'messageSize - 
(endpoint.stringLength == -1 ? 0 : endpoint.stringLength ) - 
(senderCertificate.stringLength == -1 ? 0 : senderCertificate.stringLength) - 
(receiverCertificateThumbprint.stringLength == -1 ? 0 : 
receiverCertificateThumbprint.stringLength) - 32']
+            [array           byte               'message' count 'messageSize - 
(endpoint.stringLength == -1 ? 0 : endpoint.stringLength ) - 
(senderCertificate.stringLength == -1 ? 0 : senderCertificate.stringLength) - 
(receiverCertificateThumbprint.stringLength == -1 ? 0 : 
receiverCertificateThumbprint.stringLength) - 32']
        ]
        ['OPN','true'     OpcuaOpenResponse
            [simple          string '8'         'chunk']
@@ -101,7 +101,7 @@
            [simple          PascalByteString   'receiverCertificateThumbprint']
            [simple          int 32             'sequenceNumber']
            [simple          int 32             'requestId']
-           [array           int 8              'message' count 'messageSize - 
(securityPolicyUri.stringLength == -1 ? 0 : securityPolicyUri.stringLength) - 
(senderCertificate.stringLength == -1 ? 0 : senderCertificate.stringLength) - 
(receiverCertificateThumbprint.stringLength == -1 ? 0 : 
receiverCertificateThumbprint.stringLength) - 32']
+           [array           byte               'message' count 'messageSize - 
(securityPolicyUri.stringLength == -1 ? 0 : securityPolicyUri.stringLength) - 
(senderCertificate.stringLength == -1 ? 0 : senderCertificate.stringLength) - 
(receiverCertificateThumbprint.stringLength == -1 ? 0 : 
receiverCertificateThumbprint.stringLength) - 32']
        ]
        ['CLO','false'     OpcuaCloseRequest
            [simple          string '8'         'chunk']
@@ -119,7 +119,7 @@
            [simple          int 32             'secureTokenId']
            [simple          int 32             'sequenceNumber']
            [simple          int 32             'requestId']
-           [array           int 8              'message' count 'messageSize - 
24']
+           [array           byte               'message' count 'messageSize - 
24']
        ]
        ['MSG','true'     OpcuaMessageResponse
            [simple          string '8'         'chunk']
@@ -128,14 +128,14 @@
            [simple          int 32             'secureTokenId']
            [simple          int 32             'sequenceNumber']
            [simple          int 32             'requestId']
-           [array           int 8              'message' count 'messageSize - 
24']
+           [array           byte               'message' count 'messageSize - 
24']
        ]
     ]
 ]
 
 [type 'ByteStringArray'
     [simple int 32 'arrayLength']
-    [array uint 8 'value' count 'arrayLength']
+    [array byte 'value' count 'arrayLength']
 ]
 
 [type 'GuidValue'
diff --git 
a/protocols/opcua/src/test/resources/protocols/opcua/DriverTestsuite.xml 
b/protocols/opcua/src/test/resources/protocols/opcua/DriverTestsuite.xml
index d26d59d..d3149ac 100644
--- a/protocols/opcua/src/test/resources/protocols/opcua/DriverTestsuite.xml
+++ b/protocols/opcua/src/test/resources/protocols/opcua/DriverTestsuite.xml
@@ -26,7 +26,6 @@
 
   <protocolName>opcua</protocolName>
   <outputFlavor>read-write</outputFlavor>
-
   <driver-name>opcua</driver-name>
 
   <testcase>
@@ -55,7 +54,8 @@
           </OpcuaHelloRequest>
         </MessagePDU>
       </outgoing-plc-message>
-      <incoming-plc-message name="Receive Modbus Input-Register Read Response">
+
+      <incoming-plc-message name="Receive Acknowledgement Response">
         <parser-arguments>
           <response>true</response>
         </parser-arguments>
@@ -72,6 +72,7 @@
           </OpcuaAcknowledgeResponse>
         </MessagePDU>
       </incoming-plc-message>
+<!--
       <outgoing-plc-message name="Send Opcua Open Request">
         <parser-arguments>
           <response>false</response>
@@ -104,64 +105,11 @@
             </receiverCertificateThumbprint>
             <sequenceNumber dataType="int" bitLength="32">1</sequenceNumber>
             <requestId dataType="int" bitLength="32">1</requestId>
-            <message isList="true">
-              <value dataType="int" bitLength="8">1</value>
-              <value dataType="int" bitLength="8">0</value>
-              <value dataType="int" bitLength="8">-66</value>
-              <value dataType="int" bitLength="8">1</value>
-              <value dataType="int" bitLength="8">0</value>
-              <value dataType="int" bitLength="8">0</value>
-              <value dataType="int" bitLength="8">0</value>
-              <value dataType="int" bitLength="8">13</value>
-              <value dataType="int" bitLength="8">-12</value>
-              <value dataType="int" bitLength="8">3</value>
-              <value dataType="int" bitLength="8">-44</value>
-              <value dataType="int" bitLength="8">-44</value>
-              <value dataType="int" bitLength="8">-41</value>
-              <value dataType="int" bitLength="8">1</value>
-              <value dataType="int" bitLength="8">0</value>
-              <value dataType="int" bitLength="8">0</value>
-              <value dataType="int" bitLength="8">0</value>
-              <value dataType="int" bitLength="8">0</value>
-              <value dataType="int" bitLength="8">0</value>
-              <value dataType="int" bitLength="8">0</value>
-              <value dataType="int" bitLength="8">0</value>
-              <value dataType="int" bitLength="8">0</value>
-              <value dataType="int" bitLength="8">-1</value>
-              <value dataType="int" bitLength="8">-1</value>
-              <value dataType="int" bitLength="8">-1</value>
-              <value dataType="int" bitLength="8">-1</value>
-              <value dataType="int" bitLength="8">16</value>
-              <value dataType="int" bitLength="8">39</value>
-              <value dataType="int" bitLength="8">0</value>
-              <value dataType="int" bitLength="8">0</value>
-              <value dataType="int" bitLength="8">0</value>
-              <value dataType="int" bitLength="8">0</value>
-              <value dataType="int" bitLength="8">0</value>
-              <value dataType="int" bitLength="8">0</value>
-              <value dataType="int" bitLength="8">0</value>
-              <value dataType="int" bitLength="8">0</value>
-              <value dataType="int" bitLength="8">0</value>
-              <value dataType="int" bitLength="8">0</value>
-              <value dataType="int" bitLength="8">0</value>
-              <value dataType="int" bitLength="8">0</value>
-              <value dataType="int" bitLength="8">0</value>
-              <value dataType="int" bitLength="8">1</value>
-              <value dataType="int" bitLength="8">0</value>
-              <value dataType="int" bitLength="8">0</value>
-              <value dataType="int" bitLength="8">0</value>
-              <value dataType="int" bitLength="8">-1</value>
-              <value dataType="int" bitLength="8">-1</value>
-              <value dataType="int" bitLength="8">-1</value>
-              <value dataType="int" bitLength="8">-1</value>
-              <value dataType="int" bitLength="8">0</value>
-              <value dataType="int" bitLength="8">81</value>
-              <value dataType="int" bitLength="8">37</value>
-              <value dataType="int" bitLength="8">2</value>
-            </message>
+            <message dataType="byte" 
bitLength="424">0x0100be010000f068ddb096d5d7010000000000000000ffffffff10270000000000000000000000000001000000ffffffff00512502</message>
           </OpcuaOpenRequest>
         </MessagePDU>
       </outgoing-plc-message>
+-->
     </steps>
   </testcase>
 

Reply via email to