directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r637594 - in /directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src: main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/
Date Sun, 16 Mar 2008 15:27:05 GMT
Author: akarasulu
Date: Sun Mar 16 08:27:02 2008
New Revision: 637594

URL: http://svn.apache.org/viewvc?rev=637594&view=rev
Log:
more test cases for jdbm package

Modified:
    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/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableNoDuplicatesTest.java
    directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableWithDuplicatesTest.java

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=637594&r1=637593&r2=637594&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
Sun Mar 16 08:27:02 2008
@@ -34,7 +34,6 @@
 import javax.naming.NamingException;
 import java.io.File;
 import java.io.IOException;
-import java.util.Comparator;
 
 
 /** 

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=637594&r1=637593&r2=637594&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
Sun Mar 16 08:27:02 2008
@@ -334,7 +334,12 @@
      */
     public int count( K key ) throws IOException
     {
-        if ( !allowsDuplicates )
+        if ( key == null )
+        {
+            return 0;
+        }
+
+        if ( ! allowsDuplicates )
         {
             if ( null == getNoDups( key ) )
             {
@@ -348,11 +353,6 @@
 
         DupsContainer values = getDups( key );
         
-        if ( values == null )
-        {
-            return 0;
-        }
-        
         // -------------------------------------------------------------------
         // Handle the use of a AvlTree for storing duplicates
         // -------------------------------------------------------------------
@@ -891,12 +891,12 @@
             return new DupsContainer<V>( new AvlTree<V>( valueComparator ) );
         }
 
-        if ( ! BTreeRedirectMarshaller.isRedirect( serialized ) )
+        if ( BTreeRedirectMarshaller.isRedirect( serialized ) )
         {
-            return new DupsContainer<V>( marshaller.deserialize( serialized ) );
+            return new DupsContainer<V>( BTreeRedirectMarshaller.INSTANCE.deserialize(
serialized ) );
         }
 
-        return new DupsContainer<V>( BTreeRedirectMarshaller.INSTANCE.deserialize(
serialized ) );
+        return new DupsContainer<V>( marshaller.deserialize( serialized ) );
     }
 
 

Modified: directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableNoDuplicatesTest.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/JdbmTableNoDuplicatesTest.java?rev=637594&r1=637593&r2=637594&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableNoDuplicatesTest.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableNoDuplicatesTest.java
Sun Mar 16 08:27:02 2008
@@ -87,7 +87,7 @@
         dbFile.deleteOnExit();
         dbFile = null;
     }
-
+    
 
     @Test
     public void testCloseReopen() throws Exception

Modified: directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableWithDuplicatesTest.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/JdbmTableWithDuplicatesTest.java?rev=637594&r1=637593&r2=637594&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableWithDuplicatesTest.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableWithDuplicatesTest.java
Sun Mar 16 08:27:02 2008
@@ -78,7 +78,7 @@
         table = new JdbmTable<Integer,Integer>( "test", SIZE, recman,
                 new SerializableComparator<Integer>( "" ),
                 new SerializableComparator<Integer>( "" ),
-                null, new IntegerSerializer() );
+                new IntegerSerializer(), new IntegerSerializer() );
         LOG.debug( "Created new table and populated it with data" );
     }
 
@@ -92,6 +92,43 @@
         recman = null;
         dbFile.deleteOnExit();
         dbFile = null;
+    }
+
+
+    @Test
+    public void testSerializers() throws Exception
+    {
+        assertNotNull( ( ( JdbmTable ) table ).getKeySerializer() );
+        assertNotNull( ( ( JdbmTable ) table ).getValueSerializer() );
+    }
+
+
+    @Test
+    public void testCountOneArgNoValues() throws Exception
+    {
+        assertEquals( 0, table.count( 3 ) );
+    }
+
+
+    @Test( expected = NullPointerException.class )
+    public void testNullKeyComparator() throws Exception
+    {
+        assertNotNull( ( ( JdbmTable ) table ).getKeyComparator() );
+        new JdbmTable<Integer,Integer>( "test", SIZE, recman,
+            null,
+            new SerializableComparator<Integer>( "" ),
+            null, new IntegerSerializer() );
+    }
+
+
+    @Test( expected = NullPointerException.class )
+    public void testNullValueComparator() throws Exception
+    {
+        assertNotNull( ( ( JdbmTable ) table ).getValueComparator() );
+        new JdbmTable<Integer,Integer>( "test", SIZE, recman,
+            new SerializableComparator<Integer>( "" ),
+            null,
+            null, new IntegerSerializer() );
     }
 
 



Mime
View raw message