directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r636988 - in /directory/sandbox/akarasulu/bigbang: ./ apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/ apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ apa...
Date Fri, 14 Mar 2008 04:12:46 GMT
Author: akarasulu
Date: Thu Mar 13 21:12:45 2008
New Revision: 636988

URL: http://svn.apache.org/viewvc?rev=636988&view=rev
Log:
adding more test cases and fixing bugs

Added:
    directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndexTest.java
    directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/NoEqMatchAttribute.java
Modified:
    directory/sandbox/akarasulu/bigbang/   (props changed)
    directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/Index.java
    directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java
    directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java
    directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/MarshallerSerializerBridge.java

Propchange: directory/sandbox/akarasulu/bigbang/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Thu Mar 13 21:12:45 2008
@@ -1,4 +1,5 @@
 workspace
+.clover
 *.ipr
 lost+found
 *.log

Modified: directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/Index.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/Index.java?rev=636988&r1=636987&r2=636988&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/Index.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/Index.java
Thu Mar 13 21:12:45 2008
@@ -96,6 +96,20 @@
     File getWkDirPath();
 
 
+    /**
+     * Checks whether or not calls to count the number of keys greater than or
+     * less than the key are exact.
+     *
+     * Checking to see the number of values greater than or less than some key
+     * may be excessively costly.  Since this is not a critical function but
+     * one that assists in optimizing searches some implementations can just
+     * return a worst case (maximum) guess.
+     *
+     * @return true if the count is an exact value or a worst case guess
+     */
+    boolean isCountExact();
+
+
     // -----------------------------------------------------------------------
     // E N D   C O N F I G U R A T I O N   M E T H O D S
     // -----------------------------------------------------------------------

Modified: directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.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/JdbmIndex.java?rev=636988&r1=636987&r2=636988&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java
Thu Mar 13 21:12:45 2008
@@ -34,6 +34,7 @@
 import javax.naming.NamingException;
 import java.io.File;
 import java.io.IOException;
+import java.util.Comparator;
 
 
 /** 
@@ -56,7 +57,6 @@
     /**  the key used for the reverse btree name */
     public static final String REVERSE_BTREE = "_reverse";
 
