directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1311684 - in /directory/apacheds/branches/index-work/core-integ/src/test/java/org/apache/directory/server/core/operations/search: AliasSearchIT.java SearchIT.java SearchWithIndicesIT.java
Date Tue, 10 Apr 2012 11:39:42 GMT
Author: elecharny
Date: Tue Apr 10 11:39:42 2012
New Revision: 1311684

URL: http://svn.apache.org/viewvc?rev=1311684&view=rev
Log:
Closed cursors and NamingEnumarations

Modified:
    directory/apacheds/branches/index-work/core-integ/src/test/java/org/apache/directory/server/core/operations/search/AliasSearchIT.java
    directory/apacheds/branches/index-work/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchIT.java
    directory/apacheds/branches/index-work/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchWithIndicesIT.java

Modified: directory/apacheds/branches/index-work/core-integ/src/test/java/org/apache/directory/server/core/operations/search/AliasSearchIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/index-work/core-integ/src/test/java/org/apache/directory/server/core/operations/search/AliasSearchIT.java?rev=1311684&r1=1311683&r2=1311684&view=diff
==============================================================================
--- directory/apacheds/branches/index-work/core-integ/src/test/java/org/apache/directory/server/core/operations/search/AliasSearchIT.java
(original)
+++ directory/apacheds/branches/index-work/core-integ/src/test/java/org/apache/directory/server/core/operations/search/AliasSearchIT.java
Tue Apr 10 11:39:42 2012
@@ -450,6 +450,7 @@ public class AliasSearchIT extends Abstr
                 cursor.beforeFirst();
 
                 List<String> nextResults = new ArrayList<String>();
