directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r940097 - in /directory/apacheds/trunk: avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/ jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ xdbm-base/src/main/java/org/apache/dire...
Date Sat, 01 May 2010 19:43:56 GMT
Author: seelmann
Date: Sat May  1 19:43:55 2010
New Revision: 940097

URL: http://svn.apache.org/viewvc?rev=940097&view=rev
Log:
Use UUID index for walking all entries. Adapted tests as UUID index doesn't garantee insert
time ordering.

Modified:
    directory/apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java
    directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
    directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java
    directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/Tuple.java
    directory/apacheds/trunk/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/GreaterEqTest.java
    directory/apacheds/trunk/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/LessEqTest.java
    directory/apacheds/trunk/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/NestedFilterTest.java
    directory/apacheds/trunk/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/NotCursorTest.java
    directory/apacheds/trunk/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceTest.java

Modified: directory/apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java?rev=940097&r1=940096&r2=940097&view=diff
==============================================================================
--- directory/apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java
(original)
+++ directory/apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java
Sat May  1 19:43:55 2010
@@ -164,14 +164,5 @@ public class AvlStore<E> extends Abstrac
     {
         return 0L;
     }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Index<String, E, Long> getNdnIndex()
-    {
-        // FIXME should this be entryUuidIdx?
-        return getEntryCsnIndex();
-    }
     
 }

Modified: directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java?rev=940097&r1=940096&r2=940097&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
(original)
+++ directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
Sat May  1 19:43:55 2010
@@ -68,7 +68,8 @@ public class JdbmStore<E> extends Abstra
     {
         return 1L;
     };
-    
+
+
     @Override
     protected Long getRootId()
     {
@@ -236,7 +237,7 @@ public class JdbmStore<E> extends Abstra
     protected Index<?, E, Long> convertAndInit( Index<?, E, Long> index ) throws
Exception
     {
         JdbmIndex<?, E> jdbmIndex;
-        if( index.getAttributeId().equals( ApacheSchemaConstants.APACHE_RDN_AT_OID ) )
+        if ( index.getAttributeId().equals( ApacheSchemaConstants.APACHE_RDN_AT_OID ) )
         {
             jdbmIndex = new JdbmRdnIndex();
             jdbmIndex.setAttributeId( ApacheSchemaConstants.APACHE_RDN_AT_OID );
@@ -264,37 +265,4 @@ public class JdbmStore<E> extends Abstra
         return jdbmIndex;
     }
 
-
-    /**
-     * {@inheritDoc}
-     */
-    public Index<String, E, Long> getNdnIndex()
-    {
-        // FIXME should this be entryUuidIdx?
-        return getEntryCsnIndex();
-    }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-    
-
-
 }

Modified: directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java?rev=940097&r1=940096&r2=940097&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java
(original)
+++ directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java
Sat May  1 19:43:55 2010
@@ -553,7 +553,7 @@ public abstract class AbstractStore<E, I
     @SuppressWarnings("unchecked")
     public Index<String, E, ID> getNdnIndex()
     {
-        return ( Index<String, E, ID> ) systemIndices.get( ApacheSchemaConstants.APACHE_N_DN_AT_OID
);
+        return getEntryUuidIndex();
     }
 
 

Modified: directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/Tuple.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/Tuple.java?rev=940097&r1=940096&r2=940097&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/Tuple.java
(original)
+++ directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/Tuple.java
Sat May  1 19:43:55 2010
@@ -137,6 +137,59 @@ public class Tuple<K, V>
     }
 
 
