directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 10160 - in incubator/directory/rms/trunk/je: . src/java/org/apache/rms/je src/java/org/apache/rms/je/permissions src/java/org/apache/rms/je/sequence src/test/org/apache/rms/je/permissions
Date Thu, 22 Apr 2004 01:10:46 GMT
Author: akarasulu
Date: Wed Apr 21 18:10:45 2004
New Revision: 10160

Added:
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/permissions/JeBitPermissionIndexManager.java
  (contents, props changed)
   incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/permissions/JeBitPermissionIndexDAOTest.java
  (contents, props changed)
   incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/permissions/JeBitPermissionIndexManagerTest.java
  (contents, props changed)
Modified:
   incubator/directory/rms/trunk/je/   (props changed)
   incubator/directory/rms/trunk/je/project.properties
   incubator/directory/rms/trunk/je/project.xml
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/AbstractJeTest.java
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/permissions/JeBitPermissionIndexDAO.java
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/sequence/JeSequenceDao.java
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/sequence/LoggingSequenceDaoMonitor.java
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/sequence/SequenceDaoMonitor.java
Log:
Commit changes ...

 o reverted clover config to clean up issues I was having
 o fixed a couple of bugs in the sequence manager
 o fixed a couple of bugs in the JeBitPermissionIndexDAO
 o created the bit permission index manager and test case
 o added a test case for the JeBitPermissionIndexDAO



Modified: incubator/directory/rms/trunk/je/project.properties
==============================================================================
--- incubator/directory/rms/trunk/je/project.properties	(original)
+++ incubator/directory/rms/trunk/je/project.properties	Wed Apr 21 18:10:45 2004
@@ -1,2 +1,4 @@
 maven.xdoc.jsl = file:/${basedir}/../../../sitedocs/trunk/src/etc/site.jsl
 maven.license.licenseFile = ../../../LICENSE.txt
+maven.junit.fork = yes
+#maven.clover.jar = clover-directory-1.2.4_04.jar 

Modified: incubator/directory/rms/trunk/je/project.xml
==============================================================================
--- incubator/directory/rms/trunk/je/project.xml	(original)
+++ incubator/directory/rms/trunk/je/project.xml	Wed Apr 21 18:10:45 2004
@@ -19,14 +19,14 @@
       <version>3.8.1</version>
       <url>http://junit.org</url>
     </dependency>
-
+<!--
     <dependency>
-      <groupId>commons-collections</groupId>
-      <artifactId>commons-collections</artifactId>
-      <version>3.1-dev</version>
-      <url>http://jakarta.apache.org/commons/collections</url>
+      <groupId>clover</groupId>
+      <artifactId>clover-directory</artifactId>
+      <version>1.2.4_04</version>
+      <url>http://thecortex.com</url>
     </dependency>
-
+-->
     <dependency>
       <groupId>commons-lang</groupId>
       <artifactId>commons-lang</artifactId>
@@ -39,6 +39,20 @@
       <artifactId>commons-logging</artifactId>
       <version>1.0.3</version>
       <url>http://jakarta.apache.org/commons/logging</url>
+    </dependency>
+
+    <dependency>
+      <groupId>commons-collections</groupId>
+      <artifactId>commons-collections</artifactId>
+      <version>3.1-dev</version>
+      <url>http://jakarta.apache.org/commons/collections</url>
+    </dependency>
+
+    <dependency>
+      <groupId>commons-primitives</groupId>
+      <artifactId>commons-primitives</artifactId>
+      <version>SNAPSHOT</version>
+      <url>http://jakarta.apache.org/commons/primitives</url>
     </dependency>
 
     <dependency>

Modified: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/AbstractJeTest.java
==============================================================================
--- incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/AbstractJeTest.java	(original)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/AbstractJeTest.java	Wed Apr
21 18:10:45 2004
@@ -61,6 +61,7 @@
         db = env.openDatabase( null, "testDb", dbConfig ) ;
     }
 