+                
                 while ( nextResults.size() < count && cursor.next() )
                 {
                     nextResults.add( cursor.get().getDn().getName() );
@@ -458,6 +459,7 @@ public class AliasSearchIT extends Abstr
                 cursor.next();
 
                 List<String> prevResults = new ArrayList<String>();
+                
                 while ( cursor.previous() )
                 {
                     prevResults.add( 0, cursor.get().getDn().getName() );
@@ -466,6 +468,8 @@ public class AliasSearchIT extends Abstr
                 assertEquals( nextResults.size(), prevResults.size() );
                 assertEquals( nextResults, prevResults );
             }
+            
+            cursor.close();
         }
         catch ( UnsupportedOperationException e )
         {
@@ -493,6 +497,7 @@ public class AliasSearchIT extends Abstr
                 cursor.afterLast();
 
                 List<String> prevResults = new ArrayList<String>();
+                
                 while ( prevResults.size() < count && cursor.previous() )
                 {
                     prevResults.add( cursor.get().getDn().getName() );
@@ -501,6 +506,7 @@ public class AliasSearchIT extends Abstr
                 cursor.previous();
 
                 List<String> nextResults = new ArrayList<String>();
+                
                 while ( cursor.next() )
                 {
                     nextResults.add( 0, cursor.get().getDn().getName() );
@@ -509,6 +515,8 @@ public class AliasSearchIT extends Abstr
                 assertEquals( nextResults.size(), prevResults.size() );
                 assertEquals( nextResults, prevResults );
             }
+            
+            cursor.close();
         }
         catch ( UnsupportedOperationException e )
         {
@@ -522,6 +530,7 @@ public class AliasSearchIT extends Abstr
     {
         List<String> result = search( base, scope, filter, aliasDerefMode );
         assertEquals( expectedResults.length, result.size() );
+        
         for ( String expected : expectedResults )
         {
             assertTrue( result.contains( expected ) );
@@ -577,6 +586,7 @@ public class AliasSearchIT extends Abstr
         EntryFilteringCursor cursor = getService().getAdminSession().search( new Dn( base
), scope, exprNode,
             aliasDerefMode, null );
         cursor.beforeFirst();
+        
         while ( cursor.next() )
         {
             nextResults.add( cursor.get().getDn().getName() );
@@ -586,6 +596,7 @@ public class AliasSearchIT extends Abstr
         {
             List<String> prevResults = new ArrayList<String>();
             cursor.afterLast();
+            
             while ( cursor.previous() )
             {
                 prevResults.add( 0, cursor.get().getDn().getName() );
@@ -598,6 +609,10 @@ public class AliasSearchIT extends Abstr
         {
             LOG.warn( "Partition doesn't support previous test" );
         }
+        finally
+        {
+            cursor.close();
+        }
 
         return nextResults;
     }

Modified: directory/apacheds/branches/index-work/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/index-work/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchIT.java?rev=1311684&r1=1311683&r2=1311684&view=diff
==============================================================================
--- directory/apacheds/branches/index-work/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchIT.java
(original)
+++ directory/apacheds/branches/index-work/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchIT.java
Tue Apr 10 11:39:42 2012
@@ -303,6 +303,8 @@ public class SearchIT extends AbstractLd
             map.put( result.getName(), result.getAttributes() );
         }
 
+        list.close();
+
         assertEquals( "Expected number of results returned was incorrect!", 9, map.size()
);
         assertTrue( map.containsKey( "ou=testing00,ou=system" ) );
         assertTrue( map.containsKey( "ou=testing01,ou=system" ) );
@@ -328,6 +330,8 @@ public class SearchIT extends AbstractLd
             map.put( result.getName(), result.getAttributes() );
         }
 
+        list.close();
+
         assertEquals( "Expected number of results returned was incorrect", 14, map.size()
);
         assertTrue( map.containsKey( "ou=system" ) );
         assertTrue( map.containsKey( "ou=testing00,ou=system" ) );
@@ -358,6 +362,8 @@ public class SearchIT extends AbstractLd
             map.put( result.getName(), result.getAttributes() );
         }
 
+        list.close();
+
         assertEquals( "Expected number of results returned was incorrect", 1, map.size()
);
         assertTrue( map.containsKey( "ou=testing02,ou=system" ) );
         Attributes attrs = map.get( "ou=testing02,ou=system" );
@@ -383,6 +389,8 @@ public class SearchIT extends AbstractLd
             map.put( result.getName(), result.getAttributes() );
         }
 
+        list.close();
+
         // 16 because it also matches organizationalPerson which the admin is
         assertEquals( "Expected number of results returned was incorrect", 17, map.size()
);
         assertTrue( map.containsKey( "ou=system" ) );
@@ -415,25 +423,37 @@ public class SearchIT extends AbstractLd
         NamingEnumeration<SearchResult> e = sysRoot.search( "", "(bogusAttribute=abc123)",
cons );
         assertNotNull( e );
 
+        e.close();
+        
         e = sysRoot.search( "", "(!(bogusAttribute=abc123))", cons );
         assertNotNull( e );
         assertFalse( e.hasMore() );
 
+        e.close();
+
         e = sysRoot.search( "", "(|(bogusAttribute=abc123)(bogusAttribute=abc123))", cons
);
         assertNotNull( e );
         assertFalse( e.hasMore() );
 
+        e.close();
+
         e = sysRoot.search( "", "(|(bogusAttribute=abc123)(ou=abc123))", cons );
         assertNotNull( e );
         assertFalse( e.hasMore() );
 
+        e.close();
+
         e = sysRoot.search( "", "(OBJECTclass=*)", cons );
         assertNotNull( e );
         assertTrue( e.hasMore() );
 
+        e.close();
+
         e = sysRoot.search( "", "(objectclass=*)", cons );
         assertNotNull( e );
 
+        e.close();
+
         getService().setAllowAnonymousAccess( oldSetAllowAnnonymousAccess );
     }
 
@@ -457,6 +477,8 @@ public class SearchIT extends AbstractLd
             map.put( result.getName(), result.getAttributes() );
         }
 
+        list.close();
+
         assertEquals( "Expected number of results returned was incorrect!", 2, map.size()
);
         assertTrue( map.containsKey( "ou=testing00,ou=system" ) );
         assertTrue( map.containsKey( "ou=testing01,ou=system" ) );
@@ -480,6 +502,8 @@ public class SearchIT extends AbstractLd
             SearchResult result = list.next();
             map.put( result.getName(), result.getAttributes() );
         }
+        
+        list.close();
 
         assertEquals( "size of results", 1, map.size() );
         assertTrue( "contains ou=testing00,ou=system", map.containsKey( "ou=testing00,ou=system"
) );
@@ -504,6 +528,8 @@ public class SearchIT extends AbstractLd
             map.put( result.getName(), result.getAttributes() );
         }
 
