[hornetq-commits] JBoss hornetq SVN: r12223 - branches/Branch_2_2_AS7/tests/src/org/hornetq/tests/unit/util.
do-not-reply at jboss.org
do-not-reply at jboss.org
Thu Mar 1 11:04:10 EST 2012
Author: clebert.suconic
Date: 2012-03-01 11:04:10 -0500 (Thu, 01 Mar 2012)
New Revision: 12223
Modified:
branches/Branch_2_2_AS7/tests/src/org/hornetq/tests/unit/util/LinkedListTest.java
Log:
Adding unit-test on JBPAPP-8282
Modified: branches/Branch_2_2_AS7/tests/src/org/hornetq/tests/unit/util/LinkedListTest.java
===================================================================
--- branches/Branch_2_2_AS7/tests/src/org/hornetq/tests/unit/util/LinkedListTest.java 2012-03-01 15:22:53 UTC (rev 12222)
+++ branches/Branch_2_2_AS7/tests/src/org/hornetq/tests/unit/util/LinkedListTest.java 2012-03-01 16:04:10 UTC (rev 12223)
@@ -110,6 +110,76 @@
}
+ public void testAddHeadAndRemove()
+ {
+ final AtomicInteger count = new AtomicInteger(0);
+ class MyObject
+ {
+
+ public int payload;
+
+ MyObject(int payloadcount)
+ {
+ count.incrementAndGet();
+ this.payload = payloadcount;
+ }
+
+ protected void finalize() throws Exception
+ {
+ count.decrementAndGet();
+ }
+
+ public String toString()
+ {
+ return "" + payload;
+ }
+ };
+
+ LinkedListImpl<MyObject> objs = new LinkedListImpl<MyObject>();
+
+ // Initial add
+ for (int i = 1000; i >= 0; i--)
+ {
+ objs.addHead(new MyObject(i));
+ }
+ assertCount(1001, count);
+
+ LinkedListIterator<MyObject> iter = objs.iterator();
+
+ int countLoop = 0;
+ for (countLoop = 0 ; countLoop <= 1000; countLoop++)
+ {
+ MyObject obj = iter.next();
+ assertEquals(countLoop, obj.payload);
+ if (countLoop == 500 || countLoop == 1000)
+ {
+ iter.remove();
+ }
+ }
+
+ iter.close();
+
+ iter = objs.iterator();
+
+ countLoop = 0;
+ while (iter.hasNext())
+ {
+ if (countLoop == 500 || countLoop == 1000)
+ {
+ System.out.println("Jumping " + countLoop);
+ countLoop++;
+ }
+ MyObject obj = iter.next();
+ assertEquals(countLoop, obj.payload);
+ countLoop++;
+ }
+
+
+
+ assertCount(999, count);
+
+ }
+
/**
* @param count
*/
More information about the hornetq-commits
mailing list