+    @Override
+    public int hashCode()
+    {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ( ( key == null ) ? 0 : key.hashCode() );
+        result = prime * result + ( ( value == null ) ? 0 : value.hashCode() );
+        return result;
+    }
+
+
+    @Override
+    public boolean equals( Object obj )
+    {
+        if ( this == obj )
+        {
+            return true;
+        }
+        if ( obj == null )
+        {
+            return false;
+        }
+        if ( getClass() != obj.getClass() )
+        {
+            return false;
+        }
+        Tuple other = ( Tuple ) obj;
+        if ( key == null )
+        {
+            if ( other.key != null )
+            {
+                return false;
+            }
+        }
+        else if ( !key.equals( other.key ) )
+        {
+            return false;
+        }
+        if ( value == null )
+        {
+            if ( other.value != null )
+            {
+                return false;
+            }
+        }
+        else if ( !value.equals( other.value ) )
+        {
+            return false;
+        }
+        return true;
+    }
+
+
     public String toString()
     {
         StringBuilder buf = new StringBuilder();

Modified: directory/apacheds/trunk/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/GreaterEqTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/GreaterEqTest.java?rev=940097&r1=940096&r2=940097&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/GreaterEqTest.java
(original)
+++ directory/apacheds/trunk/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/GreaterEqTest.java
Sat May  1 19:43:55 2010
@@ -28,7 +28,9 @@ import static org.junit.Assert.fail;
 
 import java.io.File;
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 import java.util.UUID;
 
 import org.apache.commons.io.FileUtils;
@@ -36,6 +38,7 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmStore;
 import org.apache.directory.server.xdbm.ForwardIndexEntry;
 import org.apache.directory.server.xdbm.Store;
+import org.apache.directory.server.xdbm.Tuple;
 import org.apache.directory.server.xdbm.tools.StoreUtils;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.csn.CsnFactory;
@@ -421,28 +424,20 @@ public class GreaterEqTest
 
         // ---------- test beforeFirst() ----------
 
+        Set<Tuple<String, Long>> set = new HashSet<Tuple<String, Long>>();
         cursor.beforeFirst();
         assertFalse( cursor.available() );
 
-        assertTrue( cursor.next() );
-        assertTrue( cursor.available() );
-        assertEquals( 5L, ( long ) cursor.get().getId() );
-        assertEquals( "3", cursor.get().getValue() );
-
-        assertTrue( cursor.next() );
-        assertTrue( cursor.available() );
-        assertEquals( 6L, ( long ) cursor.get().getId() );
-        assertEquals( "4", cursor.get().getValue() );
-
-        assertTrue( cursor.next() );
-        assertTrue( cursor.available() );
-        assertEquals( 7L, ( long ) cursor.get().getId() );
-        assertEquals( "5", cursor.get().getValue() );
-
-        assertTrue( cursor.next() );
-        assertTrue( cursor.available() );
-        assertEquals( 8L, ( long ) cursor.get().getId() );
-        assertEquals( "6", cursor.get().getValue() );
+        while ( cursor.next() )
+        {
+            assertTrue( cursor.available() );
+            set.add( new Tuple<String, Long>( cursor.get().getValue(), cursor.get().getId()
) );
+        }
+        assertEquals( 4, set.size() );
+        assertTrue( set.contains( new Tuple<String, Long>( "3", 5L ) ) );
+        assertTrue( set.contains( new Tuple<String, Long>( "4", 6L ) ) );
+        assertTrue( set.contains( new Tuple<String, Long>( "5", 7L ) ) );
+        assertTrue( set.contains( new Tuple<String, Long>( "6", 8L ) ) );
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
@@ -452,28 +447,23 @@ public class GreaterEqTest
 
         // ---------- test first() ----------
 
+        set.clear();
         cursor = new GreaterEqCursor( store, evaluator );
-        cursor.beforeFirst();
-
-        assertTrue( cursor.next() );
-        assertTrue( cursor.available() );
-        assertEquals( 5L, ( long ) cursor.get().getId() );
-        assertEquals( "3", cursor.get().getValue() );
-
-        assertTrue( cursor.next() );
-        assertTrue( cursor.available() );
-        assertEquals( 6L, ( long ) cursor.get().getId() );
-        assertEquals( "4", cursor.get().getValue() );
+        cursor.first();
 
-        assertTrue( cursor.next() );
         assertTrue( cursor.available() );
-        assertEquals( 7L, ( long ) cursor.get().getId() );
-        assertEquals( "5", cursor.get().getValue() );
+        set.add( new Tuple<String, Long>( cursor.get().getValue(), cursor.get().getId()
) );
 
-        assertTrue( cursor.next() );
-        assertTrue( cursor.available() );
-        assertEquals( 8L, ( long ) cursor.get().getId() );
-        assertEquals( "6", cursor.get().getValue() );
+        while ( cursor.next() )
+        {
+            assertTrue( cursor.available() );
+            set.add( new Tuple<String, Long>( cursor.get().getValue(), cursor.get().getId()
) );
+        }
+        assertEquals( 4, set.size() );
+        assertTrue( set.contains( new Tuple<String, Long>( "3", 5L ) ) );
+        assertTrue( set.contains( new Tuple<String, Long>( "4", 6L ) ) );
+        assertTrue( set.contains( new Tuple<String, Long>( "5", 7L ) ) );
+        assertTrue( set.contains( new Tuple<String, Long>( "6", 8L ) ) );
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
@@ -483,56 +473,44 @@ public class GreaterEqTest
 
         // ---------- test afterLast() ----------
 
+        set.clear();
         cursor = new GreaterEqCursor( store, evaluator );
         cursor.afterLast();
         assertFalse( cursor.available() );
 
-        assertTrue( cursor.previous() );
-        assertTrue( cursor.available() );
-        assertEquals( 8L, ( long ) cursor.get().getId() );
-        assertEquals( "6", cursor.get().getValue() );
-
-        assertTrue( cursor.previous() );
-        assertTrue( cursor.available() );
-        assertEquals( 7L, ( long ) cursor.get().getId() );
-        assertEquals( "5", cursor.get().getValue() );
-
-        assertTrue( cursor.previous() );
-        assertTrue( cursor.available() );
-        assertEquals( 6L, ( long ) cursor.get().getId() );
-        assertEquals( "4", cursor.get().getValue() );
-
-        assertTrue( cursor.previous() );
-        assertTrue( cursor.available() );
-        assertEquals( 5L, ( long ) cursor.get().getId() );
-        assertEquals( "3", cursor.get().getValue() );
+        while ( cursor.previous() )
+        {
+            assertTrue( cursor.available() );
+            set.add( new Tuple<String, Long>( cursor.get().getValue(), cursor.get().getId()
) );
+        }
+        assertEquals( 4, set.size() );
+        assertTrue( set.contains( new Tuple<String, Long>( "3", 5L ) ) );
+        assertTrue( set.contains( new Tuple<String, Long>( "4", 6L ) ) );
+        assertTrue( set.contains( new Tuple<String, Long>( "5", 7L ) ) );
+        assertTrue( set.contains( new Tuple<String, Long>( "6", 8L ) ) );
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
 
         // ---------- test last() ----------
 
+        set.clear();
         cursor = new GreaterEqCursor( store, evaluator );
         cursor.last();
 
         assertTrue( cursor.available() );
-        assertEquals( 8L, ( long ) cursor.get().getId() );
-        assertEquals( "6", cursor.get().getValue() );
-
-        assertTrue( cursor.previous() );
-        assertTrue( cursor.available() );
-        assertEquals( 7L, ( long ) cursor.get().getId() );
-        assertEquals( "5", cursor.get().getValue() );
-
-        assertTrue( cursor.previous() );
-        assertTrue( cursor.available() );
-        assertEquals( 6L, ( long ) cursor.get().getId() );
-        assertEquals( "4", cursor.get().getValue() );
+        set.add( new Tuple<String, Long>( cursor.get().getValue(), cursor.get().getId()
) );
 
-        assertTrue( cursor.previous() );
-        assertTrue( cursor.available() );
-        assertEquals( 5L, ( long ) cursor.get().getId() );
-        assertEquals( "3", cursor.get().getValue() );
+        while ( cursor.previous() )
+        {
+            assertTrue( cursor.available() );
+            set.add( new Tuple<String, Long>( cursor.get().getValue(), cursor.get().getId()
) );
+        }
+        assertEquals( 4, set.size() );
+        assertTrue( set.contains( new Tuple<String, Long>( "3", 5L ) ) );
+        assertTrue( set.contains( new Tuple<String, Long>( "4", 6L ) ) );
+        assertTrue( set.contains( new Tuple<String, Long>( "5", 7L ) ) );
+        assertTrue( set.contains( new Tuple<String, Long>( "6", 8L ) ) );
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );

