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

clebertsuconic pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git


The following commit(s) were added to refs/heads/main by this push:
     new b8dea0334b ARTEMIS-5164 Adding an additional test to validate scanning 
on duplicates
b8dea0334b is described below

commit b8dea0334b007c7e3abe9a6299a43861ccc63d89
Author: Clebert Suconic <[email protected]>
AuthorDate: Wed Feb 26 10:26:28 2025 -0500

    ARTEMIS-5164 Adding an additional test to validate scanning on duplicates
    
    no issues found in this test. I wrote it to double check the scanning part
    of duplicates for my last commit on LinkedList and I think it
    would be nice to keep the test.
---
 .../artemis/tests/unit/util/LinkedListTest.java    | 28 ++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git 
a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/LinkedListTest.java
 
b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/LinkedListTest.java
index af5a513d3f..1a0a23df33 100644
--- 
a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/LinkedListTest.java
+++ 
b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/LinkedListTest.java
@@ -188,6 +188,34 @@ public class LinkedListTest extends ActiveMQTestBase {
 
    }
 
+   @Test
+   public void testDuplicateScan() {
+      list.addSorted(0);
+      list.addSorted(1);
+      list.addSorted(2);
+      list.addSorted(3);
+
+      try (LinkedListIterator<Integer> listIterator = list.iterator()) {
+         assertEquals(0, listIterator.next().intValue());
+         assertEquals(1, listIterator.next().intValue());
+         assertEquals(2, listIterator.next().intValue());
+         assertEquals(3, listIterator.next().intValue());
+         // removing an element to clear the lastAdded element from the List
+         assertEquals(3, listIterator.removeLastElement().intValue());
+      }
+
+      scans = 0;
+      list.addSorted(1);
+      assertEquals(1, scans, "The test expects a scan to be made");
+
+      try (LinkedListIterator<Integer> listIterator = list.iterator()) {
+         assertEquals(0, listIterator.next().intValue());
+         assertEquals(1, listIterator.next().intValue());
+         assertEquals(1, listIterator.next().intValue());
+         assertEquals(2, listIterator.next().intValue());
+      }
+   }
+
    @Test
    public void randomSorted() {
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact


Reply via email to