+        list.close();
+
         assertEquals( "size of results", 23, map.size() );
         assertTrue( "contains ou=testing00,ou=system", map.containsKey( "ou=testing00,ou=system"
) );
         assertTrue( "contains ou=testing01,ou=system", map.containsKey( "ou=testing01,ou=system"
) );
@@ -543,6 +569,8 @@ public class SearchIT extends AbstractLd
             map.put( result.getName(), result.getAttributes() );
         }
 
+        list.close();
+
         assertEquals( "size of results", 2, map.size() );
         assertTrue( "contains ou=testing00,ou=system", map.containsKey( "ou=testing00,ou=system"
) );
         assertTrue( "contains ou=testing01,ou=system", map.containsKey( "ou=testing01,ou=system"
) );
@@ -567,6 +595,8 @@ public class SearchIT extends AbstractLd
             map.put( result.getName(), result.getAttributes() );
         }
 
+        list.close();
+
         assertEquals( "size of results", 6, map.size() );
         assertTrue( "contains ou=testing00,ou=system", map.containsKey( "ou=testing00,ou=system"
) );
         assertTrue( "contains ou=testing01,ou=system", map.containsKey( "ou=testing01,ou=system"
) );
@@ -600,6 +630,8 @@ public class SearchIT extends AbstractLd
             map.put( result.getName(), result.getAttributes() );
         }
 
+        list.close();
+
         assertEquals( "size of results", 6, map.size() );
         assertTrue( "contains ou=testing00,ou=system", map.containsKey( "ou=testing00,ou=system"
) );
         assertTrue( "contains ou=testing01,ou=system", map.containsKey( "ou=testing01,ou=system"
) );
@@ -630,6 +662,8 @@ public class SearchIT extends AbstractLd
             map.put( result.getName(), result.getAttributes() );
         }
 
+        list.close();
+
         assertEquals( "Expected number of results returned was incorrect!", 1, map.size()
);
         assertTrue( map.containsKey( "ou=testing00,ou=system" ) );
         Attributes attrs = map.get( "ou=testing00,ou=system" );
@@ -659,6 +693,8 @@ public class SearchIT extends AbstractLd
             map.put( result.getName(), result.getAttributes() );
         }
 
+        list.close();
+
         assertEquals( "Expected number of results returned was incorrect!", 1, map.size()
);
         assertTrue( map.containsKey( "ou=testing00,ou=system" ) );
         Attributes attrs = map.get( "ou=testing00,ou=system" );
@@ -705,6 +741,9 @@ public class SearchIT extends AbstractLd
         SearchResult sr = enm.next();
         assertNotNull( sr );
         assertFalse( enm.hasMore() );
+        
+        enm.close();
+        
         assertEquals( "cn=Kate Bush,ou=system", sr.getName() );
 
         enm = sysRoot.search( "", "(userCertificate=\\34\\56\\4E\\5F)", controls );
@@ -713,6 +752,8 @@ public class SearchIT extends AbstractLd
         assertNotNull( sr );
         assertFalse( enm.hasMore() );
         assertEquals( "cn=Kate Bush,ou=system", sr.getName() );
+
+        enm.close();
     }
 
 
@@ -736,6 +777,8 @@ public class SearchIT extends AbstractLd
             map.put( result.getName(), result.getAttributes() );
         }
 
+        list.close();
+
         assertEquals( "Expected number of results returned was incorrect!", 1, map.size()
);
 
         Attributes attrs = map.get( "ou=testing01,ou=system" );
@@ -767,6 +810,8 @@ public class SearchIT extends AbstractLd
             map.put( result.getName(), result.getAttributes() );
         }
 
+        list.close();
+
         assertEquals( "Expected number of results returned was incorrect!", 1, map.size()
);
 
         Attributes attrs = map.get( "ou=testing01,ou=system" );
@@ -798,6 +843,8 @@ public class SearchIT extends AbstractLd
             map.put( result.getName(), result.getAttributes() );
         }
 
+        list.close();
+
         assertEquals( "Expected number of results returned was incorrect!", 1, map.size()
);
 
         Attributes attrs = map.get( "ou=testing01,ou=system" );
@@ -829,6 +876,8 @@ public class SearchIT extends AbstractLd
             map.put( result.getName(), result.getAttributes() );
         }
 
+        list.close();
+
         assertEquals( "Expected number of results returned was incorrect!", 1, map.size()
);
 
         Attributes attrs = map.get( "ou=testing01,ou=system" );
