[infinispan-issues] [JBoss JIRA] (ISPN-2821) Correct Query Sort tests

Adrian Nistor (JIRA) jira-events at lists.jboss.org
Mon Feb 18 04:51:57 EST 2013


     [ https://issues.jboss.org/browse/ISPN-2821?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Adrian Nistor updated ISPN-2821:
--------------------------------



Integrated. Thanks!
                
> Correct Query Sort tests
> ------------------------
>
>                 Key: ISPN-2821
>                 URL: https://issues.jboss.org/browse/ISPN-2821
>             Project: Infinispan
>          Issue Type: Task
>          Components: Querying
>            Reporter: Anna Manukyan
>            Assignee: Sanne Grinovero
>            Priority: Minor
>             Fix For: 5.3.0.Alpha1
>
>         Attachments: LocalCacheTest.java
>
>
> While test development for the Query module, I've noticed some strange behaviour, which I couldn't explain anyhow. 
> The case is the following:
> 3 new objects type of Person are created and put to the cache. The age parameter is set for all these objects. 
> Then the age is changed for them (set to other values), and query is run using sort by age. 
> The thing is that even though the sort is descending by default for integers, but the returned result list is sorted in ascending order. 
> The code is:
> {code}
>       Person person2 = new Person();
>       person2.setAge(30);
>       //some other setters
>       Person person3 = new Person();
>       person3.setAge(25);
>       // some other setters
>       cache.put("key1", person2);
>       cache.put("key2", person3);
>       person2.setAge(35);
>       person3.setAge(12);
>       Sort sort = new Sort( new SortField("age", SortField.STRING)); //<--- The same happens for SortField.INT
>       queryParser = createQueryParser("name");
>       Query luceneQuery = queryParser.parse("Goat");
>       CacheQuery cacheQuery = Search.getSearchManager(cache).getQuery(luceneQuery);
>       cacheQuery.sort(sort);
>       List<Object> found = cacheQuery.list();
>       assert found.size() == 2;
>       assert found.get(0).equals(person2);   //<------ The first element should be the one with higher age, but in reality in the first place it is person3
>       assert found.get(1).equals(person3);
> {code}
> By the way, if initially you'll set the values in other order, then the test passes - the sorting works fine. 
> {code}
>       Person person2 = new Person();
>       person2.setAge(25);
>       //some other setters
>       Person person3 = new Person();
>       person3.setAge(30);
>       // some other setters
>      //............ the rest of the code
> {code}
> You can find attached the test file itself.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the infinispan-issues mailing list