Modified: directory/apacheds/trunk/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/LessEqTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/LessEqTest.java?rev=940097&r1=940096&r2=940097&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/LessEqTest.java
(original)
+++ directory/apacheds/trunk/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/LessEqTest.java
Sat May  1 19:43:55 2010
@@ -28,7 +28,9 @@ import static org.junit.Assert.fail;
 
 import java.io.File;
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 import java.util.UUID;
 
 import org.apache.commons.io.FileUtils;
@@ -36,13 +38,14 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmStore;
 import org.apache.directory.server.xdbm.ForwardIndexEntry;
 import org.apache.directory.server.xdbm.Store;
+import org.apache.directory.server.xdbm.Tuple;
 import org.apache.directory.server.xdbm.tools.StoreUtils;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.csn.CsnFactory;
 import org.apache.directory.shared.ldap.cursor.InvalidCursorPositionException;
 import org.apache.directory.shared.ldap.entry.DefaultEntry;
-import org.apache.directory.shared.ldap.entry.StringValue;
 import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.entry.StringValue;
 import org.apache.directory.shared.ldap.filter.LessEqNode;
 import org.apache.directory.shared.ldap.name.DN;
 import org.apache.directory.shared.ldap.schema.AttributeType;
@@ -441,33 +444,21 @@ public class LessEqTest
 
         // ---------- test beforeFirst() ----------
 
