gnodet-bot commented on code in PR #27201:
URL: https://github.com/apache/camel/pull/27201#discussion_r4218607362


##########
components/camel-milo/src/test/java/org/apache/camel/component/milo/MonitorItemTest.java:
##########
@@ -16,22 +16,30 @@
  */
 package org.apache.camel.component.milo;
 
+import java.time.Instant;
+import java.time.temporal.ChronoUnit;
+import java.util.List;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.camel.EndpointInject;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;

Review Comment:
   ๐Ÿงน **Unused import:** `org.apache.camel.Processor` is imported but never used 
in this test class. Please remove it.



##########
components/camel-milo/src/test/java/org/apache/camel/component/milo/MonitorItemTest.java:
##########
@@ -16,22 +16,30 @@
  */
 package org.apache.camel.component.milo;
 
+import java.time.Instant;
+import java.time.temporal.ChronoUnit;

Review Comment:
   ๐Ÿงน **Unused imports:** `java.time.Instant` and 
`java.time.temporal.ChronoUnit` are imported but never referenced in the test 
code. Please remove them.



##########
components/camel-milo/src/test/java/org/apache/camel/component/milo/MonitorItemTest.java:
##########
@@ -16,22 +16,30 @@
  */
 package org.apache.camel.component.milo;
 
+import java.time.Instant;
+import java.time.temporal.ChronoUnit;
+import java.util.List;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.camel.EndpointInject;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
 import org.apache.camel.Produce;
 import org.apache.camel.ProducerTemplate;
 import org.apache.camel.RoutesBuilder;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.milo.server.MiloServerComponent;
 import org.apache.camel.component.mock.MockEndpoint;
+import org.eclipse.milo.opcua.stack.core.types.builtin.DataValue;
+import org.jspecify.annotations.NonNull;

Review Comment:
   ๐Ÿงน **Unused import:** `org.jspecify.annotations.NonNull` is imported but 
never used. Please remove it.



##########
components/camel-milo/src/test/java/org/apache/camel/component/milo/MonitorItemTest.java:
##########
@@ -102,23 +196,61 @@ public void testMonitorItem1() throws Exception {
         LOG.info("Server Port: {}", this.getServerPort());
         LOG.info("Client URI resolved: {}", resolve(MILO_CLIENT_ITEM_C1_1));
 
-        // set server values
+        // set server values sent faster than requestedPublishingInterval so 
they must be put to queue
         this.producer1.sendBody("Foo");
         await().pollDelay(time, TimeUnit.MILLISECONDS).untilAsserted(() -> {
         });
         this.producer1.sendBody("Bar");
         await().pollDelay(time, TimeUnit.MILLISECONDS).untilAsserted(() -> {
         });
+        // This update will only be caught on MILO_CLIENT_ITEM_C1_2 because of 
dataChangeFilterTrigger=StatusValueTimestamp
+        this.producer1.sendBody("Bar");
+        await().pollDelay(time, TimeUnit.MILLISECONDS).untilAsserted(() -> {
+        });
         this.producer1.sendBody("Baz");
         await().pollDelay(time, TimeUnit.MILLISECONDS).untilAsserted(() -> {
         });
 
+        // now wait for requestedPublishingInterval so we are sure the 3 
values are passed
+        await().pollDelay(10 * time, TimeUnit.MILLISECONDS).untilAsserted(() 
-> {
+        });
+        for (int i = 1; i <= 15; i++) {
+            this.producer1.sendBody("Message " + i);
+            await().pollDelay(time, TimeUnit.MILLISECONDS).untilAsserted(() -> 
{
+            });
+        }
+        this.producer1.sendBody("Done");
+
         // tests
         testBody(this.test1Endpoint.message(0), assertGoodValue("Foo"));
         testBody(this.test1Endpoint.message(1), assertGoodValue("Bar"));
         testBody(this.test1Endpoint.message(2), assertGoodValue("Baz"));
 
+        testBody(this.test2Endpoint.message(0), assertGoodValue("Foo"));
+        testBody(this.test2Endpoint.message(1), assertGoodValue("Bar"));
+        // this client should get the extra message without value change
+        testBody(this.test2Endpoint.message(2), assertGoodValue("Bar"));
+        testBody(this.test2Endpoint.message(3), assertGoodValue("Baz"));
+
         // assert
         MockEndpoint.assertIsSatisfied(context, timeout, 
TimeUnit.MILLISECONDS);
+
+        // The number of messages must be less than the number sent, because 
from the 15 messages sent at last part,
+        // about 10 should be in one requestedPublishingInterval, everything 
over 4 should be dropped
+        int count1 = this.test1Endpoint.getReceivedCounter();
+        assertTrue(count1 < 18, "No messages have been dropped, but should 
because of queueSize");
+
+        // get the last exchange, this must be the last one, if messages are 
dropped it must be some it between
+        List<Exchange> receivedExchanges = 
this.test1Endpoint.getReceivedExchanges();
+        Exchange last = receivedExchanges.get(receivedExchanges.size() - 1);
+        assertGoodValue("Done").accept((DataValue) last.getIn().getBody());
+
+        // The third client should get no more than 6 messages
+        int count3 = this.test3Endpoint.getReceivedCounter();
+        assertTrue(count3 <= 6, "Not enough messages have been dropped, but 
should because of queueSize");
+
+        // The fourth client should get no more than 14 messages, because it 
is very sensible on the timing we allow 1 more

Review Comment:
   ๐Ÿ“ **Typo:** `sensible` โ†’ `sensitive`. The word *sensible* means "reasonable" 
in English, whereas *sensitive* means "responsive to".
   
   ```suggestion
           // The fourth client should get no more than 14 messages, because it 
is very sensitive on the timing we allow 1 more
   ```



-- 
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