+
     protected void tearDown() throws Exception
     {
         super.tearDown() ;

Modified: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/permissions/JeBitPermissionIndexDAO.java
==============================================================================
--- incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/permissions/JeBitPermissionIndexDAO.java
(original)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/permissions/JeBitPermissionIndexDAO.java
Wed Apr 21 18:10:45 2004
@@ -184,7 +184,6 @@
             key.setData( appName.getBytes( "UTF-8" ) ) ;
             cursor = db.openCursor( null, null ) ;
             status = cursor.getSearchBoth( key, value, LockMode.DEFAULT ) ;
-            cursor.close() ;
         }
         catch ( UnsupportedEncodingException e )
         {
@@ -285,7 +284,7 @@
 
         try
         {
-            appName.getBytes( "UTF-8" ) ;
+            keyBytes = appName.getBytes( "UTF-8" ) ;
         }
         catch ( UnsupportedEncodingException e )
         {
@@ -331,7 +330,7 @@
 
         try
         {
-            appName.getBytes( "UTF-8" ) ;
+            keyBytes = appName.getBytes( "UTF-8" ) ;
         }
         catch ( UnsupportedEncodingException e )
         {
@@ -396,9 +395,11 @@
             {
                 status = cursor.getSearchKey( key, value, LockMode.DEFAULT ) ;
             }
-            finally
+            catch( DatabaseException e )
             {
+                hasNext = false ;
                 cursor.close() ;
+                throw e ;
             }
 
             if ( status == OperationStatus.NOTFOUND )
@@ -407,6 +408,8 @@
                 cursor.close() ;
                 return ;
             }
+
+            prefetched = JeUtils.decodeInt( value ) ;
         }
 
 
@@ -427,12 +430,11 @@
             }
             catch ( DatabaseException e )
             {
+                hasNext = false ;
+                e.printStackTrace() ;
+                try { close() ;} catch( RmsException e2 ) {}
                 throw new NoSuchElementException( "database access failure" ) ;
             }
-            finally
-            {
-                try { close() ;} catch( RmsException e ) {}
-            }
 
             if ( status == OperationStatus.SUCCESS )
             {
@@ -440,8 +442,8 @@
             }
             else
             {
-                prefetched = -1 ;
                 hasNext = false ;
+                prefetched = -1 ;
                 try { cursor.close() ; } catch( DatabaseException e ) {}
             }
 
@@ -457,10 +459,11 @@
 
         void close() throws RmsException
         {
+            prefetched = -1 ;
+            hasNext = false ;
+
             try
             {
-                prefetched = -1 ;
-                hasNext = false ;
                 cursor.close() ;
             }
             catch ( DatabaseException e )

Added: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/permissions/JeBitPermissionIndexManager.java
==============================================================================
--- (empty file)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/permissions/JeBitPermissionIndexManager.java
Wed Apr 21 18:10:45 2004
@@ -0,0 +1,128 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.rms.je.permissions ;
+
+
+import org.apache.rms.RmsException ;
+import org.apache.commons.collections.primitives.IntIterator ;
+
+
+/**
+ * A BitPermissionIndexManager based on a JE database.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class JeBitPermissionIndexManager implements BitPermissionIndexManager
+{
+    /** DAO used for underlying database operations */
+    private final JeBitPermissionIndexDAO dao ;
+
+
+    /**
+     * Creates a JE based BitPermissionIndexManager.
+     *
+     * @param dao the DAO used to access the JE database
+     */
+    public JeBitPermissionIndexManager( JeBitPermissionIndexDAO dao )
+    {
+        this.dao = dao ;
+    }
+
+
+    /**
+     * Gets the largest permission index in use for an application.
+     *
+     * @param appName the name of the application to get the index for
+     * @return the maximum occupied index or -1 if permissions don't exist for the application
+     * @throws org.apache.rms.RmsException if there are failures accessing the backing store
+     */
+    public int getMaxIndex( String appName ) throws RmsException
+    {
+        return dao.getLast( appName ) ;
+    }
+
+
+    /**
+     * Gets the smallest free index.
+     *
+     * @param appName the name of the application to get the index for
+     * @return the minimum free index
+     * @throws org.apache.rms.RmsException if there are failures accessing the backing store
+     */
+    public int getMinFreeIndex( String appName ) throws RmsException
+    {
+        int index = -1 ;
+        IntIterator list = dao.list( appName ) ;
+
+        // iterate from smallest to largest index looking for holes
+        while( list.hasNext() )
+        {
+            int previous = index ;
+            index = list.next() ;
+
+            // 0 is a hole on first pass if the index is not zero
+            if ( previous == -1 && index > 0 )
+            {
+                ( ( JeBitPermissionIndexDAO.IndexIterator ) list ).close() ;
+                return 0 ;
+            }
+            // the current index skipped one
+            else if ( index - previous > 1 )
+            {
+                ( ( JeBitPermissionIndexDAO.IndexIterator ) list ).close() ;
+                return previous + 1 ;
+            }
+        }
+
+        // list did not contain an index so return the first index at 0
+        if ( index == -1 )
+        {
+            return 0 ;
+        }
+        // list was exhausted w/o finding a hole so return the next index
+        else
+        {
+            return index + 1 ;
+        }
+    }
+
+
+    /**
+     * Releases a claimed index.
+     *
+     * @param appName the name of the application to release the index for
+     * @throws org.apache.rms.RmsException if there are failures accessing the backing store
+     */
+    public void releaseIndex( String appName, int index ) throws RmsException
+    {
+        dao.delete( appName, index ) ;
+    }
+
+
+    /**
+     * Claims a index for an application.
+     *
+     * @param appName the name of the application to claim the index for
+     * @param index   the index to claim
+     * @throws org.apache.rms.RmsException if there are failures accessing the backing store
+     */
+    public void claimIndex( String appName, int index ) throws RmsException
+    {
+        dao.put( appName, index ) ;
+    }
+}