-
     /** the attribute type resolved for this JdbmIndex */
     private AttributeType attribute;
     /**
@@ -139,6 +139,12 @@
     {
         this.keyCache = new SynchronizedLRUMap( cacheSize );
         this.attribute = attributeType;
+
+        if ( attributeId == null )
+        {
+            setAttributeId( attribute.getName() );
+        }
+
         if ( this.wkDirPath ==  null )
         {
             this.wkDirPath = wkDirPath;
@@ -183,7 +189,7 @@
             attribute.getName() + FORWARD_BTREE, 
             numDupLimit,
             recMan, 
-            comp, null,
+            comp, LongComparator.INSTANCE,
             null, LongSerializer.INSTANCE );
 
         /*
@@ -197,9 +203,9 @@
             reverse = new JdbmTable<Long,K>(
                 attribute.getName() + REVERSE_BTREE,
                 recMan,
-                null,
+                LongComparator.INSTANCE,
                 LongSerializer.INSTANCE,
-                null);
+                null );
         }
         else
         {
@@ -207,9 +213,8 @@
                 attribute.getName() + REVERSE_BTREE,
                 numDupLimit,
                 recMan,
-                null, comp,
-                LongSerializer.INSTANCE,
-                null);
+                LongComparator.INSTANCE, comp,
+                LongSerializer.INSTANCE, null );
         }
     }
 
@@ -242,6 +247,12 @@
         }
     }
 
+
+    public boolean isCountExact()
+    {
+        return false;
+    }
+    
 
     /**
      * Gets the attribute identifier set at configuration time for this index which may not

Modified: directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.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/JdbmTable.java?rev=636988&r1=636987&r2=636988&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java
Thu Mar 13 21:12:45 2008
@@ -33,6 +33,7 @@
 import org.apache.directory.server.core.partition.impl.btree.*;
 import org.apache.directory.server.schema.SerializableComparator;
 import org.apache.directory.shared.ldap.util.SynchronizedLRUMap;
+import org.apache.directory.shared.ldap.schema.ByteArrayComparator;
 
 import java.io.IOException;
 import java.util.*;
@@ -108,23 +109,41 @@
         Serializer keySerializer, Serializer valueSerializer )
         throws IOException
     {
-        if( valueSerializer == null )
-        {
-          throw new IllegalArgumentException("Value serializer cannot be null when duplicates
are allowed in JdbmTable");  
-        }
-
         // TODO make the size of the duplicate btree cache configurable via constructor
         //noinspection unchecked
         duplicateBtrees = new SynchronizedLRUMap( 100 );
-        marshaller = new AvlTreeMarshaller<V>( valueComparator,
-                new MarshallerSerializerBridge<V>( valueSerializer ) );
+
+        if ( valueSerializer != null )
+        {
+            marshaller = new AvlTreeMarshaller<V>( valueComparator,
+                    new MarshallerSerializerBridge<V>( valueSerializer ) );
+        }
+        else
+        {
+            marshaller = new AvlTreeMarshaller<V>( valueComparator );
+        }
+
+        if ( keyComparator == null )
+        {
+            throw new NullPointerException( "Key comparator cannot be null." );
+        }
+        else
+        {
+            this.keyComparator = keyComparator;
+        }
+
+        if ( valueComparator == null )
+        {
+            throw new NullPointerException( "Value comparator must not be null for tables
with duplicate keys." );
+        }
+        else
+        {
+            this.valueComparator = valueComparator;
+        }
 
         this.numDupLimit = numDupLimit;
         this.name = name;
         this.recMan = manager;
-
-        this.keyComparator = keyComparator;
-        this.valueComparator = valueComparator;
 
         this.keySerializer = keySerializer;
         this.valueSerializer = valueSerializer;

Modified: directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/MarshallerSerializerBridge.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/MarshallerSerializerBridge.java?rev=636988&r1=636987&r2=636988&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/MarshallerSerializerBridge.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/MarshallerSerializerBridge.java
Thu Mar 13 21:12:45 2008
@@ -45,6 +45,10 @@
      */
     public MarshallerSerializerBridge( Serializer serializer )
     {
+        if ( serializer == null )
+        {
+            throw new NullPointerException( "serializer" );
+        }
         this.serializer = serializer;
     }
 

