directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1389184 [11/13] - in /directory/apacheds/trunk: core-annotations/src/main/java/org/apache/directory/server/core/factory/ core-api/src/main/java/org/apache/directory/server/core/api/ core-api/src/main/java/org/apache/directory/server/core/a...
Date Mon, 24 Sep 2012 02:17:20 GMT
Modified: directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlPartitionTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlPartitionTest.java?rev=1389184&r1=1389183&r2=1389184&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlPartitionTest.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlPartitionTest.java Mon Sep 24 02:17:13 2012
@@ -35,7 +35,6 @@ import org.apache.directory.server.const
 import org.apache.directory.server.core.api.entry.ClonedServerEntry;
 import org.apache.directory.server.core.api.interceptor.context.AddOperationContext;
 import org.apache.directory.server.core.partition.impl.avl.AvlPartition;
-import org.apache.directory.server.xdbm.Index;
 import org.apache.directory.server.xdbm.IndexEntry;
 import org.apache.directory.server.xdbm.IndexNotFoundException;
 import org.apache.directory.server.xdbm.StoreUtils;
@@ -59,6 +58,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.schemaextractor.impl.DefaultSchemaLdifExtractor;
 import org.apache.directory.shared.ldap.schemaloader.LdifSchemaLoader;
 import org.apache.directory.shared.ldap.schemamanager.impl.DefaultSchemaManager;
+import org.apache.directory.shared.util.Strings;
 import org.apache.directory.shared.util.exception.Exceptions;
 import org.junit.After;
 import org.junit.Before;
@@ -249,7 +249,6 @@ public class AvlPartitionTest
         {
         }
 
-        assertNotNull( partition.getEntryUuidIndex() );
         assertNotNull( partition.getRdnIndex() );
 
         try
@@ -287,7 +286,7 @@ public class AvlPartitionTest
 
         Iterator<String> systemIndices = partition.getSystemIndices();
 
-        for ( int i = 0; i < 8; i++ )
+        for ( int i = 0; i < 7; i++ )
         {
             assertTrue( systemIndices.hasNext() );
             assertNotNull( systemIndices.next() );
@@ -367,55 +366,55 @@ public class AvlPartitionTest
     public void testFreshStore() throws Exception
     {
         Dn dn = new Dn( schemaManager, "o=Good Times Co." );
-        assertEquals( 1L, ( long ) partition.getEntryId( dn ) );
+        assertEquals( Strings.getUUID( 1L ), partition.getEntryId( dn ) );
         assertEquals( 11, partition.count() );
 
         // note that the suffix entry returns 0 for it's parent which does not exist
-        assertEquals( 0L, ( long ) partition.getParentId( partition.getEntryId( dn ) ) );
-        assertNull( partition.getParentId( 0L ) );
+        assertEquals( Strings.getUUID( 0L ), partition.getParentId( partition.getEntryId( dn ) ) );
+        assertNull( partition.getParentId( Strings.getUUID( 0L ) ) );
 
         // should be allowed
-        partition.delete( 1L );
+        partition.delete( Strings.getUUID( 1L ) );
     }
 
 
     @Test
     public void testEntryOperations() throws Exception
     {
-        assertEquals( 3, partition.getChildCount( 1L ) );
+        assertEquals( 3, partition.getChildCount( Strings.getUUID( 1L ) ) );
 
-        Cursor<IndexEntry<Long, Long>> cursor = partition.list( 2L );
+        Cursor<IndexEntry<String, String>> cursor = partition.list( Strings.getUUID( 2L ) );
         assertNotNull( cursor );
         cursor.beforeFirst();
         assertTrue( cursor.next() );
-        assertEquals( 6L, ( long ) cursor.get().getId() );
+        assertEquals( Strings.getUUID( 6L ), cursor.get().getId() );
         assertTrue( cursor.next() );
-        assertEquals( 5L, ( long ) cursor.get().getId() );
+        assertEquals( Strings.getUUID( 5L ), cursor.get().getId() );
         assertFalse( cursor.next() );
-        
-        assertEquals( 3, partition.getChildCount( 1L ) );
 
-        partition.delete( 2L );
+        assertEquals( 3, partition.getChildCount( Strings.getUUID( 1L ) ) );
 
-        assertEquals( 2, partition.getChildCount( 1L ) );
+        partition.delete( Strings.getUUID( 2L ) );
+
+        assertEquals( 2, partition.getChildCount( Strings.getUUID( 1L ) ) );
         assertEquals( 10, partition.count() );
 
         // add an alias and delete to test dropAliasIndices method
         Dn dn = new Dn( schemaManager, "commonName=Jack Daniels,ou=Apache,ou=Board of Directors,o=Good Times Co." );
         DefaultEntry entry = new DefaultEntry( schemaManager, dn,
-            "objectClass: top", 
-            "objectClass: alias", 
+            "objectClass: top",
+            "objectClass: alias",
             "objectClass: extensibleObject",
             "ou: Apache",
             "commonName: Jack Daniels",
             "aliasedObjectName: cn=Jack Daniels,ou=Engineering,o=Good Times Co.",
             "entryCSN", new CsnFactory( 1 ).newInstance().toString(),
-            "entryUUID", UUID.randomUUID().toString() );
+            "entryUUID", Strings.getUUID( 12 ).toString() );
 
         AddOperationContext addContext = new AddOperationContext( null, entry );
         partition.add( addContext );
 
-        partition.delete( 12L );
+        partition.delete( Strings.getUUID( 12L ) );
         cursor.close();
     }
 
@@ -500,7 +499,7 @@ public class AvlPartitionTest
         partition.rename( dn, rdn, true, null );
 
         Dn dn2 = new Dn( schemaManager, "sn=Ja\\+es,ou=Engineering,o=Good Times Co." );
-        Long id = partition.getEntryId( dn2 );
+        String id = partition.getEntryId( dn2 );
         assertNotNull( id );
         Entry entry2 = partition.lookup( id );
         assertEquals( "Ja+es", entry2.get( "sn" ).getString() );