Modified: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/sequence/JeSequenceDao.java
==============================================================================
--- incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/sequence/JeSequenceDao.java
(original)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/sequence/JeSequenceDao.java
Wed Apr 21 18:10:45 2004
@@ -163,6 +163,12 @@
             throw new RmsException( e ) ;
         }
 
+        if ( status == OperationStatus.NOTFOUND )
+        {
+            monitor.doesNotExit( name ) ;
+            throw new RmsException( name + " sequence does not exist" ) ;
+        }
+
         return JeUtils.decodeInt( value ) ;
     }
 

Modified: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/sequence/LoggingSequenceDaoMonitor.java
==============================================================================
--- incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/sequence/LoggingSequenceDaoMonitor.java
(original)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/sequence/LoggingSequenceDaoMonitor.java
Wed Apr 21 18:10:45 2004
@@ -19,7 +19,6 @@
 
 import org.apache.commons.logging.Log ;
 import org.apache.commons.logging.LogFactory ;
-import org.apache.rms.je.sequence.SequenceDaoMonitor;
 
 
 /**
@@ -43,6 +42,16 @@
     }
 
 
+    public void doesNotExit( String name )
+    {
+        if ( log.isWarnEnabled() )
+        {
+            log.warn( "Attempted to access sequence " + name
+                    + " which does not exist" ) ;
+        }
+    }
+
+    
     public void sequenceExits( String name )
     {
         if ( log.isWarnEnabled() )

Modified: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/sequence/SequenceDaoMonitor.java
==============================================================================
--- incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/sequence/SequenceDaoMonitor.java
(original)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/sequence/SequenceDaoMonitor.java
Wed Apr 21 18:10:45 2004
@@ -44,4 +44,6 @@
     void failedOnCurrentValue( String name, Object info, Throwable fault ) ;
 
     void sequenceExits( String name ) ;
+
+    void doesNotExit( String name ) ;
 }

Added: incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/permissions/JeBitPermissionIndexDAOTest.java
==============================================================================
--- (empty file)
+++ incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/permissions/JeBitPermissionIndexDAOTest.java
Wed Apr 21 18:10:45 2004
@@ -0,0 +1,205 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.rms.je.permissions ;
+
+
+import org.apache.rms.je.AbstractJeTest ;
+import org.apache.commons.collections.primitives.IntIterator ;
+
+
+/**
+ * Unit test cases for the JeBitPermissionIndexDAO class.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class JeBitPermissionIndexDAOTest extends AbstractJeTest
+{
+    /** JE BitPermission Index Data Access Object instance for testing */
+    JeBitPermissionIndexDAO dao ;
+
+
+    /**
+     * Sets up the JeBitPermissionIndexDAO instance and enables duplicates.
+     * @throws Exception
+     */
+    protected void setUp() throws Exception
+    {
+        super.dbConfig.setAllowDuplicates( true ) ;
+        super.setUp() ;
+        dao = new JeBitPermissionIndexDAO( db ) ;
+    }
+
+
+    /**
+     * Nulls out the JeBitPermissionIndexDAO instance.
+     * @throws Exception
+     */
+    protected void tearDown() throws Exception
+    {
+        super.tearDown() ;
+        dao = null ;
+    }
+
+
+    /**
+     * Tests the () method and consequentially the put() method.
+     *
+     * @throws Exception
+     */
+    public void testDelete() throws Exception
+    {
+        dao.put( "app1", 0 ) ;
+        dao.put( "app1", 2 ) ;
+        dao.put( "app1", 4 ) ;
+        dao.put( "app1", 6 ) ;
+        dao.put( "app2", 7 ) ;
+        dao.put( "app2", 8 ) ;
+        dao.put( "app2", 9 ) ;
+        dao.put( "app2", 10 ) ;
+
+        dao.delete( "app1", 6 ) ;
+        assertEquals( 4, dao.getLast( "app1" ) ) ;
+        assertFalse( dao.has( "app1", 6 ) ) ;
+        dao.delete( "app1", 0 ) ;
+        assertEquals( 2, dao.getFirst( "app1" ) ) ;
+        assertFalse( dao.has( "app1", 0 ) ) ;
+        dao.delete( "app2", 8 ) ;
+        assertEquals( 10, dao.getLast( "app2" ) ) ;
+        assertFalse( dao.has( "app2", 8 ) ) ;
+        dao.delete( "app2", 9 ) ;
+        assertEquals( 7, dao.getFirst( "app2" ) ) ;
+        assertFalse( dao.has( "app2", 9 ) ) ;
+
+        IntIterator list = dao.list( "app1" ) ;
+        assertEquals( 2, list.next() ) ;
+        assertEquals( 4, list.next() ) ;
+        assertFalse( list.hasNext() ) ;
+
+        list = dao.list( "app2" ) ;
+        assertEquals( 7, list.next() ) ;
+        assertEquals( 10, list.next() ) ;
+        assertFalse( list.hasNext() ) ;
+    }
+
+
+    /**
+     * Tests the getFirst() method and consequentially the put() method.
+     *
+     * @throws Exception
+     */
+    public void testFirst() throws Exception
+    {
+        dao.put( "app1", 0 ) ;
+        dao.put( "app1", 2 ) ;
+        dao.put( "app1", 4 ) ;
+        dao.put( "app1", 6 ) ;
+        dao.put( "app2", 7 ) ;
+        dao.put( "app2", 8 ) ;
+        dao.put( "app2", 9 ) ;
+        dao.put( "app2", 10 ) ;
+
+        assertEquals( 0, dao.getFirst( "app1" ) ) ;
+        assertEquals( 7, dao.getFirst( "app2" ) ) ;
+    }
+
+
+    /**
+     * Tests the getLast() method and consequentially the put() method.
+     *
+     * @throws Exception
+     */
+    public void testLast() throws Exception
+    {
+        dao.put( "app1", 0 ) ;
+        dao.put( "app1", 2 ) ;
+        dao.put( "app1", 4 ) ;
+        dao.put( "app1", 6 ) ;
+        dao.put( "app2", 7 ) ;
+        dao.put( "app2", 8 ) ;
+        dao.put( "app2", 9 ) ;
+        dao.put( "app2", 10 ) ;
+
+        assertEquals( 6, dao.getLast( "app1" ) ) ;
+        assertEquals( 10, dao.getLast( "app2" ) ) ;
+    }
+
+
+    /**
+     * Tests the list() method and consequentially the put() method.
+     *
+     * @throws Exception
+     */
+    public void testList() throws Exception
+    {
+        dao.put( "app1", 0 ) ;
+        dao.put( "app1", 2 ) ;
+        dao.put( "app1", 4 ) ;
+        dao.put( "app1", 6 ) ;
+        dao.put( "app2", 7 ) ;
+        dao.put( "app2", 8 ) ;
+        dao.put( "app2", 9 ) ;
+        dao.put( "app2", 10 ) ;
+
+        IntIterator list = dao.list( "app1" ) ;
+        assertEquals( 0, list.next() ) ;
+        assertEquals( 2, list.next() ) ;
+        assertEquals( 4, list.next() ) ;
+        assertEquals( 6, list.next() ) ;
+        assertFalse( list.hasNext() ) ;
+
+        list = dao.list( "app2" ) ;
+        assertEquals( 7, list.next() ) ;
+        assertEquals( 8, list.next() ) ;
+        assertEquals( 9, list.next() ) ;
+        assertEquals( 10, list.next() ) ;
+        assertFalse( list.hasNext() ) ;
+    }
+
+
+    /**
+     * Tests the put method and the has method at the same time.
+     *
+     * @throws Exception
+     */
+    public void testPutHas() throws Exception
+    {
+        dao.put( "app1", 0 ) ;
+        dao.put( "app1", 2 ) ;
+        dao.put( "app1", 4 ) ;
+        dao.put( "app1", 6 ) ;
+        dao.put( "app2", 7 ) ;
+        dao.put( "app2", 8 ) ;
+        dao.put( "app2", 9 ) ;
+        dao.put( "app2", 10 ) ;
+
+        assertTrue( dao.has( "app1", 0 ) ) ;
+        assertTrue( dao.has( "app1", 2 ) ) ;
+        assertTrue( dao.has( "app1", 4 ) ) ;
+        assertTrue( dao.has( "app1", 6 ) ) ;
+        assertTrue( dao.has( "app2", 7 ) ) ;
+        assertTrue( dao.has( "app2", 8 ) ) ;
+        assertTrue( dao.has( "app2", 9 ) ) ;
+        assertTrue( dao.has( "app2", 10 ) ) ;
+
+        assertFalse( dao.has( "app1", 1 ) ) ;
+        assertFalse( dao.has( "app1", 3 ) ) ;
+        assertFalse( dao.has( "app1", 5 ) ) ;
+        assertFalse( dao.has( "app2", 11 ) ) ;
+        assertFalse( dao.has( "app2", 12 ) ) ;
+    }
+}
\ No newline at end of file

