Scott,
in your LargeSelectTest.testForPaginationCycle you don't
test record contents!

Try to retrieve author_id from first record in first page and
compare it against author_id from first record in another page.

In other words, add to LargeSelectTest.testForPaginationCycle
these two lines:

// Page 1
        int firstId = ((Author)(results.get(0))).getAuthorId().intValue();
// added line 1
....

// Page 5
        assertTrue("first record contents",
  // added line 2
                   ((Author)(results.get(0))).getAuthorId().intValue()
                   != firstId);
.....

The last assert will fail, because result returned from every page are the
same,
(pagination cycling).
If memoryPageLimit > 1 cycling is present, but less evident.

Roberto Resoli
>-- Messaggio Originale --
>Reply-To: "Turbine Torque Developers List" <[EMAIL PROTECTED]>
>Date: Mon, 14 Oct 2002 12:48:41 +1000
>Subject: Re: LargeSelect bug?
>From: Scott Eade <[EMAIL PROTECTED]>
>To: Turbine Torque Developers List <[EMAIL PROTECTED]>
>
>
>I need to be able to build a junit test case that reproduces the problem
>behaviour.  Attached is a patch to LargeSelectTest that would seem to
>indicate that there is no problem.  Can you please give me some further
>direction as to how to reproduce the problem.
>
>Thanks,
>
>Scott
>--
>Scott Eade
>Backstage Technologies Pty. Ltd.
>http://www.backstagetech.com.au
>
>> From: [EMAIL PROTECTED]
>>
>> Hi Scott,
>>
>> Voil� the Test Case (it's a stripped-down version of
>> my test class...)
>>
>>
>> /**
>> * Created on 12-set-2002
>> * $Id$
>> *
>> * To change this generated comment edit the template variable "filecomment":
>> * Window>Preferences>Java>Templates.
>> */
>> package it.trento.trytorque;
>>
>> /**
>> * @author $Author$
>> * @version $Revision$ $Date$
>> *
>> */
>> import java.io.InputStreamReader;
>> import java.util.*;
>>
>>
>> import org.apache.torque.Torque;
>>
>> import org.apache.torque.util.BasePeer;
>> import org.apache.torque.util.Criteria;
>> import org.apache.torque.util.LargeSelect;
>> import com.workingdogs.village.Record;
>>
>>
>> //My om, you can put here your own ...
>> import it.trento.comune.anagrafe.om.*;
>>
>> public class Prova {
>> public static void main(String[] args) {
>>   try {
>>     /*
>>      * Initializing Torque
>>      */
>>     Torque.init("Torque.properties");
>>
>>     LargeSelect ls = null;
>>
>>     Criteria c = new Criteria();
>>
>>     //Retrieving only 2  columns  ...
>>
>>     c.addSelectColumn(CITIZENPeer.CITIZEN_MATR);
>>     c.addSelectColumn(CITIZENPeer.CITIZEN_NAME);
>>
>>     ls =
>>       new LargeSelect(
>>         c,
>>         10,
>>         1); //memoryLimit == pageSize
>>
>>
>>     //Doesn't works!!!
>>     //ls.setMemoryPageLimit(1);
>>
>>
>>     java.io.BufferedReader br =
>>       new java.io.BufferedReader(new InputStreamReader(System.in));
>>
>>     int nPage = 0;
>>     String cmd = null;
>>     boolean isEnd = false;
>>
>>     while (!isEnd) {
>>       System.out.println("<- p previous |e : end| n -> next ");
>>       cmd = br.readLine();
>>
>>       if (cmd.equals("n")) {
>>         if (ls.getNextResultsAvailable()) {
>>           nPage++;
>>           System.out.println(
>>             "=============\tPAGE " + nPage + "\t===============");
>>
>>           printPage(ls.getNextResults(), ls.getFirstRecordNoForPage());
>>         }
>>       }
>>
>>       else
>>         if (cmd.equals("p")) {
>>           if (ls.getPreviousResultsAvailable()) {
>>             nPage--;
>>             System.out.println(
>>               "=============\tPAGE " + nPage + "\t===============");
>>             printPage(ls.getPreviousResults(), ls.getFirstRecordNoForPage());
>>           }
>>         }
>>
>>
>>       isEnd = (cmd.equals("e"));
>>     }
>>
>>   }
>>   catch (Exception e) {
>>     e.printStackTrace();
>>   }
>> }
>>
>>
>> private static void printPage(List recordList, int n) throws Exception
>> {
>>   Iterator i = recordList.iterator();
>>   while (i.hasNext()) {
>>
>>     Object obj = i.next();
>>     if (obj instanceof Record){
>>         System.out.println(
>>           n++
>>             + ") "
>>             + ((Record) obj).getValue("CITIZEN_MATR")
>>             + " "
>>             + ((Record) obj).getValue("CITIZEN_NAME"));
>>
>>     }
>>     System.out.println();
>> }
>>
>> }
>>
>>> -- Messaggio Originale --
>>> Reply-To: "Turbine Torque Developers List"
>>> <[EMAIL PROTECTED]>
>>> Date: Mon, 07 Oct 2002 19:30:22 +1000
>>> Subject: Re: LargeSelect bug?
>>> From: Scott Eade <[EMAIL PROTECTED]>
>>> To: Turbine Torque Developers List <[EMAIL PROTECTED]>
>>>
>>>
>>>> From: [EMAIL PROTECTED]
>>>>
>>>> I think there is a bug in class LargeSelect.
>>>> result set pagination cycles into the first memoryLimit block.
>>>> This is evident choosing memoryPageLimit=1 in LargeSelect constructor;
>>>> (by the way, method setMemoryPageLimit() does not works); in this
>>>> case, the page returned is alway the first.
>>>> In mehod getResults(int start, int size), fromIndex and toIndex
>>>> variables indicates results List portion to return as a page.
>>>> fromIndex is set to:
>>>> fromIndex = start - blockBegin; when block size is equal to
>>>> page size (memoryLimit == pageSize), fromIndex is always 0.
>>>> The page is always the same.
>>>> This would be correct if results List wolud contain ONLY block
>>>> results, but this is not true; results List contains all query
>>>> results, including current block.
>>>
>>> I will look into these when I get a free moment.  It would help greatly
>if
>>> you could provide some additional test cases that illustrate the problems
>and
>>> raise a defect issue in Scarab.
>>>
>>> Cheers,
>>>
>>> Scott
>>> --
>>> Scott Eade
>>> Backstage Technologies Pty. Ltd.
>>> http://www.backstagetech.com.au
>
>
>Allegato: LargeSelectTest-diff.txt
>
>--
>To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
>For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>


__________________________________________________________________
Nuova Tiscali ADSL da 12,95 euro al mese.
Abbonati subito, entro il 31 ottobre l'attivazione e i consumi sono Gratis!

http://point.tiscali.it/ADSL/




--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to