directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r650736 - in /directory/sandbox/akarasulu/bigbang/apacheds: jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ xdbm-search/src/test/ja...
Date Wed, 23 Apr 2008 03:41:21 GMT
Author: akarasulu
Date: Tue Apr 22 20:41:20 2008
New Revision: 650736

URL: http://svn.apache.org/viewvc?rev=650736&view=rev
Log:
checkpointing some work adding tests for the GreaterEq cursor and evaluator - there is some
breakage due to the jdbm bug in the substring code

Added:
    directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/GreaterEqTest.java
      - copied, changed from r650348, directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/LessEqTest.java
Modified:
    directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/DupsContainerCursor.java
    directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqCursor.java
    directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqEvaluator.java
    directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/LessEqTest.java

Modified: directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/DupsContainerCursor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/DupsContainerCursor.java?rev=650736&r1=650735&r2=650736&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/DupsContainerCursor.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/DupsContainerCursor.java
Tue Apr 22 20:41:20 2008
@@ -89,6 +89,7 @@
     public void before( Tuple<K,DupsContainer<V>> element ) throws IOException
     {
         browser = table.getBTree().browse( element.getKey() );
+        forwardDirection = null;
         clearValue();
     }
 
@@ -96,6 +97,7 @@
     public void after( Tuple<K,DupsContainer<V>> element ) throws IOException
     {
         browser = table.getBTree().browse( element.getKey() );
+        forwardDirection = null;
 
         /*
          * While the next value is less than or equal to the element keep
@@ -132,6 +134,7 @@
     public void beforeFirst() throws IOException
     {
         browser = table.getBTree().browse();
+        forwardDirection = null;
         clearValue();
     }
 
@@ -139,6 +142,7 @@
     public void afterLast() throws IOException
     {
         browser = table.getBTree().browse( null );
+        forwardDirection = null;
         clearValue();
     }
 
@@ -166,12 +170,14 @@
 
         boolean advanceSuccess = browser.getPrevious( jdbmTuple );
 
-        if ( forwardDirection == null )
+        // only want to set this if the advance is a success which means we
+        // are not at front
+        if ( forwardDirection == null && advanceSuccess )
         {
             forwardDirection = false;
         }
 
-        if ( forwardDirection )
+        if ( forwardDirection != null && forwardDirection )
         {
             advanceSuccess = browser.getPrevious( jdbmTuple );
             forwardDirection = false;
@@ -201,12 +207,14 @@
 
         boolean advanceSuccess = browser.getNext( jdbmTuple );
 
-        if ( forwardDirection == null )
+        // only want to set this if the advance is a success which means
+        // we are not at end
+        if ( forwardDirection == null && advanceSuccess )
         {
             forwardDirection = true;
         }
 
-        if ( ! forwardDirection )
+        if ( forwardDirection != null && ! forwardDirection )
         {
             advanceSuccess = browser.getNext( jdbmTuple );
             forwardDirection = true;

Modified: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqCursor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqCursor.java?rev=650736&r1=650735&r2=650736&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqCursor.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqCursor.java
Tue Apr 22 20:41:20 2008
@@ -54,6 +54,13 @@
     /** NDN Cursor on all entries in  (set when no index on user attribute) */
     private final Cursor<IndexEntry<String,Attributes>> ndnIdxCursor;
 
+    /**
+     * Used to store indexEntry from ndnCandidate so it can be saved after
+     * call to evaluate() which changes the value so it's not referring to
+     * the NDN but to the value of the attribute instead.
+     */
+    IndexEntry<String, Attributes> ndnCandidate;
+
     /** used in both modes */
     private boolean available = false;
 
@@ -163,6 +170,7 @@
         else
         {
             ndnIdxCursor.beforeFirst();
+            ndnCandidate = null;
         }
 
         available = false;
@@ -178,6 +186,7 @@
         else
         {
             ndnIdxCursor.afterLast();
+            ndnCandidate = null;
         }
 
         available = false;
@@ -221,8 +230,8 @@
 
         while( ndnIdxCursor.previous() )
         {
-            IndexEntry<?,Attributes> candidate = ndnIdxCursor.get();
-            if ( greaterEqEvaluator.evaluate( candidate ) )
+            ndnCandidate = ndnIdxCursor.get();
+            if ( greaterEqEvaluator.evaluate( ndnCandidate ) )
             {
                  return available = true;
             }
@@ -245,8 +254,8 @@
 
         while( ndnIdxCursor.next() )
         {
-            IndexEntry<?,Attributes> candidate = ndnIdxCursor.get();
-            if ( greaterEqEvaluator.evaluate( candidate ) )
+            ndnCandidate = ndnIdxCursor.get();
+            if ( greaterEqEvaluator.evaluate( ndnCandidate ) )
             {
                  return available = true;
             }
@@ -270,7 +279,7 @@
 
         if ( available )
         {
-            return ndnIdxCursor.get();
+            return ndnCandidate;
         }
 
         throw new InvalidCursorPositionException( "Cursor has not been positioned yet." );

Modified: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqEvaluator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqEvaluator.java?rev=650736&r1=650735&r2=650736&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqEvaluator.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqEvaluator.java
Tue Apr 22 20:41:20 2008
@@ -52,7 +52,7 @@
     private final AttributeType type;
     private final Normalizer normalizer;
     private final Comparator comparator;
-    private final Index<Number,Attributes> idx;
+    private final Index<Object,Attributes> idx;
 
 
     public GreaterEqEvaluator( GreaterEqNode node, Store<Attributes> db, Registries
registries )
@@ -125,7 +125,7 @@
     {
         if ( idx != null )
         {
-            return idx.forwardGreaterOrEq( ( Number ) indexEntry.getValue(), indexEntry.getId()
);
+            return idx.reverseGreaterOrEq( indexEntry.getId(), node.getValue() );
         }
 
         Attributes entry = indexEntry.getObject();
@@ -141,7 +141,7 @@
         Attribute attr = AttributeUtils.getAttribute( entry, type );
 
         // if the attribute does not exist just return false
-        if ( attr != null && evaluate( attr ) )
+        if ( attr != null && evaluate( ( IndexEntry<Object,Attributes> ) indexEntry,
attr ) )
         {
             return true;
         }
@@ -163,7 +163,7 @@
 
                 attr = AttributeUtils.getAttribute( entry, descendant );
 
-                if ( attr != null && evaluate( attr ) )
+                if ( attr != null && evaluate( ( IndexEntry<Object,Attributes>
) indexEntry, attr ) )
                 {
                     return true;
                 }
@@ -175,7 +175,7 @@
     }
 
 
-    private boolean evaluate( Attribute attribute ) throws Exception
+    private boolean evaluate( IndexEntry<Object,Attributes> indexEntry, Attribute attribute
) throws Exception
     {
         /*
          * Cycle through the attribute values testing normalized version
@@ -193,6 +193,7 @@
             //noinspection unchecked
             if ( comparator.compare( value, node.getValue() ) >= 0 )
             {
+                indexEntry.setValue( value );
                 values.close();
                 return true;
             }

Copied: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/GreaterEqTest.java
(from r650348, directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/LessEqTest.java)
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/GreaterEqTest.java?p2=directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/GreaterEqTest.java&p1=directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/LessEqTest.java&r1=650348&r2=650736&rev=650736&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/LessEqTest.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/GreaterEqTest.java
Tue Apr 22 20:41:20 2008
@@ -32,7 +32,7 @@
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex;
 import org.apache.directory.server.core.cursor.InvalidCursorPositionException;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
-import org.apache.directory.shared.ldap.filter.LessEqNode;
+import org.apache.directory.shared.ldap.filter.GreaterEqNode;
 import org.apache.directory.shared.ldap.schema.*;
 import org.apache.directory.shared.ldap.message.AttributesImpl;
 import org.apache.directory.shared.ldap.name.LdapDN;
@@ -55,14 +55,14 @@
 
 
 /**
- * Tests the LessEqEvaluator and LessEqCursor classes for correct operation.
+ * Tests the GreaterEqEvaluator and GreaterEqCursor classes for correct operation.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $$Rev$$
  */
-public class LessEqTest
+public class GreaterEqTest
 {
-    public static final Logger LOG = LoggerFactory.getLogger( OneLevelScopeTest.class );
+    public static final Logger LOG = LoggerFactory.getLogger( GreaterEqTest.class );
 
 
     File wkdir;
@@ -71,7 +71,7 @@
     AttributeTypeRegistry attributeRegistry;
 
 
-    public LessEqTest() throws Exception
+    public GreaterEqTest() throws Exception
     {
         // setup the standard registries
         BootstrapSchemaLoader loader = new BootstrapSchemaLoader();
@@ -139,9 +139,9 @@
     @Test
     public void testCursorIndexed() throws Exception
     {
-        LessEqNode node = new LessEqNode( SchemaConstants.POSTALCODE_AT_OID, "3" );
-        LessEqEvaluator evaluator = new LessEqEvaluator( node, store, registries );
-        LessEqCursor cursor = new LessEqCursor( store, evaluator );
+        GreaterEqNode node = new GreaterEqNode( SchemaConstants.POSTALCODE_AT_OID, "3" );
+        GreaterEqEvaluator evaluator = new GreaterEqEvaluator( node, store, registries );
+        GreaterEqCursor cursor = new GreaterEqCursor( store, evaluator );
         assertNotNull( cursor );
         assertFalse( cursor.available() );
         assertTrue( cursor.isElementReused() );
@@ -159,28 +159,23 @@
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
-        assertEquals( 1L, ( long ) cursor.get().getId() );
-        assertEquals( "1", cursor.get().getValue() );
+        assertEquals( 5L, ( long ) cursor.get().getId() );
+        assertEquals( "3", cursor.get().getValue() );
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
-        assertEquals( 2L, ( long ) cursor.get().getId() );
-        assertEquals( "1", cursor.get().getValue() );
+        assertEquals( 6L, ( long ) cursor.get().getId() );
+        assertEquals( "4", cursor.get().getValue() );
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
-        assertEquals( 3L, ( long ) cursor.get().getId() );
-        assertEquals( "1", cursor.get().getValue() );
+        assertEquals( 7L, ( long ) cursor.get().getId() );
+        assertEquals( "5", cursor.get().getValue() );
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
-        assertEquals( 4L, ( long ) cursor.get().getId() );
-        assertEquals( "2", cursor.get().getValue() );
-
-        assertTrue( cursor.next() );
-        assertTrue( cursor.available() );
-        assertEquals( 5L, ( long ) cursor.get().getId() );
-        assertEquals( "3", cursor.get().getValue() );
+        assertEquals( 8L, ( long ) cursor.get().getId() );
+        assertEquals( "6", cursor.get().getValue() );
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
@@ -189,33 +184,28 @@
 
         // ---------- test first() ----------
 
-        cursor = new LessEqCursor( store, evaluator );
+        cursor = new GreaterEqCursor( store, evaluator );
 
         cursor.first();
 
         assertTrue( cursor.available() );
-        assertEquals( 1L, ( long ) cursor.get().getId() );
-        assertEquals( "1", cursor.get().getValue() );
-
-        assertTrue( cursor.next() );
-        assertTrue( cursor.available() );
-        assertEquals( 2L, ( long ) cursor.get().getId() );
-        assertEquals( "1", cursor.get().getValue() );
+        assertEquals( 5L, ( long ) cursor.get().getId() );
+        assertEquals( "3", cursor.get().getValue() );
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
-        assertEquals( 3L, ( long ) cursor.get().getId() );
-        assertEquals( "1", cursor.get().getValue() );
+        assertEquals( 6L, ( long ) cursor.get().getId() );
+        assertEquals( "4", cursor.get().getValue() );
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
-        assertEquals( 4L, ( long ) cursor.get().getId() );
-        assertEquals( "2", 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() );
@@ -224,35 +214,30 @@
 
         // ---------- test afterLast() ----------
 
-        cursor = new LessEqCursor( store, evaluator );
+        cursor = new GreaterEqCursor( store, evaluator );
 
         cursor.afterLast();
         assertFalse( cursor.available() );
 
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
-        assertEquals( 5L, ( long ) cursor.get().getId() );
-        assertEquals( "3", cursor.get().getValue() );
-
-        assertTrue( cursor.previous() );
-        assertTrue( cursor.available() );
-        assertEquals( 4L, ( long ) cursor.get().getId() );
-        assertEquals( "2", cursor.get().getValue() );
+        assertEquals( 8L, ( long ) cursor.get().getId() );
+        assertEquals( "6", cursor.get().getValue() );
 
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
-        assertEquals( 3L, ( long ) cursor.get().getId() );
-        assertEquals( "1", cursor.get().getValue() );
+        assertEquals( 7L, ( long ) cursor.get().getId() );
+        assertEquals( "5", cursor.get().getValue() );
 
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
-        assertEquals( 2L, ( long ) cursor.get().getId() );
-        assertEquals( "1", cursor.get().getValue() );
+        assertEquals( 6L, ( long ) cursor.get().getId() );
+        assertEquals( "4", cursor.get().getValue() );
 
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
-        assertEquals( 1L, ( long ) cursor.get().getId() );
-        assertEquals( "1", cursor.get().getValue() );
+        assertEquals( 5L, ( long ) cursor.get().getId() );
+        assertEquals( "3", cursor.get().getValue() );
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
@@ -261,33 +246,28 @@
 
         // ---------- test last() ----------
 
-        cursor = new LessEqCursor( store, evaluator );
+        cursor = new GreaterEqCursor( store, evaluator );
 
         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( 4L, ( long ) cursor.get().getId() );
-        assertEquals( "2", cursor.get().getValue() );
+        assertEquals( 7L, ( long ) cursor.get().getId() );
+        assertEquals( "5", cursor.get().getValue() );
 
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
-        assertEquals( 3L, ( long ) cursor.get().getId() );
-        assertEquals( "1", cursor.get().getValue() );
+        assertEquals( 6L, ( long ) cursor.get().getId() );
+        assertEquals( "4", cursor.get().getValue() );
 
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
-        assertEquals( 2L, ( long ) cursor.get().getId() );
-        assertEquals( "1", cursor.get().getValue() );
-
-        assertTrue( cursor.previous() );
-        assertTrue( cursor.available() );
-        assertEquals( 1L, ( long ) cursor.get().getId() );
-        assertEquals( "1", cursor.get().getValue() );
+        assertEquals( 5L, ( long ) cursor.get().getId() );
+        assertEquals( "3", cursor.get().getValue() );
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
@@ -296,9 +276,9 @@
 
         // ---------- test before() ----------
 
-        cursor = new LessEqCursor( store, evaluator );
+        cursor = new GreaterEqCursor( store, evaluator );
         ForwardIndexEntry<String,Attributes> indexEntry = new ForwardIndexEntry<String,Attributes>();
-        indexEntry.setValue( "2" );
+        indexEntry.setValue( "5" );
 
         assertFalse( cursor.available() );
         cursor.before( indexEntry );
@@ -306,30 +286,30 @@
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
-        assertEquals( 4L, ( long ) cursor.get().getId() );
-        assertEquals( "2", 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() );
         cursor.close();
         assertTrue( cursor.isClosed() );
 
-        cursor = new LessEqCursor( store, evaluator );
+        cursor = new GreaterEqCursor( store, evaluator );
         indexEntry = new ForwardIndexEntry<String,Attributes>();
         indexEntry.setValue( "7" );
         cursor.before( indexEntry );
         assertFalse( cursor.available() );
         assertTrue( cursor.previous() );
-        assertEquals( 5L, ( long ) cursor.get().getId() );
-        assertEquals( "3", cursor.get().getValue() );
+        assertEquals( 8L, ( long ) cursor.get().getId() );
+        assertEquals( "6", cursor.get().getValue() );
         cursor.close();
 
-        cursor = new LessEqCursor( store, evaluator );
+        cursor = new GreaterEqCursor( store, evaluator );
         indexEntry = new ForwardIndexEntry<String,Attributes>();
         indexEntry.setValue( "3" );
         cursor.before( indexEntry );
@@ -341,9 +321,9 @@
 
         // ---------- test after() ----------
 
-        cursor = new LessEqCursor( store, evaluator );
+        cursor = new GreaterEqCursor( store, evaluator );
         indexEntry = new ForwardIndexEntry<String,Attributes>();
-        indexEntry.setValue( "1" );
+        indexEntry.setValue( "4" );
 
         assertFalse( cursor.available() );
         cursor.after( indexEntry );
@@ -351,30 +331,30 @@
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
-        assertEquals( 4L, ( long ) cursor.get().getId() );
-        assertEquals( "2", 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() );
         cursor.close();
         assertTrue( cursor.isClosed() );
 
-        cursor = new LessEqCursor( store, evaluator );
+        cursor = new GreaterEqCursor( store, evaluator );
         indexEntry = new ForwardIndexEntry<String,Attributes>();
         indexEntry.setValue( "7" );
         cursor.after( indexEntry );
         assertFalse( cursor.available() );
         assertTrue( cursor.previous() );
-        assertEquals( 5L, ( long ) cursor.get().getId() );
-        assertEquals( "3", cursor.get().getValue() );
+        assertEquals( 8L, ( long ) cursor.get().getId() );
+        assertEquals( "6", cursor.get().getValue() );
         cursor.close();
 
-        cursor = new LessEqCursor( store, evaluator );
+        cursor = new GreaterEqCursor( store, evaluator );
         indexEntry = new ForwardIndexEntry<String,Attributes>();
         indexEntry.setValue( "3" );
         cursor.after( indexEntry );
@@ -389,9 +369,9 @@
     @Test
     public void testCursorNotIndexed() throws Exception
     {
-        LessEqNode node = new LessEqNode( SchemaConstants.POSTOFFICEBOX_AT_OID, "3" );
-        LessEqEvaluator evaluator = new LessEqEvaluator( node, store, registries );
-        LessEqCursor cursor = new LessEqCursor( store, evaluator );
+        GreaterEqNode node = new GreaterEqNode( SchemaConstants.POSTOFFICEBOX_AT_OID, "3"
);
+        GreaterEqEvaluator evaluator = new GreaterEqEvaluator( node, store, registries );
+        GreaterEqCursor cursor = new GreaterEqCursor( store, evaluator );
         assertNotNull( cursor );
         assertFalse( cursor.available() );
         assertTrue( cursor.isElementReused() );
@@ -409,23 +389,18 @@
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
-        assertEquals( 1L, ( long ) cursor.get().getId() );
-        assertEquals( "1", cursor.get().getValue() );
+        assertEquals( 7L, ( long ) cursor.get().getId() );
+        assertEquals( "5", cursor.get().getValue() );
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
-        assertEquals( 3L, ( long ) cursor.get().getId() );
-        assertEquals( "1", cursor.get().getValue() );
+        assertEquals( 8L, ( long ) cursor.get().getId() );
+        assertEquals( "6", cursor.get().getValue() );
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
-        assertEquals( 4L, ( long ) cursor.get().getId() );
-        assertEquals( "2", cursor.get().getValue() );
-
-        assertTrue( cursor.next() );
-        assertTrue( cursor.available() );
-        assertEquals( 2L, ( long ) cursor.get().getId() );
-        assertEquals( "1", cursor.get().getValue() );
+        assertEquals( 6L, ( long ) cursor.get().getId() );
+        assertEquals( "4", cursor.get().getValue() );
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
@@ -438,29 +413,24 @@
         cursor.close();
         assertTrue( cursor.isClosed() );
 
-        // ---------- test beforeFirst() ----------
+        // ---------- test first() ----------
 
-        cursor = new LessEqCursor( store, evaluator );
+        cursor = new GreaterEqCursor( store, evaluator );
         cursor.first();
 
         assertTrue( cursor.available() );
-        assertEquals( 1L, ( 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() );
+        assertEquals( 7L, ( long ) cursor.get().getId() );
+        assertEquals( "5", cursor.get().getValue() );
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
-        assertEquals( 4L, ( long ) cursor.get().getId() );
-        assertEquals( "2", cursor.get().getValue() );
+        assertEquals( 8L, ( long ) cursor.get().getId() );
+        assertEquals( "6", cursor.get().getValue() );
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
-        assertEquals( 2L, ( long ) cursor.get().getId() );
-        assertEquals( "1", cursor.get().getValue() );
+        assertEquals( 6L, ( long ) cursor.get().getId() );
+        assertEquals( "4", cursor.get().getValue() );
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
@@ -475,7 +445,7 @@
 
         // ---------- test afterLast() ----------
 
-        cursor = new LessEqCursor( store, evaluator );
+        cursor = new GreaterEqCursor( store, evaluator );
         cursor.afterLast();
         assertFalse( cursor.available() );
 
@@ -486,30 +456,25 @@
 
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
-        assertEquals( 2L, ( long ) cursor.get().getId() );
-        assertEquals( "1", cursor.get().getValue() );
+        assertEquals( 6L, ( long ) cursor.get().getId() );
+        assertEquals( "4", cursor.get().getValue() );
 
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
-        assertEquals( 4L, ( long ) cursor.get().getId() );
-        assertEquals( "2", cursor.get().getValue() );
+        assertEquals( 8L, ( long ) cursor.get().getId() );
+        assertEquals( "6", cursor.get().getValue() );
 
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
-        assertEquals( 3L, ( long ) cursor.get().getId() );
-        assertEquals( "1", cursor.get().getValue() );
-
-        assertTrue( cursor.previous() );
-        assertTrue( cursor.available() );
-        assertEquals( 1L, ( long ) cursor.get().getId() );
-        assertEquals( "1", cursor.get().getValue() );
+        assertEquals( 7L, ( long ) cursor.get().getId() );
+        assertEquals( "5", cursor.get().getValue() );
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
 
         // ---------- test last() ----------
 
-        cursor = new LessEqCursor( store, evaluator );
+        cursor = new GreaterEqCursor( store, evaluator );
         cursor.last();
 
         assertTrue( cursor.available() );
@@ -518,30 +483,25 @@
 
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
-        assertEquals( 2L, ( long ) cursor.get().getId() );
-        assertEquals( "1", cursor.get().getValue() );
+        assertEquals( 6L, ( long ) cursor.get().getId() );
+        assertEquals( "4", cursor.get().getValue() );
 
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
-        assertEquals( 4L, ( long ) cursor.get().getId() );
-        assertEquals( "2", cursor.get().getValue() );
+        assertEquals( 8L, ( long ) cursor.get().getId() );
+        assertEquals( "6", cursor.get().getValue() );
 
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
-        assertEquals( 3L, ( long ) cursor.get().getId() );
-        assertEquals( "1", cursor.get().getValue() );
-
-        assertTrue( cursor.previous() );
-        assertTrue( cursor.available() );
-        assertEquals( 1L, ( long ) cursor.get().getId() );
-        assertEquals( "1", cursor.get().getValue() );
+        assertEquals( 7L, ( long ) cursor.get().getId() );
+        assertEquals( "5", cursor.get().getValue() );
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
 
         // ---------- test before() ----------
 
-        cursor = new LessEqCursor( store, evaluator );
+        cursor = new GreaterEqCursor( store, evaluator );
         ForwardIndexEntry<String,Attributes> indexEntry = new ForwardIndexEntry<String,Attributes>();
         indexEntry.setValue( "2" );
         try { cursor.before( indexEntry ); fail( "Should never get here." );}
@@ -549,7 +509,7 @@
 
         // ---------- test after() ----------
 
-        cursor = new LessEqCursor( store, evaluator );
+        cursor = new GreaterEqCursor( store, evaluator );
         indexEntry = new ForwardIndexEntry<String,Attributes>();
         indexEntry.setValue( "2" );
         try { cursor.after( indexEntry ); fail( "Should never get here." );}
@@ -565,8 +525,8 @@
     @Test
     public void testEvaluatorIndexed() throws Exception
     {
-        LessEqNode node = new LessEqNode( SchemaConstants.POSTALCODE_AT_OID, "3" );
-        LessEqEvaluator evaluator = new LessEqEvaluator( node, store, registries );
+        GreaterEqNode node = new GreaterEqNode( SchemaConstants.POSTALCODE_AT_OID, "3" );
+        GreaterEqEvaluator evaluator = new GreaterEqEvaluator( node, store, registries );
         ForwardIndexEntry<String,Attributes> indexEntry = new ForwardIndexEntry<String,Attributes>();
         assertEquals( node, evaluator.getExpression() );
         assertEquals( SchemaConstants.POSTALCODE_AT_OID, evaluator.getAttributeType().getOid()
);
@@ -574,11 +534,11 @@
         assertNotNull( evaluator.getComparator() );
 
         indexEntry.setId( 1L );
-        assertTrue( evaluator.evaluate( indexEntry ) );
+        assertFalse( evaluator.evaluate( indexEntry ) );
 
         indexEntry = new ForwardIndexEntry<String,Attributes>();
         indexEntry.setId( 4L );
-        assertTrue( evaluator.evaluate( indexEntry ) );
+        assertFalse( evaluator.evaluate( indexEntry ) );
 
         indexEntry = new ForwardIndexEntry<String,Attributes>();
         indexEntry.setId( 5L );
@@ -586,15 +546,15 @@
 
         indexEntry = new ForwardIndexEntry<String,Attributes>();
         indexEntry.setId( 6L );
-        assertFalse( evaluator.evaluate( indexEntry ) );
+        assertTrue( evaluator.evaluate( indexEntry ) );
 
         indexEntry = new ForwardIndexEntry<String,Attributes>();
         indexEntry.setId( 7L );
-        assertFalse( evaluator.evaluate( indexEntry ) );
+        assertTrue( evaluator.evaluate( indexEntry ) );
 
         indexEntry = new ForwardIndexEntry<String,Attributes>();
         indexEntry.setId( 8L );
-        assertFalse( evaluator.evaluate( indexEntry ) );
+        assertTrue( evaluator.evaluate( indexEntry ) );
 
         indexEntry = new ForwardIndexEntry<String,Attributes>();
         indexEntry.setId( 9L );
@@ -609,8 +569,8 @@
     @Test
     public void testEvaluatorWithDescendantValue() throws Exception
     {
-        LessEqNode node = new LessEqNode( SchemaConstants.STREET_AT_OID, "2" );
-        LessEqEvaluator evaluator = new LessEqEvaluator( node, store, registries );
+        GreaterEqNode node = new GreaterEqNode( SchemaConstants.STREET_AT_OID, "2" );
+        GreaterEqEvaluator evaluator = new GreaterEqEvaluator( node, store, registries );
         ForwardIndexEntry<String,Attributes> indexEntry = new ForwardIndexEntry<String,Attributes>();
         assertEquals( node, evaluator.getExpression() );
         assertEquals( SchemaConstants.STREET_AT_OID, evaluator.getAttributeType().getOid()
);
@@ -620,7 +580,7 @@
         LdapDN dn = new LdapDN( "cn=jane doe,o=good times co." );
         dn.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
         AttributesImpl attrs = new AttributesImpl( "objectClass", "person", true );
-        attrs.put( "c-street", "1" );
+        attrs.put( "c-street", "3" );
         attrs.put( "cn", "jane doe" );
         attrs.put( "sn", "doe" );
         store.add( dn, attrs );
@@ -633,8 +593,8 @@
     @Test
     public void testEvaluatorWithoutDescendants() throws Exception
     {
-        LessEqNode node = new LessEqNode( SchemaConstants.C_POSTALCODE_AT_OID, "2" );
-        LessEqEvaluator evaluator = new LessEqEvaluator( node, store, registries );
+        GreaterEqNode node = new GreaterEqNode( SchemaConstants.C_POSTALCODE_AT_OID, "2"
);
+        GreaterEqEvaluator evaluator = new GreaterEqEvaluator( node, store, registries );
         ForwardIndexEntry<String,Attributes> indexEntry = new ForwardIndexEntry<String,Attributes>();
         assertEquals( node, evaluator.getExpression() );
         assertEquals( SchemaConstants.C_POSTALCODE_AT_OID, evaluator.getAttributeType().getOid()
);
@@ -649,8 +609,8 @@
     @Test
     public void testEvaluatorNotIndexed() throws Exception
     {
-        LessEqNode node = new LessEqNode( SchemaConstants.POSTOFFICEBOX_AT_OID, "3" );
-        LessEqEvaluator evaluator = new LessEqEvaluator( node, store, registries );
+        GreaterEqNode node = new GreaterEqNode( SchemaConstants.POSTOFFICEBOX_AT_OID, "3"
);
+        GreaterEqEvaluator evaluator = new GreaterEqEvaluator( node, store, registries );
         ForwardIndexEntry<String,Attributes> indexEntry = new ForwardIndexEntry<String,Attributes>();
         assertEquals( node, evaluator.getExpression() );
         assertEquals( SchemaConstants.POSTOFFICEBOX_AT_OID, evaluator.getAttributeType().getOid()
);
@@ -658,11 +618,11 @@
         assertNotNull( evaluator.getComparator() );
 
         indexEntry.setId( 1L );
-        assertTrue( evaluator.evaluate( indexEntry ) );
+        assertFalse( evaluator.evaluate( indexEntry ) );
 
         indexEntry = new ForwardIndexEntry<String,Attributes>();
         indexEntry.setId( 4L );
-        assertTrue( evaluator.evaluate( indexEntry ) );
+        assertFalse( evaluator.evaluate( indexEntry ) );
 
         indexEntry = new ForwardIndexEntry<String,Attributes>();
         indexEntry.setId( 5L );
@@ -670,15 +630,15 @@
 
         indexEntry = new ForwardIndexEntry<String,Attributes>();
         indexEntry.setId( 6L );
-        assertFalse( evaluator.evaluate( indexEntry ) );
+        assertTrue( evaluator.evaluate( indexEntry ) );
 
         indexEntry = new ForwardIndexEntry<String,Attributes>();
         indexEntry.setId( 7L );
-        assertFalse( evaluator.evaluate( indexEntry ) );
+        assertTrue( evaluator.evaluate( indexEntry ) );
 
         indexEntry = new ForwardIndexEntry<String,Attributes>();
         indexEntry.setId( 8L );
-        assertFalse( evaluator.evaluate( indexEntry ) );
+        assertTrue( evaluator.evaluate( indexEntry ) );
 
         indexEntry = new ForwardIndexEntry<String,Attributes>();
         indexEntry.setId( 9L );
@@ -809,8 +769,8 @@
             }
         };
         registries.getAttributeTypeRegistry().register( at );
-        LessEqNode node = new LessEqNode( at.getOid(), "3" );
-        new LessEqEvaluator( node, store, registries );
+        GreaterEqNode node = new GreaterEqNode( at.getOid(), "3" );
+        new GreaterEqEvaluator( node, store, registries );
         registries.getAttributeTypeRegistry().unregister( at.getOid() );
     }
 
@@ -994,8 +954,8 @@
             }
         };
         registries.getAttributeTypeRegistry().register( at );
-        LessEqNode node = new LessEqNode( at.getOid(), "3" );
-        new LessEqEvaluator( node, store, registries );
+        GreaterEqNode node = new GreaterEqNode( at.getOid(), "3" );
+        new GreaterEqEvaluator( node, store, registries );
         registries.getAttributeTypeRegistry().unregister( at.getOid() );
     }
-}
+}
\ No newline at end of file

Modified: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/LessEqTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/LessEqTest.java?rev=650736&r1=650735&r2=650736&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/LessEqTest.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/LessEqTest.java
Tue Apr 22 20:41:20 2008
@@ -62,7 +62,7 @@
  */
 public class LessEqTest
 {
-    public static final Logger LOG = LoggerFactory.getLogger( OneLevelScopeTest.class );
+    public static final Logger LOG = LoggerFactory.getLogger( LessEqTest.class );
 
 
     File wkdir;



Mime
View raw message