@@ -513,8 +512,8 @@ public class AvlPartitionTest
     {
         Dn childDn = new Dn( schemaManager, "cn=Private Ryan,ou=Engineering,o=Good Times Co." );
         DefaultEntry childEntry = new DefaultEntry( schemaManager, childDn,
-            "objectClass: top", 
-            "objectClass: person", 
+            "objectClass: top",
+            "objectClass: person",
             "objectClass: organizationalPerson",
             "ou: Engineering",
             "cn", "Private Ryan",

Modified: directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlRdnIndexTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlRdnIndexTest.java?rev=1389184&r1=1389183&r2=1389184&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlRdnIndexTest.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlRdnIndexTest.java Mon Sep 24 02:17:13 2012
@@ -33,12 +33,14 @@ import org.apache.directory.server.xdbm.
 import org.apache.directory.server.xdbm.IndexEntry;
 import org.apache.directory.server.xdbm.ParentIdAndRdn;
 import org.apache.directory.shared.ldap.model.cursor.Cursor;
+import org.apache.directory.shared.ldap.model.entry.Entry;
 import org.apache.directory.shared.ldap.model.name.Rdn;
 import org.apache.directory.shared.ldap.model.schema.SchemaManager;
 import org.apache.directory.shared.ldap.schemaextractor.SchemaLdifExtractor;
 import org.apache.directory.shared.ldap.schemaextractor.impl.DefaultSchemaLdifExtractor;
 import org.apache.directory.shared.ldap.schemaloader.LdifSchemaLoader;
 import org.apache.directory.shared.ldap.schemamanager.impl.DefaultSchemaManager;
+import org.apache.directory.shared.util.Strings;
 import org.apache.directory.shared.util.exception.Exceptions;
 import org.junit.After;
 import org.junit.Before;
@@ -55,7 +57,7 @@ import org.junit.Test;
 public class AvlRdnIndexTest
 {
     private static File dbFileDir;
-    Index<ParentIdAndRdn<Long>, Long, Long> idx;
+    Index<ParentIdAndRdn, Entry, String> idx;
     private static SchemaManager schemaManager;
 
 
@@ -186,23 +188,23 @@ public class AvlRdnIndexTest
         initIndex();
         assertEquals( 0, idx.count() );
 
-        ParentIdAndRdn<Long> key = new ParentIdAndRdn<Long>( 0L, new Rdn( "cn=key" ) );
+        ParentIdAndRdn key = new ParentIdAndRdn( Strings.getUUID( 0L ), new Rdn( "cn=key" ) );
 
-        idx.add( key, 0l );
+        idx.add( key, Strings.getUUID( 0L ) );
         assertEquals( 1, idx.count() );
 
         // setting a different parentId should make this key a different key
-        key = new ParentIdAndRdn<Long>( 1L, new Rdn( "cn=key" ) );
+        key = new ParentIdAndRdn( Strings.getUUID( 1L ), new Rdn( "cn=key" ) );
 
-        idx.add( key, 1l );
+        idx.add( key, Strings.getUUID( 1L ) );
         assertEquals( 2, idx.count() );
 
         //count shouldn't get affected cause of inserting the same key
-        idx.add( key, 2l );
+        idx.add( key, Strings.getUUID( 2L ) );
         assertEquals( 2, idx.count() );
 
-        key = new ParentIdAndRdn<Long>( 2L, new Rdn( "cn=key" ) );
-        idx.add( key, 3l );
+        key = new ParentIdAndRdn( Strings.getUUID( 2L ), new Rdn( "cn=key" ) );
+        idx.add( key, Strings.getUUID( 3L ) );
         assertEquals( 3, idx.count() );
     }
 
@@ -212,11 +214,11 @@ public class AvlRdnIndexTest
     {
         initIndex();
 
-        ParentIdAndRdn<Long> key = new ParentIdAndRdn<Long>( 0L, new Rdn( "cn=key" ) );
+        ParentIdAndRdn key = new ParentIdAndRdn( Strings.getUUID( 0L ), new Rdn( "cn=key" ) );
 
         assertEquals( 0, idx.count( key ) );
 
-        idx.add( key, 0l );
+        idx.add( key, Strings.getUUID( 0L ) );
         assertEquals( 1, idx.count( key ) );
     }
 
@@ -230,13 +232,13 @@ public class AvlRdnIndexTest
     {
         initIndex();
 
-        ParentIdAndRdn<Long> key = new ParentIdAndRdn<Long>( 0L, new Rdn( "cn=key" ) );
+        ParentIdAndRdn key = new ParentIdAndRdn( Strings.getUUID( 0L ), new Rdn( "cn=key" ) );
 
         assertNull( idx.forwardLookup( key ) );
 
-        idx.add( key, 0l );
-        assertEquals( 0, ( long ) idx.forwardLookup( key ) );
-        assertEquals( key, idx.reverseLookup( 0l ) );
+        idx.add( key, Strings.getUUID( 0L ) );
+        assertEquals( Strings.getUUID( 0L ), idx.forwardLookup( key ) );
+        assertEquals( key, idx.reverseLookup( Strings.getUUID( 0L ) ) );
     }
 
 
@@ -245,17 +247,17 @@ public class AvlRdnIndexTest
     {
         initIndex();
 
-        ParentIdAndRdn<Long> key = new ParentIdAndRdn<Long>( 0L, new Rdn( "cn=key" ) );
+        ParentIdAndRdn key = new ParentIdAndRdn( Strings.getUUID( 0L ), new Rdn( "cn=key" ) );
 
         assertNull( idx.forwardLookup( key ) );
 
         // test add/drop without adding any duplicates
-        idx.add( key, 0l );
-        assertEquals( 0, ( long ) idx.forwardLookup( key ) );
+        idx.add( key, Strings.getUUID( 0L ) );
+        assertEquals( Strings.getUUID( 0L ), idx.forwardLookup( key ) );
 
-        idx.drop( key, 0l );
+        idx.drop( key, Strings.getUUID( 0L ) );
         assertNull( idx.forwardLookup( key ) );
-        assertNull( idx.reverseLookup( 0l ) );
+        assertNull( idx.reverseLookup( Strings.getUUID( 0L ) ) );
     }
 
 
@@ -268,43 +270,43 @@ public class AvlRdnIndexTest
     {
         initIndex();
 
-        ParentIdAndRdn<Long> key = new ParentIdAndRdn<Long>( 0L, new Rdn( "cn=key" ) );
+        ParentIdAndRdn key = new ParentIdAndRdn( Strings.getUUID( 0L ), new Rdn( "cn=key" ) );
 
         assertEquals( 0, idx.count() );
 
-        idx.add( key, 0l );
+        idx.add( key, Strings.getUUID( 0L ) );
         assertEquals( 1, idx.count() );
 
         for ( long i = 1; i < 5; i++ )
         {
-            key = new ParentIdAndRdn<Long>( i, new Rdn( "cn=key" + i ) );
+            key = new ParentIdAndRdn( Strings.getUUID( i ), new Rdn( "cn=key" + i ) );
 
-            idx.add( key, ( long ) i );
+            idx.add( key, Strings.getUUID( i ) );
         }
 
         assertEquals( 5, idx.count() );
 
         // use forward index's cursor
-        Cursor<IndexEntry<ParentIdAndRdn<Long>, Long>> cursor = idx.forwardCursor();
+        Cursor<IndexEntry<ParentIdAndRdn, String>> cursor = idx.forwardCursor();
         cursor.beforeFirst();
 
         cursor.next();
-        IndexEntry<ParentIdAndRdn<Long>, Long> e1 = cursor.get();
-        assertEquals( 0, ( long ) e1.getId() );
+        IndexEntry<ParentIdAndRdn, String> e1 = cursor.get();
+        assertEquals( Strings.getUUID( 0L ), e1.getId() );
         assertEquals( "cn=key", e1.getKey().getRdns()[0].getName() );
-        assertEquals( 0, e1.getKey().getParentId().longValue() );
+        assertEquals( Strings.getUUID( 0L ), e1.getKey().getParentId() );
 
         cursor.next();
-        IndexEntry<ParentIdAndRdn<Long>, Long> e2 = cursor.get();
-        assertEquals( 1, ( long ) e2.getId() );
+        IndexEntry<ParentIdAndRdn, String> e2 = cursor.get();
+        assertEquals( Strings.getUUID( 1L ), e2.getId() );
         assertEquals( "cn=key1", e2.getKey().getRdns()[0].getName() );
-        assertEquals( 1, e2.getKey().getParentId().longValue() );
+        assertEquals( Strings.getUUID( 1L ), e2.getKey().getParentId() );
 
         cursor.next();
-        IndexEntry<ParentIdAndRdn<Long>, Long> e3 = cursor.get();
-        assertEquals( 2, ( long ) e3.getId() );
+        IndexEntry<ParentIdAndRdn, String> e3 = cursor.get();
+        assertEquals( Strings.getUUID( 2L ), e3.getId() );
         assertEquals( "cn=key2", e3.getKey().getRdns()[0].getName() );
-        assertEquals( 2, e3.getKey().getParentId().longValue() );
+        assertEquals( Strings.getUUID( 2L ), e3.getKey().getParentId() );
 
         cursor.close();
     }

Added: directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/AbstractCursorTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/AbstractCursorTest.java?rev=1389184&view=auto
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/AbstractCursorTest.java (added)
+++ directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/AbstractCursorTest.java Mon Sep 24 02:17:13 2012
@@ -0,0 +1,110 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.xdbm.search.impl;
+
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.directory.server.core.api.filtering.BaseEntryFilteringCursor;
+import org.apache.directory.server.core.api.interceptor.context.SearchOperationContext;
+import org.apache.directory.server.core.api.interceptor.context.SearchingOperationContext;
+import org.apache.directory.server.core.partition.impl.btree.AbstractBTreePartition;
+import org.apache.directory.server.core.partition.impl.btree.EntryCursorAdaptor;
+import org.apache.directory.server.core.partition.impl.btree.IndexCursorAdaptor;
+import org.apache.directory.server.xdbm.IndexEntry;
+import org.apache.directory.server.xdbm.Store;
+import org.apache.directory.server.xdbm.search.Evaluator;
+import org.apache.directory.server.xdbm.search.PartitionSearchResult;
+import org.apache.directory.shared.ldap.model.cursor.Cursor;
+import org.apache.directory.shared.ldap.model.entry.Entry;
+import org.apache.directory.shared.ldap.model.filter.ExprNode;
+import org.apache.directory.shared.ldap.model.schema.SchemaManager;
+
+
+/**
+ * A class containing common method and fields for Cursor tests.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class AbstractCursorTest
+{
+    protected EvaluatorBuilder evaluatorBuilder;
+    protected CursorBuilder cursorBuilder;
+    protected Store store;
+    protected static SchemaManager schemaManager;
+
+
+    /**
+     * Creates a cursor from a filter
+     * 
+     * @param root The filter we are using for the cursor construction
+     * @return The constructed cursor
+     * @throws Exception If anything went wrong
+     */
+    protected Cursor<Entry> buildCursor( ExprNode root ) throws Exception
+    {
+        Evaluator<? extends ExprNode> evaluator = evaluatorBuilder.build( root );
+
+        PartitionSearchResult searchResult = new PartitionSearchResult( schemaManager );
+        Set<IndexEntry<String, String>> resultSet = new HashSet<IndexEntry<String, String>>();
+
+        Set<String> uuids = new HashSet<String>();
+        searchResult.setCandidateSet( uuids );
+
+        long candidates = cursorBuilder.build( root, searchResult );
+
+        if ( candidates < Long.MAX_VALUE )
+        {
+            for ( String uuid : uuids )
+            {
+                IndexEntry<String, String> indexEntry = new IndexEntry<String, String>();
+                indexEntry.setId( uuid );
+                resultSet.add( indexEntry );
+            }
+        }
+        else
+        {
+            // Full scan : use the MasterTable
+            Cursor<IndexEntry<String, String>> cursor = new IndexCursorAdaptor( store.getMasterTable().cursor(), true );
+
+            while ( cursor.next() )
+            {
+                IndexEntry<String, String> indexEntry = cursor.get();
+
+                // Here, the indexEntry contains a <UUID, Entry> tuple. Convert it to <UUID, UUID> 
+                IndexEntry<String, String> forwardIndexEntry = new IndexEntry<String, String>();
+                forwardIndexEntry.setKey( indexEntry.getKey() );
+                forwardIndexEntry.setId( indexEntry.getKey() );
+                forwardIndexEntry.setEntry( indexEntry.getEntry() );
+
+                resultSet.add( forwardIndexEntry );
+            }
+        }
+
+        searchResult.setResultSet( resultSet );
+        searchResult.setEvaluator( evaluator );
+
+        SearchingOperationContext operationContext = new SearchOperationContext( null );
+
+        return new BaseEntryFilteringCursor( new EntryCursorAdaptor( ( AbstractBTreePartition ) store, searchResult ),
+            operationContext );
+    }
+}

Modified: directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/AndCursorTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/AndCursorTest.java?rev=1389184&r1=1389183&r2=1389184&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/AndCursorTest.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/AndCursorTest.java Mon Sep 24 02:17:13 2012
@@ -26,32 +26,24 @@ import static org.junit.Assert.assertTru
 import static org.junit.Assert.fail;
 
 import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.directory.server.core.api.partition.Partition;
 import org.apache.directory.server.core.partition.impl.avl.AvlPartition;
-import org.apache.directory.server.xdbm.ForwardIndexEntry;
-import org.apache.directory.server.xdbm.IndexCursor;
-import org.apache.directory.server.xdbm.Store;
 import org.apache.directory.server.xdbm.StoreUtils;
 import org.apache.directory.server.xdbm.impl.avl.AvlIndex;
-import org.apache.directory.server.xdbm.search.Evaluator;
 import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.model.cursor.Cursor;
 import org.apache.directory.shared.ldap.model.cursor.InvalidCursorPositionException;
 import org.apache.directory.shared.ldap.model.entry.Entry;
-import org.apache.directory.shared.ldap.model.filter.AndNode;
 import org.apache.directory.shared.ldap.model.filter.ExprNode;
 import org.apache.directory.shared.ldap.model.filter.FilterParser;
-import org.apache.directory.shared.ldap.model.filter.PresenceNode;
-import org.apache.directory.shared.ldap.model.filter.SubstringNode;
 import org.apache.directory.shared.ldap.model.name.Dn;
-import org.apache.directory.shared.ldap.model.schema.SchemaManager;
 import org.apache.directory.shared.ldap.schemaextractor.SchemaLdifExtractor;
 import org.apache.directory.shared.ldap.schemaextractor.impl.DefaultSchemaLdifExtractor;
 import org.apache.directory.shared.ldap.schemaloader.LdifSchemaLoader;
 import org.apache.directory.shared.ldap.schemamanager.impl.DefaultSchemaManager;
+import org.apache.directory.shared.util.Strings;
 import org.apache.directory.shared.util.exception.Exceptions;
 import org.junit.After;
 import org.junit.Before;
@@ -67,15 +59,11 @@ import org.slf4j.LoggerFactory;
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class AndCursorTest
+public class AndCursorTest extends AbstractCursorTest
 {
     private static final Logger LOG = LoggerFactory.getLogger( AndCursorTest.class.getSimpleName() );
 
     File wkdir;
-    Store<Entry, Long> store;
-    EvaluatorBuilder evaluatorBuilder;
-    CursorBuilder cursorBuilder;
-    private static SchemaManager schemaManager;
 
 
     @BeforeClass
@@ -175,24 +163,27 @@ public class AndCursorTest
 
         ExprNode exprNode = FilterParser.parse( schemaManager, filter );
 
-        IndexCursor<?, Entry, Long> cursor = cursorBuilder.build( exprNode );
+        Cursor<Entry> cursor = buildCursor( exprNode );
 
         cursor.beforeFirst();
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
-        assertEquals( 8, ( long ) cursor.get().getId() );
-        assertEquals( "jack daniels", cursor.get().getKey() );
+        Entry entry = cursor.get();
+        assertEquals( Strings.getUUID( 5 ), entry.get( "entryUUID" ).getString() );
+        assertEquals( "JOhnny WAlkeR", entry.get( "cn" ).getString() );
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
-        assertEquals( 6, ( long ) cursor.get().getId() );
-        assertEquals( "jim bean", cursor.get().getKey() );
+        entry = cursor.get();
+        assertEquals( Strings.getUUID( 6 ), entry.get( "entryUUID" ).getString() );
+        assertEquals( "JIM BEAN", entry.get( "cn" ).getString() );
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
-        assertEquals( 5, ( long ) cursor.get().getId() );
-        assertEquals( "johnny walker", cursor.get().getKey() );
+        entry = cursor.get();
+        assertEquals( Strings.getUUID( 8 ), entry.get( "entryUUID" ).getString() );
+        assertEquals( "Jack Daniels", entry.get( "cn" ).getString() );
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
@@ -205,47 +196,31 @@ public class AndCursorTest
     @Test
     public void testAndCursorWithManualFilter() throws Exception
     {
-        AndNode andNode = new AndNode();
+        ExprNode exprNode = FilterParser.parse( schemaManager, "(&(cn=J*)(sn=*))" );
 
-        List<Evaluator<? extends ExprNode, Entry, Long>> evaluators = new ArrayList<Evaluator<? extends ExprNode, Entry, Long>>();
-        Evaluator<? extends ExprNode, Entry, Long> eval;
-
-        ExprNode exprNode = new SubstringNode( schemaManager.getAttributeType( "cn" ), "J", null );
-        eval = new SubstringEvaluator( ( SubstringNode ) exprNode, store, schemaManager );
-        IndexCursor<?, Entry, Long> wrapped = new SubstringCursor( store, ( SubstringEvaluator ) eval );
-
-        /* adding this results in NPE  adding Presence evaluator not 
-         Substring evaluator but adding Substring cursor as wrapped cursor */
-        // evaluators.add( eval ); 
-
-        andNode.addNode( exprNode );
-
-        exprNode = new PresenceNode( schemaManager.getAttributeType( "sn" ) );
-        eval = new PresenceEvaluator( ( PresenceNode ) exprNode, store, schemaManager );
-        evaluators.add( eval );
-
-        andNode.addNode( exprNode );
-
-        IndexCursor<?, Entry, Long> cursor = new AndCursor( wrapped, evaluators ); //cursorBuilder.build( andNode );
+        Cursor<Entry> cursor = buildCursor( exprNode );
 
         cursor.beforeFirst();
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
-        assertEquals( 8, ( long ) cursor.get().getId() );
-        assertEquals( "jack daniels", cursor.get().getKey() );
+        Entry entry = cursor.get();
+        assertEquals( Strings.getUUID( 5 ), entry.get( "entryUUID" ).getString() );
+        assertEquals( "JOhnny WAlkeR", entry.get( "cn" ).getString() );
 
         cursor.first();
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
-        assertEquals( 6, ( long ) cursor.get().getId() );
-        assertEquals( "jim bean", cursor.get().getKey() );
+        entry = cursor.get();
+        assertEquals( Strings.getUUID( 6 ), entry.get( "entryUUID" ).getString() );
+        assertEquals( "JIM BEAN", entry.get( "cn" ).getString() );
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
-        assertEquals( 5, ( long ) cursor.get().getId() );
-        assertEquals( "johnny walker", cursor.get().getKey() );
+        entry = cursor.get();
+        assertEquals( Strings.getUUID( 8 ), entry.get( "entryUUID" ).getString() );
+        assertEquals( "Jack Daniels", entry.get( "cn" ).getString() );
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
@@ -254,20 +229,23 @@ public class AndCursorTest
 
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
-        assertEquals( 5, ( long ) cursor.get().getId() );
-        assertEquals( "johnny walker", cursor.get().getKey() );
+        entry = cursor.get();
+        assertEquals( Strings.getUUID( 8 ), entry.get( "entryUUID" ).getString() );
+        assertEquals( "Jack Daniels", entry.get( "cn" ).getString() );
 
         cursor.last();
 
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
-        assertEquals( 6, ( long ) cursor.get().getId() );
-        assertEquals( "jim bean", cursor.get().getKey() );
+        entry = cursor.get();
+        assertEquals( Strings.getUUID( 6 ), entry.get( "entryUUID" ).getString() );
+        assertEquals( "JIM BEAN", entry.get( "cn" ).getString() );
 
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
-        assertEquals( 8, ( long ) cursor.get().getId() );
-        assertEquals( "jack daniels", cursor.get().getKey() );
+        entry = cursor.get();
+        assertEquals( Strings.getUUID( 5 ), entry.get( "entryUUID" ).getString() );
+        assertEquals( "JOhnny WAlkeR", entry.get( "cn" ).getString() );
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
@@ -281,26 +259,7 @@ public class AndCursorTest
         {
         }
 
-        try
-        {
-            cursor.after( new ForwardIndexEntry() );
-            fail( "should fail with UnsupportedOperationException " );
-        }
-        catch ( UnsupportedOperationException uoe )
-        {
-        }
-
-        try
-        {
-            cursor.before( new ForwardIndexEntry() );
-            fail( "should fail with UnsupportedOperationException " );
-        }
-        catch ( UnsupportedOperationException uoe )
-        {
-        }
-
         cursor.close();
-        wrapped.close();
+        assertTrue( cursor.isClosed() );
     }
-
 }

Added: directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/EqualityTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/EqualityTest.java?rev=1389184&view=auto
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/EqualityTest.java (added)
+++ directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/EqualityTest.java Mon Sep 24 02:17:13 2012
@@ -0,0 +1,542 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.xdbm.search.impl;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+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.api.partition.Partition;
+import org.apache.directory.server.core.partition.impl.avl.AvlPartition;
+import org.apache.directory.server.xdbm.IndexEntry;
+import org.apache.directory.server.xdbm.Store;
+import org.apache.directory.server.xdbm.StoreUtils;
+import org.apache.directory.server.xdbm.impl.avl.AvlIndex;
+import org.apache.directory.server.xdbm.search.cursor.EqualityCursor;
+import org.apache.directory.server.xdbm.search.cursor.PresenceCursor;
+import org.apache.directory.server.xdbm.search.evaluator.EqualityEvaluator;
+import org.apache.directory.server.xdbm.search.evaluator.PresenceEvaluator;
+import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.model.cursor.InvalidCursorPositionException;
+import org.apache.directory.shared.ldap.model.entry.StringValue;
+import org.apache.directory.shared.ldap.model.filter.EqualityNode;
+import org.apache.directory.shared.ldap.model.filter.PresenceNode;
+import org.apache.directory.shared.ldap.model.name.Dn;
+import org.apache.directory.shared.ldap.model.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schemaextractor.SchemaLdifExtractor;
+import org.apache.directory.shared.ldap.schemaextractor.impl.DefaultSchemaLdifExtractor;
+import org.apache.directory.shared.ldap.schemaloader.LdifSchemaLoader;
+import org.apache.directory.shared.ldap.schemamanager.impl.DefaultSchemaManager;
+import org.apache.directory.shared.util.Strings;
+import org.apache.directory.shared.util.exception.Exceptions;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * Tests EqualityCursor functionality.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class EqualityTest
+{
+    private static final Logger LOG = LoggerFactory.getLogger( EqualityTest.class.getSimpleName() );
+
+    File wkdir;
+    Store store;
+    static SchemaManager schemaManager = null;
+
+
+    @BeforeClass
+    public static void setup() throws Exception
+    {
+        String workingDirectory = System.getProperty( "workingDirectory" );
+
+        if ( workingDirectory == null )
+        {
+            String path = EqualityTest.class.getResource( "" ).getPath();
+            int targetPos = path.indexOf( "target" );
+            workingDirectory = path.substring( 0, targetPos + 6 );
+        }
+
+        File schemaRepository = new File( workingDirectory, "schema" );
+        SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor( new File( workingDirectory ) );
+        extractor.extractOrCopy( true );
+        LdifSchemaLoader loader = new LdifSchemaLoader( schemaRepository );
+        schemaManager = new DefaultSchemaManager( loader );
+
+        boolean loaded = schemaManager.loadAllEnabled();
+
+        if ( !loaded )
+        {
+            fail( "Schema load failed : " + Exceptions.printErrors( schemaManager.getErrors() ) );
+        }
+
+        loaded = schemaManager.loadWithDeps( loader.getSchema( "collective" ) );
+
+        if ( !loaded )
+        {
+            fail( "Schema load failed : " + Exceptions.printErrors( schemaManager.getErrors() ) );
+        }
+    }
+
+
+    @Before
+    public void createStore() throws Exception
+    {
+        // setup the working directory for the store
+        wkdir = File.createTempFile( getClass().getSimpleName(), "db" );
+        wkdir.delete();
+        wkdir = new File( wkdir.getParentFile(), getClass().getSimpleName() );
+        wkdir.mkdirs();
+
+        // initialize the store
+        store = new AvlPartition( schemaManager );
+        ( ( Partition ) store ).setId( "example" );
+        store.setCacheSize( 10 );
+        store.setPartitionPath( wkdir.toURI() );
+        store.setSyncOnWrite( false );
+
+        store.addIndex( new AvlIndex( SchemaConstants.OU_AT_OID ) );
+        store.addIndex( new AvlIndex( SchemaConstants.CN_AT_OID ) );
+        ( ( Partition ) store ).setSuffixDn( new Dn( schemaManager, "o=Good Times Co." ) );
+        ( ( Partition ) store ).initialize();
+
+        ( ( Partition ) store ).initialize();
+
+        StoreUtils.loadExampleData( store, schemaManager );
+
+        LOG.debug( "Created new store" );
+    }
+
+
+    @After
+    public void destroyStore() throws Exception
+    {
+        if ( store != null )
+        {
+            ( ( Partition ) store ).destroy();
+        }
+
+        store = null;
+        if ( wkdir != null )
+        {
+            FileUtils.deleteDirectory( wkdir );
+        }
+
+        wkdir = null;
+    }
+
+
+    @Test
+    public void testIndexedServerEntry() throws Exception
+    {
+        EqualityNode<String> node = new EqualityNode<String>( schemaManager.getAttributeType( "cn" ), new StringValue(
+            "JOhnny WAlkeR" ) );
+        EqualityEvaluator<String> evaluator = new EqualityEvaluator<String>( node, store, schemaManager );
+        EqualityCursor<String> cursor = new EqualityCursor<String>( store, evaluator );
+
+        assertEquals( node, evaluator.getExpression() );
+
+        // We should find two candidates :
+        // cn=JOhnny WAlkeR,ou=Sales,o=Good Times Co.
+        // cn=Johnny Walker,ou=Engineering,o=Good Times Co.
+        cursor.beforeFirst();
+        assertTrue( cursor.next() );
+        assertTrue( cursor.available() );
+        assertEquals( Strings.getUUID( 5 ), cursor.get().getId() );
+        assertTrue( cursor.next() );
+        assertTrue( cursor.available() );
+        assertEquals( Strings.getUUID( 11 ), cursor.get().getId() );
+        assertFalse( cursor.next() );
+        assertFalse( cursor.available() );
+
+        // test first()
+        cursor.first();
+        assertTrue( cursor.available() );
+        assertEquals( "JOhnny WAlkeR", cursor.get().getKey() );
+
+        // test last()
+        cursor.last();
+        assertTrue( cursor.available() );
+        assertEquals( "JOhnny WAlkeR", cursor.get().getKey() );
+
+        // test beforeFirst()
+        cursor.beforeFirst();
+        assertFalse( cursor.available() );
+        assertTrue( cursor.next() );
+        assertTrue( cursor.available() );
+        assertEquals( "JOhnny WAlkeR", cursor.get().getKey() );
+
+        // test afterLast()
+        cursor.afterLast();
+        assertFalse( cursor.available() );
+        assertTrue( cursor.previous() );
+        assertTrue( cursor.available() );
+        assertEquals( "JOhnny WAlkeR", cursor.get().getKey() );
+
+        // test before()
+        IndexEntry<String, String> entry = new IndexEntry<String, String>();
+        entry.setKey( "JOhnny WAlkeR" );
+        cursor.before( entry );
+        assertTrue( cursor.next() );
+        assertTrue( cursor.available() );
+        assertEquals( "JOhnny WAlkeR", cursor.get().getKey() );
+
+        // test after()
+        entry = new IndexEntry<String, String>();
+        cursor.after( entry );
+        assertTrue( cursor.previous() );
+        assertTrue( cursor.available() );
+        assertEquals( "JOhnny WAlkeR", cursor.get().getKey() );
+        cursor.close();
+
+        assertTrue( cursor.isClosed() );
+    }
+
+
+    @Test
+    public void testEntryUUID() throws Exception
+    {
+        EqualityNode<String> node = new EqualityNode<String>( schemaManager.getAttributeType( "entryUuid" ),
+            new StringValue( "00000000-0000-0000-0000-000000000005" ) );
+        EqualityEvaluator<String> evaluator = new EqualityEvaluator<String>( node, store, schemaManager );
+        EqualityCursor<String> cursor = new EqualityCursor<String>( store, evaluator );
+
+        assertEquals( node, evaluator.getExpression() );
+
+        // We should find one candidate :
+        // cn=JOhnny WAlkeR,ou=Sales,o=Good Times Co.
+        cursor.beforeFirst();
+        assertTrue( cursor.next() );
+        assertTrue( cursor.available() );
+        assertEquals( Strings.getUUID( 5 ), cursor.get().getId() );
+        assertFalse( cursor.next() );
+        assertFalse( cursor.available() );
+
+        // test first()
+        cursor.first();
+        assertTrue( cursor.available() );
+        assertEquals( "00000000-0000-0000-0000-000000000005", cursor.get().getKey() );
+
+        cursor.close();
+
+        assertTrue( cursor.isClosed() );
+    }
+
+
+    @Test
+    public void testSystemIndexedServerEntry() throws Exception
+    {
+        testSystemIndexedServerEntry( SchemaConstants.OBJECT_CLASS_AT_OID );
+        testSystemIndexedServerEntry( SchemaConstants.ENTRY_UUID_AT_OID );
+        testSystemIndexedServerEntry( SchemaConstants.ENTRY_CSN_AT_OID );
+    }
+
+
+    public void testSystemIndexedServerEntry( String oid ) throws Exception
+    {
+        PresenceNode node = new PresenceNode( schemaManager.getAttributeType( oid ) );
+        PresenceEvaluator evaluator = new PresenceEvaluator( node, store, schemaManager );
+        PresenceCursor cursor = new PresenceCursor( store, evaluator );
+
+        assertEquals( node, evaluator.getExpression() );
+
+        cursor.beforeFirst();
+
+        List<String> ids = new ArrayList<String>();
+
+        while ( cursor.next() && cursor.available() )
+        {
+            ids.add( cursor.get().getId() );
+        }
+
+        assertEquals( 11, ids.size() );
+        assertFalse( cursor.next() );
+        assertFalse( cursor.available() );
+
+        cursor.close();
+    }
+
+
+    @Test
+    public void testNonIndexedServerEntry() throws Exception
+    {
+        PresenceNode node = new PresenceNode( schemaManager.getAttributeType( "sn" ) );
+        PresenceEvaluator evaluator = new PresenceEvaluator( node, store, schemaManager );
+        PresenceCursor cursor = new PresenceCursor( store, evaluator );
+
+        assertEquals( node, evaluator.getExpression() );
+
+        cursor.beforeFirst();
+
+        Set<String> set = new HashSet<String>();
+
+        while ( cursor.next() )
+        {
+            assertTrue( cursor.available() );
+            assertEquals( SchemaConstants.SN_AT_OID, cursor.get().getKey() );
+            set.add( cursor.get().getId() );
+        }
+
+        assertEquals( 3, set.size() );
+        assertTrue( set.contains( Strings.getUUID( 5L ) ) );
+        assertTrue( set.contains( Strings.getUUID( 6L ) ) );
+        assertTrue( set.contains( Strings.getUUID( 8L ) ) );
+
+        assertFalse( cursor.next() );
+        assertFalse( cursor.available() );
+
+        // test first()
+        cursor.first();
+        assertTrue( cursor.available() );
+        assertEquals( SchemaConstants.SN_AT_OID, cursor.get().getKey() );
+
+        // test last()
+        cursor.last();
+        assertTrue( cursor.available() );
+        assertEquals( SchemaConstants.SN_AT_OID, cursor.get().getKey() );
+
+        // test beforeFirst()
+        cursor.beforeFirst();
+        assertFalse( cursor.available() );
+        assertTrue( cursor.next() );
+        assertTrue( cursor.available() );
+        assertEquals( SchemaConstants.SN_AT_OID, cursor.get().getKey() );
+
+        // test afterLast()
+        set.clear();
+        cursor.afterLast();
+        assertFalse( cursor.available() );
+
+        while ( cursor.previous() )
+        {
+            assertTrue( cursor.available() );
+            assertEquals( SchemaConstants.SN_AT_OID, cursor.get().getKey() );
+            set.add( cursor.get().getId() );
+        }
+
+        assertEquals( 3, set.size() );
+        assertTrue( set.contains( Strings.getUUID( 5L ) ) );
+        assertTrue( set.contains( Strings.getUUID( 6L ) ) );
+        assertTrue( set.contains( Strings.getUUID( 8L ) ) );
+
+        assertFalse( cursor.previous() );
+        assertFalse( cursor.available() );
+
+        cursor.close();
+
+        // ----------- organizationName attribute
+
+        node = new PresenceNode( schemaManager.getAttributeType( "o" ) );
+        evaluator = new PresenceEvaluator( node, store, schemaManager );
+        cursor = new PresenceCursor( store, evaluator );
+
+        cursor.beforeFirst();
+        assertTrue( cursor.next() );
+        assertTrue( cursor.available() );
+        assertEquals( Strings.getUUID( 1 ), cursor.get().getId() );
+        assertFalse( cursor.next() );
+        assertFalse( cursor.available() );
+
+        assertFalse( cursor.isClosed() );
+        cursor.close();
+        assertTrue( cursor.isClosed() );
+    }
+
+
+    @Test
+    public void testEvaluatorIndexed() throws Exception
+    {
+        PresenceNode node = new PresenceNode( schemaManager.getAttributeType( "cn" ) );
+        PresenceEvaluator evaluator = new PresenceEvaluator( node, store, schemaManager );
+        IndexEntry<String, String> entry = new IndexEntry<String, String>();
+        entry.setKey( SchemaConstants.CN_AT_OID );
+        entry.setId( Strings.getUUID( 3L ) );
+        assertFalse( evaluator.evaluate( entry ) );
+        entry = new IndexEntry<String, String>();
+        entry.setKey( SchemaConstants.CN_AT_OID );
+        entry.setId( Strings.getUUID( 5 ) );
+        assertTrue( evaluator.evaluate( entry ) );
+    }
+
+
+    @Test
+    public void testEvaluatorSystemIndexed() throws Exception
+    {
+        testEvaluatorSystemIndexed( SchemaConstants.OBJECT_CLASS_AT_OID );
+        testEvaluatorSystemIndexed( SchemaConstants.ENTRY_UUID_AT_OID );
+        testEvaluatorSystemIndexed( SchemaConstants.ENTRY_CSN_AT_OID );
+    }
+
+
+    private void testEvaluatorSystemIndexed( String oid ) throws Exception
+    {
+        PresenceNode node = new PresenceNode( schemaManager.getAttributeType( oid ) );
+        PresenceEvaluator evaluator = new PresenceEvaluator( node, store, schemaManager );
+
+        IndexEntry<String, String> entry = new IndexEntry<String, String>();
+        // no need to set a value or id, because the evaluator must always evaluate to true
+        // as each entry contains an objectClass, entryUUID, and entryCSN attribute
+        assertFalse( evaluator.evaluate( entry ) );
+
+        entry = new IndexEntry<String, String>();
+        entry.setKey( oid );
+        entry.setId( Strings.getUUID( 5 ) );
+        assertTrue( evaluator.evaluate( entry ) );
+    }
+
+
+    @Test
+    public void testEvaluatorNotIndexed() throws Exception
+    {
+        PresenceNode node = new PresenceNode( schemaManager.getAttributeType( "name" ) );
+        PresenceEvaluator evaluator = new PresenceEvaluator( node, store, schemaManager );
+        IndexEntry<String, String> entry = new IndexEntry<String, String>();
+        entry.setKey( SchemaConstants.NAME_AT_OID );
+        entry.setId( Strings.getUUID( 3 ) );
+        assertTrue( evaluator.evaluate( entry ) );
+        entry = new IndexEntry<String, String>();
+        entry.setKey( SchemaConstants.NAME_AT_OID );
+        entry.setId( Strings.getUUID( 5 ) );
+        assertTrue( evaluator.evaluate( entry ) );
+
+        node = new PresenceNode( schemaManager.getAttributeType( "searchGuide" ) );
+        evaluator = new PresenceEvaluator( node, store, schemaManager );
+        entry = new IndexEntry<String, String>();
+        entry.setKey( SchemaConstants.SEARCHGUIDE_AT_OID );
+        entry.setId( Strings.getUUID( 3 ) );
+        assertFalse( evaluator.evaluate( entry ) );
+        entry = new IndexEntry<String, String>();
+        entry.setKey( SchemaConstants.SEARCHGUIDE_AT_OID );
+        entry.setId( Strings.getUUID( 5 ) );
+        entry.setEntry( store.lookup( Strings.getUUID( 5 ) ) );
+        assertFalse( evaluator.evaluate( entry ) );
+
+        node = new PresenceNode( schemaManager.getAttributeType( "st" ) );
+        evaluator = new PresenceEvaluator( node, store, schemaManager );
+        entry = new IndexEntry<String, String>();
+        entry.setKey( SchemaConstants.ST_AT_OID );
+        entry.setId( Strings.getUUID( 3 ) );
+        assertFalse( evaluator.evaluate( entry ) );
+        entry = new IndexEntry<String, String>();
+        entry.setKey( SchemaConstants.ST_AT_OID );
+        entry.setId( Strings.getUUID( 5 ) );
+        entry.setEntry( store.lookup( Strings.getUUID( 5 ) ) );
+        assertFalse( evaluator.evaluate( entry ) );
+    }
+
+
+    @Test(expected = InvalidCursorPositionException.class)
+    public void testInvalidCursorPositionException() throws Exception
+    {
+        PresenceCursor cursor = null;
+
+        try
+        {
+            PresenceNode node = new PresenceNode( schemaManager.getAttributeType( "sn" ) );
+            PresenceEvaluator evaluator = new PresenceEvaluator( node, store, schemaManager );
+            cursor = new PresenceCursor( store, evaluator );
+            cursor.get();
+        }
+        finally
+        {
+            cursor.close();
+        }
+    }
+
+
+    @Test(expected = InvalidCursorPositionException.class)
+    public void testInvalidCursorPositionException2() throws Exception
+    {
+        PresenceCursor cursor = null;
+
+        try
+        {
+            PresenceNode node = new PresenceNode( schemaManager.getAttributeType( "cn" ) );
+            PresenceEvaluator evaluator = new PresenceEvaluator( node, store, schemaManager );
+            cursor = new PresenceCursor( store, evaluator );
+            cursor.get();
+        }
+        finally
+        {
+            cursor.close();
+        }
+    }
+
+
+    @Test(expected = UnsupportedOperationException.class)
+    public void testUnsupportBeforeWithoutIndex() throws Exception
+    {
+        PresenceCursor cursor = null;
+
+        try
+        {
+            PresenceNode node = new PresenceNode( schemaManager.getAttributeType( "sn" ) );
+            PresenceEvaluator evaluator = new PresenceEvaluator( node, store, schemaManager );
+            cursor = new PresenceCursor( store, evaluator );
+
+            // test before()
+            IndexEntry<String, String> entry = new IndexEntry<String, String>();
+            entry.setKey( SchemaConstants.SN_AT_OID );
+            cursor.before( entry );
+        }
+        finally
+        {
+            cursor.close();
+        }
+    }
+
+
+    @Test(expected = UnsupportedOperationException.class)
+    public void testUnsupportAfterWithoutIndex() throws Exception
+    {
+        PresenceCursor cursor = null;
+
+        try
+        {
+            PresenceNode node = new PresenceNode( schemaManager.getAttributeType( "sn" ) );
+            PresenceEvaluator evaluator = new PresenceEvaluator( node, store, schemaManager );
+            cursor = new PresenceCursor( store, evaluator );
+
+            // test before()
+            IndexEntry<String, String> entry = new IndexEntry<String, String>();
+            entry.setKey( SchemaConstants.SN_AT_OID );
+            cursor.after( entry );
+        }
+        finally
+        {
+            cursor.close();
+        }
+    }
+}

Modified: directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/GreaterEqTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/GreaterEqTest.java?rev=1389184&r1=1389183&r2=1389184&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/GreaterEqTest.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/GreaterEqTest.java Mon Sep 24 02:17:13 2012
@@ -31,16 +31,17 @@ 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;
 import org.apache.directory.server.core.api.interceptor.context.AddOperationContext;
 import org.apache.directory.server.core.api.partition.Partition;
 import org.apache.directory.server.core.partition.impl.avl.AvlPartition;
-import org.apache.directory.server.xdbm.ForwardIndexEntry;
+import org.apache.directory.server.xdbm.IndexEntry;
 import org.apache.directory.server.xdbm.Store;
 import org.apache.directory.server.xdbm.StoreUtils;
 import org.apache.directory.server.xdbm.impl.avl.AvlIndex;
+import org.apache.directory.server.xdbm.search.cursor.GreaterEqCursor;
+import org.apache.directory.server.xdbm.search.evaluator.GreaterEqEvaluator;
 import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.model.csn.CsnFactory;
 import org.apache.directory.shared.ldap.model.cursor.InvalidCursorPositionException;
@@ -61,6 +62,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.schemaextractor.impl.DefaultSchemaLdifExtractor;
 import org.apache.directory.shared.ldap.schemaloader.LdifSchemaLoader;
 import org.apache.directory.shared.ldap.schemamanager.impl.DefaultSchemaManager;
+import org.apache.directory.shared.util.Strings;
 import org.apache.directory.shared.util.exception.Exceptions;
 import org.junit.After;
 import org.junit.Before;
@@ -80,7 +82,7 @@ public class GreaterEqTest
     public static final Logger LOG = LoggerFactory.getLogger( GreaterEqTest.class );
 
     File wkdir;
-    Store<Entry, Long> store;
+    Store store;
     static SchemaManager schemaManager = null;
 
 
@@ -170,7 +172,7 @@ public class GreaterEqTest
         AttributeType at = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.POSTALCODE_AT_OID );
         GreaterEqNode node = new GreaterEqNode( at, new StringValue( at, "3" ) );
         GreaterEqEvaluator evaluator = new GreaterEqEvaluator( node, store, schemaManager );
