directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r931632 - in /directory/apacheds/trunk: core-constants/src/main/java/org/apache/directory/server/constants/ jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ jdbm-store/src/test/java/org/apache/directory/s...
Date Wed, 07 Apr 2010 18:09:00 GMT
Author: kayyagari
Date: Wed Apr  7 18:09:00 2010
New Revision: 931632

URL: http://svn.apache.org/viewvc?rev=931632&view=rev
Log:
changes made as part of implementing DIRSERVER-1492
 o removed normalized and userprovided DN indices
 o added a new index for RDNs
 o added a new comparator for internally comparing RDNs
 o updated the methods performing modify and modDn operations to use the new RDN index
 o updated the test cases 

Added:
    directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/InternalRdnComparator.java
    directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndex.java
    directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndexTest.java
Modified:
    directory/apacheds/trunk/core-constants/src/main/java/org/apache/directory/server/constants/ApacheSchemaConstants.java
    directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java
    directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
    directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
    directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ServerEntrySerializerTest.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/core-constants/src/main/java/org/apache/directory/server/constants/ApacheSchemaConstants.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-constants/src/main/java/org/apache/directory/server/constants/ApacheSchemaConstants.java?rev=931632&r1=931631&r2=931632&view=diff
==============================================================================
--- directory/apacheds/trunk/core-constants/src/main/java/org/apache/directory/server/constants/ApacheSchemaConstants.java (original)
+++ directory/apacheds/trunk/core-constants/src/main/java/org/apache/directory/server/constants/ApacheSchemaConstants.java Wed Apr  7 18:09:00 2010
@@ -150,4 +150,8 @@ public interface ApacheSchemaConstants
     // apacheSubLevel
     String APACHE_SUB_LEVEL_AT                      = "apacheSubLevel";
     String APACHE_SUB_LEVEL_AT_OID                  = "1.3.6.1.4.1.18060.0.4.1.2.43";
+
+    // apacheRdn
+    String APACHE_RDN_AT                      = "apacheRdn";
+    String APACHE_RDN_AT_OID                  = "1.3.6.1.4.1.18060.0.4.1.2.50";
 }

Added: directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/InternalRdnComparator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/InternalRdnComparator.java?rev=931632&view=auto
==============================================================================
--- directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/InternalRdnComparator.java (added)
+++ directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/InternalRdnComparator.java Wed Apr  7 18:09:00 2010
@@ -0,0 +1,72 @@
+/*
+ *   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.core.partition.impl.btree.jdbm;
+
+
+import org.apache.directory.shared.ldap.name.RDN;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schema.comparators.SerializableComparator;
+
+
+/**
+ * A comparator used internally by the JdbmRdnIndex class
+ * 
+ * Note: this is a special purpose comparator which compares based on the parent IDs of
+ *       the RDNs. Generic usage of this comparator is not encouraged
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class InternalRdnComparator extends SerializableComparator<RDN>
+{
+
+    private static final long serialVersionUID = 5414960421568991202L;
+
+
+    public InternalRdnComparator( String matchingRuleOid )
+    {
+        super( matchingRuleOid );
+    }
+
+
+    @Override
+    public int compare( RDN rdn1, RDN rdn2 )
+    {
+        int val = rdn1.compareTo( rdn2 );
+        if ( val == 0 )
+        {
+            if ( ( rdn1._getParentId() != -1 ) && ( rdn2._getParentId() != -1 ) )
+            {
+                val = ( int ) ( rdn1._getParentId() - rdn2._getParentId() );
+            }
+        }
+
+        return val;
+    }
+
+
+    @Override
+    public void setSchemaManager( SchemaManager schemaManager )
+    {
+        // no need to deal with the schema manager
+    }
+
+}
\ No newline at end of file

Modified: directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java?rev=931632&r1=931631&r2=931632&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java (original)
+++ directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java Wed Apr  7 18:09:00 2010
@@ -72,7 +72,7 @@ public class JdbmIndex<K, O> implements 
     public static final String REVERSE_BTREE = "_reverse";
 
     /** the attribute type resolved for this JdbmIndex */
-    private AttributeType attribute;
+    protected AttributeType attribute;
 
     /**
      * the forward btree where the btree key is the value of the indexed attribute and
@@ -112,7 +112,7 @@ public class JdbmIndex<K, O> implements 
      * the attribute identifier set at configuration time for this index which may not
      * be the OID but an alias name for the attributeType associated with this Index
      */
-    private String attributeId;
+    protected String attributeId;
 
     /** whether or not this index has been initialized */
     protected boolean initialized;

Added: directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndex.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndex.java?rev=931632&view=auto
==============================================================================
--- directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndex.java (added)
+++ directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndex.java Wed Apr  7 18:09:00 2010
@@ -0,0 +1,164 @@
+/*
+ *   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.core.partition.impl.btree.jdbm;
+
+
+import java.io.File;
+import java.io.IOException;
+
+import javax.naming.NamingException;
+
+import jdbm.helper.MRU;
+import jdbm.recman.BaseRecordManager;
+import jdbm.recman.CacheRecordManager;
+
+import org.apache.directory.server.core.partition.impl.btree.LongComparator;
+import org.apache.directory.server.i18n.I18n;
+import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.MatchingRule;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schema.comparators.SerializableComparator;
+import org.apache.directory.shared.ldap.util.SynchronizedLRUMap;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * A special index which stores RDN objects.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class JdbmRdnIndex<K, O> extends JdbmIndex<K, O>
+{
+
+    /** A logger for this class */
+    private static final Logger LOG = LoggerFactory.getLogger( JdbmRdnIndex.class.getSimpleName() );
+
+
+    public JdbmRdnIndex()
+    {
+        initialized = false;
+    }
+
+
+    public JdbmRdnIndex( String attributeId )
+    {
+        initialized = false;
+        setAttributeId( attributeId );
+    }
+
+
+    public void init( SchemaManager schemaManager, AttributeType attributeType, File wkDirPath ) throws IOException
+    {
+        LOG.debug( "Initializing an Index for attribute '{}'", attributeType.getName() );
+        keyCache = new SynchronizedLRUMap( cacheSize );
+        attribute = attributeType;
+
+        if ( attributeId == null )
+        {
+            setAttributeId( attribute.getName() );
+        }
+
+        if ( this.wkDirPath == null )
+        {
+            this.wkDirPath = wkDirPath;
+        }
+
+        File file = new File( this.wkDirPath.getPath() + File.separator + attribute.getName() );
+        String path = file.getAbsolutePath();
+        BaseRecordManager base = new BaseRecordManager( path );
+        base.disableTransactions();
+        this.recMan = new CacheRecordManager( base, new MRU( cacheSize ) );
+
+        try
+        {
+            initTables( schemaManager );
+        }
+        catch ( IOException e )
+        {
+            // clean up
+            close();
+            throw e;
+        }
+
+        initialized = true;
+    }
+
+
+    /**
+     * Initializes the forward and reverse tables used by this Index.
+     * 
+     * @throws IOException if we cannot initialize the forward and reverse
+     * tables
+     * @throws NamingException 
+     */
+    private void initTables( SchemaManager schemaManager ) throws IOException
+    {
+        MatchingRule mr = attribute.getEquality();
+
+        if ( mr == null )
+        {
+            throw new IOException( I18n.err( I18n.ERR_574, attribute.getName() ) );
+        }
+
+        SerializableComparator comp = new InternalRdnComparator( mr.getOid() );
+
+        LongComparator.INSTANCE.setSchemaManager( schemaManager );
+
+        forward = new JdbmTable<K, Long>( schemaManager, attribute.getName() + FORWARD_BTREE, recMan, comp, null,
+            LongSerializer.INSTANCE );
+        reverse = new JdbmTable<Long, K>( schemaManager, attribute.getName() + REVERSE_BTREE, recMan,
+            LongComparator.INSTANCE, LongSerializer.INSTANCE, null );
+    }
+
+
+    public void add( K rdn, Long entryId ) throws Exception
+    {
+        forward.put( rdn, entryId );
+        reverse.put( entryId, rdn );
+    }
+
+
+    public void drop( Long entryId ) throws Exception
+    {
+        K rdn = reverse.get( entryId );
+        forward.remove( rdn );
+        reverse.remove( entryId );
+    }
+
+
+    public void drop( K rdn, Long id ) throws Exception
+    {
+        long val = forward.get( rdn );
+        if ( val == id )
+        {
+            forward.remove( rdn );
+            reverse.remove( val );
+        }
+    }
+
+
+    public K getNormalized( K rdn ) throws Exception
+    {
+        return rdn;
+    }
+}

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=931632&r1=931631&r2=931632&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 Wed Apr  7 18:09:00 2010
@@ -102,12 +102,9 @@ public class JdbmStore<E> implements Sto
     /** true if we sync disks on every write operation */
     private boolean isSyncOnWrite = true;
 