+        Set<Tuple<String, Long>> set = new HashSet<Tuple<String, Long>>();
         cursor.beforeFirst();
         assertFalse( cursor.available() );
 
-        assertTrue( cursor.next() );
-        assertTrue( cursor.available() );
-        assertEquals( 1L, ( long ) cursor.get().getId() );
-        assertEquals( "1", cursor.get().getValue() );
-
-        assertTrue( cursor.next() );
-        assertTrue( cursor.available() );
-        assertEquals( 2L, ( long ) cursor.get().getId() );
-        assertEquals( "1", cursor.get().getValue() );
-
-        assertTrue( cursor.next() );
-        assertTrue( cursor.available() );
-        assertEquals( 3L, ( long ) cursor.get().getId() );
-        assertEquals( "1", cursor.get().getValue() );
-
-        assertTrue( cursor.next() );
-        assertTrue( cursor.available() );
-        assertEquals( 4L, ( long ) cursor.get().getId() );
-        assertEquals( "2", cursor.get().getValue() );
-
-        assertTrue( cursor.next() );
-        assertTrue( cursor.available() );
-        assertEquals( 5L, ( long ) cursor.get().getId() );
-        assertEquals( "3", cursor.get().getValue() );
+        while ( cursor.next() )
+        {
+            assertTrue( cursor.available() );
+            set.add( new Tuple<String, Long>( cursor.get().getValue(), cursor.get().getId()
) );
+        }
+        assertEquals( 5, set.size() );
+        assertTrue( set.contains( new Tuple<String, Long>( "1", 1L ) ) );
+        assertTrue( set.contains( new Tuple<String, Long>( "1", 2L ) ) );
+        assertTrue( set.contains( new Tuple<String, Long>( "1", 3L ) ) );
+        assertTrue( set.contains( new Tuple<String, Long>( "2", 4L ) ) );
+        assertTrue( set.contains( new Tuple<String, Long>( "3", 5L ) ) );
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
@@ -477,32 +468,24 @@ public class LessEqTest
 
         // ---------- test beforeFirst() ----------
 
+        set.clear();
         cursor = new LessEqCursor( store, evaluator );
         cursor.first();
 
         assertTrue( cursor.available() );
-        assertEquals( 1L, ( long ) cursor.get().getId() );
-        assertEquals( "1", cursor.get().getValue() );
+        set.add( new Tuple<String, Long>( cursor.get().getValue(), cursor.get().getId()
) );
 
-        assertTrue( cursor.next() );
-        assertTrue( cursor.available() );
-        assertEquals( 2L, ( long ) cursor.get().getId() );
-        assertEquals( "1", cursor.get().getValue() );
-        
-        assertTrue( cursor.next() );
-        assertTrue( cursor.available() );
-        assertEquals( 3L, ( long ) cursor.get().getId() );
-        assertEquals( "1", cursor.get().getValue() );
-
-        assertTrue( cursor.next() );
-        assertTrue( cursor.available() );
-        assertEquals( 4L, ( long ) cursor.get().getId() );
-        assertEquals( "2", cursor.get().getValue() );
-
-        assertTrue( cursor.next() );
-        assertTrue( cursor.available() );
-        assertEquals( 5L, ( long ) cursor.get().getId() );
-        assertEquals( "3", cursor.get().getValue() );
+        while ( cursor.next() )
+        {
+            assertTrue( cursor.available() );
+            set.add( new Tuple<String, Long>( cursor.get().getValue(), cursor.get().getId()
) );
+        }
+        assertEquals( 5, set.size() );
+        assertTrue( set.contains( new Tuple<String, Long>( "1", 1L ) ) );
+        assertTrue( set.contains( new Tuple<String, Long>( "1", 2L ) ) );
+        assertTrue( set.contains( new Tuple<String, Long>( "1", 3L ) ) );
+        assertTrue( set.contains( new Tuple<String, Long>( "2", 4L ) ) );
+        assertTrue( set.contains( new Tuple<String, Long>( "3", 5L ) ) );
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
@@ -512,66 +495,46 @@ public class LessEqTest
 
         // ---------- test afterLast() ----------
 