Added: incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/permissions/JeBitPermissionIndexManagerTest.java
==============================================================================
--- (empty file)
+++ incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/permissions/JeBitPermissionIndexManagerTest.java
Wed Apr 21 18:10:45 2004
@@ -0,0 +1,103 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.rms.je.permissions ;
+
+
+import org.apache.rms.je.AbstractJeTest ;
+
+
+/**
+ * Unit test cases for the JeBitPermissionIndexManager class.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class JeBitPermissionIndexManagerTest extends AbstractJeTest
+{
+    JeBitPermissionIndexDAO dao ;
+    JeBitPermissionIndexManager manager ;
+
+
+    protected void setUp() throws Exception
+    {
+        dbConfig.setAllowDuplicates( true ) ;
+        super.setUp() ;
+        dao = new JeBitPermissionIndexDAO( db ) ;
+        manager = new JeBitPermissionIndexManager( dao ) ;
+    }
+
+
+    protected void tearDown() throws Exception
+    {
+        super.tearDown() ;
+        dao = null ;
+        manager = null ;
+    }
+
+
+    public void testHoleAtHead() throws Exception
+    {
+        manager.claimIndex( "app1", 0 ) ;
+        manager.claimIndex( "app1", 1 ) ;
+        manager.claimIndex( "app1", 2 ) ;
+        manager.claimIndex( "app1", 3 ) ;
+        manager.claimIndex( "app1", 4 ) ;
+        manager.releaseIndex( "app1", 0 ) ;
+        assertEquals( 0, manager.getMinFreeIndex( "app1" ) ) ;
+    }
+
+
+    public void testHoleInMiddle() throws Exception
+    {
+        manager.claimIndex( "app1", 0 ) ;
+        manager.claimIndex( "app1", 1 ) ;
+        manager.claimIndex( "app1", 2 ) ;
+        manager.claimIndex( "app1", 3 ) ;
+        manager.claimIndex( "app1", 4 ) ;
+        manager.releaseIndex( "app1", 2 ) ;
+        assertEquals( 2, manager.getMinFreeIndex( "app1" ) ) ;
+    }
+
+
+    public void testNoHole() throws Exception
+    {
+        manager.claimIndex( "app1", 0 ) ;
+        manager.claimIndex( "app1", 1 ) ;
+        manager.claimIndex( "app1", 2 ) ;
+        manager.claimIndex( "app1", 3 ) ;
+        manager.claimIndex( "app1", 4 ) ;
+        assertEquals( 5, manager.getMinFreeIndex( "app1" ) ) ;
+    }
+
+
+    public void testTwoHolesFrontAndMiddle() throws Exception
+    {
+        manager.claimIndex( "app1", 1 ) ;
+        manager.claimIndex( "app1", 2 ) ;
+        manager.claimIndex( "app1", 4 ) ;
+        assertEquals( 0, manager.getMinFreeIndex( "app1" ) ) ;
+    }
+
+
+    public void testTwoHolesMiddel() throws Exception
+    {
+        manager.claimIndex( "app1", 0 ) ;
+        manager.claimIndex( "app1", 2 ) ;
+        manager.claimIndex( "app1", 4 ) ;
+        assertEquals( 1, manager.getMinFreeIndex( "app1" ) ) ;
+    }
+}
\ No newline at end of file

Mime
View raw message