directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r642964 - in /directory/sandbox/akarasulu/bigbang: apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/ shared/ldap-constants/src/m...
Date Mon, 31 Mar 2008 11:14:39 GMT
Author: akarasulu
Date: Mon Mar 31 04:14:37 2008
New Revision: 642964

URL: http://svn.apache.org/viewvc?rev=642964&view=rev
Log:
check point before switching to bug fixes for 1.5.2 release - some additional fixes and tests
for the PresenceCursor which has issues.

Modified:
    directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceCursor.java
    directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceCursorTest.java
    directory/sandbox/akarasulu/bigbang/shared/ldap-constants/src/main/java/org/apache/directory/shared/ldap/constants/SchemaConstants.java

Modified: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceCursor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceCursor.java?rev=642964&r1=642963&r2=642964&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceCursor.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceCursor.java
Mon Mar 31 04:14:37 2008
@@ -41,7 +41,7 @@
     private static final String UNSUPPORTED_MSG =
         "PresenceCursors do not support positioning by element without a user index on the
presence attribute.";
     private final Cursor<IndexEntry<String,Attributes>> ndnCursor;
-    private final Cursor<IndexEntry<String,Attributes>> existenceCursor;
+    private final Cursor<IndexEntry<String,Attributes>> presenceCursor;
     private final PresenceEvaluator presenceEvaluator;
     private boolean available = false;
 
@@ -53,12 +53,12 @@
 
         if ( db.hasUserIndexOn( type.getOid() ) )
         {
-            existenceCursor = db.getPresenceIndex().forwardCursor( type.getOid() );
+            presenceCursor = db.getPresenceIndex().forwardCursor( type.getOid() );
             ndnCursor = null;
         }
         else
         {
-            existenceCursor = null;
+            presenceCursor = null;
             ndnCursor = db.getNdnIndex().forwardCursor();
         }
     }