+        set.clear();
         cursor = new LessEqCursor( store, evaluator );
         cursor.afterLast();
         assertFalse( cursor.available() );
 
-        assertTrue( cursor.previous() );
-        assertTrue( cursor.available() );
-        assertEquals( 5L, ( long ) cursor.get().getId() );
-        assertEquals( "3", cursor.get().getValue() );
-
-        assertTrue( cursor.previous() );
-        assertTrue( cursor.available() );
-        assertEquals( 4L, ( long ) cursor.get().getId() );
-        assertEquals( "2", cursor.get().getValue() );
-
-        assertTrue( cursor.previous() );
-        assertTrue( cursor.available() );
-        assertEquals( 3L, ( long ) cursor.get().getId() );
-        assertEquals( "1", cursor.get().getValue() );
-
-        assertTrue( cursor.previous() );
-        assertTrue( cursor.available() );
-        assertEquals( 2L, ( long ) cursor.get().getId() );
-        assertEquals( "1", cursor.get().getValue() );
-
-        assertTrue( cursor.previous() );
-        assertTrue( cursor.available() );
-        assertEquals( 1L, ( long ) cursor.get().getId() );
-        assertEquals( "1", cursor.get().getValue() );
+        while ( cursor.previous() )
+        {
+            assertTrue( cursor.available() );
+            set.add( new Tuple<String, Long>( cursor.get().getValue(), cursor.get().getId()
) );
+        }
+        assertEquals( 5, set.size() );
+        assertTrue( set.contains( new Tuple<String, Long>( "1", 1L ) ) );
+        assertTrue( set.contains( new Tuple<String, Long>( "1", 2L ) ) );
+        assertTrue( set.contains( new Tuple<String, Long>( "1", 3L ) ) );
+        assertTrue( set.contains( new Tuple<String, Long>( "2", 4L ) ) );
+        assertTrue( set.contains( new Tuple<String, Long>( "3", 5L ) ) );
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
 
         // ---------- test last() ----------
 
+        set.clear();
         cursor = new LessEqCursor( store, evaluator );
         cursor.last();
 
         assertTrue( cursor.available() );
-        assertEquals( 5L, ( long ) cursor.get().getId() );
-        assertEquals( "3", cursor.get().getValue() );
-
-        assertTrue( cursor.previous() );
-        assertTrue( cursor.available() );
-        assertEquals( 4L, ( long ) cursor.get().getId() );
-        assertEquals( "2", cursor.get().getValue() );
-
-        assertTrue( cursor.previous() );
-        assertTrue( cursor.available() );
-        assertEquals( 3L, ( long ) cursor.get().getId() );
-        assertEquals( "1", cursor.get().getValue() );
-
-        assertTrue( cursor.previous() );
-        assertTrue( cursor.available() );
-        assertEquals( 2L, ( long ) cursor.get().getId() );
-        assertEquals( "1", cursor.get().getValue() );
+        set.add( new Tuple<String, Long>( cursor.get().getValue(), cursor.get().getId()
) );
 
-        assertTrue( cursor.previous() );
-        assertTrue( cursor.available() );
-        assertEquals( 1L, ( long ) cursor.get().getId() );
-        assertEquals( "1", cursor.get().getValue() );
+        while ( cursor.previous() )
+        {
+            assertTrue( cursor.available() );
+            set.add( new Tuple<String, Long>( cursor.get().getValue(), cursor.get().getId()
) );
+        }
+        assertEquals( 5, set.size() );
+        assertTrue( set.contains( new Tuple<String, Long>( "1", 1L ) ) );
+        assertTrue( set.contains( new Tuple<String, Long>( "1", 2L ) ) );
+        assertTrue( set.contains( new Tuple<String, Long>( "1", 3L ) ) );
+        assertTrue( set.contains( new Tuple<String, Long>( "2", 4L ) ) );
+        assertTrue( set.contains( new Tuple<String, Long>( "3", 5L ) ) );
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );

Modified: directory/apacheds/trunk/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/NestedFilterTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/NestedFilterTest.java?rev=940097&r1=940096&r2=940097&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/NestedFilterTest.java
(original)
+++ directory/apacheds/trunk/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/NestedFilterTest.java
Sat May  1 19:43:55 2010
@@ -26,12 +26,15 @@ import static org.junit.Assert.assertTru
 import static org.junit.Assert.fail;
 
 import java.io.File;