-        GreaterEqCursor<String, Long> cursor = new GreaterEqCursor<String, Long>( store, evaluator );
+        GreaterEqCursor<String> cursor = new GreaterEqCursor<String>( store, evaluator );
         assertNotNull( cursor );
         assertFalse( cursor.available() );
         assertFalse( cursor.isClosed() );
@@ -193,22 +195,22 @@ public class GreaterEqTest
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
-        assertEquals( 5L, ( long ) cursor.get().getId() );
+        assertEquals( Strings.getUUID( 5L ), cursor.get().getId() );
         assertEquals( "3", cursor.get().getKey() );
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
-        assertEquals( 6L, ( long ) cursor.get().getId() );
+        assertEquals( Strings.getUUID( 6L ), cursor.get().getId() );
         assertEquals( "4", cursor.get().getKey() );
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
-        assertEquals( 7L, ( long ) cursor.get().getId() );
+        assertEquals( Strings.getUUID( 7L ), cursor.get().getId() );
         assertEquals( "5", cursor.get().getKey() );
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
-        assertEquals( 8L, ( long ) cursor.get().getId() );
+        assertEquals( Strings.getUUID( 8L ), cursor.get().getId() );
         assertEquals( "6", cursor.get().getKey() );
 
         assertFalse( cursor.next() );
