davsclaus commented on code in PR #28212:
URL: https://github.com/apache/camel/pull/28212#discussion_r4333716382


##########
components/camel-milo/src/test/java/org/apache/camel/component/milo/CommunicationLossTest.java:
##########
@@ -195,6 +198,62 @@ void lostSessionReportsTheNodeAndResendsItsValue() throws 
Exception {
         }
     }
 
+    @Test
+    void refusedNodeIsCreatedOnceTheSessionIsActiveAgain() throws Exception {
+        producer1.sendBody("Foo");
+
+        item1Endpoint.expectedMessageCount(1);
+        testBody(item1Endpoint.message(0), assertGoodValue("Foo"));
+        context.getRouteController().startRoute("item1");
+        item1Endpoint.assertIsSatisfied();
+
+        unknownEndpoint.expectedMessageCount(1);
+        testBody(unknownEndpoint.message(0),
+                value -> assertEquals(StatusCodes.Bad_NodeIdUnknown, 
value.getStatusCode().getValue()));
+        context.getRouteController().startRoute("unknown");
+        unknownEndpoint.assertIsSatisfied();
+
+        final MiloClientEndpoint endpoint = context.getEndpoint(
+                resolve(MILO_CLIENT_ITEM_1).replace("@@relay@@", 
Integer.toString(relayPort.getPort())),
+                MiloClientEndpoint.class);
+        final MiloClientConnection connection = endpoint.createConnection();
+        try {
+            final OpcUaClient client = connection.getOpcUaClient();
+            final NodeId sessionId = client.getSession().getSessionId();
+
+            // the refused node is not reported, and delivers its value once 
it is created after the session is back
+            unknownEndpoint.reset();
+            unknownEndpoint.expectedMessageCount(1);
+            unknownEndpoint.setResultWaitTime(60_000);
+            unknownEndpoint.setAssertPeriod(2_000);
+            testBody(unknownEndpoint.message(0), assertGoodValue("Baz"));
+            item1Endpoint.reset();
+            item1Endpoint.expectedMessageCount(2);
+            item1Endpoint.setResultWaitTime(60_000);
+            item1Endpoint.setAssertPeriod(2_000);
+            testBody(item1Endpoint.message(0), assertNoCommunication());
+            testBody(item1Endpoint.message(1), assertGoodValue("Foo"));
+
+            // the server stays unreachable for longer than the retry interval 
of the refused node
+            relay.stop();
+            await().atMost(10, TimeUnit.SECONDS).until(() -> 
item1Endpoint.getReceivedCounter() >= 1);
+            await().pollDelay(12, TimeUnit.SECONDS).atMost(13, 
TimeUnit.SECONDS).until(() -> true);

Review Comment:
   **C.** This is effectively a 12 s sleep, which the test guidelines ask us to 
avoid. Waiting with `during` would also check what the comments promise, that 
the refused node is not reported while the server is unreachable:
   
   ```java
   await().during(12, TimeUnit.SECONDS).atMost(13, TimeUnit.SECONDS).until(() 
-> unknownEndpoint.getReceivedCounter() == 0);
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to