Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 34942 invoked from network); 7 Nov 2009 07:58:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 7 Nov 2009 07:58:56 -0000 Received: (qmail 44837 invoked by uid 500); 7 Nov 2009 07:58:55 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 44780 invoked by uid 500); 7 Nov 2009 07:58:55 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 44771 invoked by uid 99); 7 Nov 2009 07:58:55 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 07 Nov 2009 07:58:55 +0000 X-ASF-Spam-Status: No, hits=-3.8 required=5.0 tests=AWL,BAYES_00,SUBJECT_FUZZY_TION X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 07 Nov 2009 07:58:39 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 83D4D2388A04; Sat, 7 Nov 2009 07:57:54 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r833647 [11/17] - in /directory: apacheds/branches/apacheds-schema/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/ apacheds/branches/apacheds-schema/avl-partition/src/test/java/org/apache/directory/server/core/pa... Date: Sat, 07 Nov 2009 07:57:42 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20091107075754.83D4D2388A04@eris.apache.org> Modified: directory/apacheds/branches/apacheds-schema/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/DupsCursorTest.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/DupsCursorTest.java?rev=833647&r1=833646&r2=833647&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-schema/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/DupsCursorTest.java (original) +++ directory/apacheds/branches/apacheds-schema/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/DupsCursorTest.java Sat Nov 7 07:57:34 2009 @@ -19,30 +19,36 @@ package org.apache.directory.server.core.partition.impl.btree.jdbm; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.apache.directory.server.xdbm.Table; -import org.apache.directory.server.xdbm.Tuple; -import org.apache.directory.shared.ldap.cursor.Cursor; -import org.apache.directory.shared.ldap.cursor.InvalidCursorPositionException; -import org.apache.directory.shared.ldap.schema.registries.OidRegistry; -import org.apache.directory.shared.ldap.schema.comparators.SerializableComparator; -import org.junit.Before; -import org.junit.After; -import org.junit.Test; - import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.io.File; import jdbm.RecordManager; -import jdbm.helper.IntegerSerializer; +import jdbm.helper.DefaultSerializer; import jdbm.recman.BaseRecordManager; +import org.apache.directory.server.xdbm.Table; +import org.apache.directory.server.xdbm.Tuple; +import org.apache.directory.shared.ldap.constants.SchemaConstants; +import org.apache.directory.shared.ldap.cursor.Cursor; +import org.apache.directory.shared.ldap.cursor.InvalidCursorPositionException; +import org.apache.directory.shared.ldap.schema.SchemaManager; +import org.apache.directory.shared.ldap.schema.comparators.SerializableComparator; +import org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor; +import org.apache.directory.shared.ldap.util.ExceptionUtils; +import org.apache.directory.shared.schema.DefaultSchemaManager; +import org.apache.directory.shared.schema.loader.ldif.LdifSchemaLoader; +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * Tests the Cursor functionality of a JdbmTable when duplicate keys are @@ -57,15 +63,44 @@ private static final String TEST_OUTPUT_PATH = "test.output.path"; private static final int SIZE = 15; - transient Table table; + transient Table table; transient File dbFile; transient RecordManager recman; + private static SchemaManager schemaManager; + + + @BeforeClass + public static void init() throws Exception + { + String workingDirectory = System.getProperty( "workingDirectory" ); + if ( workingDirectory == null ) + { + String path = DupsContainerCursorTest.class.getResource( "" ).getPath(); + int targetPos = path.indexOf( "target" ); + workingDirectory = path.substring( 0, targetPos + 6 ); + } + + File schemaRepository = new File( workingDirectory, "schema" ); + SchemaLdifExtractor extractor = new SchemaLdifExtractor( new File( workingDirectory ) ); + extractor.extractOrCopy(); + LdifSchemaLoader loader = new LdifSchemaLoader( schemaRepository ); + schemaManager = new DefaultSchemaManager( loader ); + boolean loaded = schemaManager.loadAllEnabled(); + + if ( !loaded ) + { + fail( "Schema load failed : " + ExceptionUtils.printErrors( schemaManager.getErrors() ) ); + } + } + + @Before public void createTable() throws Exception { File tmpDir = null; + if ( System.getProperty( TEST_OUTPUT_PATH, null ) != null ) { tmpDir = new File( System.getProperty( TEST_OUTPUT_PATH ) ); @@ -74,15 +109,11 @@ dbFile = File.createTempFile( getClass().getSimpleName(), "db", tmpDir ); recman = new BaseRecordManager( dbFile.getAbsolutePath() ); - // gosh this is a terrible use of a global static variable - SerializableComparator.setRegistry( - new MockComparatorRegistry( - new OidRegistry() ) ); - - table = new JdbmTable( "test", SIZE, recman, - new SerializableComparator( "" ), - new SerializableComparator( "" ), - null, new IntegerSerializer() ); + SerializableComparator comparator = new SerializableComparator( SchemaConstants.INTEGER_ORDERING_MATCH_MR_OID ); + comparator.setSchemaManager( schemaManager ); + + table = new JdbmTable( schemaManager, "test", SIZE, recman, + comparator, comparator, null, new DefaultSerializer() ); LOG.debug( "Created new table and populated it with data" ); } @@ -108,7 +139,7 @@ @Test public void testEmptyTableOperations() throws Exception { - Cursor> cursor = table.cursor(); + Cursor> cursor = table.cursor(); assertFalse( cursor.next() ); cursor.afterLast(); @@ -126,19 +157,22 @@ public void testNextNoDups() throws Exception { // first try without duplicates at all - for ( int ii = 0; ii < SIZE-1; ii++ ) + for ( int i = 0; i < SIZE-1; i++ ) { - table.put( ii, ii ); + String istr = Integer.toString( i ); + table.put( istr, istr ); } - Cursor> cursor = table.cursor(); - int ii = 0; + Cursor> cursor = table.cursor(); + + int i = 0; + while ( cursor.next() ) { - Tuple tuple = cursor.get(); - assertEquals( ii, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); - ii++; + Tuple tuple = cursor.get(); + assertEquals( i, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); + i++; } } @@ -146,19 +180,22 @@ @Test public void testPreviousNoDups() throws Exception { - for ( int ii = 0; ii < SIZE-1; ii++ ) + for ( int i = 0; i < SIZE-1; i++ ) { - table.put( ii, ii ); + String istr = Integer.toString( i ); + table.put( istr, istr ); } - Cursor> cursor = table.cursor(); - int ii = SIZE-2; + Cursor> cursor = table.cursor(); + + int i = SIZE-2; + while ( cursor.previous() ) { - Tuple tuple = cursor.get(); - assertEquals( ii, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); - ii--; + Tuple tuple = cursor.get(); + assertEquals( i, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); + i--; } } @@ -166,34 +203,40 @@ @Test public void testNextDups() throws Exception { - for ( int ii = 0; ii < SIZE*3; ii++ ) + for ( int i = 0; i < SIZE*3; i++ ) { - if ( ii > 12 && ii < 17 + SIZE ) + String istr = Integer.toString( i ); + + if ( i > 12 && i < 17 + SIZE ) { - table.put( 13, ii ); + table.put( "13", istr ); } else { - table.put( ii, ii ); + table.put( istr, istr ); } } - Cursor> cursor = table.cursor(); + + Cursor> cursor = table.cursor(); - int ii = 0; + int i = 0; + while ( cursor.next() ) { - Tuple tuple = cursor.get(); - if ( ii > 12 && ii < 17 + SIZE ) + Tuple tuple = cursor.get(); + + if ( i > 12 && i < 17 + SIZE ) { - assertEquals( 13, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( 13, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } else { - assertEquals( ii, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( i, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } - ii++; + + i++; } } @@ -201,35 +244,42 @@ @Test public void testPreviousDups() throws Exception { - for ( int ii = 0; ii < SIZE*3; ii++ ) + for ( int i = 0; i < SIZE*3; i++ ) { - if ( ii > 12 && ii < 17 + SIZE ) + String istr = Integer.toString( i ); + + if ( i > 12 && i < 17 + SIZE ) { - table.put( 13, ii ); + table.put( "13", Integer.toString( i ) ); } else { - table.put( ii, ii ); + + table.put( istr, istr ); } } - Cursor> cursor = table.cursor(); + + Cursor> cursor = table.cursor(); cursor.afterLast(); - int ii = SIZE*3 - 1; + int i = SIZE*3 - 1; + while ( cursor.previous() ) { - Tuple tuple = cursor.get(); - if ( ii > 12 && ii < 17 + SIZE ) + Tuple tuple = cursor.get(); + + if ( i > 12 && i < 17 + SIZE ) { - assertEquals( 13, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( 13, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } else { - assertEquals( ii, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( i, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } - ii--; + + i--; } } @@ -237,112 +287,129 @@ @Test public void testFirstLastUnderDupLimit() throws Exception { - for ( int ii = 0; ii < SIZE*2 - 1; ii++ ) + for ( int i = 0; i < SIZE*2 - 1; i++ ) { - if ( ii > 12 && ii < 17 ) + String istr = Integer.toString( i ); + + if ( i > 12 && i < 17 ) { - table.put( 13, ii ); + table.put( "13", istr ); } else { - table.put( ii, ii ); + table.put( istr, istr ); } } - Cursor> cursor = table.cursor(); + + Cursor> cursor = table.cursor(); - int ii = 0; + int i = 0; + while ( cursor.next() ) { - Tuple tuple = cursor.get(); - if ( ii > 12 && ii < 17 ) + Tuple tuple = cursor.get(); + if ( i > 12 && i < 17 ) { - assertEquals( 13, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( 13, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } else { - assertEquals( ii, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( i, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } - ii++; + + i++; } cursor.first(); - ii = 0; + i = 0; + do { - Tuple tuple = cursor.get(); - if ( ii > 12 && ii < 17 ) + Tuple tuple = cursor.get(); + + if ( i > 12 && i < 17 ) { - assertEquals( 13, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( 13, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } else { - assertEquals( ii, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( i, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } - ii++; + + i++; } while ( cursor.next() ); // now go backwards cursor.afterLast(); - ii = SIZE*2-2; + i = SIZE*2-2; + while ( cursor.previous() ) { - Tuple tuple = cursor.get(); - if ( ii > 12 && ii < 17 ) + Tuple tuple = cursor.get(); + + if ( i > 12 && i < 17 ) { - assertEquals( 13, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( 13, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } else { - assertEquals( ii, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( i, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } - ii--; + + i--; } // now advance to last and go backwards again cursor.last(); - ii = SIZE*2-2; + i = SIZE*2-2; + do { - Tuple tuple = cursor.get(); - if ( ii > 12 && ii < 17 ) + Tuple tuple = cursor.get(); + + if ( i > 12 && i < 17 ) { - assertEquals( 13, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( 13, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } else { - assertEquals( ii, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( i, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } - ii--; + + i--; } while ( cursor.previous() ); // advance to first then last and go backwards again cursor.beforeFirst(); cursor.afterLast(); - ii = SIZE*2-2; + i = SIZE*2-2; + while ( cursor.previous() ) { - Tuple tuple = cursor.get(); - if ( ii > 12 && ii < 17 ) + Tuple tuple = cursor.get(); + + if ( i > 12 && i < 17 ) { - assertEquals( 13, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( 13, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } else { - assertEquals( ii, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( i, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } - ii--; + + i--; } } @@ -350,114 +417,131 @@ @Test public void testFirstLastOverDupLimit() throws Exception { - for ( int ii = 0; ii < SIZE*3-1; ii++ ) + for ( int i = 0; i < SIZE*3-1; i++ ) { - if ( ii < 2 + SIZE ) // keys with multiple values + String istr = Integer.toString( i ); + + if ( i < 2 + SIZE ) // keys with multiple values { - table.put( 0, ii ); + table.put( "0", istr ); } else // keys with single values { - table.put( ii, ii ); + table.put( istr, istr ); } } - Cursor> cursor = table.cursor(); + + Cursor> cursor = table.cursor(); - int ii = 0; + int i = 0; + while ( cursor.next() ) { - Tuple tuple = cursor.get(); - if ( ii < 2 + SIZE ) + Tuple tuple = cursor.get(); + + if ( i < 2 + SIZE ) { - assertEquals( 0, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( 0, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } else { - assertEquals( ii, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( i, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } - ii++; + + i++; } // now go back to first and traverse all over again cursor.first(); - ii = 0; + i = 0; + do { - Tuple tuple = cursor.get(); - if ( ii < 2 + SIZE ) + Tuple tuple = cursor.get(); + + if ( i < 2 + SIZE ) { - assertEquals( 0, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( 0, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } else { - assertEquals( ii, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( i, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } - ii++; + + i++; } while ( cursor.next() ); // now go backwards cursor.afterLast(); - ii = SIZE*3-2; + i = SIZE*3-2; + while ( cursor.previous() ) { - Tuple tuple = cursor.get(); + Tuple tuple = cursor.get(); - if ( ii < 2 + SIZE ) + if ( i < 2 + SIZE ) { - assertEquals( 0, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( 0, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } else { - assertEquals( ii, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( i, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } - ii--; + + i--; } // now advance to last and go backwards again cursor.last(); - ii = SIZE*3-2; + i = SIZE*3-2; + do { - Tuple tuple = cursor.get(); - if ( ii < 2 + SIZE ) + Tuple tuple = cursor.get(); + + if ( i < 2 + SIZE ) { - assertEquals( 0, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( 0, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } else { - assertEquals( ii, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( i, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } - ii--; + + i--; } while ( cursor.previous() ); // advance to first then last and go backwards again cursor.beforeFirst(); cursor.afterLast(); - ii = SIZE*3-2; + i = SIZE*3-2; + while ( cursor.previous() ) { - Tuple tuple = cursor.get(); - if ( ii < 2 + SIZE ) + Tuple tuple = cursor.get(); + + if ( i < 2 + SIZE ) { - assertEquals( 0, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( 0, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } else { - assertEquals( ii, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( i, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } - ii--; + + i--; } } @@ -465,231 +549,260 @@ @Test public void testFirstOverDupLimit() throws Exception { - for ( int ii = 0; ii < SIZE*3-1; ii++ ) + for ( int i = 0; i < SIZE*3-1; i++ ) { - if ( ii < 2 + SIZE ) // keys with multiple values + String istr = Integer.toString( i ); + + if ( i < 2 + SIZE ) // keys with multiple values { - table.put( 0, ii ); + table.put( "0", istr ); } else // keys with single values { - table.put( ii, ii ); + table.put( istr, istr ); } } - Cursor> cursor = table.cursor(); + + Cursor> cursor = table.cursor(); - int ii = 0; + int i = 0; + while ( cursor.next() ) { - Tuple tuple = cursor.get(); - if ( ii < 2 + SIZE ) + Tuple tuple = cursor.get(); + + if ( i < 2 + SIZE ) { - assertEquals( 0, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( 0, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } else { - assertEquals( ii, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( i, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } - ii++; + + i++; } // now go back to first and traverse all over again cursor.first(); - ii = 0; + i = 0; do { - Tuple tuple = cursor.get(); - if ( ii < 2 + SIZE ) + Tuple tuple = cursor.get(); + + if ( i < 2 + SIZE ) { - assertEquals( 0, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( 0, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } else { - assertEquals( ii, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( i, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } - ii++; + + i++; } while ( cursor.next() ); // now go backwards cursor.afterLast(); - ii = SIZE*3-2; + i = SIZE*3-2; + while ( cursor.previous() ) { - Tuple tuple = cursor.get(); + Tuple tuple = cursor.get(); - if ( ii < 2 + SIZE ) + if ( i < 2 + SIZE ) { - assertEquals( 0, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( 0, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } else { - assertEquals( ii, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( i, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } - ii--; + i--; } // now advance to last and go backwards again cursor.last(); - ii = SIZE*3-2; + i = SIZE*3-2; + do { - Tuple tuple = cursor.get(); - if ( ii < 2 + SIZE ) + Tuple tuple = cursor.get(); + if ( i < 2 + SIZE ) { - assertEquals( 0, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( 0, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } else { - assertEquals( ii, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( i, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } - ii--; + + i--; } while ( cursor.previous() ); // advance to first then last and go backwards again cursor.beforeFirst(); cursor.afterLast(); - ii = SIZE*3-2; + i = SIZE*3-2; + while ( cursor.previous() ) { - Tuple tuple = cursor.get(); - if ( ii < 2 + SIZE ) + Tuple tuple = cursor.get(); + + if ( i < 2 + SIZE ) { - assertEquals( 0, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( 0, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } else { - assertEquals( ii, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( i, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } - ii--; + + i--; } } - - @Test public void testLastOverDupLimit() throws Exception { - for ( int ii = 0; ii < SIZE*3-1; ii++ ) + for ( int i = 0; i < SIZE*3-1; i++ ) { - if ( ii > 2 + SIZE ) // keys with multiple values + String istr = Integer.toString( i ); + + if ( i > 2 + SIZE ) // keys with multiple values { - table.put( 3 + SIZE, ii ); + table.put( Integer.toString( 3 + SIZE ), istr ); } else // keys with single values { - table.put( ii, ii ); + table.put( istr, istr ); } } - Cursor> cursor = table.cursor(); + + Cursor> cursor = table.cursor(); - int ii = 0; + int i = 0; + while ( cursor.next() ) { - Tuple tuple = cursor.get(); - if ( ii > 2 + SIZE ) + Tuple tuple = cursor.get(); + + if ( i > 2 + SIZE ) { - assertEquals( 3 + SIZE, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( 3 + SIZE, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } else { - assertEquals( ii, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( i, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } - ii++; + + i++; } // now go back to first and traverse all over again cursor.first(); - ii = 0; + i = 0; + do { - Tuple tuple = cursor.get(); - if ( ii > 2 + SIZE ) + Tuple tuple = cursor.get(); + + if ( i > 2 + SIZE ) { - assertEquals( 3 + SIZE, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( 3 + SIZE, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } else { - assertEquals( ii, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( i, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } - ii++; + + i++; } while ( cursor.next() ); // now go backwards cursor.afterLast(); - ii = SIZE*3-2; + i = SIZE*3-2; + while ( cursor.previous() ) { - Tuple tuple = cursor.get(); + Tuple tuple = cursor.get(); - if ( ii > 2 + SIZE ) + if ( i > 2 + SIZE ) { - assertEquals( 3 + SIZE, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( 3 + SIZE, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } else { - assertEquals( ii, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( i, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } - ii--; + + i--; } // now advance to last and go backwards again cursor.last(); - ii = SIZE*3-2; + i = SIZE*3-2; + do { - Tuple tuple = cursor.get(); - if ( ii > 2 + SIZE ) + Tuple tuple = cursor.get(); + + if ( i > 2 + SIZE ) { - assertEquals( 3 + SIZE, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( 3 + SIZE, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } else { - assertEquals( ii, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( i, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } - ii--; + + i--; } while ( cursor.previous() ); // advance to first then last and go backwards again cursor.beforeFirst(); cursor.afterLast(); - ii = SIZE*3-2; + i = SIZE*3-2; + while ( cursor.previous() ) { - Tuple tuple = cursor.get(); - if ( ii > 2 + SIZE ) + Tuple tuple = cursor.get(); + + if ( i > 2 + SIZE ) { - assertEquals( 3 + SIZE, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( 3 + SIZE, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } else { - assertEquals( ii, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( i, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } - ii--; + + i--; } } @@ -697,11 +810,11 @@ @Test public void testOnEmptyTable() throws Exception { - Cursor> cursor = table.cursor(); + Cursor> cursor = table.cursor(); assertNotNull( cursor ); assertFalse( cursor.isClosed() ); - cursor.before( new Tuple( 1, 2 ) ); + cursor.before( new Tuple( "1", "2" ) ); assertFalse( cursor.available() ); } @@ -709,20 +822,22 @@ @Test public void testOverDupLimit() throws Exception { - table.put( 5, 5 ); - table.put( 6, 6 ); - for ( int ii = 0; ii < 20; ii++ ) + table.put( "5", "5" ); + table.put( "6", "6" ); + + for ( int i = 0; i < 20; i++ ) { - table.put( 7, ii ); + table.put( "7", Integer.toString( i ) ); } - table.put( 8, 8 ); - table.put( 9, 9 ); - Cursor> cursor = table.cursor(); + table.put( "8", "8" ); + table.put( "9", "9" ); + + Cursor> cursor = table.cursor(); assertNotNull( cursor ); assertFalse( cursor.isClosed() ); - cursor.before( new Tuple( 7, 2 ) ); + cursor.before( new Tuple( "7", "2" ) ); assertFalse( cursor.available() ); } @@ -730,20 +845,22 @@ @Test public void testUnderDupLimit() throws Exception { - table.put( 5, 5 ); - table.put( 6, 6 ); - for ( int ii = 0; ii < 10; ii++ ) + table.put( "5", "5" ); + table.put( "6", "6" ); + + for ( int i = 0; i < 10; i++ ) { - table.put( 7, ii ); + table.put( "7", Integer.toString( i ) ); } - table.put( 8, 8 ); - table.put( 9, 9 ); - Cursor> cursor = table.cursor(); + table.put( "8", "8" ); + table.put( "9", "9" ); + + Cursor> cursor = table.cursor(); assertNotNull( cursor ); assertFalse( cursor.isClosed() ); - cursor.before( new Tuple( 7, 2 ) ); + cursor.before( new Tuple( "7", "2" ) ); assertFalse( cursor.available() ); } @@ -751,261 +868,279 @@ @Test public void testBeforeAfterBelowDupLimit() throws Exception { - for ( int ii = 0; ii < SIZE*2 - 1; ii++ ) + for ( int i = 0; i < SIZE*2 - 1; i++ ) { - if ( ii > 12 && ii < 17 ) // keys with multiple values + String istr = Integer.toString( i ); + + if ( i > 12 && i < 17 ) // keys with multiple values { - table.put( 13, ii ); + table.put( "13", Integer.toString( i ) ); } - else if ( ii > 17 && ii < 21 ) // adds hole with no keys for ii + else if ( i > 17 && i < 21 ) // adds hole with no keys for i { } else // keys with single values { - table.put( ii, ii ); + table.put( istr, istr ); } } // test before to advance just before a key with a single value - int ii = 5; - Cursor> cursor = table.cursor(); - cursor.before( new Tuple( 5, 5 ) ); + int i = 5; + Cursor> cursor = table.cursor(); + cursor.before( new Tuple( "5", "5" ) ); + while ( cursor.next() ) { - if ( ii > 17 && ii < 21 ) + if ( i > 17 && i < 21 ) { - assertFalse( table.has( ii ) ); + assertFalse( table.has( Integer.toString( i ) ) ); continue; } - Tuple tuple = cursor.get(); - if ( ii > 12 && ii < 17 ) + Tuple tuple = cursor.get(); + + if ( i > 12 && i < 17 ) { - assertEquals( 13, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( 13, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } else { - assertEquals( ii, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( i, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } - ii++; + + i++; } // test before to advance just before a key with a single value but // with a null tuple value which should not advance the dupsCursor - ii = 5; + i = 5; cursor = table.cursor(); - cursor.before( new Tuple( 5, null ) ); + cursor.before( new Tuple( "5", null ) ); + while ( cursor.next() ) { - if ( ii > 17 && ii < 21 ) + if ( i > 17 && i < 21 ) { - assertFalse( table.has( ii ) ); + assertFalse( table.has( Integer.toString( i ) ) ); continue; } - Tuple tuple = cursor.get(); - if ( ii > 12 && ii < 17 ) + Tuple tuple = cursor.get(); + if ( i > 12 && i < 17 ) { - assertEquals( 13, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( 13, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } else { - assertEquals( ii, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( i, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } - ii++; + i++; } // test before to advance just before a key value pair where the key // does not exist - using value so we hit check for key equality - ii = 21; + i = 21; cursor = table.cursor(); - cursor.before( new Tuple( 18, 18 ) ); + cursor.before( new Tuple( "18", "18" ) ); + while ( cursor.next() ) { - if ( ii > 17 && ii < 21 ) + if ( i > 17 && i < 21 ) { - assertFalse( table.has( ii ) ); + assertFalse( table.has( Integer.toString( i ) ) ); continue; } - Tuple tuple = cursor.get(); - if ( ii > 12 && ii < 17 ) + Tuple tuple = cursor.get(); + + if ( i > 12 && i < 17 ) { - assertEquals( 13, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( 13, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } else { - assertEquals( ii, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( i, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } - ii++; + + i++; } // test after to advance just after the end cursor = table.cursor(); - cursor.after( new Tuple( 111, null ) ); + cursor.after( new Tuple( "111", null ) ); assertFalse( cursor.next() ); // test after to advance just before a key with a single value - ii = 6; + i = 6; cursor = table.cursor(); - cursor.after( new Tuple( 5, null ) ); + cursor.after( new Tuple( "5", null ) ); + while ( cursor.next() ) { - if ( ii > 17 && ii < 21 ) + if ( i > 17 && i < 21 ) { - assertFalse( table.has( ii ) ); + assertFalse( table.has( Integer.toString( i ) ) ); continue; } - Tuple tuple = cursor.get(); - if ( ii > 12 && ii < 17 ) + Tuple tuple = cursor.get(); + + if ( i > 12 && i < 17 ) { - assertEquals( 13, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( 13, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } else { - assertEquals( ii, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( i, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } - ii++; + + i++; } // test before to advance just before a key & value with multiple // values for the key - we should advance just before the value cursor = table.cursor(); - cursor.before( new Tuple( 13, 14 ) ); + cursor.before( new Tuple( "13", "14" ) ); cursor.next(); - Tuple tuple = cursor.get(); - assertEquals( 13, ( int ) tuple.getKey() ); - assertEquals( 14, ( int ) tuple.getValue() ); - ii = 15; + Tuple tuple = cursor.get(); + assertEquals( 13, Integer.parseInt( tuple.getKey() ) ); + assertEquals( 14, Integer.parseInt( tuple.getValue() ) ); + i = 15; while ( cursor.next() ) { - if ( ii > 17 && ii < 21 ) + if ( i > 17 && i < 21 ) { - assertFalse( table.has( ii ) ); + assertFalse( table.has( Integer.toString( i ) ) ); continue; } tuple = cursor.get(); - if ( ii > 12 && ii < 17 ) + if ( i > 12 && i < 17 ) { - assertEquals( 13, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( 13, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } else { - assertEquals( ii, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( i, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } - ii++; + i++; } // test after to advance just before a key & value with multiple // values for the key - we should advance just before the value cursor = table.cursor(); - cursor.after( new Tuple( 13, 14 ) ); + cursor.after( new Tuple( "13", "14" ) ); cursor.next(); tuple = cursor.get(); - assertEquals( 13, ( int ) tuple.getKey() ); - assertEquals( 15, ( int ) tuple.getValue() ); - ii=16; + assertEquals( 13, Integer.parseInt( tuple.getKey() ) ); + assertEquals( 15, Integer.parseInt( tuple.getValue() ) ); + i=16; while ( cursor.next() ) { - if ( ii > 17 && ii < 21 ) + if ( i > 17 && i < 21 ) { - assertFalse( table.has( ii ) ); + assertFalse( table.has( Integer.toString( i ) ) ); continue; } tuple = cursor.get(); - if ( ii > 12 && ii < 17 ) + + if ( i > 12 && i < 17 ) { - assertEquals( 13, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( 13, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } else { - assertEquals( ii, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( i, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } - ii++; + + i++; } // test after to advance just before a key that does not exist cursor = table.cursor(); - cursor.after( new Tuple( 18, null ) ); + cursor.after( new Tuple( "18", null ) ); cursor.next(); tuple = cursor.get(); - assertEquals( 21, ( int ) tuple.getKey() ); - assertEquals( 21, ( int ) tuple.getValue() ); - ii=22; + assertEquals( 21, Integer.parseInt( tuple.getKey() ) ); + assertEquals( 21, Integer.parseInt( tuple.getValue() ) ); + i=22; while ( cursor.next() ) { - if ( ii > 17 && ii < 21 ) + if ( i > 17 && i < 21 ) { - assertFalse( table.has( ii ) ); + assertFalse( table.has( Integer.toString( i ) ) ); continue; } tuple = cursor.get(); - if ( ii > 12 && ii < 17 ) + + if ( i > 12 && i < 17 ) { - assertEquals( 13, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( 13, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } else { - assertEquals( ii, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( i, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } - ii++; + + i++; } // test after to advance just before a key and value where the key // does not exist - used to force key comparison in after() cursor = table.cursor(); - cursor.after( new Tuple( 18, 18 ) ); + cursor.after( new Tuple( "18", "18" ) ); cursor.next(); tuple = cursor.get(); - assertEquals( 21, ( int ) tuple.getKey() ); - assertEquals( 21, ( int ) tuple.getValue() ); - ii=22; + assertEquals( 21, Integer.parseInt( tuple.getKey() ) ); + assertEquals( 21, Integer.parseInt( tuple.getValue() ) ); + i=22; while ( cursor.next() ) { - if ( ii > 17 && ii < 21 ) + if ( i > 17 && i < 21 ) { - assertFalse( table.has( ii ) ); + assertFalse( table.has( Integer.toString( i ) ) ); continue; } tuple = cursor.get(); - if ( ii > 12 && ii < 17 ) + + if ( i > 12 && i < 17 ) { - assertEquals( 13, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( 13, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } else { - assertEquals( ii, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( i, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } - ii++; + + i++; } } @@ -1013,261 +1148,282 @@ @Test public void testBeforeAfterOverDupLimit() throws Exception { - for ( int ii = 0; ii < SIZE*3 - 1; ii++ ) + for ( int i = 0; i < SIZE*3 - 1; i++ ) { - if ( ii > 12 && ii < 17 + SIZE ) // keys with multiple values + String istr = Integer.toString( i ); + + if ( i > 12 && i < 17 + SIZE ) // keys with multiple values { - table.put( 13, ii ); + table.put( "13", Integer.toString( i ) ); } - else if ( ii > 17 + SIZE && ii < 21 + SIZE ) // adds hole with no keys for ii + else if ( i > 17 + SIZE && i < 21 + SIZE ) // adds hole with no keys for i { } else // keys with single values { - table.put( ii, ii ); + table.put( istr, istr ); } } // test before to advance just before a key with a single value - int ii = 5; - Cursor> cursor = table.cursor(); - cursor.before( new Tuple( 5, 5 ) ); + int i = 5; + Cursor> cursor = table.cursor(); + cursor.before( new Tuple( "5", "5" ) ); + while ( cursor.next() ) { - if ( ii > 17 + SIZE && ii < 21 + SIZE ) + if ( i > 17 + SIZE && i < 21 + SIZE ) { - assertFalse( table.has( ii ) ); + assertFalse( table.has( Integer.toString( i ) ) ); continue; } - Tuple tuple = cursor.get(); - if ( ii > 12 && ii < 17 + SIZE ) + Tuple tuple = cursor.get(); + + if ( i > 12 && i < 17 + SIZE ) { - assertEquals( 13, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( 13, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } else { - assertEquals( ii, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( i, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } - ii++; + + i++; } // test before to advance just before a key with a single value but // with a null tuple value which should not advance the dupsCursor - ii = 5; + i = 5; cursor = table.cursor(); - cursor.before( new Tuple( 5, null ) ); + cursor.before( new Tuple( "5", null ) ); + while ( cursor.next() ) { - if ( ii > 17 + SIZE && ii < 21 + SIZE ) + if ( i > 17 + SIZE && i < 21 + SIZE ) { - assertFalse( table.has( ii ) ); + assertFalse( table.has( Integer.toString( i ) ) ); continue; } - Tuple tuple = cursor.get(); - if ( ii > 12 && ii < 17 + SIZE ) + Tuple tuple = cursor.get(); + + if ( i > 12 && i < 17 + SIZE ) { - assertEquals( 13, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( 13, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } else { - assertEquals( ii, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( i, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } - ii++; + i++; } // test before to advance just before a key value pair where the key // does not exist - using value so we hit check for key equality - ii = 21 + SIZE; + i = 21 + SIZE; cursor = table.cursor(); - cursor.before( new Tuple( 18 + SIZE, 18 + SIZE ) ); + String istr = Integer.toString( 18 + SIZE ); + + cursor.before( new Tuple( istr, istr ) ); + while ( cursor.next() ) { - if ( ii > 17 + SIZE && ii < 21 + SIZE ) + if ( i > 17 + SIZE && i < 21 + SIZE ) { - assertFalse( table.has( ii ) ); + assertFalse( table.has( Integer.toString( i ) ) ); continue; } - Tuple tuple = cursor.get(); - if ( ii > 12 && ii < 17 + SIZE ) + Tuple tuple = cursor.get(); + + if ( i > 12 && i < 17 + SIZE ) { - assertEquals( 13, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( 13, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } else { - assertEquals( ii, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( i, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } - ii++; + + i++; } // test after to advance just after the end cursor = table.cursor(); - cursor.after( new Tuple( 111, null ) ); + cursor.after( new Tuple( "111", null ) ); assertFalse( cursor.next() ); // test after to advance just before a key with a single value - ii = 6; + i = 6; cursor = table.cursor(); - cursor.after( new Tuple( 5, null ) ); + cursor.after( new Tuple( "5", null ) ); + while ( cursor.next() ) { - if ( ii > 17 + SIZE && ii < 21 + SIZE ) + if ( i > 17 + SIZE && i < 21 + SIZE ) { - assertFalse( table.has( ii ) ); + assertFalse( table.has( Integer.toString( i ) ) ); continue; } - Tuple tuple = cursor.get(); - if ( ii > 12 && ii < 17 + SIZE ) + Tuple tuple = cursor.get(); + + if ( i > 12 && i < 17 + SIZE ) { - assertEquals( 13, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( 13, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } else { - assertEquals( ii, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( i, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } - ii++; + + i++; } // test before to advance just before a key & value with multiple // values for the key - we should advance just before the value cursor = table.cursor(); - cursor.before( new Tuple( 13, 14 ) ); + cursor.before( new Tuple( "13", "14" ) ); cursor.next(); - Tuple tuple = cursor.get(); - assertEquals( 13, ( int ) tuple.getKey() ); - assertEquals( 14, ( int ) tuple.getValue() ); - ii = 15; + Tuple tuple = cursor.get(); + assertEquals( 13, Integer.parseInt( tuple.getKey() ) ); + assertEquals( 14, Integer.parseInt( tuple.getValue() ) ); + i = 15; while ( cursor.next() ) { - if ( ii > 17 + SIZE && ii < 21 + SIZE ) + if ( i > 17 + SIZE && i < 21 + SIZE ) { - assertFalse( table.has( ii ) ); + assertFalse( table.has( Integer.toString( i ) ) ); continue; } tuple = cursor.get(); - if ( ii > 12 && ii < 17 + SIZE ) + + if ( i > 12 && i < 17 + SIZE ) { - assertEquals( 13, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( 13, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } else { - assertEquals( ii, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( i, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } - ii++; + + i++; } // test after to advance just before a key & value with multiple // values for the key - we should advance just before the value cursor = table.cursor(); - cursor.after( new Tuple( 13, 14 ) ); + cursor.after( new Tuple( "13", "14" ) ); cursor.next(); tuple = cursor.get(); - assertEquals( 13, ( int ) tuple.getKey() ); - assertEquals( 15, ( int ) tuple.getValue() ); - ii=16; + assertEquals( 13, Integer.parseInt( tuple.getKey() ) ); + assertEquals( 15, Integer.parseInt( tuple.getValue() ) ); + i=16; while ( cursor.next() ) { - if ( ii > 17 + SIZE && ii < 21 + SIZE ) + if ( i > 17 + SIZE && i < 21 + SIZE ) { - assertFalse( table.has( ii ) ); + assertFalse( table.has( Integer.toString( i ) ) ); continue; } tuple = cursor.get(); - if ( ii > 12 && ii < 17 + SIZE ) + + if ( i > 12 && i < 17 + SIZE ) { - assertEquals( 13, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( 13, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } else { - assertEquals( ii, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( i, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } - ii++; + + i++; } // test after to advance just before a key that does not exist cursor = table.cursor(); - cursor.after( new Tuple( 18 + SIZE, null ) ); + cursor.after( new Tuple( Integer.toString( 18 + SIZE ), null ) ); cursor.next(); tuple = cursor.get(); - assertEquals( 21 + SIZE, ( int ) tuple.getKey() ); - assertEquals( 21 + SIZE, ( int ) tuple.getValue() ); - ii=22 + SIZE; + assertEquals( 21 + SIZE, Integer.parseInt( tuple.getKey() ) ); + assertEquals( 21 + SIZE, Integer.parseInt( tuple.getValue() ) ); + i=22 + SIZE; while ( cursor.next() ) { - if ( ii > 17 + SIZE && ii < 21 + SIZE ) + if ( i > 17 + SIZE && i < 21 + SIZE ) { - assertFalse( table.has( ii ) ); + assertFalse( table.has( Integer.toString( i ) ) ); continue; } tuple = cursor.get(); - if ( ii > 12 && ii < 17 + SIZE ) + if ( i > 12 && i < 17 + SIZE ) { - assertEquals( 13, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( 13, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } else { - assertEquals( ii, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( i, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } - ii++; + i++; } // test after to advance just before a key and value where the key // does not exist - used to force key comparison in after() cursor = table.cursor(); - cursor.after( new Tuple( 18 + SIZE , 18 + SIZE ) ); + cursor.after( new Tuple( istr, istr ) ); cursor.next(); tuple = cursor.get(); - assertEquals( 21 + SIZE, ( int ) tuple.getKey() ); - assertEquals( 21 + SIZE, ( int ) tuple.getValue() ); - ii=22+ SIZE; + assertEquals( 21 + SIZE, Integer.parseInt( tuple.getKey() ) ); + assertEquals( 21 + SIZE, Integer.parseInt( tuple.getValue() ) ); + i=22+ SIZE; while ( cursor.next() ) { - if ( ii > 17 + SIZE && ii < 21 + SIZE ) + if ( i > 17 + SIZE && i < 21 + SIZE ) { - assertFalse( table.has( ii ) ); + assertFalse( table.has( Integer.toString( i ) ) ); continue; } tuple = cursor.get(); - if ( ii > 12 && ii < 17 + SIZE ) + + if ( i > 12 && i < 17 + SIZE ) { - assertEquals( 13, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( 13, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } else { - assertEquals( ii, ( int ) tuple.getKey() ); - assertEquals( ii, ( int ) tuple.getValue() ); + assertEquals( i, Integer.parseInt( tuple.getKey() ) ); + assertEquals( i, Integer.parseInt( tuple.getValue() ) ); } - ii++; + + i++; } } @@ -1275,7 +1431,7 @@ @Test public void testMiscellaneous() throws Exception { - Cursor> cursor = table.cursor(); + Cursor> cursor = table.cursor(); assertNotNull( cursor ); assertTrue( cursor.isElementReused() ); Modified: directory/apacheds/branches/apacheds-schema/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndexTest.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndexTest.java?rev=833647&r1=833646&r2=833647&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-schema/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndexTest.java (original) +++ directory/apacheds/branches/apacheds-schema/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndexTest.java Sat Nov 7 07:57:34 2009 @@ -37,9 +37,7 @@ import org.apache.directory.shared.ldap.cursor.Cursor; import org.apache.directory.shared.ldap.schema.AttributeType; import org.apache.directory.shared.ldap.schema.SchemaManager; -import org.apache.directory.shared.ldap.schema.comparators.SerializableComparator; import org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor; -import org.apache.directory.shared.ldap.schema.registries.AttributeTypeRegistry; import org.apache.directory.shared.ldap.util.ExceptionUtils; import org.apache.directory.shared.schema.DefaultSchemaManager; import org.apache.directory.shared.schema.loader.ldif.LdifSchemaLoader; @@ -57,9 +55,9 @@ */ public class JdbmIndexTest { - private static AttributeTypeRegistry registry; private static File dbFileDir; Index idx; + private static SchemaManager schemaManager; @BeforeClass @@ -78,18 +76,14 @@ SchemaLdifExtractor extractor = new SchemaLdifExtractor( new File( workingDirectory ) ); extractor.extractOrCopy(); LdifSchemaLoader loader = new LdifSchemaLoader( schemaRepository ); - SchemaManager sm = new DefaultSchemaManager( loader ); + schemaManager = new DefaultSchemaManager( loader ); - boolean loaded = sm.loadAllEnabled(); + boolean loaded = schemaManager.loadAllEnabled(); if ( !loaded ) { - fail( "Schema load failed : " + ExceptionUtils.printErrors( sm.getErrors() ) ); + fail( "Schema load failed : " + ExceptionUtils.printErrors( schemaManager.getErrors() ) ); } - - SerializableComparator.setRegistry( sm.getRegistries().getComparatorRegistry() ); - - registry = sm.getRegistries().getAttributeTypeRegistry(); } @@ -151,7 +145,7 @@ jdbmIdx = new JdbmIndex(); } - jdbmIdx.init( registry.lookup( SchemaConstants.OU_AT ), dbFileDir ); + jdbmIdx.init( schemaManager, schemaManager.lookupAttributeTypeRegistry( SchemaConstants.OU_AT ), dbFileDir ); this.idx = jdbmIdx; } @@ -273,7 +267,7 @@ assertNull( jdbmIndex.getAttribute() ); initIndex(); - assertEquals( registry.lookup( "ou" ), idx.getAttribute() ); + assertEquals( schemaManager.lookupAttributeTypeRegistry( "ou" ), idx.getAttribute() ); } @@ -574,7 +568,7 @@ { AttributeType noEqMatchAttribute = new AttributeType( "1.1" ); - jdbmIndex.init( noEqMatchAttribute, dbFileDir ); + jdbmIndex.init( schemaManager, noEqMatchAttribute, dbFileDir ); fail( "should not get here" ); } catch( IOException e ) @@ -592,7 +586,7 @@ public void testSingleValuedAttribute() throws Exception { JdbmIndex jdbmIndex = new JdbmIndex(); - jdbmIndex.init( registry.lookup( SchemaConstants.CREATORS_NAME_AT ), dbFileDir ); + jdbmIndex.init( schemaManager, schemaManager.lookupAttributeTypeRegistry( SchemaConstants.CREATORS_NAME_AT ), dbFileDir ); jdbmIndex.close(); } } Modified: directory/apacheds/branches/apacheds-schema/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTableTest.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTableTest.java?rev=833647&r1=833646&r2=833647&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-schema/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTableTest.java (original) +++ directory/apacheds/branches/apacheds-schema/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTableTest.java Sat Nov 7 07:57:34 2009 @@ -31,8 +31,6 @@ import org.apache.directory.shared.ldap.schema.SchemaManager; import org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor; -import org.apache.directory.shared.ldap.schema.registries.AttributeTypeRegistry; -import org.apache.directory.shared.ldap.schema.registries.Registries; import org.apache.directory.shared.ldap.util.ExceptionUtils; import org.apache.directory.shared.schema.DefaultSchemaManager; import org.apache.directory.shared.schema.loader.ldif.LdifSchemaLoader; @@ -57,8 +55,7 @@ transient JdbmMasterTable table; transient File dbFile; transient RecordManager recman; - transient Registries registries = null; - transient AttributeTypeRegistry attributeRegistry; + transient SchemaManager schemaManager = null; public JdbmMasterTableTest() throws Exception @@ -76,18 +73,15 @@ SchemaLdifExtractor extractor = new SchemaLdifExtractor( new File( workingDirectory ) ); extractor.extractOrCopy(); LdifSchemaLoader loader = new LdifSchemaLoader( schemaRepository ); - Registries registries = new Registries(); - SchemaManager sm = new DefaultSchemaManager( loader ); + schemaManager = new DefaultSchemaManager( loader ); - boolean loaded = sm.loadAllEnabled(); + boolean loaded = schemaManager.loadAllEnabled(); if ( !loaded ) { - fail( "Schema load failed : " + ExceptionUtils.printErrors( sm.getErrors() ) ); + fail( "Schema load failed : " + ExceptionUtils.printErrors( schemaManager.getErrors() ) ); } - - attributeRegistry = sm.getRegistries().getAttributeTypeRegistry(); } @@ -104,10 +98,10 @@ dbFile = File.createTempFile( getClass().getSimpleName(), "db", tmpDir ); recman = new BaseRecordManager( dbFile.getAbsolutePath() ); - table = new JdbmMasterTable( recman, registries ); + table = new JdbmMasterTable( recman, schemaManager ); LOG.debug( "Created new table and populated it with data" ); - JdbmMasterTable t2 = new JdbmMasterTable( recman, registries ); + JdbmMasterTable t2 = new JdbmMasterTable( recman, schemaManager ); t2.close(); } Modified: directory/apacheds/branches/apacheds-schema/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java?rev=833647&r1=833646&r2=833647&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-schema/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java (original) +++ directory/apacheds/branches/apacheds-schema/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java Sat Nov 7 07:57:34 2009 @@ -62,10 +62,7 @@ import org.apache.directory.shared.ldap.schema.AttributeType; import org.apache.directory.shared.ldap.schema.SchemaManager; import org.apache.directory.shared.ldap.schema.SchemaUtils; -import org.apache.directory.shared.ldap.schema.comparators.SerializableComparator; import org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor; -import org.apache.directory.shared.ldap.schema.registries.AttributeTypeRegistry; -import org.apache.directory.shared.ldap.schema.registries.Registries; import org.apache.directory.shared.ldap.util.ExceptionUtils; import org.apache.directory.shared.schema.DefaultSchemaManager; import org.apache.directory.shared.schema.loader.ldif.LdifSchemaLoader; @@ -90,8 +87,7 @@ File wkdir; JdbmStore store; - private static Registries registries = null; - private static AttributeTypeRegistry attributeRegistry; + private static SchemaManager schemaManager = null; private static LdifSchemaLoader loader; @@ -111,18 +107,14 @@ SchemaLdifExtractor extractor = new SchemaLdifExtractor( new File( workingDirectory ) ); extractor.extractOrCopy(); loader = new LdifSchemaLoader( schemaRepository ); - SchemaManager sm = new DefaultSchemaManager( loader ); + schemaManager = new DefaultSchemaManager( loader ); - boolean loaded = sm.loadAllEnabled(); + boolean loaded = schemaManager.loadAllEnabled(); if ( !loaded ) { - fail( "Schema load failed : " + ExceptionUtils.printErrors( sm.getErrors() ) ); + fail( "Schema load failed : " + ExceptionUtils.printErrors( schemaManager.getErrors() ) ); } - - registries = sm.getRegistries(); - attributeRegistry = registries.getAttributeTypeRegistry(); - SerializableComparator.setRegistry( registries.getComparatorRegistry() ); } @@ -143,10 +135,10 @@ store.setCacheSize( 10 ); store.setWorkingDirectory( wkdir ); store.setSyncOnWrite( false ); - store.addIndex( new JdbmIndex( SchemaConstants.OU_AT_OID ) ); store.addIndex( new JdbmIndex( SchemaConstants.UID_AT_OID ) ); - StoreUtils.loadExampleData( store, registries ); + + StoreUtils.loadExampleData( store, schemaManager ); LOG.debug( "Created new store" ); } @@ -347,7 +339,7 @@ public void testFreshStore() throws Exception { LdapDN dn = new LdapDN( "o=Good Times Co." ); - dn.normalize( attributeRegistry.getNormalizerMapping() ); + dn.normalize( schemaManager.getNormalizerMapping() ); assertEquals( 1L, ( long ) store.getEntryId( dn.toNormName() ) ); assertEquals( 11, store.count() ); assertEquals( "o=Good Times Co.", store.getEntryUpdn( dn.toNormName() ) ); @@ -382,8 +374,8 @@ // add an alias and delete to test dropAliasIndices method LdapDN dn = new LdapDN( "commonName=Jack Daniels,ou=Apache,ou=Board of Directors,o=Good Times Co." ); - dn.normalize( attributeRegistry.getNormalizerMapping() ); - DefaultServerEntry entry = new DefaultServerEntry( registries, dn ); + dn.normalize( schemaManager.getNormalizerMapping() ); + DefaultServerEntry entry = new DefaultServerEntry( schemaManager, dn ); entry.add( "objectClass", "top", "alias", "extensibleObject" ); entry.add( "ou", "Apache" ); entry.add( "commonName", "Jack Daniels"); @@ -431,8 +423,8 @@ // dn id 12 LdapDN martinDn = new LdapDN( "cn=Marting King,ou=Sales,o=Good Times Co." ); - martinDn.normalize( attributeRegistry.getNormalizerMapping() ); - DefaultServerEntry entry = new DefaultServerEntry( registries, martinDn ); + martinDn.normalize( schemaManager.getNormalizerMapping() ); + DefaultServerEntry entry = new DefaultServerEntry( schemaManager, martinDn ); entry.add( "objectClass", "top", "person", "organizationalPerson" ); entry.add( "ou", "Sales" ); entry.add( "cn", "Martin King"); @@ -446,7 +438,7 @@ assertEquals( 12, ( long ) cursor.get().getId() ); LdapDN newParentDn = new LdapDN( "ou=Board of Directors,o=Good Times Co." ); - newParentDn.normalize( attributeRegistry.getNormalizerMapping() ); + newParentDn.normalize( schemaManager.getNormalizerMapping() ); store.move( martinDn, newParentDn ); cursor = idx.forwardCursor( 3L); @@ -456,8 +448,8 @@ // dn id 13 LdapDN marketingDn = new LdapDN( "ou=Marketing,ou=Sales,o=Good Times Co." ); - marketingDn.normalize( attributeRegistry.getNormalizerMapping() ); - entry = new DefaultServerEntry( registries, marketingDn ); + marketingDn.normalize( schemaManager.getNormalizerMapping() ); + entry = new DefaultServerEntry( schemaManager, marketingDn ); entry.add( "objectClass", "top", "organizationalUnit" ); entry.add( "ou", "Marketing" ); entry.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() ); @@ -466,8 +458,8 @@ // dn id 14 LdapDN jimmyDn = new LdapDN( "cn=Jimmy Wales,ou=Marketing, ou=Sales,o=Good Times Co." ); - jimmyDn.normalize( attributeRegistry.getNormalizerMapping() ); - entry = new DefaultServerEntry( registries, jimmyDn ); + jimmyDn.normalize( schemaManager.getNormalizerMapping() ); + entry = new DefaultServerEntry( schemaManager, jimmyDn ); entry.add( "objectClass", "top", "person", "organizationalPerson" ); entry.add( "ou", "Marketing" ); entry.add( "cn", "Jimmy Wales"); @@ -705,8 +697,8 @@ public void testAddWithoutParentId() throws Exception { LdapDN dn = new LdapDN( "cn=Marting King,ou=Not Present,o=Good Times Co." ); - dn.normalize( attributeRegistry.getNormalizerMapping() ); - DefaultServerEntry entry = new DefaultServerEntry( registries, dn ); + dn.normalize( schemaManager.getNormalizerMapping() ); + DefaultServerEntry entry = new DefaultServerEntry( schemaManager, dn ); entry.add( "objectClass", "top", "person", "organizationalPerson" ); entry.add( "ou", "Not Present" ); entry.add( "cn", "Martin King"); @@ -718,8 +710,8 @@ public void testAddWithoutObjectClass() throws Exception { LdapDN dn = new LdapDN( "cn=Martin King,ou=Sales,o=Good Times Co." ); - dn.normalize( attributeRegistry.getNormalizerMapping() ); - DefaultServerEntry entry = new DefaultServerEntry( registries, dn ); + dn.normalize( schemaManager.getNormalizerMapping() ); + DefaultServerEntry entry = new DefaultServerEntry( schemaManager, dn ); entry.add( "ou", "Sales" ); entry.add( "cn", "Martin King"); store.add( entry ); @@ -730,11 +722,11 @@ public void testModifyAddOUAttrib() throws Exception { LdapDN dn = new LdapDN( "cn=JOhnny WAlkeR,ou=Sales,o=Good Times Co." ); - dn.normalize( attributeRegistry.getNormalizerMapping() ); + dn.normalize( schemaManager.getNormalizerMapping() ); List mods = new ArrayList(); ServerAttribute attrib = new DefaultServerAttribute( SchemaConstants.OU_AT, - attributeRegistry.lookup( SchemaConstants.OU_AT_OID ) ); + schemaManager.lookupAttributeTypeRegistry( SchemaConstants.OU_AT_OID ) ); attrib.add( "Engineering" ); Modification add = new ServerModification( ModificationOperation.ADD_ATTRIBUTE, attrib ); @@ -749,8 +741,8 @@ public void testRename() throws Exception { LdapDN dn = new LdapDN( "cn=Pivate Ryan,ou=Engineering,o=Good Times Co." ); - dn.normalize( attributeRegistry.getNormalizerMapping() ); - DefaultServerEntry entry = new DefaultServerEntry( registries, dn ); + dn.normalize( schemaManager.getNormalizerMapping() ); + DefaultServerEntry entry = new DefaultServerEntry( schemaManager, dn ); entry.add( "objectClass", "top", "person", "organizationalPerson" ); entry.add( "ou", "Engineering" ); entry.add( "cn", "Private Ryan"); @@ -769,8 +761,8 @@ public void testMove() throws Exception { LdapDN childDn = new LdapDN( "cn=Pivate Ryan,ou=Engineering,o=Good Times Co." ); - childDn.normalize( attributeRegistry.getNormalizerMapping() ); - DefaultServerEntry childEntry = new DefaultServerEntry( registries, childDn ); + childDn.normalize( schemaManager.getNormalizerMapping() ); + DefaultServerEntry childEntry = new DefaultServerEntry( schemaManager, childDn ); childEntry.add( "objectClass", "top", "person", "organizationalPerson" ); childEntry.add( "ou", "Engineering" ); childEntry.add( "cn", "Private Ryan"); @@ -780,7 +772,7 @@ store.add( childEntry ); LdapDN parentDn = new LdapDN( "ou=Sales,o=Good Times Co." ); - parentDn.normalize( attributeRegistry.getNormalizerMapping() ); + parentDn.normalize( schemaManager.getNormalizerMapping() ); Rdn rdn = new Rdn("cn=Ryan"); @@ -788,10 +780,10 @@ // to drop the alias indices childDn = new LdapDN( "commonName=Jim Bean,ou=Apache,ou=Board of Directors,o=Good Times Co." ); - childDn.normalize( attributeRegistry.getNormalizerMapping() ); + childDn.normalize( schemaManager.getNormalizerMapping() ); parentDn = new LdapDN( "ou=Engineering,o=Good Times Co." ); - parentDn.normalize( attributeRegistry.getNormalizerMapping() ); + parentDn.normalize( schemaManager.getNormalizerMapping() ); assertEquals( 3, store.getSubAliasIndex().count() ); @@ -805,11 +797,11 @@ public void testModifyAdd() throws Exception { LdapDN dn = new LdapDN( "cn=JOhnny WAlkeR,ou=Sales,o=Good Times Co." ); - dn.normalize( attributeRegistry.getNormalizerMapping() ); + dn.normalize( schemaManager.getNormalizerMapping() ); List mods = new ArrayList(); ServerAttribute attrib = new DefaultServerAttribute( SchemaConstants.SURNAME_AT, - attributeRegistry.lookup( SchemaConstants.SURNAME_AT ) ); + schemaManager.lookupAttributeTypeRegistry( SchemaConstants.SURNAME_AT ) ); String attribVal = "Walker"; attrib.add( attribVal ); @@ -823,7 +815,7 @@ assertTrue( lookedup.get( "sn" ).contains( attribVal ) ); // testing the store.modify( dn, mod, entry ) API - ServerEntry entry = new DefaultServerEntry( registries, dn ); + ServerEntry entry = new DefaultServerEntry( schemaManager, dn ); attribVal = "+1974045779"; entry.add( "telephoneNumber", attribVal ); @@ -837,11 +829,11 @@ public void testModifyReplace() throws Exception { LdapDN dn = new LdapDN( "cn=JOhnny WAlkeR,ou=Sales,o=Good Times Co." ); - dn.normalize( attributeRegistry.getNormalizerMapping() ); + dn.normalize( schemaManager.getNormalizerMapping() ); List mods = new ArrayList(); ServerAttribute attrib = new DefaultServerAttribute( SchemaConstants.SN_AT, - attributeRegistry.lookup( SchemaConstants.SN_AT_OID ) ); + schemaManager.lookupAttributeTypeRegistry( SchemaConstants.SN_AT_OID ) ); String attribVal = "Johnny"; attrib.add( attribVal ); @@ -857,7 +849,7 @@ assertEquals( attribVal, lookedup.get( "sn" ).get().getString() ); // testing the store.modify( dn, mod, entry ) API - ServerEntry entry = new DefaultServerEntry( registries, dn ); + ServerEntry entry = new DefaultServerEntry( schemaManager, dn ); attribVal = "JWalker"; entry.add( "sn", attribVal ); @@ -870,11 +862,11 @@ public void testModifyRemove() throws Exception { LdapDN dn = new LdapDN( "cn=JOhnny WAlkeR,ou=Sales,o=Good Times Co." ); - dn.normalize( attributeRegistry.getNormalizerMapping() ); + dn.normalize( schemaManager.getNormalizerMapping() ); List mods = new ArrayList(); ServerAttribute attrib = new DefaultServerAttribute( SchemaConstants.SN_AT, - attributeRegistry.lookup( SchemaConstants.SN_AT_OID ) ); + schemaManager.lookupAttributeTypeRegistry( SchemaConstants.SN_AT_OID ) ); Modification add = new ServerModification( ModificationOperation.REMOVE_ATTRIBUTE, attrib ); mods.add( add ); @@ -887,7 +879,7 @@ assertNull( lookedup.get( "sn" ) ); // testing the store.modify( dn, mod, entry ) API - ServerEntry entry = new DefaultServerEntry( registries, dn ); + ServerEntry entry = new DefaultServerEntry( schemaManager, dn ); // add an entry for the sake of testing the remove operation entry.add( "sn", "JWalker" ); @@ -903,8 +895,8 @@ public void testModifyReplaceNonExistingIndexAttribute() throws Exception { LdapDN dn = new LdapDN( "cn=Tim B,ou=Sales,o=Good Times Co." ); - dn.normalize( attributeRegistry.getNormalizerMapping() ); - DefaultServerEntry entry = new DefaultServerEntry( registries, dn ); + dn.normalize( schemaManager.getNormalizerMapping() ); + DefaultServerEntry entry = new DefaultServerEntry( schemaManager, dn ); entry.add( "objectClass", "top", "person", "organizationalPerson" ); entry.add( "cn", "Tim B"); entry.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() ); @@ -914,7 +906,7 @@ List mods = new ArrayList(); ServerAttribute attrib = new DefaultServerAttribute( SchemaConstants.OU_AT, - attributeRegistry.lookup( SchemaConstants.OU_AT_OID ) ); + schemaManager.lookupAttributeTypeRegistry( SchemaConstants.OU_AT_OID ) ); String attribVal = "Marketing"; attrib.add( attribVal );