You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by er...@apache.org on 2007/05/24 02:27:07 UTC
svn commit: r541123 [16/25] - in
/directory/apacheds/branches/apacheds-sasl-branch: ./ benchmarks/
bootstrap-extract/ bootstrap-extract/src/ bootstrap-extract/src/main/
bootstrap-extract/src/main/java/ bootstrap-extract/src/main/java/org/
bootstrap-ext...
Modified: directory/apacheds/branches/apacheds-sasl-branch/core/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableDupsBTreeTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-sasl-branch/core/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableDupsBTreeTest.java?view=diff&rev=541123&r1=541122&r2=541123
==============================================================================
--- directory/apacheds/branches/apacheds-sasl-branch/core/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableDupsBTreeTest.java (original)
+++ directory/apacheds/branches/apacheds-sasl-branch/core/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableDupsBTreeTest.java Wed May 23 17:26:40 2007
@@ -22,7 +22,6 @@
import java.io.File;
import java.io.Serializable;
-import java.math.BigInteger;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
@@ -31,9 +30,10 @@
import org.apache.directory.server.core.partition.impl.btree.TupleComparator;
import org.apache.directory.server.schema.SerializableComparator;
import org.apache.directory.shared.ldap.util.ArrayEnumeration;
-import org.apache.directory.shared.ldap.util.BigIntegerComparator;
+import org.apache.directory.shared.ldap.util.LongComparator;
import jdbm.RecordManager;
+import jdbm.helper.LongSerializer;
import jdbm.recman.BaseRecordManager;
import junit.framework.TestCase;
@@ -50,7 +50,7 @@
private static final long serialVersionUID = 1L;
private transient File tempFile = null;
private transient RecordManager rm = null;
- private final BigIntegerComparator biComparator = new BigIntegerComparator();
+ private final LongComparator biComparator = new LongComparator();
private final SerializableComparator serializableComparator = new SerializableComparator( "integerMatchingRule" )
{
private static final long serialVersionUID = 1L;
@@ -108,16 +108,16 @@
rm = new BaseRecordManager( tempFile.getAbsolutePath() );
// make sure the table never uses a btree for duplicates
- table = new JdbmTable( "test", true, 1, rm, comparator );
+ table = new JdbmTable( "test", true, 1, rm, comparator, null, null );
- for ( BigInteger ii = BigInteger.ZERO; ii.intValue() < 3; ii = ii.add( BigInteger.ONE ) )
+ for ( Long ii = 0L; ii.intValue() < 3; ii++ )
{
- table.put( BigInteger.ONE, ii );
+ table.put( 1L, ii );
}
- table.put( new BigInteger( "2" ), BigInteger.ONE );
- table.put( new BigInteger( "4" ), BigInteger.ONE );
- table.put( new BigInteger( "5" ), BigInteger.ONE );
+ table.put( 2L, 1L );
+ table.put( 4L, 1L );
+ table.put( 5L, 1L );
}
protected void tearDown() throws Exception
@@ -142,40 +142,40 @@
public void testHas() throws Exception
{
// test the has( Object ) method
- assertTrue( table.has( BigInteger.ONE ) );
- assertTrue( table.has( new BigInteger("2") ) );
- assertTrue( table.has( new BigInteger("4") ) );
- assertTrue( table.has( new BigInteger("5") ) );
- assertFalse( table.has( new BigInteger("3") ) );
- assertFalse( table.has( BigInteger.ZERO ) );
- assertFalse( table.has( new BigInteger( "999" ) ) );
+ assertTrue( table.has( 1L ) );
+ assertTrue( table.has( 2L ) );
+ assertTrue( table.has( 4L ) );
+ assertTrue( table.has( 5L ) );
+ assertFalse( table.has( 3L ) );
+ assertFalse( table.has( 0L ) );
+ assertFalse( table.has( 999L ) );
// test the has( Object, Object ) method
- assertTrue( table.has( BigInteger.ONE, BigInteger.ONE ) );
- assertTrue( table.has( new BigInteger("2"), BigInteger.ONE ) );
- assertTrue( table.has( new BigInteger("4"), BigInteger.ONE ) );
- assertTrue( table.has( new BigInteger("5"), BigInteger.ONE ) );
- assertFalse( table.has( new BigInteger("5"), BigInteger.ZERO ) );
- assertFalse( table.has( new BigInteger("3"), BigInteger.ONE ) );
- assertFalse( table.has( BigInteger.ONE, new BigInteger("999") ) );
- assertFalse( table.has( new BigInteger( "999" ), BigInteger.ONE ) );
+ assertTrue( table.has( 1L, 1L ) );
+ assertTrue( table.has( 2L, 1L ) );
+ assertTrue( table.has( 4L, 1L ) );
+ assertTrue( table.has( 5L, 1L ) );
+ assertFalse( table.has( 5L, 0L ) );
+ assertFalse( table.has( 3L, 1L ) );
+ assertFalse( table.has( 1L, 999L ) );
+ assertFalse( table.has( 999L, 1L ) );
// test the has( Object, boolean ) method
- assertFalse( table.has( BigInteger.ZERO, false ) ); // we do not have a key less than or equal to 0
- assertTrue( table.has( BigInteger.ONE, false ) ); // we do have a key less than or equal to 1
- assertTrue( table.has( BigInteger.ZERO, true ) ); // we do have a key greater than or equal to 0
- assertTrue( table.has( BigInteger.ONE, true ) ); // we do have a key greater than or equal to 1
- assertTrue( table.has( new BigInteger( "5" ), true ) ); // we do have a key greater than or equal to 5
- assertFalse( table.has( new BigInteger( "6" ), true ) ); // we do NOT have a key greater than or equal to 11
- assertFalse( table.has( new BigInteger( "999" ), true ) ); // we do NOT have a key greater than or equal to 12
+ assertFalse( table.has( Long.valueOf( 0L ), false ) ); // we do not have a key less than or equal to 0
+ assertTrue( table.has( Long.valueOf( 1L ), false ) ); // we do have a key less than or equal to 1
+ assertTrue( table.has( Long.valueOf( 0L ), true ) ); // we do have a key greater than or equal to 0
+ assertTrue( table.has( Long.valueOf( 1L ), true ) ); // we do have a key greater than or equal to 1
+ assertTrue( table.has( Long.valueOf( 5L ), true ) ); // we do have a key greater than or equal to 5
+ assertFalse( table.has( Long.valueOf( 6L ), true ) ); // we do NOT have a key greater than or equal to 11
+ assertFalse( table.has( Long.valueOf( 999L ), true ) ); // we do NOT have a key greater than or equal to 12
// test the has( Object, Object, boolean ) method
- assertTrue( table.has( BigInteger.ONE, BigInteger.ZERO, true ) );
- assertTrue( table.has( BigInteger.ONE, BigInteger.ONE, true ) );
- assertTrue( table.has( BigInteger.ONE, new BigInteger("2"), true ) );
- assertFalse( table.has( BigInteger.ONE, new BigInteger("3"), true ) );
- assertTrue( table.has( BigInteger.ONE, BigInteger.ZERO, false ) );
- assertFalse( table.has( BigInteger.ONE, new BigInteger("-1"), false ) );
+ assertTrue( table.has( 1L, 0L, true ) );
+ assertTrue( table.has( 1L, 1L, true ) );
+ assertTrue( table.has( 1L, 2L, true ) );
+ assertFalse( table.has( 1L, 3L, true ) );
+ assertTrue( table.has( 1L, 0L, false ) );
+ assertFalse( table.has( 1L, -1L, false ) );
}
@@ -195,13 +195,13 @@
assertEquals( 6, table.count() );
// test the count(Object) method
- assertEquals( 3, table.count( BigInteger.ONE ) );
- assertEquals( 0, table.count( BigInteger.ZERO ) );
- assertEquals( 1, table.count( new BigInteger( "2" ) ) );
+ assertEquals( 3, table.count( 1L ) );
+ assertEquals( 0, table.count( 0L ) );
+ assertEquals( 1, table.count( 2L ) );
// test the count( Object, boolean ) method
// note for speed this count method returns the same as count()
- assertEquals( table.count(), table.count( BigInteger.ONE, true ) );
+ assertEquals( table.count(), table.count( 1L, true ) );
}
@@ -212,11 +212,11 @@
*/
public void testGet() throws Exception
{
- assertEquals( BigInteger.ZERO, table.get( BigInteger.ONE ) );
- assertEquals( BigInteger.ONE, table.get( new BigInteger( "2" ) ) );
- assertEquals( null, table.get( new BigInteger( "3" ) ) );
- assertEquals( BigInteger.ONE, table.get( new BigInteger( "4" ) ) );
- assertEquals( BigInteger.ONE, table.get( new BigInteger( "5" ) ) );
+ assertEquals( 0L, table.get( 1L ) );
+ assertEquals( 1L, table.get( 2L ) );
+ assertEquals( null, table.get( 3L ) );
+ assertEquals( 1L, table.get( 4L ) );
+ assertEquals( 1L, table.get( 5L ) );
}
@@ -243,33 +243,33 @@
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( BigInteger.ONE, tuple.getKey() );
- assertEquals( BigInteger.ZERO, tuple.getValue() );
+ assertEquals( 1L, tuple.getKey() );
+ assertEquals( 0L, tuple.getValue() );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( BigInteger.ONE, tuple.getKey() );
- assertEquals( BigInteger.ONE, tuple.getValue() );
+ assertEquals( 1L, tuple.getKey() );
+ assertEquals( 1L, tuple.getValue() );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( BigInteger.ONE, tuple.getKey() );
- assertEquals( new BigInteger( "2" ), tuple.getValue() );
+ assertEquals( 1L, tuple.getKey() );
+ assertEquals( 2L, tuple.getValue() );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( new BigInteger( "2" ), tuple.getKey() );
- assertEquals( BigInteger.ONE, tuple.getValue() );
+ assertEquals( 2L, tuple.getKey() );
+ assertEquals( 1L, tuple.getValue() );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( new BigInteger( "4" ), tuple.getKey() );
- assertEquals( BigInteger.ONE, tuple.getValue() );
+ assertEquals( 4L, tuple.getKey() );
+ assertEquals( 1L, tuple.getValue() );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( new BigInteger( "5" ), tuple.getKey() );
- assertEquals( BigInteger.ONE, tuple.getValue() );
+ assertEquals( 5L, tuple.getKey() );
+ assertEquals( 1L, tuple.getValue() );
assertFalse( tuples.hasMore() );
@@ -277,31 +277,31 @@
// test the listTuples(Object) method
// -------------------------------------------------------------------
- tuples = table.listTuples( BigInteger.ZERO );
+ tuples = table.listTuples( 0L );
assertFalse( tuples.hasMore() );
- tuples = table.listTuples( new BigInteger( "2" ) );
+ tuples = table.listTuples( 2L );
assertTrue( tuples.hasMore() );
tuple = ( Tuple ) tuples.next();
- assertEquals( new BigInteger( "2" ), tuple.getKey() );
- assertEquals( BigInteger.ONE, tuple.getValue() );
+ assertEquals( 2L, tuple.getKey() );
+ assertEquals( 1L, tuple.getValue() );
assertFalse( tuples.hasMore() );
- tuples = table.listTuples( BigInteger.ONE );
+ tuples = table.listTuples( 1L );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( BigInteger.ONE, tuple.getKey() );
- assertEquals( BigInteger.ZERO, tuple.getValue() );
+ assertEquals( 1L, tuple.getKey() );
+ assertEquals( 0L, tuple.getValue() );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( BigInteger.ONE, tuple.getKey() );
- assertEquals( BigInteger.ONE, tuple.getValue() );
+ assertEquals( 1L, tuple.getKey() );
+ assertEquals( 1L, tuple.getValue() );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( BigInteger.ONE, tuple.getKey() );
- assertEquals( new BigInteger( "2" ), tuple.getValue() );
+ assertEquals( 1L, tuple.getKey() );
+ assertEquals( 2L, tuple.getValue() );
assertFalse( tuples.hasMore() );
@@ -309,141 +309,141 @@
// test the listTuples(Object, boolean) method
// -------------------------------------------------------------------
- tuples = table.listTuples( BigInteger.ZERO, false );
+ tuples = table.listTuples( 0L, false );
assertFalse( tuples.hasMore() );
- tuples = table.listTuples( BigInteger.ONE, false );
+ tuples = table.listTuples( 1L, false );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( BigInteger.ONE, tuple.getKey() );
- assertEquals( new BigInteger( "2" ), tuple.getValue() );
+ assertEquals( 1L, tuple.getKey() );
+ assertEquals( 2L, tuple.getValue() );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( BigInteger.ONE, tuple.getKey() );
- assertEquals( BigInteger.ONE, tuple.getValue() );
+ assertEquals( 1L, tuple.getKey() );
+ assertEquals( 1L, tuple.getValue() );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( BigInteger.ONE, tuple.getKey() );
- assertEquals( BigInteger.ZERO, tuple.getValue() );
+ assertEquals( 1L, tuple.getKey() );
+ assertEquals( 0L, tuple.getValue() );
assertFalse( tuples.hasMore() );
- tuples = table.listTuples( new BigInteger( "2" ), false );
+ tuples = table.listTuples( 2L, false );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( new BigInteger( "2" ), tuple.getKey() );
- assertEquals( BigInteger.ONE, tuple.getValue() );
+ assertEquals( 2L, tuple.getKey() );
+ assertEquals( 1L, tuple.getValue() );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( BigInteger.ONE, tuple.getKey() );
- assertEquals( new BigInteger( "2" ), tuple.getValue() );
+ assertEquals( 1L, tuple.getKey() );
+ assertEquals( 2L, tuple.getValue() );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( BigInteger.ONE, tuple.getKey() );
- assertEquals( BigInteger.ONE, tuple.getValue() );
+ assertEquals( 1L, tuple.getKey() );
+ assertEquals( 1L, tuple.getValue() );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( BigInteger.ONE, tuple.getKey() );
- assertEquals( BigInteger.ZERO, tuple.getValue() );
+ assertEquals( 1L, tuple.getKey() );
+ assertEquals( 0L, tuple.getValue() );
assertFalse( tuples.hasMore() );
- tuples = table.listTuples( new BigInteger( "6" ), true );
+ tuples = table.listTuples( 6L, true );
assertFalse( tuples.hasMore() );
- tuples = table.listTuples( new BigInteger( "5" ), true );
+ tuples = table.listTuples( 5L, true );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( new BigInteger( "5" ), tuple.getKey() );
- assertEquals( BigInteger.ONE, tuple.getValue() );
+ assertEquals( 5L, tuple.getKey() );
+ assertEquals( 1L, tuple.getValue() );
assertFalse( tuples.hasMore() );
- tuples = table.listTuples( new BigInteger( "4" ), true );
+ tuples = table.listTuples( 4L, true );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( new BigInteger( "4" ), tuple.getKey() );
- assertEquals( BigInteger.ONE, tuple.getValue() );
+ assertEquals( 4L, tuple.getKey() );
+ assertEquals( 1L, tuple.getValue() );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( new BigInteger( "5" ), tuple.getKey() );
- assertEquals( BigInteger.ONE, tuple.getValue() );
+ assertEquals( 5L, tuple.getKey() );
+ assertEquals( 1L, tuple.getValue() );
assertFalse( tuples.hasMore() );
// -------------------------------------------------------------------
// test the listTuples(Object,Object,boolean) method
// -------------------------------------------------------------------
- tuples = table.listTuples( BigInteger.ZERO, BigInteger.ZERO, true );
+ tuples = table.listTuples( 0L, 0L, true );
assertFalse( tuples.hasMore() );
- tuples = table.listTuples( BigInteger.ZERO, BigInteger.ZERO, false );
+ tuples = table.listTuples( 0L, 0L, false );
assertFalse( tuples.hasMore() );
- tuples = table.listTuples( new BigInteger( "2" ), BigInteger.ZERO, false );
+ tuples = table.listTuples( 2L, 0L, false );
assertFalse( tuples.hasMore() );
- tuples = table.listTuples( new BigInteger( "2" ), new BigInteger( "99" ), true );
+ tuples = table.listTuples( 2L, 99L, true );
assertFalse( tuples.hasMore() );
- tuples = table.listTuples( new BigInteger( "2" ), BigInteger.ONE, false );
+ tuples = table.listTuples( 2L, 1L, false );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( new BigInteger( "2" ), tuple.getKey() );
- assertEquals( BigInteger.ONE, tuple.getValue() );
+ assertEquals( 2L, tuple.getKey() );
+ assertEquals( 1L, tuple.getValue() );
assertFalse( tuples.hasMore() );
- tuples = table.listTuples( new BigInteger( "2" ), new BigInteger( "99" ), false );
+ tuples = table.listTuples( 2L, 99L, false );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( new BigInteger( "2" ), tuple.getKey() );
- assertEquals( BigInteger.ONE, tuple.getValue() );
+ assertEquals( 2L, tuple.getKey() );
+ assertEquals( 1L, tuple.getValue() );
assertFalse( tuples.hasMore() );
- tuples = table.listTuples( BigInteger.ONE, new BigInteger( "3" ), true );
+ tuples = table.listTuples( 1L, 3L, true );
assertFalse( tuples.hasMore() );
- tuples = table.listTuples( BigInteger.ONE, new BigInteger( "-1" ), false );
+ tuples = table.listTuples( 1L, -1L, false );
assertFalse( tuples.hasMore() );
- tuples = table.listTuples( BigInteger.ONE, new BigInteger( "1" ), true );
+ tuples = table.listTuples( 1L, 1L, true );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( BigInteger.ONE, tuple.getKey() );
- assertEquals( BigInteger.ONE, tuple.getValue() );
+ assertEquals( 1L, tuple.getKey() );
+ assertEquals( 1L, tuple.getValue() );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( BigInteger.ONE, tuple.getKey() );
- assertEquals( new BigInteger( "2" ), tuple.getValue() );
+ assertEquals( 1L, tuple.getKey() );
+ assertEquals( 2L, tuple.getValue() );
assertFalse( tuples.hasMore() );
- tuples = table.listTuples( BigInteger.ONE, new BigInteger( "1" ), false );
+ tuples = table.listTuples( 1L, 1L, false );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( BigInteger.ONE, tuple.getKey() );
- assertEquals( BigInteger.ONE, tuple.getValue() );
+ assertEquals( 1L, tuple.getKey() );
+ assertEquals( 1L, tuple.getValue() );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( BigInteger.ONE, tuple.getKey() );
- assertEquals( BigInteger.ZERO, tuple.getValue() );
+ assertEquals( 1L, tuple.getKey() );
+ assertEquals( 0L, tuple.getValue() );
assertFalse( tuples.hasMore() );
@@ -459,27 +459,27 @@
// test the listValues(Object) method
// -------------------------------------------------------------------
- NamingEnumeration values = table.listValues( BigInteger.ZERO );
+ NamingEnumeration values = table.listValues( 0L );
assertFalse( values.hasMore() );
- values = table.listValues( new BigInteger( "2" ) );
+ values = table.listValues( 2L );
assertTrue( values.hasMore() );
Object value = values.next();
- assertEquals( BigInteger.ONE, value );
+ assertEquals( 1L, value );
assertFalse( values.hasMore() );
- values = table.listValues( BigInteger.ONE );
+ values = table.listValues( 1L );
assertTrue( values.hasMore() ) ;
value = values.next();
- assertEquals( BigInteger.ZERO, value );
+ assertEquals( 0L, value );
assertTrue( values.hasMore() ) ;
value = values.next();
- assertEquals( BigInteger.ONE, value );
+ assertEquals( 1L, value );
assertTrue( values.hasMore() ) ;
value = values.next();
- assertEquals( new BigInteger( "2" ), value );
+ assertEquals( 2L, value );
assertFalse( values.hasMore() );
}
@@ -498,63 +498,63 @@
// this instead tests the NamingEnumeration overload
NamingEnumeration values = new ArrayNE( new Object[] {
- new BigInteger( "3" ),
- new BigInteger( "4" ),
- new BigInteger( "5" ),
- new BigInteger( "6" ),
+ 3L,
+ 4L,
+ 5L,
+ 6L,
} );
- table.put( BigInteger.ONE, values );
+ table.put( 1L, values );
assertFalse( values.hasMore() );
- values = table.listValues( BigInteger.ONE );
+ values = table.listValues( 1L );
assertTrue( values.hasMore() );
- assertEquals( BigInteger.ZERO, values.next() );
+ assertEquals( 0L, values.next() );
assertTrue( values.hasMore() );
- assertEquals( BigInteger.ONE, values.next() );
+ assertEquals( 1L, values.next() );
assertTrue( values.hasMore() );
- assertEquals( new BigInteger( "2" ), values.next() );
+ assertEquals( 2L, values.next() );
assertTrue( values.hasMore() );
- assertEquals( new BigInteger( "3" ), values.next() );
+ assertEquals( 3L, values.next() );
assertTrue( values.hasMore() );
- assertEquals( new BigInteger( "4" ), values.next() );
+ assertEquals( 4L, values.next() );
assertTrue( values.hasMore() );
- assertEquals( new BigInteger( "5" ), values.next() );
+ assertEquals( 5L, values.next() );
assertTrue( values.hasMore() );
- assertEquals( new BigInteger( "6" ), values.next() );
+ assertEquals( 6L, values.next() );
assertFalse( values.hasMore() );
values = new ArrayNE( new Object[] {
- new BigInteger( "3" ),
- new BigInteger( "4" ),
- new BigInteger( "5" ),
- new BigInteger( "6" ),
+ 3L,
+ 4L,
+ 5L,
+ 6L,
} );
- table.put( BigInteger.ZERO, values );
+ table.put( 0L, values );
assertFalse( values.hasMore() );
- values = table.listValues( BigInteger.ZERO );
+ values = table.listValues( 0L );
assertTrue( values.hasMore() );
- assertEquals( new BigInteger( "3" ), values.next() );
+ assertEquals( 3L, values.next() );
assertTrue( values.hasMore() );
- assertEquals( new BigInteger( "4" ), values.next() );
+ assertEquals( 4L, values.next() );
assertTrue( values.hasMore() );
- assertEquals( new BigInteger( "5" ), values.next() );
+ assertEquals( 5L, values.next() );
assertTrue( values.hasMore() );
- assertEquals( new BigInteger( "6" ), values.next() );
+ assertEquals( 6L, values.next() );
assertFalse( values.hasMore() );
}
@@ -570,19 +570,19 @@
try
{
- table.remove( BigInteger.ZERO );
+ table.remove( 0L );
fail( "should not get here trying to remove non-existent key" );
}
catch ( IllegalArgumentException e )
{
}
- Object value = table.remove( new BigInteger( "2" ) );
- assertEquals( BigInteger.ONE, value );
+ Object value = table.remove( 2L );
+ assertEquals( 1L, value );
assertEquals( 5, table.count() );
- value = table.remove( BigInteger.ONE );
- assertEquals( BigInteger.ZERO, value ); // return first value of dups
+ value = table.remove( 1L );
+ assertEquals( 0L, value ); // return first value of dups
assertEquals( 2, table.count() );
}
@@ -596,15 +596,15 @@
// tests the remove(Object) method
// -------------------------------------------------------------------
- Object value = table.remove( BigInteger.ZERO, BigInteger.ZERO );
+ Object value = table.remove( 0L, 0L );
assertNull( value );
- value = table.remove( new BigInteger( "2" ), BigInteger.ONE );
- assertEquals( BigInteger.ONE, value );
+ value = table.remove( 2L, 1L );
+ assertEquals( 1L, value );
assertEquals( 5, table.count() );
- value = table.remove( BigInteger.ONE, new BigInteger( "2" ) );
- assertEquals( new BigInteger( "2" ), value );
+ value = table.remove( 1L, 2L );
+ assertEquals( 2L, value );
assertEquals( 4, table.count() );
}
@@ -615,12 +615,12 @@
public void testRemoveObjectNamingEnumeration() throws Exception
{
NamingEnumeration values = new ArrayNE( new Object[] {
- new BigInteger( "1" ),
- new BigInteger( "2" )
+ 1L,
+ 2L
} );
- Object value = table.remove( BigInteger.ONE, values );
- assertEquals( BigInteger.ONE, value );
+ Object value = table.remove( 1L, values );
+ assertEquals( 1L, value );
assertEquals( 4, table.count() );
}
Modified: directory/apacheds/branches/apacheds-sasl-branch/core/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableDupsTreeSetTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-sasl-branch/core/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableDupsTreeSetTest.java?view=diff&rev=541123&r1=541122&r2=541123
==============================================================================
--- directory/apacheds/branches/apacheds-sasl-branch/core/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableDupsTreeSetTest.java (original)
+++ directory/apacheds/branches/apacheds-sasl-branch/core/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableDupsTreeSetTest.java Wed May 23 17:26:40 2007
@@ -22,7 +22,6 @@
import java.io.File;
import java.io.Serializable;
-import java.math.BigInteger;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
@@ -31,9 +30,10 @@
import org.apache.directory.server.core.partition.impl.btree.TupleComparator;
import org.apache.directory.server.schema.SerializableComparator;
import org.apache.directory.shared.ldap.util.ArrayEnumeration;
-import org.apache.directory.shared.ldap.util.BigIntegerComparator;
+import org.apache.directory.shared.ldap.util.LongComparator;
import jdbm.RecordManager;
+import jdbm.helper.LongSerializer;
import jdbm.recman.BaseRecordManager;
import junit.framework.TestCase;
@@ -50,7 +50,7 @@
private static final long serialVersionUID = 1L;
private transient File tempFile = null;
private transient RecordManager rm = null;
- private final BigIntegerComparator biComparator = new BigIntegerComparator();
+ private final LongComparator biComparator = new LongComparator();
private final SerializableComparator serializableComparator = new SerializableComparator( "integerMatchingRule" )
{
private static final long serialVersionUID = 1L;
@@ -108,16 +108,17 @@
rm = new BaseRecordManager( tempFile.getAbsolutePath() );
// make sure the table never uses a btree for duplicates
- table = new JdbmTable( "test", true, Integer.MAX_VALUE, rm, comparator );
+ table = new JdbmTable( "test", true, Integer.MAX_VALUE, rm,
+ comparator, null, null );
- for ( BigInteger ii = BigInteger.ZERO; ii.intValue() < 3; ii = ii.add( BigInteger.ONE ) )
+ for ( Long ii = 0L; ii.intValue() < 3; ii++ )
{
- table.put( BigInteger.ONE, ii );
+ table.put( 1L, ii );
}
- table.put( new BigInteger( "2" ), BigInteger.ONE );
- table.put( new BigInteger( "4" ), BigInteger.ONE );
- table.put( new BigInteger( "5" ), BigInteger.ONE );
+ table.put( 2L, 1L );
+ table.put( 4L, 1L );
+ table.put( 5L, 1L );
}
protected void tearDown() throws Exception
@@ -143,40 +144,40 @@
public void testHas() throws Exception
{
// test the has( Object ) method
- assertTrue( table.has( BigInteger.ONE ) );
- assertTrue( table.has( new BigInteger("2") ) );
- assertTrue( table.has( new BigInteger("4") ) );
- assertTrue( table.has( new BigInteger("5") ) );
- assertFalse( table.has( new BigInteger("3") ) );
- assertFalse( table.has( BigInteger.ZERO ) );
- assertFalse( table.has( new BigInteger( "999" ) ) );
+ assertTrue( table.has( 1L ) );
+ assertTrue( table.has( 2L ) );
+ assertTrue( table.has( 4L ) );
+ assertTrue( table.has( 5L ) );
+ assertFalse( table.has( 3L ) );
+ assertFalse( table.has( 0L ) );
+ assertFalse( table.has( 999L ) );
// test the has( Object, Object ) method
- assertTrue( table.has( BigInteger.ONE, BigInteger.ONE ) );
- assertTrue( table.has( new BigInteger("2"), BigInteger.ONE ) );
- assertTrue( table.has( new BigInteger("4"), BigInteger.ONE ) );
- assertTrue( table.has( new BigInteger("5"), BigInteger.ONE ) );
- assertFalse( table.has( new BigInteger("5"), BigInteger.ZERO ) );
- assertFalse( table.has( new BigInteger("3"), BigInteger.ONE ) );
- assertFalse( table.has( BigInteger.ONE, new BigInteger("999") ) );
- assertFalse( table.has( new BigInteger( "999" ), BigInteger.ONE ) );
+ assertTrue( table.has( 1L, 1L ) );
+ assertTrue( table.has( 2L, 1L ) );
+ assertTrue( table.has( 4L, 1L ) );
+ assertTrue( table.has( 5L, 1L ) );
+ assertFalse( table.has( 5L, 0L ) );
+ assertFalse( table.has( 3L, 1L ) );
+ assertFalse( table.has( 1L, 999L ) );
+ assertFalse( table.has( 999L, 1L ) );
// test the has( Object, boolean ) method
- assertFalse( table.has( BigInteger.ZERO, false ) ); // we do not have a key less than or equal to 0
- assertTrue( table.has( BigInteger.ONE, false ) ); // we do have a key less than or equal to 1
- assertTrue( table.has( BigInteger.ZERO, true ) ); // we do have a key greater than or equal to 0
- assertTrue( table.has( BigInteger.ONE, true ) ); // we do have a key greater than or equal to 1
- assertTrue( table.has( new BigInteger( "5" ), true ) ); // we do have a key greater than or equal to 5
- assertFalse( table.has( new BigInteger( "6" ), true ) ); // we do NOT have a key greater than or equal to 11
- assertFalse( table.has( new BigInteger( "999" ), true ) ); // we do NOT have a key greater than or equal to 12
+ assertFalse( table.has( Long.valueOf( 0 ), false ) ); // we do not have a key less than or equal to 0
+ assertTrue( table.has( Long.valueOf( 1 ), false ) ); // we do have a key less than or equal to 1
+ assertTrue( table.has( Long.valueOf( 0 ), true ) ); // we do have a key greater than or equal to 0
+ assertTrue( table.has( Long.valueOf( 1 ), true ) ); // we do have a key greater than or equal to 1
+ assertTrue( table.has( Long.valueOf( 5 ), true ) ); // we do have a key greater than or equal to 5
+ assertFalse( table.has( Long.valueOf( 6 ), true ) ); // we do NOT have a key greater than or equal to 11
+ assertFalse( table.has( Long.valueOf( 999 ), true ) ); // we do NOT have a key greater than or equal to 12
// test the has( Object, Object, boolean ) method
- assertTrue( table.has( BigInteger.ONE, BigInteger.ZERO, true ) );
- assertTrue( table.has( BigInteger.ONE, BigInteger.ONE, true ) );
- assertTrue( table.has( BigInteger.ONE, new BigInteger("2"), true ) );
- assertFalse( table.has( BigInteger.ONE, new BigInteger("3"), true ) );
- assertTrue( table.has( BigInteger.ONE, BigInteger.ZERO, false ) );
- assertFalse( table.has( BigInteger.ONE, new BigInteger("-1"), false ) );
+ assertTrue( table.has( 1L, 0L, true ) );
+ assertTrue( table.has( 1L, 1L, true ) );
+ assertTrue( table.has( 1L, 2L, true ) );
+ assertFalse( table.has( 1L, 3L, true ) );
+ assertTrue( table.has( 1L, 0L, false ) );
+ assertFalse( table.has( 1L, -1L, false ) );
}
@@ -196,13 +197,13 @@
assertEquals( 6, table.count() );
// test the count(Object) method
- assertEquals( 3, table.count( BigInteger.ONE ) );
- assertEquals( 0, table.count( BigInteger.ZERO ) );
- assertEquals( 1, table.count( new BigInteger( "2" ) ) );
+ assertEquals( 3, table.count( 1L ) );
+ assertEquals( 0, table.count( 0L ) );
+ assertEquals( 1, table.count( 2L ) );
// test the count( Object, boolean ) method
// note for speed this count method returns the same as count()
- assertEquals( table.count(), table.count( BigInteger.ONE, true ) );
+ assertEquals( table.count(), table.count( 1L, true ) );
}
@@ -213,11 +214,11 @@
*/
public void testGet() throws Exception
{
- assertEquals( BigInteger.ZERO, table.get( BigInteger.ONE ) );
- assertEquals( BigInteger.ONE, table.get( new BigInteger( "2" ) ) );
- assertEquals( null, table.get( new BigInteger( "3" ) ) );
- assertEquals( BigInteger.ONE, table.get( new BigInteger( "4" ) ) );
- assertEquals( BigInteger.ONE, table.get( new BigInteger( "5" ) ) );
+ assertEquals( 0L, table.get( 1L ) );
+ assertEquals( 1L, table.get( 2L ) );
+ assertEquals( null, table.get( 3L ) );
+ assertEquals( 1L, table.get( 4L ) );
+ assertEquals( 1L, table.get( 5L ) );
}
@@ -244,33 +245,33 @@
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( BigInteger.ONE, tuple.getKey() );
- assertEquals( BigInteger.ZERO, tuple.getValue() );
+ assertEquals( 1L, tuple.getKey() );
+ assertEquals( 0L, tuple.getValue() );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( BigInteger.ONE, tuple.getKey() );
- assertEquals( BigInteger.ONE, tuple.getValue() );
+ assertEquals( 1L, tuple.getKey() );
+ assertEquals( 1L, tuple.getValue() );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( BigInteger.ONE, tuple.getKey() );
- assertEquals( new BigInteger( "2" ), tuple.getValue() );
+ assertEquals( 1L, tuple.getKey() );
+ assertEquals( 2L, tuple.getValue() );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( new BigInteger( "2" ), tuple.getKey() );
- assertEquals( BigInteger.ONE, tuple.getValue() );
+ assertEquals( 2L, tuple.getKey() );
+ assertEquals( 1L, tuple.getValue() );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( new BigInteger( "4" ), tuple.getKey() );
- assertEquals( BigInteger.ONE, tuple.getValue() );
+ assertEquals( 4L, tuple.getKey() );
+ assertEquals( 1L, tuple.getValue() );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( new BigInteger( "5" ), tuple.getKey() );
- assertEquals( BigInteger.ONE, tuple.getValue() );
+ assertEquals( 5L, tuple.getKey() );
+ assertEquals( 1L, tuple.getValue() );
assertFalse( tuples.hasMore() );
@@ -278,31 +279,31 @@
// test the listTuples(Object) method
// -------------------------------------------------------------------
- tuples = table.listTuples( BigInteger.ZERO );
+ tuples = table.listTuples( 0L );
assertFalse( tuples.hasMore() );
- tuples = table.listTuples( new BigInteger( "2" ) );
+ tuples = table.listTuples( 2L );
assertTrue( tuples.hasMore() );
tuple = ( Tuple ) tuples.next();
- assertEquals( new BigInteger( "2" ), tuple.getKey() );
- assertEquals( BigInteger.ONE, tuple.getValue() );
+ assertEquals( 2L, tuple.getKey() );
+ assertEquals( 1L, tuple.getValue() );
assertFalse( tuples.hasMore() );
- tuples = table.listTuples( BigInteger.ONE );
+ tuples = table.listTuples( 1L );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( BigInteger.ONE, tuple.getKey() );
- assertEquals( BigInteger.ZERO, tuple.getValue() );
+ assertEquals( 1L, tuple.getKey() );
+ assertEquals( 0L, tuple.getValue() );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( BigInteger.ONE, tuple.getKey() );
- assertEquals( BigInteger.ONE, tuple.getValue() );
+ assertEquals( 1L, tuple.getKey() );
+ assertEquals( 1L, tuple.getValue() );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( BigInteger.ONE, tuple.getKey() );
- assertEquals( new BigInteger( "2" ), tuple.getValue() );
+ assertEquals( 1L, tuple.getKey() );
+ assertEquals( 2L, tuple.getValue() );
assertFalse( tuples.hasMore() );
@@ -310,141 +311,141 @@
// test the listTuples(Object, boolean) method
// -------------------------------------------------------------------
- tuples = table.listTuples( BigInteger.ZERO, false );
+ tuples = table.listTuples( 0L, false );
assertFalse( tuples.hasMore() );
- tuples = table.listTuples( BigInteger.ONE, false );
+ tuples = table.listTuples( 1L, false );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( BigInteger.ONE, tuple.getKey() );
- assertEquals( new BigInteger( "2" ), tuple.getValue() );
+ assertEquals( 1L, tuple.getKey() );
+ assertEquals( 2L, tuple.getValue() );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( BigInteger.ONE, tuple.getKey() );
- assertEquals( BigInteger.ONE, tuple.getValue() );
+ assertEquals( 1L, tuple.getKey() );
+ assertEquals( 1L, tuple.getValue() );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( BigInteger.ONE, tuple.getKey() );
- assertEquals( BigInteger.ZERO, tuple.getValue() );
+ assertEquals( 1L, tuple.getKey() );
+ assertEquals( 0L, tuple.getValue() );
assertFalse( tuples.hasMore() );
- tuples = table.listTuples( new BigInteger( "2" ), false );
+ tuples = table.listTuples( 2L, false );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( new BigInteger( "2" ), tuple.getKey() );
- assertEquals( BigInteger.ONE, tuple.getValue() );
+ assertEquals( 2L, tuple.getKey() );
+ assertEquals( 1L, tuple.getValue() );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( BigInteger.ONE, tuple.getKey() );
- assertEquals( new BigInteger( "2" ), tuple.getValue() );
+ assertEquals( 1L, tuple.getKey() );
+ assertEquals( 2L, tuple.getValue() );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( BigInteger.ONE, tuple.getKey() );
- assertEquals( BigInteger.ONE, tuple.getValue() );
+ assertEquals( 1L, tuple.getKey() );
+ assertEquals( 1L, tuple.getValue() );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( BigInteger.ONE, tuple.getKey() );
- assertEquals( BigInteger.ZERO, tuple.getValue() );
+ assertEquals( 1L, tuple.getKey() );
+ assertEquals( 0L, tuple.getValue() );
assertFalse( tuples.hasMore() );
- tuples = table.listTuples( new BigInteger( "6" ), true );
+ tuples = table.listTuples( 6L, true );
assertFalse( tuples.hasMore() );
- tuples = table.listTuples( new BigInteger( "5" ), true );
+ tuples = table.listTuples( 5L, true );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( new BigInteger( "5" ), tuple.getKey() );
- assertEquals( BigInteger.ONE, tuple.getValue() );
+ assertEquals( 5L, tuple.getKey() );
+ assertEquals( 1L, tuple.getValue() );
assertFalse( tuples.hasMore() );
- tuples = table.listTuples( new BigInteger( "4" ), true );
+ tuples = table.listTuples( 4L, true );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( new BigInteger( "4" ), tuple.getKey() );
- assertEquals( BigInteger.ONE, tuple.getValue() );
+ assertEquals( 4L, tuple.getKey() );
+ assertEquals( 1L, tuple.getValue() );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( new BigInteger( "5" ), tuple.getKey() );
- assertEquals( BigInteger.ONE, tuple.getValue() );
+ assertEquals( 5L, tuple.getKey() );
+ assertEquals( 1L, tuple.getValue() );
assertFalse( tuples.hasMore() );
// -------------------------------------------------------------------
// test the listTuples(Object,Object,boolean) method
// -------------------------------------------------------------------
- tuples = table.listTuples( BigInteger.ZERO, BigInteger.ZERO, true );
+ tuples = table.listTuples( 0L, 0L, true );
assertFalse( tuples.hasMore() );
- tuples = table.listTuples( BigInteger.ZERO, BigInteger.ZERO, false );
+ tuples = table.listTuples( 0L, 0L, false );
assertFalse( tuples.hasMore() );
- tuples = table.listTuples( new BigInteger( "2" ), BigInteger.ZERO, false );
+ tuples = table.listTuples( 2L, 0L, false );
assertFalse( tuples.hasMore() );
- tuples = table.listTuples( new BigInteger( "2" ), new BigInteger( "99" ), true );
+ tuples = table.listTuples( 2L, 99L, true );
assertFalse( tuples.hasMore() );
- tuples = table.listTuples( new BigInteger( "2" ), BigInteger.ONE, false );
+ tuples = table.listTuples( 2L, 1L, false );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( new BigInteger( "2" ), tuple.getKey() );
- assertEquals( BigInteger.ONE, tuple.getValue() );
+ assertEquals( 2L, tuple.getKey() );
+ assertEquals( 1L, tuple.getValue() );
assertFalse( tuples.hasMore() );
- tuples = table.listTuples( new BigInteger( "2" ), new BigInteger( "99" ), false );
+ tuples = table.listTuples( 2L, 99L, false );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( new BigInteger( "2" ), tuple.getKey() );
- assertEquals( BigInteger.ONE, tuple.getValue() );
+ assertEquals( 2L, tuple.getKey() );
+ assertEquals( 1L, tuple.getValue() );
assertFalse( tuples.hasMore() );
- tuples = table.listTuples( BigInteger.ONE, new BigInteger( "3" ), true );
+ tuples = table.listTuples( 1L, 3L, true );
assertFalse( tuples.hasMore() );
- tuples = table.listTuples( BigInteger.ONE, new BigInteger( "-1" ), false );
+ tuples = table.listTuples( 1L, -1L, false );
assertFalse( tuples.hasMore() );
- tuples = table.listTuples( BigInteger.ONE, new BigInteger( "1" ), true );
+ tuples = table.listTuples( 1L, 1L, true );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( BigInteger.ONE, tuple.getKey() );
- assertEquals( BigInteger.ONE, tuple.getValue() );
+ assertEquals( 1L, tuple.getKey() );
+ assertEquals( 1L, tuple.getValue() );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( BigInteger.ONE, tuple.getKey() );
- assertEquals( new BigInteger( "2" ), tuple.getValue() );
+ assertEquals( 1L, tuple.getKey() );
+ assertEquals( 2L, tuple.getValue() );
assertFalse( tuples.hasMore() );
- tuples = table.listTuples( BigInteger.ONE, new BigInteger( "1" ), false );
+ tuples = table.listTuples( 1L, 1L, false );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( BigInteger.ONE, tuple.getKey() );
- assertEquals( BigInteger.ONE, tuple.getValue() );
+ assertEquals( 1L, tuple.getKey() );
+ assertEquals( 1L, tuple.getValue() );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( BigInteger.ONE, tuple.getKey() );
- assertEquals( BigInteger.ZERO, tuple.getValue() );
+ assertEquals( 1L, tuple.getKey() );
+ assertEquals( 0L, tuple.getValue() );
assertFalse( tuples.hasMore() );
@@ -460,27 +461,27 @@
// test the listValues(Object) method
// -------------------------------------------------------------------
- NamingEnumeration values = table.listValues( BigInteger.ZERO );
+ NamingEnumeration values = table.listValues( 0L );
assertFalse( values.hasMore() );
- values = table.listValues( new BigInteger( "2" ) );
+ values = table.listValues( 2L );
assertTrue( values.hasMore() );
Object value = values.next();
- assertEquals( BigInteger.ONE, value );
+ assertEquals( 1L, value );
assertFalse( values.hasMore() );
- values = table.listValues( BigInteger.ONE );
+ values = table.listValues( 1L );
assertTrue( values.hasMore() ) ;
value = values.next();
- assertEquals( BigInteger.ZERO, value );
+ assertEquals( 0L, value );
assertTrue( values.hasMore() ) ;
value = values.next();
- assertEquals( BigInteger.ONE, value );
+ assertEquals( 1L, value );
assertTrue( values.hasMore() ) ;
value = values.next();
- assertEquals( new BigInteger( "2" ), value );
+ assertEquals( 2L, value );
assertFalse( values.hasMore() );
}
@@ -499,63 +500,63 @@
// this instead tests the NamingEnumeration overload
NamingEnumeration values = new ArrayNE( new Object[] {
- new BigInteger( "3" ),
- new BigInteger( "4" ),
- new BigInteger( "5" ),
- new BigInteger( "6" ),
+ 3L,
+ 4L,
+ 5L,
+ 6L,
} );
- table.put( BigInteger.ONE, values );
+ table.put( 1L, values );
assertFalse( values.hasMore() );
- values = table.listValues( BigInteger.ONE );
+ values = table.listValues( 1L );
assertTrue( values.hasMore() );
- assertEquals( BigInteger.ZERO, values.next() );
+ assertEquals( 0L, values.next() );
assertTrue( values.hasMore() );
- assertEquals( BigInteger.ONE, values.next() );
+ assertEquals( 1L, values.next() );
assertTrue( values.hasMore() );
- assertEquals( new BigInteger( "2" ), values.next() );
+ assertEquals( 2L, values.next() );
assertTrue( values.hasMore() );
- assertEquals( new BigInteger( "3" ), values.next() );
+ assertEquals( 3L, values.next() );
assertTrue( values.hasMore() );
- assertEquals( new BigInteger( "4" ), values.next() );
+ assertEquals( 4L, values.next() );
assertTrue( values.hasMore() );
- assertEquals( new BigInteger( "5" ), values.next() );
+ assertEquals( 5L, values.next() );
assertTrue( values.hasMore() );
- assertEquals( new BigInteger( "6" ), values.next() );
+ assertEquals( 6L, values.next() );
assertFalse( values.hasMore() );
values = new ArrayNE( new Object[] {
- new BigInteger( "3" ),
- new BigInteger( "4" ),
- new BigInteger( "5" ),
- new BigInteger( "6" ),
+ 3L,
+ 4L,
+ 5L,
+ 6L,
} );
- table.put( BigInteger.ZERO, values );
+ table.put( 0L, values );
assertFalse( values.hasMore() );
- values = table.listValues( BigInteger.ZERO );
+ values = table.listValues( 0L );
assertTrue( values.hasMore() );
- assertEquals( new BigInteger( "3" ), values.next() );
+ assertEquals( 3L, values.next() );
assertTrue( values.hasMore() );
- assertEquals( new BigInteger( "4" ), values.next() );
+ assertEquals( 4L, values.next() );
assertTrue( values.hasMore() );
- assertEquals( new BigInteger( "5" ), values.next() );
+ assertEquals( 5L, values.next() );
assertTrue( values.hasMore() );
- assertEquals( new BigInteger( "6" ), values.next() );
+ assertEquals( 6L, values.next() );
assertFalse( values.hasMore() );
}
@@ -571,19 +572,19 @@
try
{
- table.remove( BigInteger.ZERO );
+ table.remove( 0L );
fail( "should not get here trying to remove non-existent key" );
}
catch ( IllegalArgumentException e )
{
}
- Object value = table.remove( new BigInteger( "2" ) );
- assertEquals( BigInteger.ONE, value );
+ Object value = table.remove( 2L );
+ assertEquals( 1L, value );
assertEquals( 5, table.count() );
- value = table.remove( BigInteger.ONE );
- assertEquals( BigInteger.ZERO, value ); // return first value of dups
+ value = table.remove( 1L );
+ assertEquals( 0L, value ); // return first value of dups
assertEquals( 2, table.count() );
}
@@ -597,15 +598,15 @@
// tests the remove(Object) method
// -------------------------------------------------------------------
- Object value = table.remove( BigInteger.ZERO, BigInteger.ZERO );
+ Object value = table.remove( 0L, 0L );
assertNull( value );
- value = table.remove( new BigInteger( "2" ), BigInteger.ONE );
- assertEquals( BigInteger.ONE, value );
+ value = table.remove( 2L, 1L );
+ assertEquals( 1L, value );
assertEquals( 5, table.count() );
- value = table.remove( BigInteger.ONE, new BigInteger( "2" ) );
- assertEquals( new BigInteger( "2" ), value );
+ value = table.remove( 1L, 2L );
+ assertEquals( 2L, value );
assertEquals( 4, table.count() );
}
@@ -616,12 +617,12 @@
public void testRemoveObjectNamingEnumeration() throws Exception
{
NamingEnumeration values = new ArrayNE( new Object[] {
- new BigInteger( "1" ),
- new BigInteger( "2" )
+ 1L,
+ 2L
} );
- Object value = table.remove( BigInteger.ONE, values );
- assertEquals( BigInteger.ONE, value );
+ Object value = table.remove( 1L, values );
+ assertEquals( 1L, value );
assertEquals( 4, table.count() );
}
Modified: directory/apacheds/branches/apacheds-sasl-branch/core/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableNoDupsTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-sasl-branch/core/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableNoDupsTest.java?view=diff&rev=541123&r1=541122&r2=541123
==============================================================================
--- directory/apacheds/branches/apacheds-sasl-branch/core/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableNoDupsTest.java (original)
+++ directory/apacheds/branches/apacheds-sasl-branch/core/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableNoDupsTest.java Wed May 23 17:26:40 2007
@@ -22,7 +22,6 @@
import java.io.File;
import java.io.Serializable;
-import java.math.BigInteger;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
@@ -31,9 +30,11 @@
import org.apache.directory.server.core.partition.impl.btree.TupleRenderer;
import org.apache.directory.server.schema.SerializableComparator;
import org.apache.directory.shared.ldap.util.ArrayEnumeration;
-import org.apache.directory.shared.ldap.util.BigIntegerComparator;
+import org.apache.directory.shared.ldap.util.LongComparator;
import jdbm.RecordManager;
+import jdbm.helper.LongSerializer;
+import jdbm.helper.Serializer;
import jdbm.recman.BaseRecordManager;
import junit.framework.TestCase;
@@ -50,7 +51,7 @@
private static final long serialVersionUID = 1L;
private transient File tempFile = null;
private transient RecordManager rm = null;
- private final BigIntegerComparator biComparator = new BigIntegerComparator();
+ private final LongComparator biComparator = new LongComparator();
private final SerializableComparator serializableComparator = new SerializableComparator( "integerMatchingRule" )
{
private static final long serialVersionUID = 1L;
@@ -82,12 +83,12 @@
rm = new BaseRecordManager( tempFile.getAbsolutePath() );
// make sure the table does not use duplicates
- table = new JdbmTable( "test", rm, serializableComparator );
+ table = new JdbmTable( "test", rm, serializableComparator, LongSerializer.INSTANCE, LongSerializer.INSTANCE );
- table.put( new BigInteger( "1" ), BigInteger.ONE );
- table.put( new BigInteger( "2" ), BigInteger.ONE );
- table.put( new BigInteger( "4" ), BigInteger.ONE );
- table.put( new BigInteger( "5" ), BigInteger.ONE );
+ table.put( 1L, 1L );
+ table.put( 2L, 1L );
+ table.put( 4L, 1L );
+ table.put( 5L, 1L );
}
protected void tearDown() throws Exception
@@ -119,7 +120,7 @@
table.sync();
table.close();
- table = new JdbmTable( "test", rm, serializableComparator );
+ table = new JdbmTable( "test", rm, serializableComparator, LongSerializer.INSTANCE, LongSerializer.INSTANCE );
}
@@ -137,37 +138,37 @@
public void testHas() throws Exception
{
// test the has( Object ) method
- assertTrue( table.has( BigInteger.ONE ) );
- assertTrue( table.has( new BigInteger("2") ) );
- assertTrue( table.has( new BigInteger("4") ) );
- assertTrue( table.has( new BigInteger("5") ) );
- assertFalse( table.has( new BigInteger("3") ) );
- assertFalse( table.has( BigInteger.ZERO ) );
- assertFalse( table.has( new BigInteger( "999" ) ) );
+ assertTrue( table.has( 1L ) );
+ assertTrue( table.has( 2L ) );
+ assertTrue( table.has( 4L ) );
+ assertTrue( table.has( 5L ) );
+ assertFalse( table.has( 3L ) );
+ assertFalse( table.has( 0L ) );
+ assertFalse( table.has( 999L ) );
// test the has( Object, Object ) method
- assertTrue( table.has( BigInteger.ONE, BigInteger.ONE ) );
- assertTrue( table.has( new BigInteger("2"), BigInteger.ONE ) );
- assertTrue( table.has( new BigInteger("4"), BigInteger.ONE ) );
- assertTrue( table.has( new BigInteger("5"), BigInteger.ONE ) );
- assertFalse( table.has( new BigInteger("5"), BigInteger.ZERO ) );
- assertFalse( table.has( new BigInteger("3"), BigInteger.ONE ) );
- assertFalse( table.has( BigInteger.ONE, new BigInteger("999") ) );
- assertFalse( table.has( new BigInteger( "999" ), BigInteger.ONE ) );
+ assertTrue( table.has( 1L, 1L ) );
+ assertTrue( table.has( 2L, 1L ) );
+ assertTrue( table.has( 4L, 1L ) );
+ assertTrue( table.has( 5L, 1L ) );
+ assertFalse( table.has( 5L, 0L ) );
+ assertFalse( table.has( 3L, 1L ) );
+ assertFalse( table.has( 1L, 999L ) );
+ assertFalse( table.has( 999L, 1L ) );
// test the has( Object, boolean ) method
- assertFalse( table.has( BigInteger.ZERO, false ) ); // we do not have a key less than or equal to 0
- assertTrue( table.has( BigInteger.ONE, false ) ); // we do have a key less than or equal to 1
- assertTrue( table.has( BigInteger.ZERO, true ) ); // we do have a key greater than or equal to 0
- assertTrue( table.has( BigInteger.ONE, true ) ); // we do have a key greater than or equal to 1
- assertTrue( table.has( new BigInteger( "5" ), true ) ); // we do have a key greater than or equal to 5
- assertFalse( table.has( new BigInteger( "6" ), true ) ); // we do NOT have a key greater than or equal to 11
- assertFalse( table.has( new BigInteger( "999" ), true ) ); // we do NOT have a key greater than or equal to 12
+ assertFalse( table.has( Long.valueOf(0), false ) ); // we do not have a key less than or equal to 0
+ assertTrue( table.has( Long.valueOf(1), false ) ); // we do have a key less than or equal to 1
+ assertTrue( table.has( Long.valueOf(0), true ) ); // we do have a key greater than or equal to 0
+ assertTrue( table.has( Long.valueOf(1), true ) ); // we do have a key greater than or equal to 1
+ assertTrue( table.has( Long.valueOf(5), true ) ); // we do have a key greater than or equal to 5
+ assertFalse( table.has( Long.valueOf(6), true ) ); // we do NOT have a key greater than or equal to 11
+ assertFalse( table.has( Long.valueOf(999), true ) ); // we do NOT have a key greater than or equal to 12
// test the has( Object, Object, boolean ) method
try
{
- table.has( BigInteger.ONE, BigInteger.ZERO, true );
+ table.has( 1L, 0L, true );
}
catch ( UnsupportedOperationException usoe )
{
@@ -192,13 +193,13 @@
assertEquals( 4, table.count() );
// test the count(Object) method
- assertEquals( 1, table.count( BigInteger.ONE ) );
- assertEquals( 0, table.count( BigInteger.ZERO ) );
- assertEquals( 1, table.count( new BigInteger( "2" ) ) );
+ assertEquals( 1, table.count( 1L ) );
+ assertEquals( 0, table.count( 0L ) );
+ assertEquals( 1, table.count( 2L ) );
// test the count( Object, boolean ) method
// note for speed this count method returns the same as count()
- assertEquals( table.count(), table.count( BigInteger.ONE, true ) );
+ assertEquals( table.count(), table.count( 1L, true ) );
}
@@ -209,11 +210,11 @@
*/
public void testGet() throws Exception
{
- assertEquals( BigInteger.ONE, table.get( BigInteger.ONE ) );
- assertEquals( BigInteger.ONE, table.get( new BigInteger( "2" ) ) );
- assertEquals( null, table.get( new BigInteger( "3" ) ) );
- assertEquals( BigInteger.ONE, table.get( new BigInteger( "4" ) ) );
- assertEquals( BigInteger.ONE, table.get( new BigInteger( "5" ) ) );
+ assertEquals( 1L, table.get( 1L ) );
+ assertEquals( 1L, table.get( 2L ) );
+ assertEquals( null, table.get( 3L ) );
+ assertEquals( 1L, table.get( 4L ) );
+ assertEquals( 1L, table.get( 5L ) );
}
@@ -240,23 +241,23 @@
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( BigInteger.ONE, tuple.getKey() );
- assertEquals( BigInteger.ONE, tuple.getValue() );
+ assertEquals( 1L, tuple.getKey() );
+ assertEquals( 1L, tuple.getValue() );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( new BigInteger( "2" ), tuple.getKey() );
- assertEquals( BigInteger.ONE, tuple.getValue() );
+ assertEquals( 2L, tuple.getKey() );
+ assertEquals( 1L, tuple.getValue() );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( new BigInteger( "4" ), tuple.getKey() );
- assertEquals( BigInteger.ONE, tuple.getValue() );
+ assertEquals( 4L, tuple.getKey() );
+ assertEquals( 1L, tuple.getValue() );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( new BigInteger( "5" ), tuple.getKey() );
- assertEquals( BigInteger.ONE, tuple.getValue() );
+ assertEquals( 5L, tuple.getKey() );
+ assertEquals( 1L, tuple.getValue() );
assertFalse( tuples.hasMore() );
@@ -264,69 +265,69 @@
// test the listTuples(Object) method
// -------------------------------------------------------------------
- tuples = table.listTuples( BigInteger.ZERO );
+ tuples = table.listTuples( 0L );
assertFalse( tuples.hasMore() );
- tuples = table.listTuples( new BigInteger( "2" ) );
+ tuples = table.listTuples( 2L );
assertTrue( tuples.hasMore() );
tuple = ( Tuple ) tuples.next();
- assertEquals( new BigInteger( "2" ), tuple.getKey() );
- assertEquals( BigInteger.ONE, tuple.getValue() );
+ assertEquals( 2L, tuple.getKey() );
+ assertEquals( 1L, tuple.getValue() );
assertFalse( tuples.hasMore() );
// -------------------------------------------------------------------
// test the listTuples(Object, boolean) method
// -------------------------------------------------------------------
- tuples = table.listTuples( BigInteger.ZERO, false );
+ tuples = table.listTuples( 0L, false );
assertFalse( tuples.hasMore() );
- tuples = table.listTuples( BigInteger.ONE, false );
+ tuples = table.listTuples( 1L, false );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( BigInteger.ONE, tuple.getKey() );
- assertEquals( new BigInteger( "1" ), tuple.getValue() );
+ assertEquals( 1L, tuple.getKey() );
+ assertEquals( 1L, tuple.getValue() );
assertFalse( tuples.hasMore() );
- tuples = table.listTuples( new BigInteger( "2" ), false );
+ tuples = table.listTuples( 2L, false );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( new BigInteger( "2" ), tuple.getKey() );
- assertEquals( BigInteger.ONE, tuple.getValue() );
+ assertEquals( 2L, tuple.getKey() );
+ assertEquals( 1L, tuple.getValue() );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( BigInteger.ONE, tuple.getKey() );
- assertEquals( BigInteger.ONE, tuple.getValue() );
+ assertEquals( 1L, tuple.getKey() );
+ assertEquals( 1L, tuple.getValue() );
assertFalse( tuples.hasMore() );
- tuples = table.listTuples( new BigInteger( "6" ), true );
+ tuples = table.listTuples( 6L, true );
assertFalse( tuples.hasMore() );
- tuples = table.listTuples( new BigInteger( "5" ), true );
+ tuples = table.listTuples( 5L, true );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( new BigInteger( "5" ), tuple.getKey() );
- assertEquals( BigInteger.ONE, tuple.getValue() );
+ assertEquals( 5L, tuple.getKey() );
+ assertEquals( 1L, tuple.getValue() );
assertFalse( tuples.hasMore() );
- tuples = table.listTuples( new BigInteger( "4" ), true );
+ tuples = table.listTuples( 4L, true );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( new BigInteger( "4" ), tuple.getKey() );
- assertEquals( BigInteger.ONE, tuple.getValue() );
+ assertEquals( 4L, tuple.getKey() );
+ assertEquals( 1L, tuple.getValue() );
assertTrue( tuples.hasMore() ) ;
tuple = ( Tuple ) tuples.next();
- assertEquals( new BigInteger( "5" ), tuple.getKey() );
- assertEquals( BigInteger.ONE, tuple.getValue() );
+ assertEquals( 5L, tuple.getKey() );
+ assertEquals( 1L, tuple.getValue() );
assertFalse( tuples.hasMore() );
// -------------------------------------------------------------------
@@ -335,7 +336,7 @@
try
{
- tuples = table.listTuples( BigInteger.ZERO, BigInteger.ZERO, true );
+ tuples = table.listTuples( 0L, 0L, true );
}
catch( UnsupportedOperationException e )
{
@@ -353,19 +354,19 @@
// test the listValues(Object) method
// -------------------------------------------------------------------
- NamingEnumeration values = table.listValues( BigInteger.ZERO );
+ NamingEnumeration values = table.listValues( 0L );
assertFalse( values.hasMore() );
- values = table.listValues( new BigInteger( "2" ) );
+ values = table.listValues( 2L );
assertTrue( values.hasMore() );
Object value = values.next();
- assertEquals( BigInteger.ONE, value );
+ assertEquals( 1L, value );
assertFalse( values.hasMore() );
- values = table.listValues( BigInteger.ONE );
+ values = table.listValues( 1L );
assertTrue( values.hasMore() ) ;
value = values.next();
- assertEquals( BigInteger.ONE, value );
+ assertEquals( 1L, value );
assertFalse( values.hasMore() );
}
@@ -383,15 +384,15 @@
// this instead tests the NamingEnumeration overload
NamingEnumeration values = new ArrayNE( new Object[] {
- new BigInteger( "3" ),
- new BigInteger( "4" ),
- new BigInteger( "5" ),
- new BigInteger( "6" ),
+ 3L,
+ 4L,
+ 5L,
+ 6L,
} );
try
{
- table.put( BigInteger.ONE, values );
+ table.put( 1L, values );
}
catch( UnsupportedOperationException e )
{
@@ -410,19 +411,19 @@
try
{
- table.remove( BigInteger.ZERO );
+ table.remove( 0L );
fail( "should not get here trying to remove non-existent key" );
}
catch ( IllegalArgumentException e )
{
}
- Object value = table.remove( new BigInteger( "2" ) );
- assertEquals( BigInteger.ONE, value );
+ Object value = table.remove( 2L );
+ assertEquals( 1L, value );
assertEquals( 3, table.count() );
- value = table.remove( BigInteger.ONE );
- assertEquals( BigInteger.ONE, value );
+ value = table.remove( 1L );
+ assertEquals( 1L, value );
assertEquals( 2, table.count() );
}
@@ -436,14 +437,14 @@
// tests the remove(Object) method
// -------------------------------------------------------------------
- Object value = table.remove( BigInteger.ZERO, BigInteger.ZERO );
+ Object value = table.remove( 0L, 0L );
assertNull( value );
- value = table.remove( new BigInteger( "2" ), BigInteger.ONE );
- assertEquals( BigInteger.ONE, value );
+ value = table.remove( 2L, 1L );
+ assertEquals( 1L, value );
assertEquals( 3, table.count() );
- value = table.remove( BigInteger.ONE, new BigInteger( "2" ) );
+ value = table.remove( 1L, 2L );
assertEquals( null, value );
assertEquals( 3, table.count() );
}
@@ -455,13 +456,13 @@
public void testRemoveObjectNamingEnumeration() throws Exception
{
NamingEnumeration values = new ArrayNE( new Object[] {
- new BigInteger( "1" ),
- new BigInteger( "2" )
+ 1L,
+ 2L
} );
try
{
- table.remove( BigInteger.ONE, values );
+ table.remove( 1L, values );
}
catch( UnsupportedOperationException e )
{
Modified: directory/apacheds/branches/apacheds-sasl-branch/core/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-sasl-branch/core/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java?view=diff&rev=541123&r1=541122&r2=541123
==============================================================================
--- directory/apacheds/branches/apacheds-sasl-branch/core/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java (original)
+++ directory/apacheds/branches/apacheds-sasl-branch/core/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java Wed May 23 17:26:40 2007
@@ -74,7 +74,7 @@
super.setUp();
// setup working directory
- File workingDirectory = new File( System.getProperty( "workingDirectory" ) );
+ File workingDirectory = new File( System.getProperty( "workingDirectory", System.getProperty( "user.dir" ) ) );
if ( ! workingDirectory.exists() )
{
workingDirectory.mkdirs();
Modified: directory/apacheds/branches/apacheds-sasl-branch/jdbm-store/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-sasl-branch/jdbm-store/pom.xml?view=diff&rev=541123&r1=541122&r2=541123
==============================================================================
--- directory/apacheds/branches/apacheds-sasl-branch/jdbm-store/pom.xml (original)
+++ directory/apacheds/branches/apacheds-sasl-branch/jdbm-store/pom.xml Wed May 23 17:26:40 2007
@@ -4,7 +4,7 @@
<parent>
<groupId>org.apache.directory.server</groupId>
<artifactId>build</artifactId>
- <version>1.5.0-SNAPSHOT</version>
+ <version>1.5.1-SNAPSHOT</version>
</parent>
<artifactId>apacheds-jdbm-store</artifactId>
<name>ApacheDS JDBM Store</name>
Modified: directory/apacheds/branches/apacheds-sasl-branch/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-sasl-branch/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java?view=diff&rev=541123&r1=541122&r2=541123
==============================================================================
--- directory/apacheds/branches/apacheds-sasl-branch/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java (original)
+++ directory/apacheds/branches/apacheds-sasl-branch/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java Wed May 23 17:26:40 2007
@@ -22,7 +22,6 @@
import java.io.File;
import java.io.IOException;
-import java.math.BigInteger;
import java.util.regex.Pattern;
import javax.naming.NamingEnumeration;
@@ -138,7 +137,14 @@
* primary keys. A value for an attribute can occur several times in
* different entries so the forward map can have more than one value.
*/
- forward = new JdbmTable( attribute.getName() + FORWARD_BTREE, true, numDupLimit, recMan, new IndexComparator( comp, true ) );
+ forward = new JdbmTable(
+ attribute.getName() + FORWARD_BTREE,
+ true,
+ numDupLimit,
+ recMan,
+ new IndexComparator( comp, true ),
+ null, null );
+ //LongSerializer.INSTANCE );
/*
* Now the reverse map stores the primary key into the master table as
@@ -146,8 +152,14 @@
* is single valued according to its specification based on a schema
* then duplicate keys should not be allowed within the reverse table.
*/
- reverse = new JdbmTable( attribute.getName() + REVERSE_BTREE, !attribute.isSingleValue(), numDupLimit, recMan,
- new IndexComparator( comp, false ) );
+ reverse = new JdbmTable(
+ attribute.getName() + REVERSE_BTREE,
+ !attribute.isSingleValue(),
+ numDupLimit,
+ recMan,
+ new IndexComparator( comp, false ),
+ null, //LongSerializer.INSTANCE,
+ null);
}
@@ -198,16 +210,16 @@
/**
* @see Index#forwardLookup(java.lang.Object)
*/
- public BigInteger forwardLookup( Object attrVal ) throws NamingException
+ public Long forwardLookup( Object attrVal ) throws NamingException
{
- return ( BigInteger ) forward.get( getNormalized( attrVal ) );
+ return ( Long ) forward.get( getNormalized( attrVal ) );
}
/**
* @see Index#reverseLookup(java.math.BigInteger)
*/
- public Object reverseLookup( BigInteger id ) throws NamingException
+ public Object reverseLookup( Object id ) throws NamingException
{
return reverse.get( id );
}
@@ -221,7 +233,7 @@
* @see org.apache.directory.server.core.partition.impl.btree.Index#add(java.lang.Object,
* java.math.BigInteger)
*/
- public synchronized void add( Object attrVal, BigInteger id ) throws NamingException
+ public synchronized void add( Object attrVal, Object id ) throws NamingException
{
forward.put( getNormalized( attrVal ), id );
reverse.put( id, getNormalized( attrVal ) );
@@ -232,7 +244,7 @@
* @see org.apache.directory.server.core.partition.impl.btree.Index#add(
* javax.naming.directory.Attribute, java.math.BigInteger)
*/
- public synchronized void add( Attribute attr, BigInteger id ) throws NamingException
+ public synchronized void add( Attribute attr, Object id ) throws NamingException
{
// Can efficiently batch add to the reverse table
NamingEnumeration values = attr.getAll();
@@ -251,7 +263,7 @@
* @see Index#add(
* javax.naming.directory.Attributes, java.math.BigInteger)
*/
- public synchronized void add( Attributes attrs, BigInteger id ) throws NamingException
+ public synchronized void add( Attributes attrs, Object id ) throws NamingException
{
add( AttributeUtils.getAttribute( attrs, attribute ), id );
}
@@ -261,7 +273,7 @@
* @see org.apache.directory.server.core.partition.impl.btree.Index#drop(java.lang.Object,
* java.math.BigInteger)
*/
- public synchronized void drop( Object attrVal, BigInteger id ) throws NamingException
+ public synchronized void drop( Object attrVal, Object id ) throws NamingException
{
forward.remove( getNormalized( attrVal ), id );
reverse.remove( id, getNormalized( attrVal ) );
@@ -271,7 +283,7 @@
/**
* @see Index#drop(java.math.BigInteger)
*/
- public void drop( BigInteger entryId ) throws NamingException
+ public void drop( Object entryId ) throws NamingException
{
NamingEnumeration values = reverse.listValues( entryId );
@@ -288,7 +300,7 @@
* @see Index#drop(
* javax.naming.directory.Attribute, java.math.BigInteger)
*/
- public void drop( Attribute attr, BigInteger id ) throws NamingException
+ public void drop( Attribute attr, Object id ) throws NamingException
{
// Can efficiently batch remove from the reverse table
NamingEnumeration values = attr.getAll();
@@ -315,7 +327,7 @@
* @see org.apache.directory.server.core.partition.impl.btree.Index#drop(
* javax.naming.directory.Attributes, java.math.BigInteger)
*/
- public void drop( Attributes attrs, BigInteger id ) throws NamingException
+ public void drop( Attributes attrs, Object id ) throws NamingException
{
drop( AttributeUtils.getAttribute( attrs, attribute ), id );
}
@@ -328,7 +340,7 @@
/**
* @see Index#listReverseIndices(BigInteger)
*/
- public IndexEnumeration listReverseIndices( BigInteger id ) throws NamingException
+ public IndexEnumeration listReverseIndices( Object id ) throws NamingException
{
return new IndexEnumeration( reverse.listTuples( id ), true );
}
@@ -389,7 +401,7 @@
* @see Index#hasValue(java.lang.Object,
* java.math.BigInteger)
*/
- public boolean hasValue( Object attrVal, BigInteger id ) throws NamingException
+ public boolean hasValue( Object attrVal, Object id ) throws NamingException
{
return forward.has( getNormalized( attrVal ), id );
}
@@ -399,7 +411,7 @@
* @see Index#hasValue(java.lang.Object,
* java.math.BigInteger, boolean)
*/
- public boolean hasValue( Object attrVal, BigInteger id, boolean isGreaterThan ) throws NamingException
+ public boolean hasValue( Object attrVal, Object id, boolean isGreaterThan ) throws NamingException
{
return forward.has( getNormalized( attrVal ), id, isGreaterThan );
}
@@ -409,7 +421,7 @@
* @see Index#hasValue(org.apache.regexp.RE,
* java.math.BigInteger)
*/
- public boolean hasValue( Pattern regex, BigInteger id ) throws NamingException
+ public boolean hasValue( Pattern regex, Object id ) throws NamingException
{
IndexEnumeration list = new IndexEnumeration( reverse.listTuples( id ), true, regex );
boolean hasValue = list.hasMore();
@@ -469,6 +481,11 @@
*/
public Object getNormalized( Object attrVal ) throws NamingException
{
+ if ( attrVal instanceof Long )
+ {
+ return attrVal;
+ }
+
Object normalized = keyCache.get( attrVal );
if ( null == normalized )
Modified: directory/apacheds/branches/apacheds-sasl-branch/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTable.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-sasl-branch/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTable.java?view=diff&rev=541123&r1=541122&r2=541123
==============================================================================
--- directory/apacheds/branches/apacheds-sasl-branch/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTable.java (original)
+++ directory/apacheds/branches/apacheds-sasl-branch/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTable.java Wed May 23 17:26:40 2007
@@ -20,17 +20,15 @@
package org.apache.directory.server.core.partition.impl.btree.jdbm;
-import java.math.BigInteger;
-
import javax.naming.NamingException;
import javax.naming.directory.Attributes;
import jdbm.RecordManager;
+import jdbm.helper.LongSerializer;
import jdbm.helper.StringComparator;
import org.apache.directory.server.core.partition.impl.btree.MasterTable;
import org.apache.directory.server.schema.SerializableComparator;
-import org.apache.directory.shared.ldap.util.BigIntegerComparator;
/**
@@ -42,7 +40,7 @@
public class JdbmMasterTable extends JdbmTable implements MasterTable
{
private static final StringComparator STRCOMP = new StringComparator();
- private static final SerializableComparator BIG_INTEGER_COMPARATOR = new SerializableComparator(
+ private static final SerializableComparator LONG_COMPARATOR = new SerializableComparator(
"1.3.6.1.4.1.18060.0.4.1.1.2" )
{
private static final long serialVersionUID = 4048791282048841016L;
@@ -50,7 +48,23 @@
public int compare( Object o1, Object o2 )
{
- return BigIntegerComparator.INSTANCE.compare( o1, o2 );
+ try
+ {
+ long thisVal = (Long)o1;
+ long anotherVal = (Long)o2;
+ return ( thisVal < anotherVal ? -1 : ( thisVal == anotherVal ? 0 : 1 ) );
+ }
+ catch ( NullPointerException npe )
+ {
+ if ( o1 == null )
+ {
+ throw new IllegalArgumentException( "Argument 'obj1' is null" );
+ }
+ else
+ {
+ throw new IllegalArgumentException( "Argument 'obj2' is null" );
+ }
+ }
}
};
private static final SerializableComparator STRING_COMPARATOR = new SerializableComparator(
@@ -76,13 +90,13 @@
*/
public JdbmMasterTable(RecordManager recMan) throws NamingException
{
- super( DBF, recMan, BIG_INTEGER_COMPARATOR );
- adminTbl = new JdbmTable( "admin", recMan, STRING_COMPARATOR );
+ super( DBF, recMan, LONG_COMPARATOR, LongSerializer.INSTANCE, new AttributesSerializer() );
+ adminTbl = new JdbmTable( "admin", recMan, STRING_COMPARATOR, null, null );
String seqValue = ( String ) adminTbl.get( SEQPROP_KEY );
if ( null == seqValue )
{
- adminTbl.put( SEQPROP_KEY, BigInteger.ZERO.toString() );
+ adminTbl.put( SEQPROP_KEY, "0" );
}
}
@@ -94,7 +108,7 @@
* @return the Attributes of the entry with operational attributes and all.
* @throws NamingException if there is a read error on the underlying Db.
*/
- public Attributes get( BigInteger id ) throws NamingException
+ public Attributes get( Object id ) throws NamingException
{
return ( Attributes ) super.get( id );
}
@@ -110,7 +124,7 @@
* @return the Attributes of the entry put
* @throws NamingException if there is a write error on the underlying Db.
*/
- public Attributes put( Attributes entry, BigInteger id ) throws NamingException
+ public Attributes put( Attributes entry, Object id ) throws NamingException
{
return ( Attributes ) super.put( id, entry );
}
@@ -123,7 +137,7 @@
* @return the Attributes of the deleted entry
* @throws NamingException if there is a write error on the underlying Db
*/
- public Attributes delete( BigInteger id ) throws NamingException
+ public Attributes delete( Object id ) throws NamingException
{
return ( Attributes ) super.remove( id );
}
@@ -137,18 +151,18 @@
* @throws NamingException if the admin table storing sequences cannot be
* read.
*/
- public BigInteger getCurrentId() throws NamingException
+ public Long getCurrentId() throws NamingException
{
- BigInteger id = null;
+ Long id = null;
synchronized ( adminTbl )
{
- id = new BigInteger( ( String ) adminTbl.get( SEQPROP_KEY ) );
+ id = new Long( ( String ) adminTbl.get( SEQPROP_KEY ) );
if ( null == id )
{
- adminTbl.put( SEQPROP_KEY, BigInteger.ZERO.toString() );
- id = BigInteger.ZERO;
+ adminTbl.put( SEQPROP_KEY, "0" );
+ id = 0L;
}
}
@@ -166,23 +180,23 @@
* @throws NamingException if the admin table storing sequences cannot be
* read and writen to.
*/
- public BigInteger getNextId() throws NamingException
+ public Long getNextId() throws NamingException
{
- BigInteger lastVal = null;
- BigInteger nextVal = null;
+ Long lastVal = null;
+ Long nextVal = null;
synchronized ( adminTbl )
{
- lastVal = new BigInteger( ( String ) adminTbl.get( SEQPROP_KEY ) );
+ lastVal = new Long( ( String ) adminTbl.get( SEQPROP_KEY ) );
if ( null == lastVal )
{
- adminTbl.put( SEQPROP_KEY, BigInteger.ONE.toString() );
- return BigInteger.ONE;
+ adminTbl.put( SEQPROP_KEY, "1" );
+ return 1L;
}
else
{
- nextVal = lastVal.add( BigInteger.ONE );
+ nextVal = lastVal + 1L;
adminTbl.put( SEQPROP_KEY, nextVal.toString() );
}
}