Return-Path: Delivered-To: apmail-commons-issues-archive@locus.apache.org Received: (qmail 17114 invoked from network); 2 Apr 2008 08:36:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 Apr 2008 08:36:53 -0000 Received: (qmail 33967 invoked by uid 500); 2 Apr 2008 08:36:51 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 33908 invoked by uid 500); 2 Apr 2008 08:36:51 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 33899 invoked by uid 99); 2 Apr 2008 08:36:51 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Apr 2008 01:36:51 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Apr 2008 08:36:18 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 01AA1234C0B6 for ; Wed, 2 Apr 2008 01:34:25 -0700 (PDT) Message-ID: <1811112399.1207125265005.JavaMail.jira@brutus> Date: Wed, 2 Apr 2008 01:34:25 -0700 (PDT) From: "Frank Hefter (JIRA)" To: issues@commons.apache.org Subject: [jira] Commented: (COLLECTIONS-246) LoopingListIterator behaves unexpected on next and previous mixed MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/COLLECTIONS-246?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12584459#action_12584459 ] Frank Hefter commented on COLLECTIONS-246: ------------------------------------------ For my opinion this test case is to simple and can't be compared with the more complex swap over at the beginning and the end of this LoopingList (thats the error I ment btw. !). You simply take a java.util.Iterator test. But this ignores the abilities of this class comletely. Again, please give me test cases that are better than mine. Also your test works with this fix, too. So it is an iterator? Right? Just for the case: I don't care about the implementation. Just my tests have to apply. So we can focus on the tests and make them more complexe. Is there a LoopIterator pattern somewhere? If not: Let's create it ! > LoopingListIterator behaves unexpected on next and previous mixed > ----------------------------------------------------------------- > > Key: COLLECTIONS-246 > URL: https://issues.apache.org/jira/browse/COLLECTIONS-246 > Project: Commons Collections > Issue Type: Bug > Components: Iterator > Affects Versions: 3.2 > Environment: JDK 1.4.2_12 > Common Collections 3.2 > Reporter: Frank Hefter > Priority: Blocker > Fix For: 3.3 > > Attachments: LoopingListIterator.java, LoopingListIterator.java, LoopingListIteratorTest.java > > > Using ArrayList as the backing list. > This combination at least returns unexpected results as you can see in the testcase below. > I used this for a list navigator in a web frontend and had trouble with users. > I suspect java.util.AbstrList$ListItr (role of "cursor" var seems to be wrong implemented ) to cause this problem. If so maybe we have to implement it in a different way. > Testcase (it runs without hassle but the comments show whats wrong): > ------------------------------------------- > import java.util.ArrayList; > import junit.framework.TestCase; > import org.apache.commons.collections.iterators.LoopingListIterator; > public class SelectionControllerTest extends TestCase { > public void testSelectorForApache() { > ArrayList al = new ArrayList(); > al.add("0"); al.add("1"); al.add("2"); > LoopingListIterator it = new LoopingListIterator(al); > assertEquals("0", it.next()); // This is OK > // here I am on "0" > assertEquals("0", it.previous()); // Wrong ! This should be 2! > // here I am on "0" too! This is wrong. > assertEquals("2", it.previous()); > assertEquals("1", it.previous()); > assertEquals("0", it.previous()); > assertEquals("2", it.previous()); > // here I am on "2" > assertEquals("2", it.next()); // Wrong ! This should be 0! > // here I am on "2" too! This is wrong. > assertEquals("0", it.next()); > assertEquals("1", it.next()); > // here I am on "1" > assertEquals("1", it.previous()); // Wrong ! This should be 0! > } > } > ------------------------------------------- > Thanks for your help. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.