@@ -223,22 +225,22 @@ public class GreaterEqTest
         cursor.first();
 
         assertTrue( cursor.available() );
-        assertEquals( 5L, ( long ) cursor.get().getId() );
+        assertEquals( Strings.getUUID( 5L ), cursor.get().getId() );
         assertEquals( "3", cursor.get().getKey() );
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
-        assertEquals( 6L, ( long ) cursor.get().getId() );
+        assertEquals( Strings.getUUID( 6L ), cursor.get().getId() );
         assertEquals( "4", cursor.get().getKey() );
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
-        assertEquals( 7L, ( long ) cursor.get().getId() );
+        assertEquals( Strings.getUUID( 7L ), cursor.get().getId() );
         assertEquals( "5", cursor.get().getKey() );
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
-        assertEquals( 8L, ( long ) cursor.get().getId() );
+        assertEquals( Strings.getUUID( 8L ), cursor.get().getId() );
         assertEquals( "6", cursor.get().getKey() );
 
         assertFalse( cursor.next() );
@@ -255,22 +257,22 @@ public class GreaterEqTest
 
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
-        assertEquals( 8L, ( long ) cursor.get().getId() );
+        assertEquals( Strings.getUUID( 8L ), cursor.get().getId() );
         assertEquals( "6", cursor.get().getKey() );
 
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
-        assertEquals( 7L, ( long ) cursor.get().getId() );
+        assertEquals( Strings.getUUID( 7L ), cursor.get().getId() );
         assertEquals( "5", cursor.get().getKey() );
 
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
-        assertEquals( 6L, ( long ) cursor.get().getId() );
+        assertEquals( Strings.getUUID( 6L ), cursor.get().getId() );
         assertEquals( "4", cursor.get().getKey() );
 
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
-        assertEquals( 5L, ( long ) cursor.get().getId() );
+        assertEquals( Strings.getUUID( 5L ), cursor.get().getId() );
         assertEquals( "3", cursor.get().getKey() );
 
         assertFalse( cursor.previous() );