@@ -860,6 +909,8 @@ public class SearchIT extends AbstractLd
             map.put( result.getName(), result.getAttributes() );
         }
 
+        list.close();
+
         assertEquals( "Expected number of results returned was incorrect!", 1, map.size()
);
 
         Attributes attrs = map.get( "ou=testing01,ou=system" );
@@ -891,6 +942,8 @@ public class SearchIT extends AbstractLd
             map.put( result.getName(), result.getAttributes() );
         }
 
+        list.close();
+
         assertEquals( "Expected number of results returned was incorrect!", 1, map.size()
);
 
         Attributes attrs = map.get( "ou=testing01,ou=system" );
@@ -1067,6 +1120,8 @@ public class SearchIT extends AbstractLd
             SearchResult result = list.next();
             results.add( result.getName() );
         }
+        
+        list.close();
 
         return results;
     }
@@ -1106,6 +1161,8 @@ public class SearchIT extends AbstractLd
             SearchResult result = list.next();
             results.add( result.getName() );
         }
+        
+        list.close();
 
         return results;
     }
@@ -1135,6 +1192,8 @@ public class SearchIT extends AbstractLd
             SearchResult result = list.next();
             results.add( result.getName() );
         }
+        
+        list.close();
 
         return results;
     }
@@ -1301,6 +1360,8 @@ public class SearchIT extends AbstractLd
             map.put( result.getName(), result.getAttributes() );
         }
 
+        list.close();
+
         assertEquals( "Expected number of results returned was incorrect!", 1, map.size()
);
 
         Attributes attrs = map.get( "cn=Sid Vicious,ou=system" );
@@ -1338,6 +1399,7 @@ public class SearchIT extends AbstractLd
 
         String[] filters = new String[]
             { "(description=*\\28*)", "(description=*\\29*)", "(description=*\\2A*)", "(description=*\\5C*)"
};
+        
         for ( String filter : filters )
         {
             HashMap<String, Attributes> map = new HashMap<String, Attributes>();
@@ -1349,6 +1411,8 @@ public class SearchIT extends AbstractLd
                 map.put( result.getName(), result.getAttributes() );
             }
 
+            list.close();
+
             assertEquals( "Expected number of results returned was incorrect!", 1, map.size()
);
 
             Attributes attrs = map.get( "cn=Sid Vicious,ou=system" );
@@ -1378,11 +1442,15 @@ public class SearchIT extends AbstractLd
         assertEquals( "x*y*z*", res.next().getAttributes().get( "cn" ).get() );
         assertFalse( res.hasMore() );
 
+        res.close();
+        
         res = sysRoot.search( "", "(cn=*{0}*)", new String[]
             { "x*y*z*" }, controls );
         assertTrue( res.hasMore() );
         assertEquals( "x*y*z*", res.next().getAttributes().get( "cn" ).get() );
         assertFalse( res.hasMore() );
+        
+        res.close();
     }
 
 
@@ -1545,6 +1613,8 @@ public class SearchIT extends AbstractLd
             map.put( result.getName(), result.getAttributes() );
         }
 
+        list.close();
+
         assertEquals( "Expected number of results returned was incorrect!", 2, map.size()
);
         assertTrue( map.containsKey( "cn=Heather Nova, ou=system" ) || map.containsKey( "cn=Heather
Nova,ou=system" ) );
     }
@@ -1569,6 +1639,8 @@ public class SearchIT extends AbstractLd
             map.put( result.getName(), result.getAttributes() );
         }
 
+        list.close();
+
         assertEquals( "Expected number of results returned was incorrect", 1, map.size()
);
         assertTrue( map.containsKey( "cn=with-dn, ou=system" ) || map.containsKey( "cn=with-dn,ou=system"
) );
     }
@@ -1598,6 +1670,8 @@ public class SearchIT extends AbstractLd
             SearchResult result = list.next();
             map.put( result.getName(), result.getAttributes() );
         }
+        
+        list.close();
 
         assertEquals( "size of results", 5, map.size() );
         assertTrue( map.containsKey( "cn=testGroup0,ou=groups,ou=system" ) );
@@ -1634,6 +1708,8 @@ public class SearchIT extends AbstractLd
             map.put( result.getName(), result.getAttributes() );
         }
 
+        list.close();
+
         assertEquals( "Expected number of results returned was incorrect!", 1, map.size()
);
 
         Attributes attrs = map.get( "ou=testing01,ou=system" );