+import java.util.HashSet;
+import java.util.Set;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex;
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmStore;
 import org.apache.directory.server.xdbm.IndexCursor;
 import org.apache.directory.server.xdbm.Store;
+import org.apache.directory.server.xdbm.Tuple;
 import org.apache.directory.server.xdbm.search.Optimizer;
 import org.apache.directory.server.xdbm.tools.StoreUtils;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
@@ -46,6 +49,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.schema.manager.impl.DefaultSchemaManager;
 import org.apache.directory.shared.ldap.schema.normalizers.ConcreteNameComponentNormalizer;
 import org.apache.directory.shared.ldap.schema.syntaxCheckers.CsnSyntaxChecker;
+import org.apache.directory.shared.ldap.schema.syntaxCheckers.UuidSyntaxChecker;
 import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.junit.After;
 import org.junit.Before;
@@ -215,22 +219,23 @@ public class NestedFilterTest
     {
         String filter = "(&(|(postalCode=5)(postalCode=6))(!(ou=sales)))";
 
-        CsnSyntaxChecker csnSynChecker = new CsnSyntaxChecker();
-        
+        UuidSyntaxChecker uuidSynChecker = new UuidSyntaxChecker();
+
         ExprNode exprNode = FilterParser.parse( filter );
         optimizer.annotate( exprNode );
 
         IndexCursor<?, Entry, Long> cursor = cursorBuilder.build( exprNode );
 
-        assertTrue( cursor.next() );
-        assertTrue( cursor.available() );
-        assertEquals( 7, ( long ) cursor.get().getId() );
-        assertTrue( csnSynChecker.isValidSyntax( cursor.get().getValue() ) );
-
-        assertTrue( cursor.next() );
-        assertTrue( cursor.available() );
-        assertEquals( 8, ( long ) cursor.get().getId() );
-        assertTrue( csnSynChecker.isValidSyntax( cursor.get().getValue() ) );
+        Set<Long> set = new HashSet<Long>();
+        while ( cursor.next() )
+        {
+            assertTrue( cursor.available() );
+            set.add( cursor.get().getId() );
+            assertTrue( uuidSynChecker.isValidSyntax( cursor.get().getValue() ) );
+        }
+        assertEquals( 2, set.size() );
+        assertTrue( set.contains( 7L ) );
+        assertTrue( set.contains( 8L ) );
 
         assertFalse( cursor.next() );
     }

Modified: directory/apacheds/trunk/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/NotCursorTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/NotCursorTest.java?rev=940097&r1=940096&r2=940097&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/NotCursorTest.java
(original)
+++ directory/apacheds/trunk/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/NotCursorTest.java
Sat May  1 19:43:55 2010
@@ -26,6 +26,8 @@ import static org.junit.Assert.assertTru
 import static org.junit.Assert.fail;
 
 import java.io.File;
+import java.util.HashSet;
+import java.util.Set;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex;
@@ -50,6 +52,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.schema.manager.impl.DefaultSchemaManager;
 import org.apache.directory.shared.ldap.schema.syntaxCheckers.CsnSidSyntaxChecker;
 import org.apache.directory.shared.ldap.schema.syntaxCheckers.CsnSyntaxChecker;
+import org.apache.directory.shared.ldap.schema.syntaxCheckers.UuidSyntaxChecker;
 import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.junit.After;
 import org.junit.Before;