@@ -285,22 +287,22 @@ public class GreaterEqTest
         cursor.last();
 
         assertTrue( cursor.available() );
-        assertEquals( 8L, ( long ) cursor.get().getId() );
+        assertEquals( Strings.getUUID( 8L ), cursor.get().getId() );
         assertEquals( "6", cursor.get().getKey() );
 
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
-        assertEquals( 7L, ( long ) cursor.get().getId() );
+        assertEquals( Strings.getUUID( 7L ), cursor.get().getId() );
         assertEquals( "5", cursor.get().getKey() );
 
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
-        assertEquals( 6L, ( long ) cursor.get().getId() );
+        assertEquals( Strings.getUUID( 6L ), cursor.get().getId() );
         assertEquals( "4", cursor.get().getKey() );
 
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
-        assertEquals( 5L, ( long ) cursor.get().getId() );
+        assertEquals( Strings.getUUID( 5L ), cursor.get().getId() );
         assertEquals( "3", cursor.get().getKey() );
 
         assertFalse( cursor.previous() );
@@ -311,7 +313,7 @@ public class GreaterEqTest
         // ---------- test before() ----------
 
         cursor = new GreaterEqCursor( store, evaluator );
-        ForwardIndexEntry<String, Long> indexEntry = new ForwardIndexEntry<String, Long>();
+        IndexEntry<String, String> indexEntry = new IndexEntry<String, String>();
         indexEntry.setKey( "5" );
 
         assertFalse( cursor.available() );