Added: directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndexTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndexTest.java?rev=636988&view=auto
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndexTest.java
(added)
+++ directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndexTest.java
Thu Mar 13 21:12:45 2008
@@ -0,0 +1,468 @@
+/*
+ *  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.junit.Before;
+import org.junit.Test;
+import org.junit.After;
+import org.junit.Ignore;
+import static org.junit.Assert.*;
+
+import org.apache.directory.server.schema.bootstrap.*;
+import org.apache.directory.server.schema.registries.*;
+import org.apache.directory.server.schema.SerializableComparator;
+import org.apache.directory.server.core.partition.impl.btree.Index;
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
+
+import java.util.Set;
+import java.util.HashSet;
+import java.io.File;
+import java.io.IOException;
+
+
+/**
+ * TODO doc me!
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class JdbmIndexTest
+{
+    AttributeTypeRegistry registry;
+    File dbFileDir;
+    Index<String> idx;
+
+
+    @Before
+    public void setup() throws Exception
+    {
+        BootstrapSchemaLoader loader = new BootstrapSchemaLoader();
+        OidRegistry oidRegistry = new DefaultOidRegistry();
+        Registries registries = new DefaultRegistries( "bootstrap", loader, oidRegistry );
+        SerializableComparator.setRegistry( registries.getComparatorRegistry() );
+
+        // load essential bootstrap schemas
+        Set<Schema> bootstrapSchemas = new HashSet<Schema>();
+        bootstrapSchemas.add( new ApachemetaSchema() );
+        bootstrapSchemas.add( new ApacheSchema() );
+        bootstrapSchemas.add( new CoreSchema() );
+        bootstrapSchemas.add( new SystemSchema() );
+        loader.loadWithDependencies( bootstrapSchemas, registries );
+        this.registry = registries.getAttributeTypeRegistry();
+
+        if ( dbFileDir != null )
+        {
+            dbFileDir.delete();
+        }
+
+        dbFileDir = new File( File.createTempFile(
+            JdbmIndexTest.class.getSimpleName(), "db" ).getParentFile(),
+            JdbmIndexTest.class.getSimpleName() );
+
+        dbFileDir.mkdirs();
+    }
+
+
+    @After
+    public void teardown() throws Exception
+    {
+        registry = null;
+        destroyIndex();
+    }
+
+
+    void destroyIndex() throws Exception
+    {
+        if ( idx != null )
+        {
+            idx.sync();
+            idx.close();
+            File file = new File( idx.getWkDirPath(), idx.getAttribute().getName() + ".db"
);
+            file.delete();
+        }
+        idx = null;
+    }
+
+
+    void initIndex() throws Exception
+    {
+        initIndex( new JdbmIndex() );
+    }
+
+
+    void initIndex( JdbmIndex jdbmIdx ) throws Exception
+    {
+        if ( jdbmIdx == null )
+        {
+            jdbmIdx = new JdbmIndex();
+        }
+
+        jdbmIdx.init( registry.lookup( SchemaConstants.OU_AT ), dbFileDir );
+        this.idx = jdbmIdx;
+    }
+
+
+    // -----------------------------------------------------------------------
+    // Property Test Methods
+    // -----------------------------------------------------------------------
+
+
+    @Test
+    public void testAttributeId() throws Exception
+    {
+        // uninitialized index
+        JdbmIndex jdbmIndex = new JdbmIndex();
+        jdbmIndex.setAttributeId( "foo" );
+        assertEquals( "foo", jdbmIndex.getAttributeId() );
+
+        jdbmIndex = new JdbmIndex( "bar" );
+        assertEquals( "bar", jdbmIndex.getAttributeId() );
+
+        // initialized index
+        initIndex();
+        try
+        {
+            idx.setAttributeId( "foo" );
+            fail( "Should not be able to set attributeId after initialization." );
+        }
+        catch ( Exception e )
+        {
+        }
+        assertEquals( "ou", idx.getAttributeId() );
+
+        destroyIndex();
+        initIndex( new JdbmIndex( "foo" ) );
+        assertEquals( "foo", idx.getAttributeId() );
+    }
+
+
+    @Test
+    public void testCacheSize() throws Exception
+    {
+        // uninitialized index
+        JdbmIndex jdbmIndex = new JdbmIndex();
+        jdbmIndex.setCacheSize( 337 );
+        assertEquals( 337, jdbmIndex.getCacheSize() );
+
+        // initialized index
+        initIndex();
+        try
+        {
+            idx.setCacheSize( 30 );
+            fail( "Should not be able to set cacheSize after initialization." );
+        }
+        catch ( Exception e )
+        {
+        }
+        assertEquals( Index.DEFAULT_INDEX_CACHE_SIZE, idx.getCacheSize() );
+    }
+
+
+    @Test
+    public void testWkDirPath() throws Exception
+    {
+        // uninitialized index
+        JdbmIndex jdbmIndex = new JdbmIndex();
+        jdbmIndex.setWkDirPath( new File( dbFileDir, "foo" ) );
+        assertEquals( "foo", jdbmIndex.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();
+        jdbmIndex = new JdbmIndex();
+        File wkdir = new File( dbFileDir, "foo" );
+        wkdir.mkdirs();
+        jdbmIndex.setWkDirPath( wkdir );
+        initIndex( jdbmIndex );
+        assertEquals( wkdir, idx.getWkDirPath() );
+    }
+
+
+    @Test
+    public void testNumDupLimit() throws Exception
+    {
+        // uninitialized index
+        JdbmIndex jdbmIndex = new JdbmIndex();
+        jdbmIndex.setNumDupLimit( 337 );
+        assertEquals( 337, jdbmIndex.getNumDupLimit() );
+
+        // initialized index
+        initIndex();
+        try
+        {
+            ( ( JdbmIndex ) idx).setNumDupLimit( 30 );
+            fail( "Should not be able to set numDupLimit after initialization." );
+        }
+        catch ( Exception e )
+        {
+        }
+        assertEquals( JdbmIndex.DEFAULT_DUPLICATE_LIMIT, ( ( JdbmIndex ) idx).getNumDupLimit()
);
+    }
+
+
+    @Test
+    public void testGetAttribute() throws Exception
+    {
+        // uninitialized index
+        JdbmIndex jdbmIndex = new JdbmIndex();
+        assertNull( jdbmIndex.getAttribute() );
+
+        initIndex();
+        assertEquals( registry.lookup( "ou" ), idx.getAttribute() );
+    }
+
+
+    @Test
+    public void testIsCountExact() throws Exception
+    {
+        assertFalse( new JdbmIndex().isCountExact() );
+    }
+
+
+    // -----------------------------------------------------------------------
+    // Count Test Methods
+    // -----------------------------------------------------------------------
+
+
+    @Test
+    public void testCount() throws Exception
+    {
+        initIndex();
+        assertEquals( 0, idx.count() );
+
+        idx.add( "foo", 1234L );
+        assertEquals( 1, idx.count() );
+
+        idx.add( "foo", 333L );
+        assertEquals( 2, idx.count() );
+
+        idx.add( "bar", 555L );
+        assertEquals( 3, idx.count() );
+    }
+
+
+    @Test
+    public void testCountOneArg() throws Exception
+    {
+        initIndex();
+        assertEquals( 0, idx.count( "foo" ) );
+
+        idx.add( "bar", 1234L );
+        assertEquals( 0, idx.count( "foo" ) );
+
+        idx.add( "foo", 1234L );
+        assertEquals( 1, idx.count( "foo" ) );
+
+        idx.add( "foo", 333L );
+        assertEquals( 2, idx.count( "foo" ) );
+    }
+
+
+    @Test
+    public void testGreaterThanCount() throws Exception
+    {
+        initIndex();
+        assertEquals( 0, idx.greaterThanCount( "a" ) );
+
+        for ( char ch = 'a'; ch <= 'z'; ch++ )
+        {
+            idx.add( String.valueOf( ch ), ( long ) ch );
+        }
+        assertEquals( 26, idx.greaterThanCount( "a" ) );
+    }
+
+
+    @Test
+    public void testLessThanCount() throws Exception
+    {
+        initIndex();
+        assertEquals( 0, idx.lessThanCount( "z" ) );
+
+        for ( char ch = 'a'; ch <= 'z'; ch++ )
+        {
+            idx.add( String.valueOf( ch ), ( long ) ch );
+        }
+        assertEquals( 26, idx.lessThanCount( "z" ) );
+    }
+
+
+    // -----------------------------------------------------------------------
+    // Add, Drop and Lookup Test Methods
+    // -----------------------------------------------------------------------
+
+
+    @Test
+    public void testLookups() throws Exception
+    {
+        initIndex();
+        assertNull( idx.forwardLookup( "foo" ) );
+        assertNull( idx.forwardLookup( "bar" ) );
+        assertNull( idx.reverseLookup( 0L ) );
+
+        idx.add( "foo", 0L );
+        assertEquals( 0L, ( long ) idx.forwardLookup( "foo" ) );
+        assertEquals( "foo", idx.reverseLookup( 0L ) );
+
+        idx.add( "foo", 1L );
+        assertEquals( 0L, ( long ) idx.forwardLookup( "foo" ) );
+        assertEquals( "foo", idx.reverseLookup( 0L ) );
+        assertEquals( "foo", idx.reverseLookup( 1L ) );
+
+        idx.add( "bar", 0L );
+        assertEquals( 0L, ( long ) idx.forwardLookup( "bar" ) );
+        assertEquals( "bar", idx.reverseLookup( 0L ) );  // reverse lookup returns first
val
+    }
+
+
+    @Test
+    @Ignore( "Will not work until duplicates cursor is finished." )
+    public void testAddDropById() throws Exception
+    {
+        initIndex();
+        assertNull( idx.forwardLookup( "foo" ) );
+        assertNull( idx.forwardLookup( "bar" ) );
+        assertNull( idx.reverseLookup( 0L ) );
+        assertNull( idx.reverseLookup( 1L ) );
+
+        // test add/drop without adding any duplicates
+        idx.add( "foo", 0L );
+        assertEquals( 0L, ( long ) idx.forwardLookup( "foo" ) );
+        assertEquals( "foo", idx.reverseLookup( 0L ) );
+
+        idx.drop( 0L );
+        assertNull( idx.forwardLookup( "foo" ) );
+        assertNull( idx.reverseLookup( 0L ) );
+
+        // test add/drop with duplicates in bulk
+        idx.add( "foo", 0L );
+        idx.add( "foo", 1L );
+        idx.add( "bar", 0L );
+        assertEquals( 0L, ( long ) idx.forwardLookup( "foo" ) );
+        assertEquals( 0L, ( long ) idx.forwardLookup( "bar" ) );
+        assertEquals( "bar", idx.reverseLookup( 0L ) );
+        assertEquals( "foo", idx.reverseLookup( 1L ) );
+
+        idx.drop( 0L );
+        assertEquals( 0L, ( long ) idx.forwardLookup( "foo" ) );
+        assertEquals( "foo", idx.reverseLookup( 1L ) );
+        assertFalse( idx.hasValue( "bar", 0L ) );
+        assertFalse( idx.hasValue( "foo", 0L ) );
+
+        idx.drop( 1L );
+        assertNull( idx.forwardLookup( "foo" ) );
+        assertNull( idx.forwardLookup( "bar" ) );
+        assertNull( idx.reverseLookup( 0L ) );
+        assertNull( idx.reverseLookup( 1L ) );
+        assertEquals( 0, idx.count() );
+    }
+
+
+    @Test
+    public void testAddDropOneByOne() throws Exception
+    {
+        initIndex();
+        assertNull( idx.forwardLookup( "foo" ) );
+        assertNull( idx.forwardLookup( "bar" ) );
+        assertNull( idx.reverseLookup( 0L ) );
+        assertNull( idx.reverseLookup( 1L ) );
+
+        // test add/drop without adding any duplicates
+        idx.add( "foo", 0L );
+        assertEquals( 0L, ( long ) idx.forwardLookup( "foo" ) );
+        assertEquals( "foo", idx.reverseLookup( 0L ) );
+
+        idx.drop( "foo", 0L );
+        assertNull( idx.forwardLookup( "foo" ) );
+        assertNull( idx.reverseLookup( 0L ) );
+
+        // test add/drop with duplicates but one at a time
+        idx.add( "foo", 0L );
+        idx.add( "foo", 1L );
+        idx.add( "bar", 0L );
+        assertEquals( 0L, ( long ) idx.forwardLookup( "foo" ) );
+        assertEquals( 0L, ( long ) idx.forwardLookup( "bar" ) );
+        assertEquals( "bar", idx.reverseLookup( 0L ) );
+        assertEquals( "foo", idx.reverseLookup( 1L ) );
+
+        idx.drop( "bar", 0L );
+        assertEquals( 0L, ( long ) idx.forwardLookup( "foo" ) );
+        assertEquals( "foo", idx.reverseLookup( 0L ) );
+        assertEquals( "foo", idx.reverseLookup( 1L ) );
+        assertFalse( idx.hasValue( "bar", 0L ) );
+
+        idx.drop( "foo", 0L );
+        assertEquals( 1L, ( long ) idx.forwardLookup( "foo" ) );
+        assertEquals( "foo", idx.reverseLookup( 1L ) );
+        assertFalse( idx.hasValue( "foo", 0L ) );
+
+        idx.drop( "foo", 1L );
+        assertNull( idx.forwardLookup( "foo" ) );
+        assertNull( idx.forwardLookup( "bar" ) );
+        assertNull( idx.reverseLookup( 0L ) );
+        assertNull( idx.reverseLookup( 1L ) );
+        assertEquals( 0, idx.count() );
+    }
+
+
+    // -----------------------------------------------------------------------
+    // Miscellaneous Test Methods
+    // -----------------------------------------------------------------------
+
+
+    @Test
+    public void testNoEqualityMatching() throws Exception
+    {
+        JdbmIndex jdbmIndex = new JdbmIndex();
+
+        try
+        {
+            jdbmIndex.init( new NoEqMatchAttribute(), dbFileDir );
+            fail( "should not get here" );
+        }
+        catch( IOException e )
+        {
+        }
+    }
+
+
+    // -----------------------------------------------------------------------
+    // Failing Tests
+    // -----------------------------------------------------------------------
+
+
+    @Test
+    @Ignore ( "not working now" )
+    public void testSingleValuedAttribute() throws Exception
+    {
+        JdbmIndex jdbmIndex = new JdbmIndex();
+        jdbmIndex.init( registry.lookup( SchemaConstants.CREATORS_NAME_AT ), dbFileDir );
+    }
+}

Added: directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/NoEqMatchAttribute.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/NoEqMatchAttribute.java?rev=636988&view=auto
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/NoEqMatchAttribute.java
(added)
+++ directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/NoEqMatchAttribute.java
Thu Mar 13 21:12:45 2008
@@ -0,0 +1,151 @@
+/*
+ *  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.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.UsageEnum;
+import org.apache.directory.shared.ldap.schema.Syntax;
+import org.apache.directory.shared.ldap.schema.MatchingRule;
+
+import javax.naming.NamingException;
+
+
+/**
+ * TODO doc me!
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $$Rev$$
+ */
+public class NoEqMatchAttribute implements AttributeType
+{
+    public boolean isSingleValue()
+    {
+        return false;  //To change body of implemented methods use File | Settings | File
Templates.
+    }
+
+
+    public boolean isCanUserModify()
+    {
+        return false;  //To change body of implemented methods use File | Settings | File
Templates.
+    }
+
+
+    public boolean isCollective()
+    {
+        return false;  //To change body of implemented methods use File | Settings | File
Templates.
+    }
+
+
+    public UsageEnum getUsage()
+    {
+        return null;  //To change body of implemented methods use File | Settings | File
Templates.
+    }
+
+
+    public AttributeType getSuperior() throws NamingException
+    {
+        return null;  //To change body of implemented methods use File | Settings | File
Templates.
+    }
+
+
+    public Syntax getSyntax() throws NamingException
+    {
+        return null;  //To change body of implemented methods use File | Settings | File
Templates.
+    }
+
+
+    public int getLength()
+    {
+        return 0;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+
+    public MatchingRule getEquality() throws NamingException
+    {
+        throw new NamingException( "Just for testing." );
+    }
+
+
+    public MatchingRule getOrdering() throws NamingException
+    {
+        return null;  //To change body of implemented methods use File | Settings | File
Templates.
+    }
+
+
+    public MatchingRule getSubstr() throws NamingException
+    {
+        return null;  //To change body of implemented methods use File | Settings | File
Templates.
+    }
+
+
+    public boolean isAncestorOf( AttributeType descendant ) throws NamingException
+    {
+        return false;  //To change body of implemented methods use File | Settings | File
Templates.
+    }
+
+
+    public boolean isDescentantOf( AttributeType ancestor ) throws NamingException
+    {
+        return false;  //To change body of implemented methods use File | Settings | File
Templates.
+    }
+
+
+    public boolean isObsolete()
+    {
+        return false;  //To change body of implemented methods use File | Settings | File
Templates.
+    }
+
+
+    public String getOid()
+    {
+        return null;  //To change body of implemented methods use File | Settings | File
Templates.
+    }
+
+
+    public String[] getNames()
+    {
+        return new String[0];  //To change body of implemented methods use File | Settings
| File Templates.
+    }
+
+
+    public String getName()
+    {
+        return null;  //To change body of implemented methods use File | Settings | File
Templates.
+    }
+
+
+    public String getDescription()
+    {
+        return null;  //To change body of implemented methods use File | Settings | File
Templates.
+    }
+
+
+    public String getSchema()
+    {
+        return null;  //To change body of implemented methods use File | Settings | File
Templates.
+    }
+
+
+    public void setSchema( String schemaName )
+    {
+        //To change body of implemented methods use File | Settings | File Templates.
+    }
+}



Mime
View raw message