@@ -66,9 +66,9 @@
 
     public boolean available()
     {
-        if ( existenceCursor != null )
+        if ( presenceCursor != null )
         {
-            return existenceCursor.available();
+            return presenceCursor.available();
         }
 
         return available;
@@ -77,10 +77,10 @@
 
     public void before( IndexEntry<?, Attributes> element ) throws Exception
     {
-        if ( existenceCursor != null )
+        if ( presenceCursor != null )
         {
             //noinspection unchecked
-            existenceCursor.before( ( IndexEntry<String,Attributes> ) element );
+            presenceCursor.before( ( IndexEntry<String,Attributes> ) element );
         }
 
         throw new UnsupportedOperationException( UNSUPPORTED_MSG );
@@ -89,10 +89,10 @@
 
     public void after( IndexEntry<?, Attributes> element ) throws Exception
     {
-        if ( existenceCursor != null )
+        if ( presenceCursor != null )
         {
             //noinspection unchecked
-            existenceCursor.after( ( IndexEntry<String,Attributes> ) element );
+            presenceCursor.after( ( IndexEntry<String,Attributes> ) element );
         }
 
         throw new UnsupportedOperationException( UNSUPPORTED_MSG );
@@ -101,9 +101,10 @@
 
     public void beforeFirst() throws Exception
     {
-        if ( existenceCursor != null )
+        if ( presenceCursor != null )
         {
-            existenceCursor.beforeFirst();
+            presenceCursor.beforeFirst();
+            return;
         }
 
         ndnCursor.beforeFirst();
@@ -113,9 +114,10 @@
 
     public void afterLast() throws Exception
     {
-        if ( existenceCursor != null )
+        if ( presenceCursor != null )
         {
-            existenceCursor.afterLast();
+            presenceCursor.afterLast();
+            return;
         }
 
         ndnCursor.afterLast();
@@ -125,9 +127,9 @@
 
     public boolean first() throws Exception
     {
-        if ( existenceCursor != null )
+        if ( presenceCursor != null )
         {
-            return existenceCursor.first();
+            return presenceCursor.first();
         }
 
         beforeFirst();
@@ -137,9 +139,9 @@
 
     public boolean last() throws Exception
     {
-        if ( existenceCursor != null )
+        if ( presenceCursor != null )
         {
-            return existenceCursor.last();
+            return presenceCursor.last();
         }
 
         afterLast();
@@ -149,9 +151,9 @@
 
     public boolean previous() throws Exception
     {
-        if ( existenceCursor != null )
+        if ( presenceCursor != null )
         {
-            return existenceCursor.previous();
+            return presenceCursor.previous();
         }
 
         while ( ndnCursor.previous() )
@@ -169,9 +171,9 @@
 
     public boolean next() throws Exception
     {
-        if ( existenceCursor != null )
+        if ( presenceCursor != null )
         {
-            return existenceCursor.next();
+            return presenceCursor.next();
         }
 
         while ( ndnCursor.next() )
@@ -189,11 +191,11 @@
 
     public IndexEntry<String, Attributes> get() throws Exception
     {
-        if ( existenceCursor != null )
+        if ( presenceCursor != null )
         {
-            if ( existenceCursor.available() )
+            if ( presenceCursor.available() )
             {
-                return existenceCursor.get();
+                return presenceCursor.get();
             }
 
             throw new InvalidCursorPositionException( "Cursor has not been positioned yet."
);
@@ -210,9 +212,9 @@
 
     public boolean isElementReused()
     {
-        if ( existenceCursor != null )
+        if ( presenceCursor != null )
         {
-            return existenceCursor.isElementReused();
+            return presenceCursor.isElementReused();
         }
 
         return ndnCursor.isElementReused();
@@ -223,9 +225,9 @@
     {
         super.close();
 
-        if ( existenceCursor != null )
+        if ( presenceCursor != null )
         {
-            existenceCursor.close();
+            presenceCursor.close();
         }
         else
         {

Modified: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceCursorTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceCursorTest.java?rev=642964&r1=642963&r2=642964&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceCursorTest.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceCursorTest.java
Mon Mar 31 04:14:37 2008
@@ -31,10 +31,12 @@
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex;
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmStore;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.filter.PresenceNode;
 import org.apache.commons.io.FileUtils;
 import org.junit.Before;
 import org.junit.After;
 import org.junit.Test;
+import static org.junit.Assert.*;
 
 import javax.naming.directory.Attributes;
 import java.io.File;
@@ -96,7 +98,7 @@
         store.setSyncOnWrite( false );
 
         store.addIndex( new JdbmIndex( SchemaConstants.OU_AT_OID ) );
-        store.addIndex( new JdbmIndex( SchemaConstants.UID_AT_OID ) );
+        store.addIndex( new JdbmIndex( SchemaConstants.CN_AT_OID ) );
         StoreUtils.loadExampleData( store, registries );
         LOG.debug( "Created new store" );
     }
@@ -121,8 +123,65 @@
 
 
     @Test
-    public void testPresenceIndex() throws Exception
+    public void testIndexedAttributes() throws Exception
     {
-        IndexUtils.printContents( store.getPresenceIndex() );
+        PresenceNode node = new PresenceNode( SchemaConstants.CN_AT_OID );
+        PresenceEvaluator evaluator = new PresenceEvaluator( node, store, registries );
+        PresenceCursor cursor = new PresenceCursor( store, evaluator );
+
+        cursor.beforeFirst();
+        assertTrue( cursor.next() );
+        assertEquals( 5, ( long ) cursor.get().getId() );
+        assertTrue( cursor.next() );
+        assertEquals( 6, ( long ) cursor.get().getId() );
+        assertTrue( cursor.next() );
+        assertEquals( 7, ( long ) cursor.get().getId() );
+        assertFalse( cursor.next() );
+
+        node = new PresenceNode( SchemaConstants.OU_AT_OID );
+        evaluator = new PresenceEvaluator( node, store, registries );
+        cursor = new PresenceCursor( store, evaluator );
+
+        cursor.beforeFirst();
+        assertTrue( cursor.next() );
+        assertEquals( 2, ( long ) cursor.get().getId() );
+        assertTrue( cursor.next() );
+        assertEquals( 3, ( long ) cursor.get().getId() );
+        assertTrue( cursor.next() );
+        assertEquals( 4, ( long ) cursor.get().getId() );
+        assertTrue( cursor.next() );
+        assertEquals( 5, ( long ) cursor.get().getId() );
+        assertTrue( cursor.next() );
+        assertEquals( 6, ( long ) cursor.get().getId() );
+        assertTrue( cursor.next() );
+        assertEquals( 7, ( long ) cursor.get().getId() );
+        assertFalse( cursor.next() );
+    }
+
+
+    @Test
+    public void testNonIndexedAttributes() throws Exception
+    {
+        PresenceNode node = new PresenceNode( SchemaConstants.SN_AT_OID );
+        PresenceEvaluator evaluator = new PresenceEvaluator( node, store, registries );
+        PresenceCursor cursor = new PresenceCursor( store, evaluator );
+
+        cursor.beforeFirst();
+        assertTrue( cursor.next() );
+        assertEquals( 5, ( long ) cursor.get().getId() );
+        assertTrue( cursor.next() );
+        assertEquals( 6, ( long ) cursor.get().getId() );
+        assertTrue( cursor.next() );
+        assertEquals( 7, ( long ) cursor.get().getId() );
+        assertFalse( cursor.next() );
+
+        node = new PresenceNode( SchemaConstants.O_AT_OID );
+        evaluator = new PresenceEvaluator( node, store, registries );
+        cursor = new PresenceCursor( store, evaluator );
+
+        cursor.beforeFirst();
+        assertTrue( cursor.next() );
+        assertEquals( 1, ( long ) cursor.get().getId() );
+        assertFalse( cursor.next() );
     }
 }

Modified: directory/sandbox/akarasulu/bigbang/shared/ldap-constants/src/main/java/org/apache/directory/shared/ldap/constants/SchemaConstants.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/shared/ldap-constants/src/main/java/org/apache/directory/shared/ldap/constants/SchemaConstants.java?rev=642964&r1=642963&r2=642964&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/shared/ldap-constants/src/main/java/org/apache/directory/shared/ldap/constants/SchemaConstants.java
(original)
+++ directory/sandbox/akarasulu/bigbang/shared/ldap-constants/src/main/java/org/apache/directory/shared/ldap/constants/SchemaConstants.java
Mon Mar 31 04:14:37 2008
@@ -140,10 +140,15 @@
     String SN_AT_OID = "2.5.4.4";
     
     // Ou
+    String O_AT = "o";
+    String ORGANIZATION_NAME_AT = "organizationName";
+    String O_AT_OID = "2.5.4.10";
+
+    // Ou
     String OU_AT = "ou";
     String ORGANIZATIONAL_UNIT_NAME_AT = "organizationalUnitName";
     String OU_AT_OID = "2.5.4.11";
-    
+
     // Member
     String MEMBER_AT = "member";
     String MEMBER_AT_OID = "2.5.4.31";



Mime
View raw message