-    /** the normalized distinguished name index */
-    private JdbmIndex<String, E> ndnIdx;
-
-    /** the user provided distinguished name index */
-    private JdbmIndex<String, E> updnIdx;
-
+    /** the relative distinguished name index */
+    private JdbmRdnIndex<RDN, Long> rdnIdx;
+    
     /** the attribute presence index */
     private JdbmIndex<String, E> presenceIdx;
 
@@ -317,24 +314,15 @@ public class JdbmStore<E> implements Sto
             systemIndices = tmp;
         }
 
-        if ( ndnIdx == null )
+        if ( rdnIdx == null )
         {
-            ndnIdx = new JdbmIndex<String, E>();
-            ndnIdx.setAttributeId( ApacheSchemaConstants.APACHE_N_DN_AT_OID );
-            systemIndices.put( ApacheSchemaConstants.APACHE_N_DN_AT_OID, ndnIdx );
-            ndnIdx.init( schemaManager, schemaManager
-                .lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_N_DN_AT_OID ), workingDirectory );
-        }
-
-        if ( updnIdx == null )
-        {
-            updnIdx = new JdbmIndex<String, E>();
-            updnIdx.setAttributeId( ApacheSchemaConstants.APACHE_UP_DN_AT_OID );
-            systemIndices.put( ApacheSchemaConstants.APACHE_UP_DN_AT_OID, updnIdx );
-            updnIdx.init( schemaManager, schemaManager
-                .lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_UP_DN_AT_OID ), workingDirectory );
+            rdnIdx = new JdbmRdnIndex<RDN, Long>();
+            rdnIdx.setAttributeId( ApacheSchemaConstants.APACHE_RDN_AT_OID );
+            systemIndices.put( ApacheSchemaConstants.APACHE_RDN_AT_OID, ( JdbmIndex ) rdnIdx );
+            rdnIdx.init( schemaManager, schemaManager
+                .lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_RDN_AT_OID ), workingDirectory );
         }
-
+        
         if ( presenceIdx == null )
         {
             presenceIdx = new JdbmIndex<String, E>();
@@ -552,8 +540,6 @@ public class JdbmStore<E> implements Sto
 
         List<Index<?, E, Long>> array = new ArrayList<Index<?, E, Long>>();
         array.addAll( userIndices.values() );
-        array.add( ndnIdx );
-        array.add( updnIdx );
         array.add( aliasIdx );
         array.add( oneAliasIdx );
         array.add( subAliasIdx );
@@ -726,7 +712,9 @@ public class JdbmStore<E> implements Sto
      */
     public Index<String, E, Long> getUpdnIndex()
     {
-        return updnIdx;
+        // FIXME this method shouldn't be supported anymore after the
+        // introduction of the RDN index, but keeping to minimise the number changes done to interface
+        return entryUuidIdx;
     }
 
 
@@ -735,9 +723,6 @@ public class JdbmStore<E> implements Sto
      */
     public void setUpdnIndex( Index<String, E, Long> index ) throws LdapException
     {
-        protect( "updnIndex" );
-        updnIdx = convertIndex( index );
-        systemIndices.put( index.getAttributeId(), updnIdx );
     }
 
 
@@ -746,7 +731,8 @@ public class JdbmStore<E> implements Sto
      */
     public Index<String, E, Long> getNdnIndex()
     {
-        return ndnIdx;
+        // FIXME should this be entryUuidIdx?
+        return entryCsnIdx;
     }
 
 
@@ -755,9 +741,6 @@ public class JdbmStore<E> implements Sto
      */
     public void setNdnIndex( Index<String, E, Long> index ) throws LdapException
     {
-        protect( "ndnIndex" );
-        ndnIdx = convertIndex( index );
-        systemIndices.put( index.getAttributeId(), ndnIdx );
     }
 
 
@@ -941,19 +924,122 @@ public class JdbmStore<E> implements Sto
     }
 
 
+    /**
+     * @see #getEntryId(DN)
+     */
     public Long getEntryId( String dn ) throws Exception
     {
-        return ndnIdx.forwardLookup( dn );
+        return getEntryId( new DN( dn ) );
     }
 
 
+    /**
+     * gets the entry id of the given DN using RDN index
+     *
+     * @param dn the DN of the entry
+     * @return id of the entry represented by the given DN
+     * @throws Exception
+     */
+    public Long getEntryId( DN dn ) throws Exception
+    {
+        if( !dn.isNormalized() )
+        {
+            dn.normalize( schemaManager.getNormalizerMapping() );
+        }
+        
+        int dnSize = dn.size();
+        int i = normSuffix.size(); 
+
+        RDN key = new RDN( normSuffix.getNormName() );
+        key._setParentId( 0 );
+        
+        Long curEntryId = rdnIdx.forwardLookup( key );
+        
+        for( ; i < dnSize; i++ )
+        {
+            key = dn.getRdn( i );
+            key._setParentId( curEntryId );
+            curEntryId = rdnIdx.forwardLookup( key );
+            if( curEntryId == null )
+            {
+                break;
+            }
+        }
+        
+        return curEntryId;
+    }
+    
+    
+    /**
+     * gives the normalized name of the DN of the entry identified by the given id
+     * @param id the entry's id 
+     */
     public String getEntryDn( Long id ) throws Exception
     {
-        return ndnIdx.reverseLookup( id );
+        return buildEntryDn( id ).getNormName();
     }
 
