• Views
  • Iteration Report
  • My Iteration Report
  •  
OMERO.server
  • Login
  • Help/Guide
  • About Trac
  • Preferences
  • Wiki
  • Timeline
  • Roadmap
  • Browse Source
  • View Tickets
  • Search

Context Navigation

  • ← Previous Changeset
  • Next Changeset →

Changeset 2386

Show
Ignore:
Timestamp:
05/20/08 14:33:20 (6 months ago)
Author:
jmoore
Message:

ticket:897 and ticket:975 Adding test for search bugs, cleanup

Location:
trunk/components/server
Files:
2 modified

  • src/ome/services/search/SearchAction.java (modified) (1 diff)
  • test/ome/server/itests/search/SearchTest.java (modified) (3 diffs)

Legend:

Unmodified
Added
Removed
  • trunk/components/server/src/ome/services/search/SearchAction.java

    r2109 r2386  
    467467        } 
    468468 
    469         /** replace leading and trailing apostrophes* */ 
     469        // 
     470        // If begins and ends with a quote, 
     471        // then replace leading and trailing apostrophes, 
     472        // otherwise return 
     473        // 
    470474        String svalue = value.toString(); 
    471  
    472475        if (svalue.charAt(0) == '\'' 
    473476                && svalue.charAt(svalue.length() - 1) == '\'') { 
    474             value = svalue.substring(0, svalue.length() - 1).substring(1); 
    475             /** ***************************************** */ 
    476         } 
    477  
    478         if (!value.equals(typedValue.getValue())) { 
     477            value = svalue.substring(1, svalue.length() - 1); 
    479478            return new TypedValue(typedValue.getType(), value, EntityMode.POJO); 
    480479        } else { 
  • trunk/components/server/test/ome/server/itests/search/SearchTest.java

    r2385 r2386  
    2929import ome.model.core.OriginalFile; 
    3030import ome.model.internal.Details; 
     31import ome.model.internal.Permissions; 
    3132import ome.model.meta.Experimenter; 
    3233import ome.model.meta.ExperimenterGroup; 
    … …  
    16451646 
    16461647    /** 
     1648     * Attempting to make a lone "*" expand in other situations. 
     1649     */ 
     1650    @Test(groups = "ticket:897") 
     1651    public void testWildcardWithTerm() { 
     1652 
     1653        final String query = "* term"; 
     1654 
     1655        Search search = this.factory.createSearchService(); 
     1656        search.onlyType(Image.class); 
     1657        search.setAllowLeadingWildcard(true); 
     1658        search.byFullText(query); 
     1659        // Seems to be ok. 
     1660    } 
     1661 
     1662    /** 
    16471663     * This was a first test for #975 which always passed. 
    16481664     */ 
    … …  
    17041720        search.onlyType(Image.class); 
    17051721        search.bySomeMustNone(new String[] { "an*" }, null, null); 
    1706  
     1722        for (IObject test : search.results()) { 
     1723            assertTrue(test.toString(), test instanceof Image); 
     1724        } 
     1725 
     1726        Class[] klass = new Class[1]; 
     1727        klass[0] = TagAnnotation.class; 
     1728        search.onlyAnnotatedWith(klass); 
     1729        search.onlyType(Image.class); 
     1730        search.bySomeMustNone(new String[] { "an*" }, null, null); 
     1731 
     1732        for (IObject test : search.results()) { 
     1733            assertTrue(test.toString(), test instanceof Image); 
     1734            ids.remove(test.getId()); 
     1735        } 
     1736        assertTrue(ids + " should be empty", ids.size() == 0); 
     1737 
     1738    } 
     1739 
     1740    /** 
     1741     * Checking for a security leak due to this issue. 
     1742     */ 
     1743    @Test(groups = "ticket:975") 
     1744    public void testImagesAndTagsReturnedMultiuser() { 
     1745 
     1746        final List<Long> ids = new ArrayList<Long>(); 
     1747        final IUpdate update = this.factory.getUpdateService(); 
     1748 
     1749        // Save a public image 
     1750        Experimenter user1 = loginNewUser(); 
     1751        Image i = new Image("foo"); 
     1752        i = update.saveAndReturnObject(i); 
     1753        update.indexObject(i); 
     1754        ids.add(i.getId()); 
     1755 
     1756        // Create a private tag on the image 
     1757        Experimenter user2 = loginNewUser(); 
     1758        i = this.factory.getQueryService() 
     1759                .findByQuery( 
     1760                        "select i from Image i " 
     1761                                + "left outer join fetch i.annotationLinks " 
     1762                                + "where i.id = :id", 
     1763                        new Parameters().addId(i.getId())); 
     1764        TagAnnotation tag = new TagAnnotation(); 
     1765        tag.setTextValue("annotation"); 
     1766        tag.getDetails().setPermissions(Permissions.USER_PRIVATE); 
     1767        i.linkAnnotation(tag); 
     1768        i = update.saveAndReturnObject(i); 
     1769        update.indexObject(i); 
     1770 
     1771        // Return to first user and see if it sees the TagAnnotation 
     1772        loginUser(user1.getOmeName()); 
     1773        Search search = this.factory.createSearchService(); 
    17071774        Class[] klass = new Class[1]; 
    17081775        klass[0] = TagAnnotation.class; 

Download in other formats:

  • Unified Diff
  • Zip Archive

Trac Powered

Powered by Trac 0.11
By Edgewall Software.

Visit the Trac open source project at
http://trac.edgewall.org/