@@ -70,8 +73,8 @@ public class NotCursorTest
 {
     private static final Logger LOG = LoggerFactory.getLogger( NotCursorTest.class.getSimpleName()
);
 
-    CsnSyntaxChecker csnSynChecker = new CsnSyntaxChecker();
-    
+    UuidSyntaxChecker uuidSynChecker = new UuidSyntaxChecker();
+
     File wkdir;
     Store<Entry, Long> store;
     static SchemaManager schemaManager = null;
@@ -174,31 +177,19 @@ public class NotCursorTest
 
         cursor.beforeFirst();
 
-        assertTrue( cursor.next() );
-        assertTrue( cursor.available() );
-        assertEquals( 1, ( long ) cursor.get().getId() );
-        assertTrue( csnSynChecker.isValidSyntax( cursor.get().getValue() ) );
-
-        assertTrue( cursor.next() );
-        assertTrue( cursor.available() );
-        assertEquals( 2, ( long ) cursor.get().getId() );
-        assertTrue( csnSynChecker.isValidSyntax( cursor.get().getValue() ) );
-
-        assertTrue( cursor.next() );
-        assertTrue( cursor.available() );
-        assertEquals( 3, ( long ) cursor.get().getId() );
-        assertTrue( csnSynChecker.isValidSyntax( cursor.get().getValue() ) );
-
-        assertTrue( cursor.next() );
-        assertTrue( cursor.available() );
-        assertEquals( 4, ( long ) cursor.get().getId() );
-        assertTrue( csnSynChecker.isValidSyntax( cursor.get().getValue() ) );
-
-        assertTrue( cursor.next() );
-        assertTrue( cursor.available() );
-        assertEquals( 7, ( long ) cursor.get().getId() );
-        assertTrue( csnSynChecker.isValidSyntax( cursor.get().getValue() ) );
-
+        Set<Long> set = new HashSet<Long>();
+        while ( cursor.next() )
+        {
+            assertTrue( cursor.available() );
+            set.add( cursor.get().getId() );
+            assertTrue( uuidSynChecker.isValidSyntax( cursor.get().getValue() ) );
+        }
+        assertEquals( 5, set.size() );
+        assertTrue( set.contains( 1L ) );
+        assertTrue( set.contains( 2L ) );
+        assertTrue( set.contains( 3L ) );
+        assertTrue( set.contains( 4L ) );
+        assertTrue( set.contains( 7L ) );
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
@@ -214,69 +205,45 @@ public class NotCursorTest
         NotNode notNode = new NotNode();
 
         ExprNode exprNode = new SubstringNode( "cn", "J", null );
-        Evaluator<? extends ExprNode, Entry, Long> eval = new SubstringEvaluator( (
SubstringNode ) exprNode,
-            store, schemaManager );
+        Evaluator<? extends ExprNode, Entry, Long> eval = new SubstringEvaluator( (
SubstringNode ) exprNode, store,
+            schemaManager );
         notNode.addNode( exprNode );
 
         NotCursor<String, Long> cursor = new NotCursor( store, eval ); //cursorBuilder.build(
andNode );
+        cursor.beforeFirst();
 
-        assertTrue( cursor.next() );
-        assertTrue( cursor.available() );
-        assertEquals( 1, ( long ) cursor.get().getId() );
-        assertTrue( csnSynChecker.isValidSyntax( cursor.get().getValue() ) );
-
-        cursor.first();
-
-        assertTrue( cursor.next() );
-        assertTrue( cursor.available() );
-        assertEquals( 2, ( long ) cursor.get().getId() );
-        assertTrue( csnSynChecker.isValidSyntax( cursor.get().getValue() ) );
-
-        assertTrue( cursor.next() );
-        assertTrue( cursor.available() );
-        assertEquals( 3, ( long ) cursor.get().getId() );
-        assertTrue( csnSynChecker.isValidSyntax( cursor.get().getValue() ) );
-
-        assertTrue( cursor.next() );
-        assertTrue( cursor.available() );
-        assertEquals( 4, ( long ) cursor.get().getId() );
-        assertTrue( csnSynChecker.isValidSyntax( cursor.get().getValue() ) );
-
-        assertTrue( cursor.next() );
-        assertTrue( cursor.available() );
-        assertEquals( 7, ( long ) cursor.get().getId() );
-        assertTrue( csnSynChecker.isValidSyntax( cursor.get().getValue() ) );
+        Set<Long> set = new HashSet<Long>();
+        while ( cursor.next() )
+        {
+            assertTrue( cursor.available() );
+            set.add( cursor.get().getId() );
+            assertTrue( uuidSynChecker.isValidSyntax( cursor.get().getValue() ) );
+        }
+        assertEquals( 5, set.size() );
+        assertTrue( set.contains( 1L ) );
+        assertTrue( set.contains( 2L ) );
+        assertTrue( set.contains( 3L ) );
+        assertTrue( set.contains( 4L ) );
+        assertTrue( set.contains( 7L ) );
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
 
         cursor.afterLast();
 