@@ -320,12 +322,12 @@ public class GreaterEqTest
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
-        assertEquals( 7L, ( long ) cursor.get().getId() );
+        assertEquals( Strings.getUUID( 7L ), cursor.get().getId() );
         assertEquals( "5", cursor.get().getKey() );
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
-        assertEquals( 8L, ( long ) cursor.get().getId() );
+        assertEquals( Strings.getUUID( 8L ), cursor.get().getId() );
         assertEquals( "6", cursor.get().getKey() );
 
         assertFalse( cursor.next() );
@@ -334,29 +336,29 @@ public class GreaterEqTest
         assertTrue( cursor.isClosed() );
 
         cursor = new GreaterEqCursor( store, evaluator );
-        indexEntry = new ForwardIndexEntry<String, Long>();
+        indexEntry = new IndexEntry<String, String>();
         indexEntry.setKey( "7" );
         cursor.before( indexEntry );
         assertFalse( cursor.available() );
         assertTrue( cursor.previous() );
-        assertEquals( 8L, ( long ) cursor.get().getId() );
+        assertEquals( Strings.getUUID( 8L ), cursor.get().getId() );
         assertEquals( "6", cursor.get().getKey() );
         cursor.close();
 
         cursor = new GreaterEqCursor( store, evaluator );
