You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by fe...@apache.org on 2010/06/11 15:20:54 UTC

svn commit: r953693 - in /directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm: JdbmBrowserBugTest.java JdbmIndexTest.java JdbmRdnIndexTest.java KeyBTreeCursorTest.java KeyCursorTest.java

Author: felixk
Date: Fri Jun 11 13:20:53 2010
New Revision: 953693

URL: http://svn.apache.org/viewvc?rev=953693&view=rev
Log:
Add type safety

Modified:
    directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmBrowserBugTest.java
    directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndexTest.java
    directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndexTest.java
    directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyBTreeCursorTest.java
    directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyCursorTest.java

Modified: directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmBrowserBugTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmBrowserBugTest.java?rev=953693&r1=953692&r2=953693&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmBrowserBugTest.java (original)
+++ directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmBrowserBugTest.java Fri Jun 11 13:20:53 2010
@@ -49,7 +49,7 @@ import static junit.framework.Assert.ass
 public class JdbmBrowserBugTest
 {
     Comparator<Integer> comparator;
-    BTree bt;
+    BTree<Integer, Integer> bt;
     private static final String TEST_OUTPUT_PATH = "test.output.path";
     private static final Logger LOG = LoggerFactory.getLogger( JdbmBrowserBugTest.class.getSimpleName() );
     private File dbFile = null;
@@ -112,19 +112,19 @@ public class JdbmBrowserBugTest
         bt.insert( 30, 3, true );
         bt.insert( 25, 3, true );
 
-        Tuple tuple = new Tuple();
-        TupleBrowser browser = bt.browse( null );
+        Tuple<Integer, Integer> tuple = new Tuple<Integer, Integer>();
+        TupleBrowser<Integer, Integer> browser = bt.browse( null );
         assertTrue( browser.getPrevious( tuple ) );
         //noinspection AssertEqualsBetweenInconvertibleTypes
-        assertEquals( 30, tuple.getKey() );
+        assertEquals( Integer.valueOf( 30 ), tuple.getKey() );
 
         assertTrue( browser.getPrevious( tuple ) );
         //noinspection AssertEqualsBetweenInconvertibleTypes
-        assertEquals( 25, tuple.getKey() );
+        assertEquals( Integer.valueOf( 25 ), tuple.getKey() );
 
         assertTrue( browser.getNext( tuple ) );
         //noinspection AssertEqualsBetweenInconvertibleTypes
         assertEquals( "If this works the jdbm bug is gone: will start to return " +
-            "30 instead as expected for correct operation", 25, tuple.getKey() );
+            "30 instead as expected for correct operation", Integer.valueOf( 25 ), tuple.getKey() );
     }
 }