-        assertTrue( cursor.previous() );
-        assertTrue( cursor.available() );
-        assertEquals( 7, ( long ) cursor.get().getId() );
-        assertTrue( csnSynChecker.isValidSyntax( cursor.get().getValue() ) );
-
-        cursor.last();
-        assertTrue( cursor.previous() );
-        assertTrue( cursor.available() );
-        assertEquals( 4, ( long ) cursor.get().getId() );
-        assertTrue( csnSynChecker.isValidSyntax( cursor.get().getValue() ) );
-
-        assertTrue( cursor.previous() );
-        assertTrue( cursor.available() );
-        assertEquals( 3, ( long ) cursor.get().getId() );
-        assertTrue( csnSynChecker.isValidSyntax( cursor.get().getValue() ) );
-
-        assertTrue( cursor.previous() );
-        assertTrue( cursor.available() );
-        assertEquals( 2, ( long ) cursor.get().getId() );
-        assertTrue( csnSynChecker.isValidSyntax( cursor.get().getValue() ) );
-
-        assertTrue( cursor.previous() );
-        assertTrue( cursor.available() );
-        assertEquals( 1, ( long ) cursor.get().getId() );
-        assertTrue( csnSynChecker.isValidSyntax( cursor.get().getValue() ) );
+        set.clear();
+        while ( cursor.previous() )
+        {
+            assertTrue( cursor.available() );
+            set.add( cursor.get().getId() );
+            assertTrue( uuidSynChecker.isValidSyntax( cursor.get().getValue() ) );
+        }
+        assertEquals( 5, set.size() );
+        assertTrue( set.contains( 1L ) );
+        assertTrue( set.contains( 2L ) );
+        assertTrue( set.contains( 3L ) );
+        assertTrue( set.contains( 4L ) );
+        assertTrue( set.contains( 7L ) );
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );

Modified: directory/apacheds/trunk/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceTest.java?rev=940097&r1=940096&r2=940097&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceTest.java
(original)
+++ directory/apacheds/trunk/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceTest.java
Sat May  1 19:43:55 2010
@@ -27,7 +27,9 @@ import static org.junit.Assert.fail;
 
 import java.io.File;
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex;
@@ -301,15 +303,19 @@ public class PresenceTest
         assertTrue( cursor.isElementReused() );
 
         cursor.beforeFirst();
-        assertTrue( cursor.next() );
-        assertTrue( cursor.available() );
-        assertEquals( 5, ( long ) cursor.get().getId() );
-        assertTrue( cursor.next() );
-        assertTrue( cursor.available() );
-        assertEquals( 6, ( long ) cursor.get().getId() );
-        assertTrue( cursor.next() );
-        assertTrue( cursor.available() );
-        assertEquals( 8, ( long ) cursor.get().getId() );
+
+        Set<Long> set = new HashSet<Long>();
+        while ( cursor.next() )
+        {
+            assertTrue( cursor.available() );
+            assertEquals( SchemaConstants.SN_AT_OID, cursor.get().getValue() );
+            set.add( cursor.get().getId() );
+        }
+        assertEquals( 3, set.size() );
+        assertTrue( set.contains( 5L ) );
+        assertTrue( set.contains( 6L ) );
+        assertTrue( set.contains( 8L ) );
+
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
 
@@ -331,23 +337,20 @@ public class PresenceTest
         assertEquals( SchemaConstants.SN_AT_OID, cursor.get().getValue() );
 
         // test afterLast()
+        set.clear();
         cursor.afterLast();
         assertFalse( cursor.available() );
-        assertTrue( cursor.previous() );
-        assertTrue( cursor.available() );
-        assertEquals( SchemaConstants.SN_AT_OID, cursor.get().getValue() );
-        assertEquals( 8, ( long ) cursor.get().getId() );
-
-        // keep testing previous
-        assertTrue( cursor.previous() );
-        assertTrue( cursor.available() );
-        assertEquals( SchemaConstants.SN_AT_OID, cursor.get().getValue() );
-        assertEquals( 6, ( long ) cursor.get().getId() );
 
-        assertTrue( cursor.previous() );
-        assertTrue( cursor.available() );
-        assertEquals( SchemaConstants.SN_AT_OID, cursor.get().getValue() );
-        assertEquals( 5, ( long ) cursor.get().getId() );
+        while ( cursor.previous() )
+        {
+            assertTrue( cursor.available() );
+            assertEquals( SchemaConstants.SN_AT_OID, cursor.get().getValue() );
+            set.add( cursor.get().getId() );
+        }
+        assertEquals( 3, set.size() );
+        assertTrue( set.contains( 5L ) );
+        assertTrue( set.contains( 6L ) );
+        assertTrue( set.contains( 8L ) );
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );



Mime
View raw message