-        indexEntry = new ForwardIndexEntry<String, Long>();
+        indexEntry = new IndexEntry<String, String>();
         indexEntry.setKey( "3" );
         cursor.before( indexEntry );
         assertFalse( cursor.available() );
         assertTrue( cursor.next() );
-        assertEquals( 5L, ( long ) cursor.get().getId() );
+        assertEquals( Strings.getUUID( 5L ), cursor.get().getId() );
         assertEquals( "3", cursor.get().getKey() );
         cursor.close();
 
         // ---------- test after() ----------
 
         cursor = new GreaterEqCursor( store, evaluator );
-        indexEntry = new ForwardIndexEntry<String, Long>();
+        indexEntry = new IndexEntry<String, String>();
         indexEntry.setKey( "4" );
 
         assertFalse( cursor.available() );
@@ -365,12 +367,12 @@ public class GreaterEqTest
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
-        assertEquals( 7L, ( long ) cursor.get().getId() );
+        assertEquals( Strings.getUUID( 7L ), cursor.get().getId() );
         assertEquals( "5", cursor.get().getKey() );
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
-        assertEquals( 8L, ( long ) cursor.get().getId() );
+        assertEquals( Strings.getUUID( 8L ), cursor.get().getId() );
         assertEquals( "6", cursor.get().getKey() );
 
         assertFalse( cursor.next() );
@@ -379,22 +381,22 @@ public class GreaterEqTest
         assertTrue( cursor.isClosed() );
 
         cursor = new GreaterEqCursor( store, evaluator );
-        indexEntry = new ForwardIndexEntry<String, Long>();
+        indexEntry = new IndexEntry<String, String>();
         indexEntry.setKey( "7" );
         cursor.after( indexEntry );
         assertFalse( cursor.available() );
         assertTrue( cursor.previous() );
-        assertEquals( 8L, ( long ) cursor.get().getId() );
+        assertEquals( Strings.getUUID( 8L ), cursor.get().getId() );
         assertEquals( "6", cursor.get().getKey() );
         cursor.close();
 
         cursor = new GreaterEqCursor( store, evaluator );
-        indexEntry = new ForwardIndexEntry<String, Long>();
+        indexEntry = new IndexEntry<String, String>();
         indexEntry.setKey( "3" );
         cursor.after( indexEntry );
         assertFalse( cursor.available() );
         assertTrue( cursor.previous() );
-        assertEquals( 5L, ( long ) cursor.get().getId() );
+        assertEquals( Strings.getUUID( 5L ), cursor.get().getId() );
         assertEquals( "3", cursor.get().getKey() );
         cursor.close();
     }
@@ -406,7 +408,7 @@ public class GreaterEqTest
         AttributeType at = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.POSTOFFICEBOX_AT_OID );
         GreaterEqNode node = new GreaterEqNode( at, new StringValue( at, "3" ) );
         GreaterEqEvaluator evaluator = new GreaterEqEvaluator( node, store, schemaManager );
-        GreaterEqCursor<String, Long> cursor = new GreaterEqCursor<String, Long>( store, evaluator );
+        GreaterEqCursor<String> cursor = new GreaterEqCursor<String>( store, evaluator );
         assertNotNull( cursor );
         assertFalse( cursor.available() );
         assertFalse( cursor.isClosed() );
@@ -424,20 +426,20 @@ public class GreaterEqTest
 
         // ---------- test beforeFirst() ----------
 
-        Set<Tuple<String, Long>> set = new HashSet<Tuple<String, Long>>();
+        Set<Tuple<String, String>> set = new HashSet<Tuple<String, String>>();
         cursor.beforeFirst();
         assertFalse( cursor.available() );
 
         while ( cursor.next() )
         {
             assertTrue( cursor.available() );
-            set.add( new Tuple<String, Long>( cursor.get().getKey(), cursor.get().getId() ) );
+            set.add( new Tuple<String, String>( cursor.get().getKey(), 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 ) ) );
+        assertTrue( set.contains( new Tuple<String, String>( "3", Strings.getUUID( 5L ) ) ) );
+        assertTrue( set.contains( new Tuple<String, String>( "4", Strings.getUUID( 6L ) ) ) );
+        assertTrue( set.contains( new Tuple<String, String>( "5", Strings.getUUID( 7L ) ) ) );
+        assertTrue( set.contains( new Tuple<String, String>( "6", Strings.getUUID( 8L ) ) ) );
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
@@ -452,18 +454,18 @@ public class GreaterEqTest
         cursor.first();
 
         assertTrue( cursor.available() );
-        set.add( new Tuple<String, Long>( cursor.get().getKey(), cursor.get().getId() ) );
+        set.add( new Tuple<String, String>( cursor.get().getKey(), cursor.get().getId() ) );
 
         while ( cursor.next() )
         {
             assertTrue( cursor.available() );
-            set.add( new Tuple<String, Long>( cursor.get().getKey(), cursor.get().getId() ) );
+            set.add( new Tuple<String, String>( cursor.get().getKey(), 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 ) ) );
+        assertTrue( set.contains( new Tuple<String, String>( "3", Strings.getUUID( 5L ) ) ) );
+        assertTrue( set.contains( new Tuple<String, String>( "4", Strings.getUUID( 6L ) ) ) );
+        assertTrue( set.contains( new Tuple<String, String>( "5", Strings.getUUID( 7L ) ) ) );
+        assertTrue( set.contains( new Tuple<String, String>( "6", Strings.getUUID( 8L ) ) ) );
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
@@ -481,13 +483,13 @@ public class GreaterEqTest
         while ( cursor.previous() )
         {
             assertTrue( cursor.available() );
-            set.add( new Tuple<String, Long>( cursor.get().getKey(), cursor.get().getId() ) );
+            set.add( new Tuple<String, String>( cursor.get().getKey(), 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 ) ) );
+        assertTrue( set.contains( new Tuple<String, String>( "3", Strings.getUUID( 5L ) ) ) );
+        assertTrue( set.contains( new Tuple<String, String>( "4", Strings.getUUID( 6L ) ) ) );
+        assertTrue( set.contains( new Tuple<String, String>( "5", Strings.getUUID( 7L ) ) ) );
+        assertTrue( set.contains( new Tuple<String, String>( "6", Strings.getUUID( 8L ) ) ) );
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
@@ -501,18 +503,18 @@ public class GreaterEqTest
         cursor.last();
 
         assertTrue( cursor.available() );
-        set.add( new Tuple<String, Long>( cursor.get().getKey(), cursor.get().getId() ) );
+        set.add( new Tuple<String, String>( cursor.get().getKey(), cursor.get().getId() ) );
 
         while ( cursor.previous() )
         {
             assertTrue( cursor.available() );
-            set.add( new Tuple<String, Long>( cursor.get().getKey(), cursor.get().getId() ) );
+            set.add( new Tuple<String, String>( cursor.get().getKey(), 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 ) ) );
+        assertTrue( set.contains( new Tuple<String, String>( "3", Strings.getUUID( 5L ) ) ) );
+        assertTrue( set.contains( new Tuple<String, String>( "4", Strings.getUUID( 6L ) ) ) );
+        assertTrue( set.contains( new Tuple<String, String>( "5", Strings.getUUID( 7L ) ) ) );
+        assertTrue( set.contains( new Tuple<String, String>( "6", Strings.getUUID( 8L ) ) ) );
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
@@ -522,9 +524,9 @@ public class GreaterEqTest
         // ---------- test before() ----------
 
         cursor = new GreaterEqCursor( store, evaluator );