@@ -1667,6 +1743,8 @@ public class SearchIT extends AbstractLd
             map.put( result.getName(), result.getAttributes() );
         }
 
+        list.close();
+
         assertEquals( "Expected number of results returned was incorrect!", 1, map.size()
);
 
         Attributes attrs = map.get( "ou=testing01,ou=system" );
@@ -1702,6 +1780,8 @@ public class SearchIT extends AbstractLd
             map.put( result.getName(), result.getAttributes() );
         }
 
+        list.close();
+
         assertEquals( "Expected number of results returned was incorrect!", 1, map.size()
);
 
         Attributes attrs = map.get( "ou=testing01,ou=system" );
@@ -1735,6 +1815,8 @@ public class SearchIT extends AbstractLd
             map.put( result.getName(), result.getAttributes() );
         }
 
+        list.close();
+
         assertEquals( 2, map.size() );
 
         assertTrue( map.containsKey( "ou=system" ) );
@@ -1760,6 +1842,8 @@ public class SearchIT extends AbstractLd
             map.put( result.getName(), result.getAttributes() );
         }
 
+        list.close();
+
         assertTrue( map.size() > 2 );
 
         assertTrue( map.containsKey( "ou=system" ) );
@@ -1785,6 +1869,8 @@ public class SearchIT extends AbstractLd
             map.put( result.getName(), result.getAttributes() );
         }
 
+        list.close();
+
         assertEquals( 0, map.size() );
 
         assertFalse( map.containsKey( "ou=system" ) );
@@ -1810,6 +1896,8 @@ public class SearchIT extends AbstractLd
             map.put( result.getName(), result.getAttributes() );
         }
 
+        list.close();
+
         assertEquals( 0, map.size() );
 
         assertFalse( map.containsKey( "ou=system" ) );
@@ -1832,10 +1920,10 @@ public class SearchIT extends AbstractLd
 
         // add an entry to have a entry with higher CSN value
         Dn dn2 = new Dn( "cn=testHigherCsnAdd,ou=system" );
-        Entry entry2 = new DefaultEntry( dn2 );
-        entry2.add( "objectClass", SchemaConstants.PERSON_OC );
-        entry2.add( "cn", "testHigherCsnAdd_cn" );
-        entry2.add( "sn", "testHigherCsnAdd_sn" );
+        Entry entry2 = new DefaultEntry( dn2,
+            "objectClass :person",
+            "cn: testHigherCsnAdd_cn",
+            "sn: testHigherCsnAdd_sn" );
 
         connection.add( entry2 );
 
@@ -1920,6 +2008,8 @@ public class SearchIT extends AbstractLd
             SearchResult result = list.next();
             map.put( result.getName(), result.getAttributes() );
         }
+        
+        list.close();
 
         assertEquals( "Expected number of results returned was incorrect!", 1, map.size()
);
         assertTrue( map.containsKey( "ou=testing01,ou=system" ) );
@@ -1944,6 +2034,8 @@ public class SearchIT extends AbstractLd
             map.put( result.getName(), result.getAttributes() );
         }
 
+        list.close();
+
         assertEquals( "Expected number of results returned was incorrect!", 0, map.size()
);
     }
 }

Modified: directory/apacheds/branches/index-work/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchWithIndicesIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/index-work/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchWithIndicesIT.java?rev=1311684&r1=1311683&r2=1311684&view=diff
==============================================================================
--- directory/apacheds/branches/index-work/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchWithIndicesIT.java
(original)
+++ directory/apacheds/branches/index-work/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchWithIndicesIT.java
Tue Apr 10 11:39:42 2012
@@ -136,6 +136,8 @@ public class SearchWithIndicesIT extends
         {
             results.add( cursor.get().getDn().getName() );
         }
+        
+        cursor.close();
 
         return results;
     }
@@ -248,6 +250,8 @@ public class SearchWithIndicesIT extends
             assertEquals( "ou=testPresence,ou=system", cursor.get().getDn().toString() );
         }
         
+        cursor.close();
+        
         // Modify the entry to remove the description
         connection.modify( "ou=testPresence,ou=system",
             new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, "description"
) );
@@ -259,5 +263,7 @@ public class SearchWithIndicesIT extends
         {
             fail( "The search should not return any entry" );
         }
+        
+        cursor.close();
     }
 }



Mime
View raw message