+    
+    /**
+     * builds the DN of the entry identified by the given id
+     *
+     * @param id the entry's id
+     * @return the normalized DN of the entry
+     * @throws Exception
+     */
+    private DN buildEntryDn( Long id ) throws Exception
+    {
+        DN dn = new DN();
+        
+        // form the DN
+        RDN curRdn = rdnIdx.reverseLookup( id );
+
+        dn.addNormalizedInOrder( curRdn );
+        
+        while( curRdn._getParentId() != 0 )
+        {
+            curRdn = rdnIdx.reverseLookup( curRdn._getParentId() );
+            dn.addNormalizedInOrder( curRdn );
+        }
+
+        return dn;
+    }
 
     /**
+     * 
+     * contructs a normalized DN using the RDN index. This is useful
+     * to identify in cases like finding the parent entry's id
+     * (cause that will be stored in the RDN of the entry identified by the given DN in string form)
+     *
+     * @param dn the DN of the entry in string form
+     * @return DN object build after fetching all the RDNs from RDN index
+     * @throws Exception
+     */
+    private DN buildEntryDn( String dn ) throws Exception
+    {
+        DN normDN = new DN( dn );
+        normDN.normalize( schemaManager.getNormalizerMapping() );
+        
+        int dnSize = normDN.size();
+        int i = normSuffix.size(); 
+
+        RDN key = new RDN( normSuffix.getNormName() );
+        key._setParentId( 0 );
+
+        Long curEntryId = rdnIdx.forwardLookup( key );
+        
+        for( ; i < dnSize; i++ )
+        {
+            key = normDN.getRdn( i );
+            key._setParentId( curEntryId );
+            curEntryId = rdnIdx.forwardLookup( key );
+        }
+        
+        return normDN;
+    }
+    
+    
+    /**
      * Gets the Long id of an entry's parent using the child entry's
      * normalized DN. Note that the suffix entry returns 0, which does not
      * map to any entry.
@@ -965,27 +1051,41 @@ public class JdbmStore<E> implements Sto
      */
     public Long getParentId( String dn ) throws Exception
     {
-        Long childId = ndnIdx.forwardLookup( dn );
-        return oneLevelIdx.reverseLookup( childId );
+        DN normDN = new DN( dn );
+        normDN.normalize( schemaManager.getNormalizerMapping() );
+        
+        if( normSuffix.equals( normDN ) )
+        {
+            return 0L;
+        }
+        
+        normDN = buildEntryDn( dn );
+        return normDN.getRdn()._getParentId();
     }
 
 
     public Long getParentId( Long childId ) throws Exception
     {
-        return oneLevelIdx.reverseLookup( childId );
+        //return oneLevelIdx.reverseLookup( childId );
+        RDN rdn = rdnIdx.reverseLookup( childId );
+        if( rdn == null )
+        {
+            return null;
+        }
+        
+        return rdn._getParentId();
     }
 
 
     public String getEntryUpdn( Long id ) throws Exception
     {
-        return updnIdx.reverseLookup( id );
+        return buildEntryDn( id ).getName();
     }
 
 
     public String getEntryUpdn( String dn ) throws Exception
     {
-        Long id = ndnIdx.forwardLookup( dn );
-        return updnIdx.reverseLookup( id );
+        return buildEntryDn( dn ).getName();
     }
 
 
@@ -1013,7 +1113,7 @@ public class JdbmStore<E> implements Sto
 
         DN ancestorDn = ( DN ) aliasDN.clone();
         ancestorDn.remove( aliasDN.size() - 1 );
-        Long ancestorId = getEntryId( ancestorDn.getNormName() );
+        Long ancestorId = getEntryId( ancestorDn );
 
         /*
          * We cannot just drop all tuples in the one level and subtree userIndices
@@ -1061,8 +1161,8 @@ public class JdbmStore<E> implements Sto
         Long ancestorId; // Id of an alias entry relative
 
         // Access aliasedObjectName, normalize it and generate the Name 
-        normalizedAliasTargetDn = new DN( aliasTarget );
-        normalizedAliasTargetDn.normalize( schemaManager.getNormalizerMapping() );
+        normalizedAliasTargetDn = buildEntryDn( aliasTarget );//new DN( aliasTarget );
+        //normalizedAliasTargetDn.normalize( schemaManager.getNormalizerMapping() );
 
         /*
          * Check For Cycles
@@ -1107,7 +1207,7 @@ public class JdbmStore<E> implements Sto
         }
 
         // L O O K U P   T A R G E T   I D
-        targetId = ndnIdx.forwardLookup( normalizedAliasTargetDn.getNormName() );
+        targetId = rdnIdx.forwardLookup( normalizedAliasTargetDn.getRdn() );
 
         /*
          * Check For Target Existence
@@ -1154,7 +1254,7 @@ public class JdbmStore<E> implements Sto
          */
         ancestorDn = ( DN ) aliasDn.clone();
         ancestorDn.remove( aliasDn.size() - 1 );
-        ancestorId = getEntryId( ancestorDn.getNormName() );
+        ancestorId = getEntryId( ancestorDn );
 
         // check if alias parent and aliased entry are the same
         DN normalizedAliasTargetParentDn = ( DN ) normalizedAliasTargetDn.clone();
@@ -1211,16 +1311,20 @@ public class JdbmStore<E> implements Sto
         //
         DN entryDn = entry.getDn();
         DN parentDn = null;
+        RDN rdn = null;
 
         if ( entryDn.getNormName().equals( normSuffix.getNormName() ) )
         {
             parentId = 0L;
+            rdn = new RDN( normSuffix.getNormName() );
+            rdn.setUpName( entryDn.getName() );
         }
         else
         {
+            rdn = entryDn.getRdn();
             parentDn = ( DN ) entryDn.clone();
             parentDn.remove( parentDn.size() - 1 );
-            parentId = getEntryId( parentDn.getNormName() );
+            parentId = getEntryId( parentDn );
         }
 
         // don't keep going if we cannot find the parent Id
@@ -1229,6 +1333,9 @@ public class JdbmStore<E> implements Sto
             throw new LdapNoSuchObjectException( I18n.err( I18n.ERR_216, parentDn ) );
         }
 
+        rdn._setParentId( parentId );
+        rdnIdx.add( rdn, id );
+
         EntryAttribute objectClass = entry.get( OBJECT_CLASS_AT );
 
         if ( objectClass == null )
@@ -1259,8 +1366,7 @@ public class JdbmStore<E> implements Sto
             throw new IllegalStateException( I18n.err( I18n.ERR_218, entryDn.getNormName() ) );
         }
 
-        ndnIdx.add( entryDn.getNormName(), id );
-        updnIdx.add( entryDn.getName(), id );
+        
         oneLevelIdx.add( parentId, id );
 
         // Update the EntryCsn index
@@ -1329,7 +1435,15 @@ public class JdbmStore<E> implements Sto
 
     public ServerEntry lookup( Long id ) throws Exception
     {
-        return ( ServerEntry ) master.get( id );
+        ServerEntry se = ( ServerEntry ) master.get( id );
+        
+        if( se == null )
+        {
+            return null;
+        }
+        
+        se.setDn( buildEntryDn( id ) );
+        return se;
     }
 
 
@@ -1338,7 +1452,7 @@ public class JdbmStore<E> implements Sto
      */
     public synchronized void delete( Long id ) throws Exception
     {
-        ServerEntry entry = lookup( id );
+        ServerEntry entry = master.get( id );
         Long parentId = getParentId( id );
 
         EntryAttribute objectClass = entry.get( OBJECT_CLASS_AT );
@@ -1353,8 +1467,7 @@ public class JdbmStore<E> implements Sto
             objectClassIdx.drop( value.getString(), id );
         }
 