-        ForwardIndexEntry<String, Long> indexEntry = new ForwardIndexEntry<String, Long>();
+        IndexEntry<String, String> indexEntry = new IndexEntry<String, String>();
         indexEntry.setKey( "2" );
-        
+
         try
         {
             cursor.before( indexEntry );
@@ -539,7 +541,7 @@ public class GreaterEqTest
         // ---------- test after() ----------
 
         cursor = new GreaterEqCursor( store, evaluator );
-        indexEntry = new ForwardIndexEntry<String, Long>();
+        indexEntry = new IndexEntry<String, String>();
         indexEntry.setKey( "2" );
         try
         {
@@ -564,41 +566,41 @@ public class GreaterEqTest
         AttributeType at = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.POSTALCODE_AT_OID );
         GreaterEqNode node = new GreaterEqNode( at, new StringValue( at, "3" ) );
         GreaterEqEvaluator evaluator = new GreaterEqEvaluator( node, store, schemaManager );
-        ForwardIndexEntry<String, Long> indexEntry = new ForwardIndexEntry<String, Long>();
+        IndexEntry<String, String> indexEntry = new IndexEntry<String, String>();
         assertEquals( node, evaluator.getExpression() );
         assertEquals( SchemaConstants.POSTALCODE_AT_OID, evaluator.getAttributeType().getOid() );
         assertNotNull( evaluator.getNormalizer() );
         assertNotNull( evaluator.getComparator() );
 
-        indexEntry.setId( 1L );
+        indexEntry.setId( Partition.DEFAULT_ID );
         assertFalse( evaluator.evaluate( indexEntry ) );
 
-        indexEntry = new ForwardIndexEntry<String, Long>();
-        indexEntry.setId( 4L );
+        indexEntry = new IndexEntry<String, String>();
+        indexEntry.setId( Strings.getUUID( 4L ) );
         assertFalse( evaluator.evaluate( indexEntry ) );
 
-        indexEntry = new ForwardIndexEntry<String, Long>();
-        indexEntry.setId( 5L );
+        indexEntry = new IndexEntry<String, String>();
+        indexEntry.setId( Strings.getUUID( 5L ) );
         assertTrue( evaluator.evaluate( indexEntry ) );
 
-        indexEntry = new ForwardIndexEntry<String, Long>();
-        indexEntry.setId( 6L );
+        indexEntry = new IndexEntry<String, String>();
+        indexEntry.setId( Strings.getUUID( 6L ) );
         assertTrue( evaluator.evaluate( indexEntry ) );
 
-        indexEntry = new ForwardIndexEntry<String, Long>();
-        indexEntry.setId( 7L );
+        indexEntry = new IndexEntry<String, String>();
+        indexEntry.setId( Strings.getUUID( 7L ) );
         assertTrue( evaluator.evaluate( indexEntry ) );
 
-        indexEntry = new ForwardIndexEntry<String, Long>();
-        indexEntry.setId( 8L );
+        indexEntry = new IndexEntry<String, String>();
+        indexEntry.setId( Strings.getUUID( 8L ) );
         assertTrue( evaluator.evaluate( indexEntry ) );
 
-        indexEntry = new ForwardIndexEntry<String, Long>();
-        indexEntry.setId( 9L );
+        indexEntry = new IndexEntry<String, String>();
+        indexEntry.setId( Strings.getUUID( 9L ) );
         assertFalse( evaluator.evaluate( indexEntry ) );
 
-        indexEntry = new ForwardIndexEntry<String, Long>();
-        indexEntry.setId( 10L );
+        indexEntry = new IndexEntry<String, String>();
+        indexEntry.setId( Strings.getUUID( 10L ) );
         assertFalse( evaluator.evaluate( indexEntry ) );
     }
 
@@ -609,7 +611,7 @@ public class GreaterEqTest
         AttributeType at = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.STREET_AT_OID );
         GreaterEqNode node = new GreaterEqNode( at, new StringValue( at, "2" ) );
         GreaterEqEvaluator evaluator = new GreaterEqEvaluator( node, store, schemaManager );
-        ForwardIndexEntry<String, Long> indexEntry = new ForwardIndexEntry<String, Long>();
+        IndexEntry<String, String> indexEntry = new IndexEntry<String, String>();
         assertEquals( node, evaluator.getExpression() );
         assertEquals( SchemaConstants.STREET_AT_OID, evaluator.getAttributeType().getOid() );
         assertNotNull( evaluator.getNormalizer() );
@@ -622,12 +624,12 @@ public class GreaterEqTest
         attrs.add( "cn", "jane doe" );
         attrs.add( "sn", "doe" );
         attrs.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
-        attrs.add( "entryUUID", UUID.randomUUID().toString() );
+        attrs.add( "entryUUID", Strings.getUUID( 12L ).toString() );
 
         AddOperationContext addContext = new AddOperationContext( null, attrs );
         ( ( Partition ) store ).add( addContext );
 
-        indexEntry.setId( 12L );
+        indexEntry.setId( Strings.getUUID( 12L ) );
         assertTrue( evaluator.evaluate( indexEntry ) );
     }
 
@@ -639,13 +641,13 @@ public class GreaterEqTest
         GreaterEqNode node = new GreaterEqNode( at, new StringValue( at, "2" ) );
 
         GreaterEqEvaluator evaluator = new GreaterEqEvaluator( node, store, schemaManager );
-        ForwardIndexEntry<String, Long> indexEntry = new ForwardIndexEntry<String, Long>();
+        IndexEntry<String, String> indexEntry = new IndexEntry<String, String>();
         assertEquals( node, evaluator.getExpression() );
         assertEquals( SchemaConstants.C_POSTALCODE_AT_OID, evaluator.getAttributeType().getOid() );
         assertNotNull( evaluator.getNormalizer() );
         assertNotNull( evaluator.getComparator() );
 
-        indexEntry.setId( 1L );
+        indexEntry.setId( Partition.DEFAULT_ID );
         assertFalse( evaluator.evaluate( indexEntry ) );
     }
 
@@ -657,41 +659,41 @@ public class GreaterEqTest
         GreaterEqNode node = new GreaterEqNode( at, new StringValue( at, "3" ) );
 
         GreaterEqEvaluator evaluator = new GreaterEqEvaluator( node, store, schemaManager );
-        ForwardIndexEntry<String, Long> indexEntry = new ForwardIndexEntry<String, Long>();
+        IndexEntry<String, String> indexEntry = new IndexEntry<String, String>();
         assertEquals( node, evaluator.getExpression() );
         assertEquals( SchemaConstants.POSTOFFICEBOX_AT_OID, evaluator.getAttributeType().getOid() );
         assertNotNull( evaluator.getNormalizer() );
         assertNotNull( evaluator.getComparator() );
 
-        indexEntry.setId( 1L );
+        indexEntry.setId( Strings.getUUID( 1L ) );
         assertFalse( evaluator.evaluate( indexEntry ) );
 
-        indexEntry = new ForwardIndexEntry<String, Long>();
-        indexEntry.setId( 4L );
+        indexEntry = new IndexEntry<String, String>();
+        indexEntry.setId( Strings.getUUID( 4L ) );
         assertFalse( evaluator.evaluate( indexEntry ) );
 
-        indexEntry = new ForwardIndexEntry<String, Long>();
-        indexEntry.setId( 5L );
+        indexEntry = new IndexEntry<String, String>();
+        indexEntry.setId( Strings.getUUID( 5L ) );
         assertTrue( evaluator.evaluate( indexEntry ) );
 
-        indexEntry = new ForwardIndexEntry<String, Long>();
-        indexEntry.setId( 6L );
+        indexEntry = new IndexEntry<String, String>();
+        indexEntry.setId( Strings.getUUID( 6L ) );
         assertTrue( evaluator.evaluate( indexEntry ) );
 
-        indexEntry = new ForwardIndexEntry<String, Long>();
-        indexEntry.setId( 7L );
+        indexEntry = new IndexEntry<String, String>();
+        indexEntry.setId( Strings.getUUID( 7L ) );
         assertTrue( evaluator.evaluate( indexEntry ) );
 
-        indexEntry = new ForwardIndexEntry<String, Long>();
-        indexEntry.setId( 8L );
+        indexEntry = new IndexEntry<String, String>();
+        indexEntry.setId( Strings.getUUID( 8L ) );
         assertTrue( evaluator.evaluate( indexEntry ) );
 
-        indexEntry = new ForwardIndexEntry<String, Long>();
-        indexEntry.setId( 9L );
+        indexEntry = new IndexEntry<String, String>();
+        indexEntry.setId( Strings.getUUID( 9L ) );
         assertFalse( evaluator.evaluate( indexEntry ) );
 
-        indexEntry = new ForwardIndexEntry<String, Long>();
-        indexEntry.setId( 10L );
+        indexEntry = new IndexEntry<String, String>();
+        indexEntry.setId( Strings.getUUID( 10L ) );
         assertFalse( evaluator.evaluate( indexEntry ) );
     }
 



Mime
View raw message