Modified: directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndexTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndexTest.java?rev=953693&r1=953692&r2=953693&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndexTest.java (original)
+++ directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndexTest.java Fri Jun 11 13:20:53 2010
@@ -160,11 +160,11 @@ public class JdbmIndexTest
     public void testAttributeId() throws Exception
     {
         // uninitialized index
-        JdbmIndex jdbmIndex1 = new JdbmIndex();
+        JdbmIndex<Object, Object> jdbmIndex1 = new JdbmIndex<Object, Object>();
         jdbmIndex1.setAttributeId( "foo" );
         assertEquals( "foo", jdbmIndex1.getAttributeId() );
 
-        JdbmIndex jdbmIndex2 = new JdbmIndex( "bar" );
+        JdbmIndex<Object, Object> jdbmIndex2 = new JdbmIndex<Object, Object>( "bar" );
         assertEquals( "bar", jdbmIndex2.getAttributeId() );
 
         // initialized index
@@ -190,7 +190,7 @@ public class JdbmIndexTest
     public void testCacheSize() throws Exception
     {
         // uninitialized index
-        JdbmIndex jdbmIndex = new JdbmIndex();
+        JdbmIndex<Object, Object> jdbmIndex = new JdbmIndex<Object, Object>();
         jdbmIndex.setCacheSize( 337 );
         assertEquals( 337, jdbmIndex.getCacheSize() );
 
@@ -242,7 +242,7 @@ public class JdbmIndexTest
     public void testNumDupLimit() throws Exception
     {
         // uninitialized index
-        JdbmIndex jdbmIndex = new JdbmIndex();
+        JdbmIndex<Object, Object> jdbmIndex = new JdbmIndex<Object, Object>();
         jdbmIndex.setNumDupLimit( 337 );
         assertEquals( 337, jdbmIndex.getNumDupLimit() );
 
@@ -250,13 +250,13 @@ public class JdbmIndexTest
         initIndex();
         try
         {
-            ( ( JdbmIndex ) idx ).setNumDupLimit( 30 );
+            ( ( JdbmIndex<String, Entry> ) idx ).setNumDupLimit( 30 );
             fail( "Should not be able to set numDupLimit after initialization." );
         }
         catch ( Exception e )
         {
         }
-        assertEquals( JdbmIndex.DEFAULT_DUPLICATE_LIMIT, ( ( JdbmIndex ) idx ).getNumDupLimit() );
+        assertEquals( JdbmIndex.DEFAULT_DUPLICATE_LIMIT, ( ( JdbmIndex<String, Entry> ) idx ).getNumDupLimit() );
     }
 
 
@@ -264,7 +264,7 @@ public class JdbmIndexTest
     public void testGetAttribute() throws Exception
     {
         // uninitialized index
-        JdbmIndex jdbmIndex = new JdbmIndex();
+        JdbmIndex<Object, Object> jdbmIndex = new JdbmIndex<Object, Object>();
         assertNull( jdbmIndex.getAttribute() );
 
         initIndex();
@@ -275,7 +275,7 @@ public class JdbmIndexTest
     @Test
     public void testIsCountExact() throws Exception
     {
-        assertFalse( new JdbmIndex().isCountExact() );
+        assertFalse( new JdbmIndex<Object, Object>().isCountExact() );
     }
 
 
@@ -560,7 +560,7 @@ public class JdbmIndexTest
     @Test
     public void testNoEqualityMatching() throws Exception
     {
-        JdbmIndex jdbmIndex = new JdbmIndex();
+        JdbmIndex<Object, Object> jdbmIndex = new JdbmIndex<Object, Object>();
 
         try
         {
@@ -582,7 +582,7 @@ public class JdbmIndexTest
     @Test
     public void testSingleValuedAttribute() throws Exception
     {
-        JdbmIndex jdbmIndex = new JdbmIndex();
+        JdbmIndex<Object, Object> jdbmIndex = new JdbmIndex<Object, Object>();
         jdbmIndex.init( schemaManager, schemaManager.lookupAttributeTypeRegistry( SchemaConstants.CREATORS_NAME_AT ),
             dbFileDir );
         jdbmIndex.close();

Modified: directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndexTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndexTest.java?rev=953693&r1=953692&r2=953693&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndexTest.java (original)
+++ directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndexTest.java Fri Jun 11 13:20:53 2010
@@ -35,7 +35,6 @@ import org.apache.directory.server.xdbm.
 import org.apache.directory.server.xdbm.IndexEntry;
 import org.apache.directory.server.xdbm.ParentIdAndRdn;
 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;
@@ -137,15 +136,15 @@ public class JdbmRdnIndexTest
 
     void initIndex() throws Exception
     {
-        initIndex( new JdbmRdnIndex() );
+        initIndex( new JdbmRdnIndex<Long>() );
     }
 
 
-    void initIndex( JdbmRdnIndex jdbmIdx ) throws Exception
+    void initIndex( JdbmRdnIndex<Long> jdbmIdx ) throws Exception
     {
         if ( jdbmIdx == null )
         {
-            jdbmIdx = new JdbmRdnIndex();
+            jdbmIdx = new JdbmRdnIndex<Long>();
         }
 
         jdbmIdx.init( schemaManager, schemaManager.lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_RDN_AT_OID ), dbFileDir );
@@ -161,7 +160,7 @@ public class JdbmRdnIndexTest
     public void testCacheSize() throws Exception
     {
         // uninitialized index
-        JdbmRdnIndex JdbmRdnIndex = new JdbmRdnIndex();
+        JdbmRdnIndex<Object> JdbmRdnIndex = new JdbmRdnIndex<Object>();
         JdbmRdnIndex.setCacheSize( 337 );
         assertEquals( 337, JdbmRdnIndex.getCacheSize() );
 
@@ -187,7 +186,7 @@ public class JdbmRdnIndexTest
     public void testWkDirPath() throws Exception
     {
         // uninitialized index
-        JdbmRdnIndex jdbmRdnIndex = new JdbmRdnIndex();
+        JdbmRdnIndex<Long> jdbmRdnIndex = new JdbmRdnIndex<Long>();
         jdbmRdnIndex.setWkDirPath( new File( dbFileDir, "foo" ) );
         assertEquals( "foo", jdbmRdnIndex.getWkDirPath().getName() );
 
@@ -204,7 +203,7 @@ public class JdbmRdnIndexTest
         assertEquals( dbFileDir, idx.getWkDirPath() );
 
         destroyIndex();
-        jdbmRdnIndex = new JdbmRdnIndex();
+        jdbmRdnIndex = new JdbmRdnIndex<Long>();
         File wkdir = new File( dbFileDir, "foo" );
         wkdir.mkdirs();
         jdbmRdnIndex.setWkDirPath( wkdir );
@@ -217,7 +216,7 @@ public class JdbmRdnIndexTest
     public void testGetAttribute() throws Exception
     {
         // uninitialized index
-        JdbmRdnIndex rdnIndex = new JdbmRdnIndex();
+        JdbmRdnIndex<Object> rdnIndex = new JdbmRdnIndex<Object>();
         assertNull( rdnIndex.getAttribute() );
 
         initIndex();
@@ -228,7 +227,7 @@ public class JdbmRdnIndexTest
     @Test
     public void testIsCountExact() throws Exception
     {
-        assertFalse( new JdbmRdnIndex().isCountExact() );
+        assertFalse( new JdbmRdnIndex<Object>().isCountExact() );
     }
 
 

Modified: directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyBTreeCursorTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyBTreeCursorTest.java?rev=953693&r1=953692&r2=953693&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyBTreeCursorTest.java (original)
+++ directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyBTreeCursorTest.java Fri Jun 11 13:20:53 2010
@@ -57,13 +57,12 @@ public class KeyBTreeCursorTest
 
     File dbFile;
     RecordManager recman;
-    BTree bt;
+    BTree<String, byte[]> bt;
     Comparator<String> comparator;
 
     KeyBTreeCursor<String> cursor;
 
 
-    @SuppressWarnings({"unchecked"})
     @Before
     public void createCursor() throws Exception
     {
@@ -239,9 +238,9 @@ public class KeyBTreeCursorTest
 
         // browse will position us right after "4" and getNext() will return 8
         // since "5", "6", and "7" do not exist
-        TupleBrowser browser = bt.browse( "5" );
+        TupleBrowser<String, byte[]> browser = bt.browse( "5" );
         assertNotNull( browser );
-        Tuple tuple = new Tuple();
+        Tuple<String, byte[]> tuple = new Tuple<String, byte[]>();
         browser.getNext( tuple );
         assertEquals( "8", tuple.getKey() );
 
@@ -249,7 +248,7 @@ public class KeyBTreeCursorTest
         // since "2" exists.
         browser = bt.browse( "2" );
         assertNotNull( browser );
-        tuple = new Tuple();
+        tuple = new Tuple<String, byte[]>();
         browser.getNext( tuple );
         assertEquals( "2", tuple.getKey() );
 
@@ -257,7 +256,7 @@ public class KeyBTreeCursorTest
         // since nothing else exists past 8.  We've come to the end.
         browser = bt.browse( "9" );
         assertNotNull( browser );
-        tuple = new Tuple();
+        tuple = new Tuple<String, byte[]>();
         browser.getNext( tuple );
         assertNull( tuple.getKey() );
 
@@ -266,7 +265,7 @@ public class KeyBTreeCursorTest
         // getNext() will however return "1".
         browser = bt.browse( "0" );
         assertNotNull( browser );
-        tuple = new Tuple();
+        tuple = new Tuple<String, byte[]>();
         browser.getPrevious( tuple );
         assertNull( tuple.getKey() );
         browser.getNext( tuple );

Modified: directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyCursorTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyCursorTest.java?rev=953693&r1=953692&r2=953693&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyCursorTest.java (original)
+++ directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyCursorTest.java Fri Jun 11 13:20:53 2010
@@ -57,13 +57,12 @@ public class KeyCursorTest
 
     File dbFile;
     RecordManager recman;
-    BTree bt;
+    BTree<String, byte[]> bt;
     Comparator<String> comparator;
 
     KeyBTreeCursor<String> cursor;
 
 
-    @SuppressWarnings({"unchecked"})
     @Before
     public void createCursor() throws Exception
     {
@@ -239,9 +238,9 @@ public class KeyCursorTest
 
         // browse will position us right after "4" and getNext() will return 8
         // since "5", "6", and "7" do not exist
-        TupleBrowser browser = bt.browse( "5" );
+        TupleBrowser<String, byte[]> browser = bt.browse( "5" );
         assertNotNull( browser );
-        Tuple tuple = new Tuple();
+        Tuple<String, byte[]> tuple = new Tuple<String, byte[]>();
         browser.getNext( tuple );
         assertEquals( "8", tuple.getKey() );
 
@@ -249,7 +248,7 @@ public class KeyCursorTest
         // since "2" exists.
         browser = bt.browse( "2" );
         assertNotNull( browser );
-        tuple = new Tuple();
+        tuple = new Tuple<String, byte[]>();
         browser.getNext( tuple );
         assertEquals( "2", tuple.getKey() );
 
@@ -257,7 +256,7 @@ public class KeyCursorTest
         // since nothing else exists past 8.  We've come to the end.
         browser = bt.browse( "9" );
         assertNotNull( browser );
-        tuple = new Tuple();
+        tuple = new Tuple<String, byte[]>();
         browser.getNext( tuple );
         assertNull( tuple.getKey() );
 
@@ -266,7 +265,7 @@ public class KeyCursorTest
         // getNext() will however return "1".
         browser = bt.browse( "0" );
         assertNotNull( browser );
-        tuple = new Tuple();
+        tuple = new Tuple<String, byte[]>();
         browser.getPrevious( tuple );
         assertNull( tuple.getKey() );
         browser.getNext( tuple );