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

sruehl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git


The following commit(s) were added to refs/heads/develop by this push:
     new 2d343c9bda test(plc4j/opcua): Cleanup testcase 
manySubscriptionsOnSingleConnection (#1160)
2d343c9bda is described below

commit 2d343c9bda6baee0ed6bf493733674d68320e397
Author: Rajmund Takács <[email protected]>
AuthorDate: Wed Oct 18 17:57:09 2023 +0200

    test(plc4j/opcua): Cleanup testcase manySubscriptionsOnSingleConnection 
(#1160)
---
 .../plc4x/java/opcua/OpcuaPlcDriverTest.java       | 26 +++++++++++-----------
 1 file changed, 13 insertions(+), 13 deletions(-)

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 60fd30e248..516f8b01fe 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
@@ -179,6 +179,8 @@ public class OpcuaPlcDriverTest {
         }
         @Test
         public void manySubscriptionsOnSingleConnection() throws Exception {
+            final int numberOfSubscriptions = 25;
+
             PlcDriverManager driverManager = new DefaultPlcDriverManager();
             PlcConnectionManager connectionManager = 
driverManager.getConnectionManager();
 
@@ -186,7 +188,7 @@ public class OpcuaPlcDriverTest {
             ConcurrentLinkedDeque<PlcSubscriptionEvent> events = new 
ConcurrentLinkedDeque<>();
 
             try (PlcConnection connection = 
connectionManager.getConnection(tcpConnectionAddress)) {
-                for (int i = 0; i < 25; i++) {
+                for (int i = 0; i < numberOfSubscriptions; i++) {
                     PlcSubscriptionRequest request = 
connection.subscriptionRequestBuilder()
                             .addChangeOfStateTag("Demo", 
OpcuaTag.of(INTEGER_IDENTIFIER_READ_WRITE))
                             .build();
@@ -199,19 +201,17 @@ public class OpcuaPlcDriverTest {
                     response.getSubscriptionHandles().forEach(handle -> 
handle.register(events::add));
                 }
 
-                CompletableFuture.supplyAsync(() -> {
-                    for (int i = 0; i < 60; i++) {
-                        if (events.size() == 25) {
-                            break;
-                        }
-                        try {
-                            Thread.sleep(1000);
-                        } catch (InterruptedException e) {
-                            throw new RuntimeException(e);
-                        }
+                for (int i = 0; i < 60; i++) {
+                    if (events.size() == numberOfSubscriptions) {
+                        break;
+                    }
+                    try {
+                        Thread.sleep(1000);
+                    } catch (InterruptedException e) {
+                        throw new RuntimeException(e);
                     }
-                    return null;
-                }, newSingleThreadExecutor()).get(60, TimeUnit.SECONDS);
+                }
+                assertThat(events.size()).isEqualTo(numberOfSubscriptions);
 
                 for (PlcSubscriptionResponse response : 
plcSubscriptionResponses) {
                     connection.unsubscriptionRequestBuilder()

Reply via email to