-        ndnIdx.drop( id );
-        updnIdx.drop( id );
+        rdnIdx.drop( id );
         oneLevelIdx.drop( id );
         entryCsnIdx.drop( id );
         entryUuidIdx.drop( id );
@@ -1497,8 +1610,8 @@ public class JdbmStore<E> implements Sto
 
         if ( modsOid.equals( SchemaConstants.ALIASED_OBJECT_NAME_AT_OID ) )
         {
-            String ndnStr = ndnIdx.reverseLookup( id );
-            addAliasIndices( id, new DN( ndnStr ), mods.getString() );
+            DN ndn = buildEntryDn( id );
+            addAliasIndices( id, ndn, mods.getString() );
         }
     }
 
@@ -1672,8 +1785,8 @@ public class JdbmStore<E> implements Sto
 
         if ( modsOid.equals( aliasAttributeOid ) && mods.size() > 0 )
         {
-            String ndnStr = ndnIdx.reverseLookup( id );
-            addAliasIndices( id, new DN( ndnStr ), mods.getString() );
+            DN ndn = buildEntryDn( id );
+            addAliasIndices( id, ndn, mods.getString() );
         }
     }
 
@@ -1777,7 +1890,7 @@ public class JdbmStore<E> implements Sto
     @SuppressWarnings("unchecked")
     public void rename( DN dn, RDN newRdn, boolean deleteOldRdn ) throws Exception
     {
-        Long id = getEntryId( dn.getNormName() );
+        Long id = getEntryId( dn );
         ServerEntry entry = lookup( id );
         DN updn = entry.getDn();
 
@@ -1888,10 +2001,15 @@ public class JdbmStore<E> implements Sto
         // gotta normalize cuz this thang is cloned and not normalized by default
         newUpdn.normalize( schemaManager.getNormalizerMapping() );
 
+        // restore the parentId from the old RDN
+        newRdn = newUpdn.getRdn();
+        newRdn._setParentId( updn.getRdn()._getParentId() );
+        
         modifyDn( id, newUpdn, false ); // propagate dn changes
 
         // Update the current entry
         entry.setDn( newUpdn );
+
         master.put( id, entry );
 
         if ( isSyncOnWrite )
@@ -1921,20 +2039,16 @@ public class JdbmStore<E> implements Sto
     private void modifyDn( Long id, DN updn, boolean isMove ) throws Exception
     {
         String aliasTarget;
-
-        // update normalized DN index
-        ndnIdx.drop( id );
-
-        if ( !updn.isNormalized() )
+        
+        //updated the RDN index
+        rdnIdx.drop( id );
+        if( !updn.isNormalized() )
         {
-            updn.normalize( schemaManager.getNormalizerMapping() );
+            // just normalize the RDN alone
+            updn.getRdn().normalize( schemaManager.getNormalizerMapping() );
         }
-
-        ndnIdx.add( updn.getNormName(), id );
-
-        // update user provided DN index
-        updnIdx.drop( id );
-        updnIdx.add( updn.getName(), id );
+        
+        rdnIdx.add( updn.getRdn(), id );
 
         /* 
          * Read Alias Index Tuples
@@ -1952,51 +2066,20 @@ public class JdbmStore<E> implements Sto
 
             if ( null != aliasTarget )
             {
-                addAliasIndices( id, new DN( getEntryDn( id ) ), aliasTarget );
+                addAliasIndices( id, buildEntryDn( id ), aliasTarget );
             }
         }
-
-        Cursor<IndexEntry<Long, E, Long>> children = list( id );
-
-        while ( children.next() )
-        {
-            // Get the child and its id
-            IndexEntry<Long, E, Long> rec = children.get();
-            Long childId = rec.getId();
-
-            /* 
-             * Calculate the DN for the child's new name by copying the parents
-             * new name and adding the child's old upRdn to new name as its RDN
-             */
-            DN childUpdn = ( DN ) updn.clone();
-            DN oldUpdn = new DN( getEntryUpdn( childId ) );
-
-            String rdn = oldUpdn.get( oldUpdn.size() - 1 );
-            DN rdnDN = new DN( rdn );
-            rdnDN.normalize( schemaManager.getNormalizerMapping() );
-            childUpdn.add( rdnDN.getRdn() );
-
-            // Modify the child
-            ServerEntry entry = lookup( childId );
-            entry.setDn( childUpdn );
-            master.put( childId, entry );
-
-            // Recursively change the names of the children below
-            modifyDn( childId, childUpdn, isMove );
-        }
-
-        children.close();
     }
 
 
     public void move( DN oldChildDn, DN newParentDn, RDN newRdn, boolean deleteOldRdn ) throws Exception
     {
-        Long childId = getEntryId( oldChildDn.getNormName() );
+        Long childId = getEntryId( oldChildDn );
         rename( oldChildDn, newRdn, deleteOldRdn );
         DN newUpdn = move( oldChildDn, childId, newParentDn );
 
         // Update the current entry
-        ServerEntry entry = lookup( childId );
+        ServerEntry entry = master.get( childId );
         entry.setDn( newUpdn );
         master.put( childId, entry );
 
@@ -2009,11 +2092,11 @@ public class JdbmStore<E> implements Sto
 
     public void move( DN oldChildDn, DN newParentDn ) throws Exception
     {
-        Long childId = getEntryId( oldChildDn.getNormName() );
+        Long childId = getEntryId( oldChildDn );
         DN newUpdn = move( oldChildDn, childId, newParentDn );
 
         // Update the current entry
-        ServerEntry entry = lookup( childId );
+        ServerEntry entry = master.get( childId );
         entry.setDn( newUpdn );
         master.put( childId, entry );
 
@@ -2041,7 +2124,7 @@ public class JdbmStore<E> implements Sto
     private DN move( DN oldChildDn, Long childId, DN newParentDn ) throws Exception
     {
         // Get the child and the new parent to be entries and Ids
-        Long newParentId = getEntryId( newParentDn.getNormName() );
+        Long newParentId = getEntryId( newParentDn );
         Long oldParentId = getParentId( childId );
 
         /*
@@ -2068,10 +2151,13 @@ public class JdbmStore<E> implements Sto
          * user provided RDN & the new parent's UPDN.  Basically add the child's
          * UpRdn String to the tail of the new parent's Updn Name.
          */
-        DN childUpdn = new DN( getEntryUpdn( childId ) );
-        String childRdn = childUpdn.get( childUpdn.size() - 1 );
-        DN newUpdn = new DN( getEntryUpdn( newParentId ) );
-        newUpdn.add( newUpdn.size(), childRdn );
+        
+        DN childUpdn = buildEntryDn( childId );
+        RDN childRdn = childUpdn.getRdn( childUpdn.size() - 1 );
+        childRdn._setParentId( newParentId );
+        DN newUpdn = buildEntryDn( newParentId );
+        
+        newUpdn.add( childRdn );
 
         // Call the modifyDn operation with the new updn
         modifyDn( childId, newUpdn, true );

Added: directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndexTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndexTest.java?rev=931632&view=auto
==============================================================================
--- directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndexTest.java (added)
+++ directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndexTest.java Wed Apr  7 18:09:00 2010
@@ -0,0 +1,385 @@
+/*
+ *  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.core.partition.impl.btree.jdbm;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.directory.server.constants.ApacheSchemaConstants;
+import org.apache.directory.server.xdbm.Index;
+import org.apache.directory.server.xdbm.IndexEntry;
+import org.apache.directory.shared.ldap.cursor.Cursor;
+import org.apache.directory.shared.ldap.name.DN;
+import org.apache.directory.shared.ldap.name.RDN;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor;
+import org.apache.directory.shared.ldap.schema.ldif.extractor.impl.DefaultSchemaLdifExtractor;
+import org.apache.directory.shared.ldap.schema.loader.ldif.LdifSchemaLoader;
+import org.apache.directory.shared.ldap.schema.manager.impl.DefaultSchemaManager;
+import org.apache.directory.shared.ldap.util.ExceptionUtils;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+/**
+ * Tests the JdbmRdnIndex.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class JdbmRdnIndexTest
+{
+    private static File dbFileDir;
+    Index<RDN, Long, Long> idx;
+    private static SchemaManager schemaManager;
+
+
+    @BeforeClass
+    public static void init() throws Exception
+    {
+        String workingDirectory = System.getProperty( "workingDirectory" );
+
+        if ( workingDirectory == null )
+        {
+            String path = JdbmRdnIndexTest.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 : " + ExceptionUtils.printErrors( schemaManager.getErrors() ) );
+        }
+    }
+
+
+    @Before
+    public void setup() throws IOException
+    {
+
+        File tmpIndexFile = File.createTempFile( JdbmRdnIndexTest.class.getSimpleName(), "db" );
+        tmpIndexFile.deleteOnExit();
+        dbFileDir = new File( tmpIndexFile.getParentFile(), JdbmRdnIndexTest.class.getSimpleName() );
+
+        dbFileDir.mkdirs();
+    }
+
+
+    @After
+    public void teardown() throws Exception
+    {
+        destroyIndex();
+
+        if ( ( dbFileDir != null ) && dbFileDir.exists() )
+        {
+            FileUtils.deleteDirectory( dbFileDir );
+        }
+    }
+
+
+    void destroyIndex() throws Exception
+    {
+        if ( idx != null )
+        {
+            idx.sync();
+            idx.close();
+
+            // created by this test
+            File dbFile = new File( idx.getWkDirPath(), idx.getAttribute().getName() + ".db" );
+            assert dbFile.delete();
+
+            // created by TransactionManager
+            File logFile = new File( idx.getWkDirPath(), idx.getAttribute().getName() + ".lg" );
+            assert logFile.delete();
+        }
+
+        idx = null;
+    }
+
+
+    void initIndex() throws Exception
+    {
+        initIndex( new JdbmRdnIndex<RDN, Long>() );
+    }
+
+
+    void initIndex( JdbmRdnIndex<RDN, Long> jdbmIdx ) throws Exception
+    {
+        if ( jdbmIdx == null )
+        {
+            jdbmIdx = new JdbmRdnIndex<RDN, Long>();
+        }
+
+        jdbmIdx.init( schemaManager, schemaManager.lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_RDN_AT_OID ), dbFileDir );
+        this.idx = jdbmIdx;
+    }
+
+
+    // -----------------------------------------------------------------------
+    // Property Test Methods
+    // -----------------------------------------------------------------------
+
+    @Test
+    public void testCacheSize() throws Exception
+    {
+        // uninitialized index
+        JdbmRdnIndex JdbmRdnIndex = new JdbmRdnIndex();
+        JdbmRdnIndex.setCacheSize( 337 );
+        assertEquals( 337, JdbmRdnIndex.getCacheSize() );
+
+        // initialized index
+        initIndex();
+        try
+        {
+            idx.setCacheSize( 30 );
+            fail( "Should not be able to set cacheSize after initialization." );
+        }
+        catch ( Exception e )
+        {
+        }
+        
+        destroyIndex();
+        initIndex();
+        
+        assertEquals( Index.DEFAULT_INDEX_CACHE_SIZE, idx.getCacheSize() );
+    }
+
+
+    @Test
+    public void testWkDirPath() throws Exception
+    {
+        // uninitialized index
+        JdbmRdnIndex<RDN, Long> JdbmRdnIndex = new JdbmRdnIndex<RDN, Long>();
+        JdbmRdnIndex.setWkDirPath( new File( dbFileDir, "foo" ) );
+        assertEquals( "foo", JdbmRdnIndex.getWkDirPath().getName() );
+
+        // initialized index
+        initIndex();
+        try
+        {
+            idx.setWkDirPath( new File( dbFileDir, "foo" ) );
+            fail( "Should not be able to set wkDirPath after initialization." );
+        }
+        catch ( Exception e )
+        {
+        }
+        assertEquals( dbFileDir, idx.getWkDirPath() );
+
+        destroyIndex();
+        JdbmRdnIndex = new JdbmRdnIndex<RDN, Long>();
+        File wkdir = new File( dbFileDir, "foo" );
+        wkdir.mkdirs();
+        JdbmRdnIndex.setWkDirPath( wkdir );
+        initIndex( JdbmRdnIndex );
+        assertEquals( wkdir, idx.getWkDirPath() );
+    }
+
+
+    @Test
+    public void testGetAttribute() throws Exception
+    {
+        // uninitialized index
+        JdbmRdnIndex rdnIndex = new JdbmRdnIndex();
+        assertNull( rdnIndex.getAttribute() );
+
+        initIndex();
+        assertEquals( schemaManager.lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_RDN_AT ), idx.getAttribute() );
+    }
+
+
+    @Test
+    public void testIsCountExact() throws Exception
+    {
+        assertFalse( new JdbmRdnIndex().isCountExact() );
+    }
+
+
+    // -----------------------------------------------------------------------
+    // Count Test Methods
+    // -----------------------------------------------------------------------
+
+    @Test
+    public void testCount() throws Exception
+    {
+        initIndex();
+        assertEquals( 0, idx.count() );
+
+        RDN key = new RDN( "cn=key" );
+        key._setParentId( 0 );
+
+        idx.add( key, 0l );
+        assertEquals( 1, idx.count() );
+
+        // setting a different parentId should make this key a different key
+        key = new RDN( "cn=key" );
+        key._setParentId( 1 );
+        
+        idx.add( key, 1l );
+        assertEquals( 2, idx.count() );
+
+        //count shouldn't get affected cause of inserting the same key
+        idx.add( key, 2l );
+        assertEquals( 2, idx.count() );
+        
+        key = new RDN( "cn=key" );
+        key._setParentId( 2 );
+        idx.add( key, 3l );
+        assertEquals( 3, idx.count() );
+    }
+
+
+    @Test
+    public void testCountOneArg() throws Exception
+    {
+        initIndex();
+        
+        RDN key = new RDN( "cn=key" );
+        
+        assertEquals( 0, idx.count( key ) );
+
+        idx.add( key, 0l );
+        assertEquals( 1, idx.count( key ) );
+    }
+
+
+    // -----------------------------------------------------------------------
+    // Add, Drop and Lookup Test Methods
+    // -----------------------------------------------------------------------
+
+    @Test
+    public void testLookups() throws Exception
+    {
+        initIndex();
+        
+        RDN key = new RDN( "cn=key" );
+        
+        assertNull( idx.forwardLookup( key ) );
+
+        idx.add( key, 0l );
+        assertEquals( 0, ( long ) idx.forwardLookup( key ) );
+        assertEquals( key, idx.reverseLookup( 0l ) );
+    }
+
+
+    @Test
+    public void testAddDropById() throws Exception
+    {
+        initIndex();
+        
+        RDN key = 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.drop( key, 0l );
+        assertNull( idx.forwardLookup( key ) );
+        assertNull( idx.reverseLookup( 0l ) );
+    }
+
+
+    // -----------------------------------------------------------------------
+    // Miscellaneous Test Methods
+    // -----------------------------------------------------------------------
+
+    @Test
+    public void testCursors() throws Exception
+    {
+        initIndex();
+        
+        RDN key = new RDN( "cn=key" );
+        
+        assertEquals( 0, idx.count() );
+
+        idx.add( key, 0l );
+        assertEquals( 1, idx.count() );
+        
+        for( int i=1; i< 5; i++ )
+        {
+            key = new RDN( "cn=key" + i );
+            key._setParentId( i );
+            
+            idx.add( key, ( long ) i );
+        }
+
+        assertEquals( 5, idx.count() );
+        
+        // use forward index's cursor
+        Cursor<IndexEntry<RDN, Long, Long>> cursor = idx.forwardCursor();
+        cursor.beforeFirst();
+
+        cursor.next();
+        IndexEntry<RDN, Long, Long> e1 = cursor.get();
+        assertEquals( 0, ( long ) e1.getId() );
+        assertEquals( "cn=key", e1.getValue().getName() );
+        assertEquals( -1, e1.getValue()._getParentId() );
+
+        cursor.next();
+        IndexEntry<RDN, Long, Long> e2 = cursor.get();
+        assertEquals( 1, ( long ) e2.getId() );
+        assertEquals( "cn=key1", e2.getValue().getName() );
+        assertEquals( 1, e2.getValue()._getParentId() );
+        
+        cursor.next();
+        IndexEntry<RDN, Long, Long> e3 = cursor.get();
+        assertEquals( 2, ( long ) e3.getId() );
+        assertEquals( "cn=key2", e3.getValue().getName() );
+        assertEquals( 2, e3.getValue()._getParentId() );
+    }
+
+
+    @Test
+    public void testStoreRdnWithTwoATAVs() throws Exception
+    {
+        initIndex();
+        
+        DN dn = new DN( "dc=example,dc=com" );
+        dn.normalize( schemaManager.getNormalizerMapping() );
+        
+        RDN rdn = new RDN( dn.getName() );
+        rdn._setParentId( 1 );
+        idx.add( rdn, 0l );
+        
+        RDN rdn2 = idx.reverseLookup( 0l );
+        System.out.println( rdn2 );
+        InternalRdnComparator rdnCom = new InternalRdnComparator( "" );
+        assertEquals( 0, rdnCom.compare( rdn, rdn2 ) );
+    }
+}

Modified: directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java?rev=931632&r1=931631&r2=931632&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java (original)
+++ directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java Wed Apr  7 18:09:00 2010
@@ -191,13 +191,13 @@ public class JdbmStoreTest
         store.setName( "foo" );
         assertEquals( "foo", store.getName() );
 
-        assertNull( store.getNdnIndex() );
-        store.setNdnIndex( new JdbmIndex<String, Attributes>( "ndn" ) );
-        assertNotNull( store.getNdnIndex() );
+//        assertNull( store.getNdnIndex() );
+//        store.setNdnIndex( new JdbmIndex<String, Attributes>( "ndn" ) );
+//        assertNotNull( store.getNdnIndex() );
 
         assertNull( store.getOneAliasIndex() );
         store.setOneAliasIndex( new JdbmIndex<Long, Attributes>( "oneAlias" ) );
-        assertNotNull( store.getNdnIndex() );
+        assertNotNull( store.getOneAliasIndex() );
 
         assertNull( store.getSubAliasIndex() );
         store.setSubAliasIndex( new JdbmIndex<Long, Attributes>( "subAlias" ) );
@@ -207,10 +207,6 @@ public class JdbmStoreTest
         store.setSuffixDn( "dc=example,dc=com" );
         assertEquals( "dc=example,dc=com", store.getSuffixDn() );
 
-        assertNull( store.getUpdnIndex() );
-        store.setUpdnIndex( new JdbmIndex<String, Attributes>( "updn" ) );
-        assertNotNull( store.getUpdnIndex() );
-
         assertNull( store.getUpSuffix() );
         assertNull( store.getSuffix() );
 
@@ -297,14 +293,6 @@ public class JdbmStoreTest
         }
 
         assertNotNull( store.getNdnIndex() );
-        try
-        {
-            store.setNdnIndex( new JdbmIndex<String, ServerEntry>( "ndn" ) );
-            fail();
-        }
-        catch ( IllegalStateException e )
-        {
-        }
 
         assertNotNull( store.getOneAliasIndex() );
         try
@@ -336,18 +324,9 @@ public class JdbmStoreTest
         {
         }
 
-        assertNotNull( store.getUpdnIndex() );
-        try
-        {
-            store.setUpdnIndex( new JdbmIndex<String, ServerEntry>( "updn" ) );
-            fail();
-        }
-        catch ( IllegalStateException e )
-        {
-        }
         Iterator<String> systemIndices = store.systemIndices();
 
-        for ( int ii = 0; ii < 11; ii++ )
+        for ( int ii = 0; ii < 10; ii++ )
         {
             assertTrue( systemIndices.hasNext() );
             assertNotNull( systemIndices.next() );
@@ -436,7 +415,7 @@ public class JdbmStoreTest
         dn.normalize( schemaManager.getNormalizerMapping() );
         assertEquals( 1L, ( long ) store.getEntryId( dn.getNormName() ) );
         assertEquals( 11, store.count() );
-        assertEquals( "o=Good Times Co.", store.getEntryUpdn( dn.getNormName() ) );
+        assertEquals( "o=Good Times Co.", store.getEntryUpdn( dn.getName() ) );
         assertEquals( dn.getNormName(), store.getEntryDn( 1L ) );
         assertEquals( dn.getName(), store.getEntryUpdn( 1L ) );
 

Modified: directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ServerEntrySerializerTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ServerEntrySerializerTest.java?rev=931632&r1=931631&r2=931632&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ServerEntrySerializerTest.java (original)
+++ directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ServerEntrySerializerTest.java Wed Apr  7 18:09:00 2010
@@ -150,6 +150,10 @@ public class ServerEntrySerializerTest
         
         ServerEntry result = (ServerEntry)ses.deserialize( data );
         
+        DN newDn = new DN();
+        newDn.add( dn.getRdn() );
+        entry.setDn( newDn );
+        
         assertEquals( entry, result );
     }
 
@@ -168,6 +172,10 @@ public class ServerEntrySerializerTest
         
         ServerEntry result = (ServerEntry)ses.deserialize( data );
         
+        DN newDn = new DN();
+        newDn.add( dn.getRdn() );
+        entry.setDn( newDn );
+        
         assertEquals( entry, result );
     }
 
@@ -189,6 +197,10 @@ public class ServerEntrySerializerTest
         
         ServerEntry result = (ServerEntry)ses.deserialize( data );
         
+        DN newDn = new DN();
+        newDn.add( dn.getRdn() );
+        entry.setDn( newDn );
+        
         assertEquals( entry, result );
     }
 

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=931632&r1=931631&r2=931632&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 Wed Apr  7 18:09:00 2010
@@ -426,23 +426,23 @@ public class GreaterEqTest
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
-        assertEquals( 7L, ( long ) cursor.get().getId() );
-        assertEquals( "5", cursor.get().getValue() );
+        assertEquals( 5L, ( long ) cursor.get().getId() );
+        assertEquals( "3", cursor.get().getValue() );
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
-        assertEquals( 8L, ( long ) cursor.get().getId() );
-        assertEquals( "6", cursor.get().getValue() );
+        assertEquals( 6L, ( long ) cursor.get().getId() );
+        assertEquals( "4", cursor.get().getValue() );
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
-        assertEquals( 6L, ( long ) cursor.get().getId() );
-        assertEquals( "4", cursor.get().getValue() );
+        assertEquals( 7L, ( long ) cursor.get().getId() );
+        assertEquals( "5", cursor.get().getValue() );
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
-        assertEquals( 5L, ( long ) cursor.get().getId() );
-        assertEquals( "3", cursor.get().getValue() );
+        assertEquals( 8L, ( long ) cursor.get().getId() );
+        assertEquals( "6", cursor.get().getValue() );
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
@@ -453,16 +453,12 @@ public class GreaterEqTest
         // ---------- test first() ----------
 
         cursor = new GreaterEqCursor( store, evaluator );
-        cursor.first();
-
-        assertTrue( cursor.available() );
-        assertEquals( 7L, ( long ) cursor.get().getId() );
-        assertEquals( "5", cursor.get().getValue() );
+        cursor.beforeFirst();
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
-        assertEquals( 8L, ( long ) cursor.get().getId() );
-        assertEquals( "6", cursor.get().getValue() );
+        assertEquals( 5L, ( long ) cursor.get().getId() );
+        assertEquals( "3", cursor.get().getValue() );
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
@@ -471,8 +467,13 @@ public class GreaterEqTest
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
-        assertEquals( 5L, ( long ) cursor.get().getId() );
-        assertEquals( "3", cursor.get().getValue() );
+        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() );
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
@@ -488,23 +489,23 @@ public class GreaterEqTest
 
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
-        assertEquals( 5L, ( long ) cursor.get().getId() );
-        assertEquals( "3", cursor.get().getValue() );
+        assertEquals( 8L, ( long ) cursor.get().getId() );
+        assertEquals( "6", cursor.get().getValue() );
 
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
-        assertEquals( 6L, ( long ) cursor.get().getId() );
-        assertEquals( "4", cursor.get().getValue() );
+        assertEquals( 7L, ( long ) cursor.get().getId() );
+        assertEquals( "5", cursor.get().getValue() );
 
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
-        assertEquals( 8L, ( long ) cursor.get().getId() );
-        assertEquals( "6", cursor.get().getValue() );
+        assertEquals( 6L, ( long ) cursor.get().getId() );
+        assertEquals( "4", cursor.get().getValue() );
 
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
-        assertEquals( 7L, ( long ) cursor.get().getId() );
-        assertEquals( "5", cursor.get().getValue() );
+        assertEquals( 5L, ( long ) cursor.get().getId() );
+        assertEquals( "3", cursor.get().getValue() );
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
@@ -515,23 +516,23 @@ public class GreaterEqTest
         cursor.last();
 
         assertTrue( cursor.available() );
-        assertEquals( 5L, ( long ) cursor.get().getId() );
-        assertEquals( "3", cursor.get().getValue() );
+        assertEquals( 8L, ( long ) cursor.get().getId() );
+        assertEquals( "6", cursor.get().getValue() );
 
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
-        assertEquals( 6L, ( long ) cursor.get().getId() );
-        assertEquals( "4", cursor.get().getValue() );
+        assertEquals( 7L, ( long ) cursor.get().getId() );
+        assertEquals( "5", cursor.get().getValue() );
 
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
-        assertEquals( 8L, ( long ) cursor.get().getId() );
-        assertEquals( "6", cursor.get().getValue() );
+        assertEquals( 6L, ( long ) cursor.get().getId() );
+        assertEquals( "4", cursor.get().getValue() );
 
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
-        assertEquals( 7L, ( long ) cursor.get().getId() );
-        assertEquals( "5", cursor.get().getValue() );
+        assertEquals( 5L, ( long ) cursor.get().getId() );
+        assertEquals( "3", cursor.get().getValue() );
 
         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=931632&r1=931631&r2=931632&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 Wed Apr  7 18:09:00 2010
@@ -451,18 +451,18 @@ public class LessEqTest
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
-        assertEquals( 3L, ( long ) cursor.get().getId() );
+        assertEquals( 2L, ( 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() );
+        assertEquals( 3L, ( 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() );
+        assertEquals( 4L, ( long ) cursor.get().getId() );
+        assertEquals( "2", cursor.get().getValue() );
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
@@ -486,6 +486,11 @@ public class LessEqTest
 
         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() );
 
@@ -496,11 +501,6 @@ public class LessEqTest
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
-        assertEquals( 2L, ( long ) cursor.get().getId() );
-        assertEquals( "1", cursor.get().getValue() );
-
-        assertTrue( cursor.next() );
-        assertTrue( cursor.available() );
         assertEquals( 5L, ( long ) cursor.get().getId() );
         assertEquals( "3", cursor.get().getValue() );
 
@@ -523,11 +523,6 @@ public class LessEqTest
 
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
-        assertEquals( 2L, ( long ) cursor.get().getId() );
-        assertEquals( "1", cursor.get().getValue() );
-
-        assertTrue( cursor.previous() );
-        assertTrue( cursor.available() );
         assertEquals( 4L, ( long ) cursor.get().getId() );
         assertEquals( "2", cursor.get().getValue() );
 
@@ -538,6 +533,11 @@ public class LessEqTest
 
         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() );
 
@@ -555,11 +555,6 @@ public class LessEqTest
 
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
-        assertEquals( 2L, ( long ) cursor.get().getId() );
-        assertEquals( "1", cursor.get().getValue() );
-
-        assertTrue( cursor.previous() );
-        assertTrue( cursor.available() );
         assertEquals( 4L, ( long ) cursor.get().getId() );
         assertEquals( "2", cursor.get().getValue() );
 
@@ -570,6 +565,11 @@ public class LessEqTest
 
         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() );
 

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=931632&r1=931631&r2=931632&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 Wed Apr  7 18:09:00 2010
@@ -45,6 +45,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.schema.loader.ldif.LdifSchemaLoader;
 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.util.ExceptionUtils;
 import org.junit.After;
 import org.junit.Before;
@@ -214,6 +215,8 @@ public class NestedFilterTest
     {
         String filter = "(&(|(postalCode=5)(postalCode=6))(!(ou=sales)))";
 
+        CsnSyntaxChecker csnSynChecker = new CsnSyntaxChecker();
+        
         ExprNode exprNode = FilterParser.parse( filter );
         optimizer.annotate( exprNode );
 
@@ -222,12 +225,12 @@ public class NestedFilterTest
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
         assertEquals( 7, ( long ) cursor.get().getId() );
-        assertEquals( "2.5.4.11=apache,2.5.4.11=board of directors,2.5.4.10=good times co.", cursor.get().getValue() );
+        assertTrue( csnSynChecker.isValidSyntax( cursor.get().getValue() ) );
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
         assertEquals( 8, ( long ) cursor.get().getId() );
-        assertEquals( "2.5.4.3=jack daniels,2.5.4.11=engineering,2.5.4.10=good times co.", cursor.get().getValue() );
+        assertTrue( csnSynChecker.isValidSyntax( cursor.get().getValue() ) );
 
         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=931632&r1=931631&r2=931632&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 Wed Apr  7 18:09:00 2010
@@ -36,6 +36,7 @@ import org.apache.directory.server.xdbm.
 import org.apache.directory.server.xdbm.search.Evaluator;
 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.ServerEntry;
 import org.apache.directory.shared.ldap.filter.ExprNode;
@@ -47,6 +48,8 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.schema.ldif.extractor.impl.DefaultSchemaLdifExtractor;
 import org.apache.directory.shared.ldap.schema.loader.ldif.LdifSchemaLoader;
 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.util.ExceptionUtils;
 import org.junit.After;
 import org.junit.Before;
@@ -67,6 +70,8 @@ public class NotCursorTest
 {
     private static final Logger LOG = LoggerFactory.getLogger( NotCursorTest.class.getSimpleName() );
 
+    CsnSyntaxChecker csnSynChecker = new CsnSyntaxChecker();
+    
     File wkdir;
     Store<ServerEntry, Long> store;
     static SchemaManager schemaManager = null;
@@ -172,27 +177,28 @@ public class NotCursorTest
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
         assertEquals( 1, ( long ) cursor.get().getId() );
-        assertEquals( "2.5.4.10=good times co.", cursor.get().getValue() );
+        assertTrue( csnSynChecker.isValidSyntax( cursor.get().getValue() ) );
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
-        assertEquals( 7, ( long ) cursor.get().getId() );
-        assertEquals( "2.5.4.11=apache,2.5.4.11=board of directors,2.5.4.10=good times co.", cursor.get().getValue() );
+        assertEquals( 2, ( long ) cursor.get().getId() );
+        assertTrue( csnSynChecker.isValidSyntax( cursor.get().getValue() ) );
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
         assertEquals( 3, ( long ) cursor.get().getId() );
-        assertEquals( "2.5.4.11=board of directors,2.5.4.10=good times co.", cursor.get().getValue() );
+        assertTrue( csnSynChecker.isValidSyntax( cursor.get().getValue() ) );
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
         assertEquals( 4, ( long ) cursor.get().getId() );
-        assertEquals( "2.5.4.11=engineering,2.5.4.10=good times co.", cursor.get().getValue() );
+        assertTrue( csnSynChecker.isValidSyntax( cursor.get().getValue() ) );
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
-        assertEquals( 2, ( long ) cursor.get().getId() );
-        assertEquals( "2.5.4.11=sales,2.5.4.10=good times co.", cursor.get().getValue() );
+        assertEquals( 7, ( long ) cursor.get().getId() );
+        assertTrue( csnSynChecker.isValidSyntax( cursor.get().getValue() ) );
+
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
@@ -217,29 +223,29 @@ public class NotCursorTest
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
         assertEquals( 1, ( long ) cursor.get().getId() );
-        assertEquals( "2.5.4.10=good times co.", cursor.get().getValue() );
+        assertTrue( csnSynChecker.isValidSyntax( cursor.get().getValue() ) );
 
         cursor.first();
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
-        assertEquals( 7, ( long ) cursor.get().getId() );
-        assertEquals( "2.5.4.11=apache,2.5.4.11=board of directors,2.5.4.10=good times co.", cursor.get().getValue() );
+        assertEquals( 2, ( long ) cursor.get().getId() );
+        assertTrue( csnSynChecker.isValidSyntax( cursor.get().getValue() ) );
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
         assertEquals( 3, ( long ) cursor.get().getId() );
-        assertEquals( "2.5.4.11=board of directors,2.5.4.10=good times co.", cursor.get().getValue() );
+        assertTrue( csnSynChecker.isValidSyntax( cursor.get().getValue() ) );
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
         assertEquals( 4, ( long ) cursor.get().getId() );
-        assertEquals( "2.5.4.11=engineering,2.5.4.10=good times co.", cursor.get().getValue() );
+        assertTrue( csnSynChecker.isValidSyntax( cursor.get().getValue() ) );
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
-        assertEquals( 2, ( long ) cursor.get().getId() );
-        assertEquals( "2.5.4.11=sales,2.5.4.10=good times co.", cursor.get().getValue() );
+        assertEquals( 7, ( long ) cursor.get().getId() );
+        assertTrue( csnSynChecker.isValidSyntax( cursor.get().getValue() ) );
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
@@ -248,29 +254,29 @@ public class NotCursorTest
 
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
-        assertEquals( 2, ( long ) cursor.get().getId() );
-        assertEquals( "2.5.4.11=sales,2.5.4.10=good times co.", cursor.get().getValue() );
+        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() );
-        assertEquals( "2.5.4.11=engineering,2.5.4.10=good times co.", cursor.get().getValue() );
+        assertTrue( csnSynChecker.isValidSyntax( cursor.get().getValue() ) );
 
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
         assertEquals( 3, ( long ) cursor.get().getId() );
-        assertEquals( "2.5.4.11=board of directors,2.5.4.10=good times co.", cursor.get().getValue() );
+        assertTrue( csnSynChecker.isValidSyntax( cursor.get().getValue() ) );
 
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
-        assertEquals( 7, ( long ) cursor.get().getId() );
-        assertEquals( "2.5.4.11=apache,2.5.4.11=board of directors,2.5.4.10=good times co.", cursor.get().getValue() );
+        assertEquals( 2, ( long ) cursor.get().getId() );
+        assertTrue( csnSynChecker.isValidSyntax( cursor.get().getValue() ) );
 
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
         assertEquals( 1, ( long ) cursor.get().getId() );
-        assertEquals( "2.5.4.10=good times co.", cursor.get().getValue() );
+        assertTrue( csnSynChecker.isValidSyntax( cursor.get().getValue() ) );
 
         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=931632&r1=931631&r2=931632&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 Wed Apr  7 18:09:00 2010
@@ -303,13 +303,13 @@ public class PresenceTest
         cursor.beforeFirst();
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
-        assertEquals( 8, ( long ) cursor.get().getId() );
+        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( 5, ( long ) cursor.get().getId() );
+        assertEquals( 8, ( long ) cursor.get().getId() );
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
 
@@ -336,7 +336,7 @@ public class PresenceTest
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
         assertEquals( SchemaConstants.SN_AT_OID, cursor.get().getValue() );
-        assertEquals( 5, ( long ) cursor.get().getId() );
+        assertEquals( 8, ( long ) cursor.get().getId() );
 
         // keep testing previous
         assertTrue( cursor.previous() );
@@ -347,7 +347,7 @@ public class PresenceTest
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
         assertEquals( SchemaConstants.SN_AT_OID, cursor.get().getValue() );
-        assertEquals( 8, ( long ) cursor.get().getId() );
+        assertEquals( 5, ( long ) cursor.get().getId() );
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );



Mime
View raw message