You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2012/09/24 04:17:20 UTC
svn commit: r1389184 [3/13] - in /directory/apacheds/trunk:
core-annotations/src/main/java/org/apache/directory/server/core/factory/
core-api/src/main/java/org/apache/directory/server/core/api/
core-api/src/main/java/org/apache/directory/server/core/ap...
Modified: directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndexTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndexTest.java?rev=1389184&r1=1389183&r2=1389184&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndexTest.java (original)
+++ directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndexTest.java Mon Sep 24 02:17:13 2012
@@ -41,6 +41,7 @@ import org.apache.directory.shared.ldap.
import org.apache.directory.shared.ldap.schemaextractor.impl.DefaultSchemaLdifExtractor;
import org.apache.directory.shared.ldap.schemaloader.LdifSchemaLoader;
import org.apache.directory.shared.ldap.schemamanager.impl.DefaultSchemaManager;
+import org.apache.directory.shared.util.Strings;
import org.apache.directory.shared.util.exception.Exceptions;
import org.junit.After;
import org.junit.Before;
@@ -56,7 +57,7 @@ import org.junit.Test;
public class JdbmIndexTest
{
private static File dbFileDir;
- Index<String, Entry, Long> idx;
+ Index<String, Entry, String> idx;
private static SchemaManager schemaManager;
@@ -137,7 +138,8 @@ public class JdbmIndexTest
void initIndex() throws Exception
{
- JdbmIndex<String, Entry> index = new JdbmIndex<String, Entry>();
+ AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.OU_AT );
+ JdbmIndex<String, Entry> index = new JdbmIndex<String, Entry>( attributeType.getName(), false );
index.setWkDirPath( dbFileDir.toURI() );
initIndex( index );
}
@@ -145,13 +147,13 @@ public class JdbmIndexTest
void initIndex( JdbmIndex<String, Entry> jdbmIdx ) throws Exception
{
+ AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.OU_AT );
+
if ( jdbmIdx == null )
{
- jdbmIdx = new JdbmIndex<String, Entry>();
+ jdbmIdx = new JdbmIndex<String, Entry>( attributeType.getName(), false );
}
- AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.OU_AT );
-
jdbmIdx.init( schemaManager, attributeType );
this.idx = jdbmIdx;
}
@@ -165,11 +167,10 @@ public class JdbmIndexTest
public void testAttributeId() throws Exception
{
// uninitialized index
- JdbmIndex<Object, Object> jdbmIndex1 = new JdbmIndex<Object, Object>();
- jdbmIndex1.setAttributeId( "foo" );
+ JdbmIndex<Object, Object> jdbmIndex1 = new JdbmIndex<Object, Object>( "foo", false );
assertEquals( "foo", jdbmIndex1.getAttributeId() );
- JdbmIndex<Object, Object> jdbmIndex2 = new JdbmIndex<Object, Object>( "bar" );
+ JdbmIndex<Object, Object> jdbmIndex2 = new JdbmIndex<Object, Object>( "bar", false );
assertEquals( "bar", jdbmIndex2.getAttributeId() );
// initialized index
@@ -187,7 +188,7 @@ public class JdbmIndexTest
assertEquals( "ou", idx.getAttributeId() );
destroyIndex();
- JdbmIndex<String, Entry> index = new JdbmIndex<String, Entry>( "foo" );
+ JdbmIndex<String, Entry> index = new JdbmIndex<String, Entry>( "foo", false );
index.setWkDirPath( dbFileDir.toURI() );
initIndex( index );
assertEquals( "foo", idx.getAttributeId() );
@@ -198,12 +199,13 @@ public class JdbmIndexTest
public void testCacheSize() throws Exception
{
// uninitialized index
- JdbmIndex<Object, Object> jdbmIndex = new JdbmIndex<Object, Object>();
+ JdbmIndex<Object, Object> jdbmIndex = new JdbmIndex<Object, Object>( "ou", false );
jdbmIndex.setCacheSize( 337 );
assertEquals( 337, jdbmIndex.getCacheSize() );
// initialized index
initIndex();
+
try
{
idx.setCacheSize( 30 );
@@ -222,7 +224,7 @@ public class JdbmIndexTest
File wkdir = new File( dbFileDir, "foo" );
// uninitialized index
- JdbmIndex<String, Entry> jdbmIndex = new JdbmIndex<String, Entry>();
+ JdbmIndex<String, Entry> jdbmIndex = new JdbmIndex<String, Entry>( "foo", false );
jdbmIndex.setWkDirPath( wkdir.toURI() );
assertEquals( "foo", new File( jdbmIndex.getWkDirPath() ).getName() );
@@ -241,7 +243,7 @@ public class JdbmIndexTest
assertEquals( dbFileDir.toURI(), idx.getWkDirPath() );
destroyIndex();
- jdbmIndex = new JdbmIndex<String, Entry>();
+ jdbmIndex = new JdbmIndex<String, Entry>( "ou", false );
wkdir.mkdirs();
jdbmIndex.setWkDirPath( wkdir.toURI() );
initIndex( jdbmIndex );
@@ -253,13 +255,13 @@ public class JdbmIndexTest
public void testNumDupLimit() throws Exception
{
// uninitialized index
- JdbmIndex<Object, Object> jdbmIndex = new JdbmIndex<Object, Object>();
+ JdbmIndex<Object, Object> jdbmIndex = new JdbmIndex<Object, Object>( "ou", false );
jdbmIndex.setNumDupLimit( 337 );
assertEquals( 337, jdbmIndex.getNumDupLimit() );
// initialized index
initIndex();
-
+
try
{
( ( JdbmIndex<String, Entry> ) idx ).setNumDupLimit( 30 );
@@ -268,7 +270,7 @@ public class JdbmIndexTest
catch ( Exception e )
{
}
-
+
assertEquals( JdbmIndex.DEFAULT_DUPLICATE_LIMIT, ( ( JdbmIndex<String, Entry> ) idx ).getNumDupLimit() );
}
@@ -277,7 +279,7 @@ public class JdbmIndexTest
public void testGetAttribute() throws Exception
{
// uninitialized index
- JdbmIndex<Object, Object> jdbmIndex = new JdbmIndex<Object, Object>();
+ JdbmIndex<Object, Object> jdbmIndex = new JdbmIndex<Object, Object>( "ou", false );
assertNull( jdbmIndex.getAttribute() );
initIndex();
@@ -295,13 +297,13 @@ public class JdbmIndexTest
initIndex();
assertEquals( 0, idx.count() );
- idx.add( "foo", 1234L );
+ idx.add( "foo", Strings.getUUID( 1234L ) );
assertEquals( 1, idx.count() );
- idx.add( "foo", 333L );
+ idx.add( "foo", Strings.getUUID( 333L ) );
assertEquals( 2, idx.count() );
- idx.add( "bar", 555L );
+ idx.add( "bar", Strings.getUUID( 555L ) );
assertEquals( 3, idx.count() );
}
@@ -312,13 +314,13 @@ public class JdbmIndexTest
initIndex();
assertEquals( 0, idx.count( "foo" ) );
- idx.add( "bar", 1234L );
+ idx.add( "bar", Strings.getUUID( 1234L ) );
assertEquals( 0, idx.count( "foo" ) );
- idx.add( "foo", 1234L );
+ idx.add( "foo", Strings.getUUID( 1234L ) );
assertEquals( 1, idx.count( "foo" ) );
- idx.add( "foo", 333L );
+ idx.add( "foo", Strings.getUUID( 333L ) );
assertEquals( 2, idx.count( "foo" ) );
}
@@ -331,9 +333,9 @@ public class JdbmIndexTest
for ( char ch = 'a'; ch <= 'z'; ch++ )
{
- idx.add( String.valueOf( ch ), ( long ) ch );
+ idx.add( String.valueOf( ch ), Strings.getUUID( ch ) );
}
-
+
assertEquals( 26, idx.greaterThanCount( "a" ) );
}
@@ -346,9 +348,9 @@ public class JdbmIndexTest
for ( char ch = 'a'; ch <= 'z'; ch++ )
{
- idx.add( String.valueOf( ch ), ( long ) ch );
+ idx.add( String.valueOf( ch ), Strings.getUUID( ch ) );
}
-
+
assertEquals( 26, idx.lessThanCount( "z" ) );
}
@@ -363,58 +365,53 @@ public class JdbmIndexTest
initIndex();
assertNull( idx.forwardLookup( "foo" ) );
assertNull( idx.forwardLookup( "bar" ) );
- assertNull( idx.reverseLookup( 0L ) );
- assertFalse( idx.forwardGreaterOrEq( "foo", 0L ) );
- assertFalse( idx.forwardGreaterOrEq( "foo", -24L ) );
- assertFalse( idx.forwardGreaterOrEq( "foo", 24L ) );
- assertFalse( idx.forwardLessOrEq( "foo", 0L ) );
- assertFalse( idx.forwardLessOrEq( "foo", 24L ) );
- assertFalse( idx.forwardLessOrEq( "foo", -24L ) );
-
- idx.add( "foo", 0L );
- assertEquals( 0L, ( long ) idx.forwardLookup( "foo" ) );
- assertEquals( "foo", idx.reverseLookup( 0L ) );
- assertTrue( idx.forward( "foo", 0L ) );
- assertTrue( idx.forwardGreaterOrEq( "foo", 0L ) );
- assertTrue( idx.forwardGreaterOrEq( "foo", -1L ) );
- assertFalse( idx.forwardGreaterOrEq( "foo", 1L ) );
- assertTrue( idx.forwardLessOrEq( "foo", 0L ) );
- assertTrue( idx.forwardLessOrEq( "foo", 1L ) );
- assertFalse( idx.forwardLessOrEq( "foo", -1L ) );
-
- idx.add( "foo", 1L );
- assertEquals( 0L, ( long ) idx.forwardLookup( "foo" ) );
- assertEquals( "foo", idx.reverseLookup( 0L ) );
- assertEquals( "foo", idx.reverseLookup( 1L ) );
- assertTrue( idx.forward( "foo", 0L ) );
- assertTrue( idx.forward( "foo", 1L ) );
- assertTrue( idx.forwardGreaterOrEq( "foo", 0L ) );
- assertTrue( idx.forwardGreaterOrEq( "foo", 1L ) );
- assertTrue( idx.forwardGreaterOrEq( "foo", -1L ) );
- assertFalse( idx.forwardGreaterOrEq( "foo", 2L ) );
- assertTrue( idx.forwardLessOrEq( "foo", 0L ) );
- assertTrue( idx.forwardLessOrEq( "foo", 1L ) );
- assertTrue( idx.forwardLessOrEq( "foo", 2L ) );
- assertFalse( idx.forwardLessOrEq( "foo", -1L ) );
-
- idx.add( "bar", 0L );
- assertEquals( 0L, ( long ) idx.forwardLookup( "bar" ) );
- assertEquals( "bar", idx.reverseLookup( 0L ) ); // reverse lookup returns first val
- assertTrue( idx.forward( "bar", 0L ) );
- assertTrue( idx.forward( "foo", 0L ) );
- assertTrue( idx.forward( "foo", 1L ) );
- assertTrue( idx.forwardGreaterOrEq( "bar", 0L ) );
- assertTrue( idx.forwardGreaterOrEq( "foo", 0L ) );
- assertTrue( idx.forwardGreaterOrEq( "foo", 1L ) );
- assertTrue( idx.forwardGreaterOrEq( "foo", -1L ) );
- assertFalse( idx.forwardGreaterOrEq( "foo", 2L ) );
- assertFalse( idx.forwardGreaterOrEq( "bar", 1L ) );
- assertTrue( idx.forwardLessOrEq( "bar", 0L ) );
- assertTrue( idx.forwardLessOrEq( "foo", 0L ) );
- assertTrue( idx.forwardLessOrEq( "foo", 1L ) );
- assertTrue( idx.forwardLessOrEq( "foo", 2L ) );
- assertFalse( idx.forwardLessOrEq( "foo", -1L ) );
- assertFalse( idx.forwardLessOrEq( "bar", -1L ) );
+ assertFalse( idx.forwardGreaterOrEq( "foo", Strings.getUUID( 0L ) ) );
+ assertFalse( idx.forwardGreaterOrEq( "foo", Strings.getUUID( -24L ) ) );
+ assertFalse( idx.forwardGreaterOrEq( "foo", Strings.getUUID( 24L ) ) );
+ assertFalse( idx.forwardLessOrEq( "foo", Strings.getUUID( 0L ) ) );
+ assertFalse( idx.forwardLessOrEq( "foo", Strings.getUUID( 24L ) ) );
+ assertFalse( idx.forwardLessOrEq( "foo", Strings.getUUID( -24L ) ) );
+
+ idx.add( "foo", Strings.getUUID( 0L ) );
+ assertEquals( Strings.getUUID( 0L ), idx.forwardLookup( "foo" ) );
+ assertTrue( idx.forward( "foo", Strings.getUUID( 0L ) ) );
+ assertTrue( idx.forwardGreaterOrEq( "foo", Strings.getUUID( 0L ) ) );
+ assertFalse( idx.forwardGreaterOrEq( "foo", Strings.getUUID( -1L ) ) );
+ assertFalse( idx.forwardGreaterOrEq( "foo", Strings.getUUID( 1L ) ) );
+ assertTrue( idx.forwardLessOrEq( "foo", Strings.getUUID( 0L ) ) );
+ assertTrue( idx.forwardLessOrEq( "foo", Strings.getUUID( 1L ) ) );
+ assertTrue( idx.forwardLessOrEq( "foo", Strings.getUUID( -1L ) ) );
+
+ idx.add( "foo", Strings.getUUID( 1L ) );
+ assertEquals( Strings.getUUID( 0L ), idx.forwardLookup( "foo" ) );
+ assertTrue( idx.forward( "foo", Strings.getUUID( 0L ) ) );
+ assertTrue( idx.forward( "foo", Strings.getUUID( 1L ) ) );
+ assertTrue( idx.forwardGreaterOrEq( "foo", Strings.getUUID( 0L ) ) );
+ assertTrue( idx.forwardGreaterOrEq( "foo", Strings.getUUID( 1L ) ) );
+ assertFalse( idx.forwardGreaterOrEq( "foo", Strings.getUUID( -1L ) ) );
+ assertFalse( idx.forwardGreaterOrEq( "foo", Strings.getUUID( 2L ) ) );
+ assertTrue( idx.forwardLessOrEq( "foo", Strings.getUUID( 0L ) ) );
+ assertTrue( idx.forwardLessOrEq( "foo", Strings.getUUID( 1L ) ) );
+ assertTrue( idx.forwardLessOrEq( "foo", Strings.getUUID( 2L ) ) );
+ assertTrue( idx.forwardLessOrEq( "foo", Strings.getUUID( -1L ) ) );
+
+ idx.add( "bar", Strings.getUUID( 0L ) );
+ assertEquals( Strings.getUUID( 0L ), idx.forwardLookup( "bar" ) );
+ assertTrue( idx.forward( "bar", Strings.getUUID( 0L ) ) );
+ assertTrue( idx.forward( "foo", Strings.getUUID( 0L ) ) );
+ assertTrue( idx.forward( "foo", Strings.getUUID( 1L ) ) );
+ assertTrue( idx.forwardGreaterOrEq( "bar", Strings.getUUID( 0L ) ) );
+ assertTrue( idx.forwardGreaterOrEq( "foo", Strings.getUUID( 0L ) ) );
+ assertTrue( idx.forwardGreaterOrEq( "foo", Strings.getUUID( 1L ) ) );
+ assertFalse( idx.forwardGreaterOrEq( "foo", Strings.getUUID( -1L ) ) );
+ assertFalse( idx.forwardGreaterOrEq( "foo", Strings.getUUID( 2L ) ) );
+ assertFalse( idx.forwardGreaterOrEq( "bar", Strings.getUUID( 1L ) ) );
+ assertTrue( idx.forwardLessOrEq( "bar", Strings.getUUID( 0L ) ) );
+ assertTrue( idx.forwardLessOrEq( "foo", Strings.getUUID( 0L ) ) );
+ assertTrue( idx.forwardLessOrEq( "foo", Strings.getUUID( 1L ) ) );
+ assertTrue( idx.forwardLessOrEq( "foo", Strings.getUUID( 2L ) ) );
+ assertTrue( idx.forwardLessOrEq( "foo", Strings.getUUID( -1L ) ) );
+ assertTrue( idx.forwardLessOrEq( "bar", Strings.getUUID( -1L ) ) );
}
@@ -424,37 +421,30 @@ public class JdbmIndexTest
initIndex();
assertNull( idx.forwardLookup( "foo" ) );
assertNull( idx.forwardLookup( "bar" ) );
- assertNull( idx.reverseLookup( 0L ) );
- assertNull( idx.reverseLookup( 1L ) );
// test add/drop without adding any duplicates
- idx.add( "foo", 0L );
- assertEquals( 0L, ( long ) idx.forwardLookup( "foo" ) );
- assertEquals( "foo", idx.reverseLookup( 0L ) );
+ idx.add( "foo", Strings.getUUID( 0L ) );
+ assertEquals( Strings.getUUID( 0L ), idx.forwardLookup( "foo" ) );
- idx.drop( 0L );
+ idx.drop( "foo", Strings.getUUID( 0L ) );
assertNull( idx.forwardLookup( "foo" ) );
- assertNull( idx.reverseLookup( 0L ) );
// test add/drop with duplicates in bulk
- idx.add( "foo", 0L );
- idx.add( "foo", 1L );
- idx.add( "bar", 0L );
- assertEquals( 0L, ( long ) idx.forwardLookup( "foo" ) );
- assertEquals( 0L, ( long ) idx.forwardLookup( "bar" ) );
- assertEquals( "bar", idx.reverseLookup( 0L ) );
- assertEquals( "foo", idx.reverseLookup( 1L ) );
-
- idx.drop( 0L );
- assertEquals( "foo", idx.reverseLookup( 1L ) );
- assertFalse( idx.forward( "bar", 0L ) );
- assertFalse( idx.forward( "foo", 0L ) );
+ idx.add( "foo", Strings.getUUID( 0L ) );
+ idx.add( "foo", Strings.getUUID( 1L ) );
+ idx.add( "bar", Strings.getUUID( 0L ) );
+ assertEquals( Strings.getUUID( 0L ), idx.forwardLookup( "foo" ) );
+ assertEquals( Strings.getUUID( 0L ), idx.forwardLookup( "bar" ) );
+
+ idx.drop( "foo", Strings.getUUID( 0L ) );
+ idx.drop( "bar", Strings.getUUID( 0L ) );
+ assertFalse( idx.forward( "bar", Strings.getUUID( 0L ) ) );
+ assertFalse( idx.forward( "foo", Strings.getUUID( 0L ) ) );
- idx.drop( 1L );
+ idx.drop( "bar", Strings.getUUID( 1L ) );
+ idx.drop( "foo", Strings.getUUID( 1L ) );
assertNull( idx.forwardLookup( "foo" ) );
assertNull( idx.forwardLookup( "bar" ) );
- assertNull( idx.reverseLookup( 0L ) );
- assertNull( idx.reverseLookup( 1L ) );
assertEquals( 0, idx.count() );
}
@@ -465,43 +455,32 @@ public class JdbmIndexTest
initIndex();
assertNull( idx.forwardLookup( "foo" ) );
assertNull( idx.forwardLookup( "bar" ) );
- assertNull( idx.reverseLookup( 0L ) );
- assertNull( idx.reverseLookup( 1L ) );
// test add/drop without adding any duplicates
- idx.add( "foo", 0L );
- assertEquals( 0L, ( long ) idx.forwardLookup( "foo" ) );
- assertEquals( "foo", idx.reverseLookup( 0L ) );
+ idx.add( "foo", Strings.getUUID( 0L ) );
+ assertEquals( Strings.getUUID( 0L ), idx.forwardLookup( "foo" ) );
- idx.drop( "foo", 0L );
+ idx.drop( "foo", Strings.getUUID( 0L ) );
assertNull( idx.forwardLookup( "foo" ) );
- assertNull( idx.reverseLookup( 0L ) );
// test add/drop with duplicates but one at a time
- idx.add( "foo", 0L );
- idx.add( "foo", 1L );
- idx.add( "bar", 0L );
- assertEquals( 0L, ( long ) idx.forwardLookup( "foo" ) );
- assertEquals( 0L, ( long ) idx.forwardLookup( "bar" ) );
- assertEquals( "bar", idx.reverseLookup( 0L ) );
- assertEquals( "foo", idx.reverseLookup( 1L ) );
-
- idx.drop( "bar", 0L );
- assertEquals( 0L, ( long ) idx.forwardLookup( "foo" ) );
- assertEquals( "foo", idx.reverseLookup( 0L ) );
- assertEquals( "foo", idx.reverseLookup( 1L ) );
- assertFalse( idx.forward( "bar", 0L ) );
-
- idx.drop( "foo", 0L );
- assertEquals( 1L, ( long ) idx.forwardLookup( "foo" ) );
- assertEquals( "foo", idx.reverseLookup( 1L ) );
- assertFalse( idx.forward( "foo", 0L ) );
+ idx.add( "foo", Strings.getUUID( 0L ) );
+ idx.add( "foo", Strings.getUUID( 1L ) );
+ idx.add( "bar", Strings.getUUID( 0L ) );
+ assertEquals( Strings.getUUID( 0L ), idx.forwardLookup( "foo" ) );
+ assertEquals( Strings.getUUID( 0L ), idx.forwardLookup( "bar" ) );
+
+ idx.drop( "bar", Strings.getUUID( 0L ) );
+ assertEquals( Strings.getUUID( 0L ), idx.forwardLookup( "foo" ) );
+ assertFalse( idx.forward( "bar", Strings.getUUID( 0L ) ) );
+
+ idx.drop( "foo", Strings.getUUID( 0L ) );
+ assertEquals( Strings.getUUID( 1L ), idx.forwardLookup( "foo" ) );
+ assertFalse( idx.forward( "foo", Strings.getUUID( 0L ) ) );
- idx.drop( "foo", 1L );
+ idx.drop( "foo", Strings.getUUID( 1L ) );
assertNull( idx.forwardLookup( "foo" ) );
assertNull( idx.forwardLookup( "bar" ) );
- assertNull( idx.reverseLookup( 0L ) );
- assertNull( idx.reverseLookup( 1L ) );
assertEquals( 0, idx.count() );
}
@@ -516,55 +495,36 @@ public class JdbmIndexTest
initIndex();
assertEquals( 0, idx.count() );
- idx.add( "foo", 1234L );
+ idx.add( "foo", Strings.getUUID( 1234L ) );
assertEquals( 1, idx.count() );
- idx.add( "foo", 333L );
+ idx.add( "foo", Strings.getUUID( 333L ) );
assertEquals( 2, idx.count() );
- idx.add( "bar", 555L );
+ idx.add( "bar", Strings.getUUID( 555L ) );
assertEquals( 3, idx.count() );
// use forward index's cursor
- Cursor<IndexEntry<String, Long>> cursor = idx.forwardCursor();
+ Cursor<IndexEntry<String, String>> cursor = idx.forwardCursor();
cursor.beforeFirst();
+ assertEquals( 3, idx.count() );
+
cursor.next();
- IndexEntry<String, Long> e1 = cursor.get();
- assertEquals( 555L, ( long ) e1.getId() );
+ IndexEntry<String, String> e1 = cursor.get();
+ assertEquals( Strings.getUUID( 555L ), e1.getId() );
assertEquals( "bar", e1.getKey() );
cursor.next();
- IndexEntry<String, Long> e2 = cursor.get();
- assertEquals( 333L, ( long ) e2.getId() );
+ IndexEntry<String, String> e2 = cursor.get();
+ assertEquals( Strings.getUUID( 333L ), e2.getId() );
assertEquals( "foo", e2.getKey() );
cursor.next();
- IndexEntry<String, Long> e3 = cursor.get();
- assertEquals( 1234L, ( long ) e3.getId() );
+ IndexEntry<String, String> e3 = cursor.get();
+ assertEquals( Strings.getUUID( 1234L ), e3.getId() );
assertEquals( "foo", e3.getKey() );
-
- cursor.close();
-
- // use reverse index's cursor
- cursor = idx.reverseCursor();
- cursor.beforeFirst();
-
- cursor.next();
- e1 = cursor.get();
- assertEquals( 333L, ( long ) e1.getId() );
- assertEquals( "foo", e1.getKey() );
-
- cursor.next();
- e2 = cursor.get();
- assertEquals( 555L, ( long ) e2.getId() );
- assertEquals( "bar", e2.getKey() );
- cursor.next();
- e3 = cursor.get();
- assertEquals( 1234L, ( long ) e3.getId() );
- assertEquals( "foo", e3.getKey() );
-
cursor.close();
}
@@ -572,7 +532,7 @@ public class JdbmIndexTest
@Test
public void testNoEqualityMatching() throws Exception
{
- JdbmIndex<Object, Object> jdbmIndex = new JdbmIndex<Object, Object>();
+ JdbmIndex<Object, Object> jdbmIndex = new JdbmIndex<Object, Object>( "1.1", false );
try
{
@@ -594,7 +554,7 @@ public class JdbmIndexTest
@Test
public void testSingleValuedAttribute() throws Exception
{
- JdbmIndex<Object, Object> jdbmIndex = new JdbmIndex<Object, Object>();
+ JdbmIndex<Object, Object> jdbmIndex = new JdbmIndex<Object, Object>( SchemaConstants.CREATORS_NAME_AT, false );
jdbmIndex.setWkDirPath( dbFileDir.toURI() );
jdbmIndex.init( schemaManager, schemaManager.lookupAttributeTypeRegistry( SchemaConstants.CREATORS_NAME_AT ) );
jdbmIndex.close();
Modified: directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTableTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTableTest.java?rev=1389184&r1=1389183&r2=1389184&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTableTest.java (original)
+++ directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTableTest.java Mon Sep 24 02:17:13 2012
@@ -34,6 +34,7 @@ import org.apache.directory.shared.ldap.
import org.apache.directory.shared.ldap.schemaextractor.impl.DefaultSchemaLdifExtractor;
import org.apache.directory.shared.ldap.schemaloader.LdifSchemaLoader;
import org.apache.directory.shared.ldap.schemamanager.impl.DefaultSchemaManager;
+import org.apache.directory.shared.util.Strings;
import org.apache.directory.shared.util.exception.Exceptions;
import org.junit.After;
import org.junit.Before;
@@ -52,7 +53,7 @@ public class JdbmMasterTableTest
private static final Logger LOG = LoggerFactory.getLogger( JdbmMasterTableTest.class.getSimpleName() );
private static final String TEST_OUTPUT_PATH = "test.output.path";
- JdbmMasterTable<Integer> table;
+ JdbmMasterTable table;
File dbFile;
RecordManager recman;
SchemaManager schemaManager = null;
@@ -98,10 +99,10 @@ public class JdbmMasterTableTest
dbFile = File.createTempFile( getClass().getSimpleName(), "db", tmpDir );
recman = new BaseRecordManager( dbFile.getAbsolutePath() );
- table = new JdbmMasterTable<Integer>( recman, schemaManager );
+ table = new JdbmMasterTable( recman, schemaManager );
LOG.debug( "Created new table and populated it with data" );
- JdbmMasterTable<Integer> t2 = new JdbmMasterTable<Integer>( recman, schemaManager );
+ JdbmMasterTable t2 = new JdbmMasterTable( recman, schemaManager );
t2.close();
}
@@ -139,12 +140,7 @@ public class JdbmMasterTableTest
@Test
public void testAll() throws Exception
{
- assertNull( table.get( 0L ) );
+ assertNull( table.get( Strings.getUUID( 0L ) ) );
assertEquals( 0, table.count() );
-
- assertEquals( 1, ( long ) table.getNextId( null ) );
- assertEquals( 0, table.count() );
-
- assertEquals( 2, ( long ) table.getNextId( null ) );
}
}
Modified: directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndexTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndexTest.java?rev=1389184&r1=1389183&r2=1389184&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndexTest.java (original)
+++ directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndexTest.java Mon Sep 24 02:17:13 2012
@@ -34,12 +34,14 @@ import org.apache.directory.server.xdbm.
import org.apache.directory.server.xdbm.IndexEntry;
import org.apache.directory.server.xdbm.ParentIdAndRdn;
import org.apache.directory.shared.ldap.model.cursor.Cursor;
+import org.apache.directory.shared.ldap.model.entry.Entry;
import org.apache.directory.shared.ldap.model.name.Rdn;
import org.apache.directory.shared.ldap.model.schema.SchemaManager;
import org.apache.directory.shared.ldap.schemaextractor.SchemaLdifExtractor;
import org.apache.directory.shared.ldap.schemaextractor.impl.DefaultSchemaLdifExtractor;
import org.apache.directory.shared.ldap.schemaloader.LdifSchemaLoader;
import org.apache.directory.shared.ldap.schemamanager.impl.DefaultSchemaManager;
+import org.apache.directory.shared.util.Strings;
import org.apache.directory.shared.util.exception.Exceptions;
import org.junit.After;
import org.junit.Before;
@@ -55,7 +57,7 @@ import org.junit.Test;
public class JdbmRdnIndexTest
{
private static File dbFileDir;
- Index<ParentIdAndRdn<Long>, Long, Long> idx;
+ Index<ParentIdAndRdn, Entry, String> idx;
private static SchemaManager schemaManager;
@@ -136,17 +138,17 @@ public class JdbmRdnIndexTest
void initIndex() throws Exception
{
- JdbmRdnIndex<Long> index = new JdbmRdnIndex<Long>();
+ JdbmRdnIndex index = new JdbmRdnIndex();
index.setWkDirPath( dbFileDir.toURI() );
initIndex( index );
}
- void initIndex( JdbmRdnIndex<Long> jdbmIdx ) throws Exception
+ void initIndex( JdbmRdnIndex jdbmIdx ) throws Exception
{
if ( jdbmIdx == null )
{
- jdbmIdx = new JdbmRdnIndex<Long>();
+ jdbmIdx = new JdbmRdnIndex();
}
jdbmIdx.init( schemaManager,
@@ -163,7 +165,7 @@ public class JdbmRdnIndexTest
public void testCacheSize() throws Exception
{
// uninitialized index
- JdbmRdnIndex<Object> JdbmRdnIndex = new JdbmRdnIndex<Object>();
+ JdbmRdnIndex JdbmRdnIndex = new JdbmRdnIndex();
JdbmRdnIndex.setCacheSize( 337 );
assertEquals( 337, JdbmRdnIndex.getCacheSize() );
@@ -191,7 +193,7 @@ public class JdbmRdnIndexTest
File wkdir = new File( dbFileDir, "foo" );
// uninitialized index
- JdbmRdnIndex<Long> jdbmRdnIndex = new JdbmRdnIndex<Long>();
+ JdbmRdnIndex jdbmRdnIndex = new JdbmRdnIndex();
jdbmRdnIndex.setWkDirPath( wkdir.toURI() );
assertEquals( "foo", new File( jdbmRdnIndex.getWkDirPath() ).getName() );
@@ -211,7 +213,7 @@ public class JdbmRdnIndexTest
destroyIndex();
- jdbmRdnIndex = new JdbmRdnIndex<Long>();
+ jdbmRdnIndex = new JdbmRdnIndex();
wkdir.mkdirs();
jdbmRdnIndex.setWkDirPath( wkdir.toURI() );
initIndex( jdbmRdnIndex );
@@ -223,7 +225,7 @@ public class JdbmRdnIndexTest
public void testGetAttribute() throws Exception
{
// uninitialized index
- JdbmRdnIndex<Object> rdnIndex = new JdbmRdnIndex<Object>();
+ JdbmRdnIndex rdnIndex = new JdbmRdnIndex();
assertNull( rdnIndex.getAttribute() );
initIndex();
@@ -242,23 +244,23 @@ public class JdbmRdnIndexTest
initIndex();
assertEquals( 0, idx.count() );
- ParentIdAndRdn<Long> key = new ParentIdAndRdn<Long>( 0L, new Rdn( "cn=key" ) );
+ ParentIdAndRdn key = new ParentIdAndRdn( Strings.getUUID( 0L ), new Rdn( "cn=key" ) );
- idx.add( key, 0l );
+ idx.add( key, Strings.getUUID( 0L ) );
assertEquals( 1, idx.count() );
// setting a different parentId should make this key a different key
- key = new ParentIdAndRdn<Long>( 1L, new Rdn( "cn=key" ) );
+ key = new ParentIdAndRdn( Strings.getUUID( 1L ), new Rdn( "cn=key" ) );
- idx.add( key, 1l );
+ idx.add( key, Strings.getUUID( 1L ) );
assertEquals( 2, idx.count() );
//count shouldn't get affected cause of inserting the same key
- idx.add( key, 2l );
+ idx.add( key, Strings.getUUID( 2L ) );
assertEquals( 2, idx.count() );
- key = new ParentIdAndRdn<Long>( 2L, new Rdn( "cn=key" ) );
- idx.add( key, 3l );
+ key = new ParentIdAndRdn( Strings.getUUID( 2L ), new Rdn( "cn=key" ) );
+ idx.add( key, Strings.getUUID( 3L ) );
assertEquals( 3, idx.count() );
}
@@ -268,11 +270,11 @@ public class JdbmRdnIndexTest
{
initIndex();
- ParentIdAndRdn<Long> key = new ParentIdAndRdn<Long>( 0L, new Rdn( "cn=key" ) );
+ ParentIdAndRdn key = new ParentIdAndRdn( Strings.getUUID( 0L ), new Rdn( "cn=key" ) );
assertEquals( 0, idx.count( key ) );
- idx.add( key, 0l );
+ idx.add( key, Strings.getUUID( 0L ) );
assertEquals( 1, idx.count( key ) );
}
@@ -286,19 +288,19 @@ public class JdbmRdnIndexTest
{
initIndex();
- ParentIdAndRdn<Long> key = new ParentIdAndRdn<Long>( 0L, new Rdn( schemaManager, "cn=key" ) );
+ ParentIdAndRdn key = new ParentIdAndRdn( Strings.getUUID( 0L ), new Rdn( schemaManager, "cn=key" ) );
assertNull( idx.forwardLookup( key ) );
- idx.add( key, 0l );
- assertEquals( 0, ( long ) idx.forwardLookup( key ) );
- assertEquals( key, idx.reverseLookup( 0l ) );
+ idx.add( key, Strings.getUUID( 0L ) );
+ assertEquals( Strings.getUUID( 0L ), idx.forwardLookup( key ) );
+ assertEquals( key, idx.reverseLookup( Strings.getUUID( 0L ) ) );
// check with the different case in UP name, this ensures that the custom
// key comparator is used
- key = new ParentIdAndRdn<Long>( 0L, new Rdn( schemaManager, "cn=KEY" ) );
- assertEquals( 0, ( long ) idx.forwardLookup( key ) );
- assertEquals( key, idx.reverseLookup( 0l ) );
+ key = new ParentIdAndRdn( Strings.getUUID( 0L ), new Rdn( schemaManager, "cn=KEY" ) );
+ assertEquals( Strings.getUUID( 0L ), idx.forwardLookup( key ) );
+ assertEquals( key, idx.reverseLookup( Strings.getUUID( 0L ) ) );
}
@@ -307,17 +309,17 @@ public class JdbmRdnIndexTest
{
initIndex();
- ParentIdAndRdn<Long> key = new ParentIdAndRdn<Long>( 0L, new Rdn( "cn=key" ) );
+ ParentIdAndRdn key = new ParentIdAndRdn( Strings.getUUID( 0L ), new Rdn( "cn=key" ) );
assertNull( idx.forwardLookup( key ) );
// test add/drop without adding any duplicates
- idx.add( key, 0l );
- assertEquals( 0, ( long ) idx.forwardLookup( key ) );
+ idx.add( key, Strings.getUUID( 0L ) );
+ assertEquals( Strings.getUUID( 0L ), idx.forwardLookup( key ) );
- idx.drop( key, 0l );
+ idx.drop( key, Strings.getUUID( 0L ) );
assertNull( idx.forwardLookup( key ) );
- assertNull( idx.reverseLookup( 0l ) );
+ assertNull( idx.reverseLookup( Strings.getUUID( 0L ) ) );
}
@@ -330,44 +332,44 @@ public class JdbmRdnIndexTest
{
initIndex();
- ParentIdAndRdn<Long> key = new ParentIdAndRdn<Long>( 0L, new Rdn( "cn=key" ) );
+ ParentIdAndRdn key = new ParentIdAndRdn( Strings.getUUID( 0L ), new Rdn( "cn=key" ) );
assertEquals( 0, idx.count() );
- idx.add( key, 0l );
+ idx.add( key, Strings.getUUID( 0L ) );
assertEquals( 1, idx.count() );
for ( long i = 1; i < 5; i++ )
{
- key = new ParentIdAndRdn<Long>( i, new Rdn( "cn=key" + i ) );
+ key = new ParentIdAndRdn( Strings.getUUID( i ), new Rdn( "cn=key" + i ) );
- idx.add( key, ( long ) i );
+ idx.add( key, Strings.getUUID( i ) );
}
assertEquals( 5, idx.count() );
// use forward index's cursor
- Cursor<IndexEntry<ParentIdAndRdn<Long>, Long>> cursor = idx.forwardCursor();
+ Cursor<IndexEntry<ParentIdAndRdn, String>> cursor = idx.forwardCursor();
cursor.beforeFirst();
cursor.next();
- IndexEntry<ParentIdAndRdn<Long>, Long> e1 = cursor.get();
- assertEquals( 0, ( long ) e1.getId() );
+ IndexEntry<ParentIdAndRdn, String> e1 = cursor.get();
+ assertEquals( Strings.getUUID( 0L ), e1.getId() );
assertEquals( "cn=key", e1.getKey().getRdns()[0].getName() );
- assertEquals( 0, e1.getKey().getParentId().longValue() );
+ assertEquals( Strings.getUUID( 0L ), e1.getKey().getParentId() );
cursor.next();
- IndexEntry<ParentIdAndRdn<Long>, Long> e2 = cursor.get();
- assertEquals( 1, ( long ) e2.getId() );
+ IndexEntry<ParentIdAndRdn, String> e2 = cursor.get();
+ assertEquals( Strings.getUUID( 1L ), e2.getId() );
assertEquals( "cn=key1", e2.getKey().getRdns()[0].getName() );
- assertEquals( 1, e2.getKey().getParentId().longValue() );
+ assertEquals( Strings.getUUID( 1L ), e2.getKey().getParentId() );
cursor.next();
- IndexEntry<ParentIdAndRdn<Long>, Long> e3 = cursor.get();
- assertEquals( 2, ( long ) e3.getId() );
+ IndexEntry<ParentIdAndRdn, String> e3 = cursor.get();
+ assertEquals( Strings.getUUID( 2L ), e3.getId() );
assertEquals( "cn=key2", e3.getKey().getRdns()[0].getName() );
- assertEquals( 2, e3.getKey().getParentId().longValue() );
-
+ assertEquals( Strings.getUUID( 2 ), e3.getKey().getParentId() );
+
cursor.close();
}
Modified: directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java?rev=1389184&r1=1389183&r2=1389184&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java (original)
+++ directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java Mon Sep 24 02:17:13 2012
@@ -36,13 +36,11 @@ import org.apache.directory.server.const
import org.apache.directory.server.core.api.interceptor.context.AddOperationContext;
import org.apache.directory.server.core.api.interceptor.context.LookupOperationContext;
import org.apache.directory.server.xdbm.Index;
-import org.apache.directory.server.xdbm.IndexEntry;
import org.apache.directory.server.xdbm.IndexNotFoundException;
import org.apache.directory.server.xdbm.Store;
import org.apache.directory.server.xdbm.StoreUtils;
import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
import org.apache.directory.shared.ldap.model.csn.CsnFactory;
-import org.apache.directory.shared.ldap.model.cursor.Cursor;
import org.apache.directory.shared.ldap.model.entry.Attribute;
import org.apache.directory.shared.ldap.model.entry.DefaultAttribute;
import org.apache.directory.shared.ldap.model.entry.DefaultEntry;
@@ -60,6 +58,7 @@ import org.apache.directory.shared.ldap.
import org.apache.directory.shared.ldap.schemaextractor.impl.DefaultSchemaLdifExtractor;
import org.apache.directory.shared.ldap.schemaloader.LdifSchemaLoader;
import org.apache.directory.shared.ldap.schemamanager.impl.DefaultSchemaManager;
+import org.apache.directory.shared.util.Strings;
import org.apache.directory.shared.util.exception.Exceptions;
import org.junit.After;
import org.junit.Before;
@@ -147,11 +146,11 @@ public class JdbmStoreTest
store.setPartitionPath( wkdir.toURI() );
store.setSyncOnWrite( false );
- JdbmIndex ouIndex = new JdbmIndex( SchemaConstants.OU_AT_OID );
+ JdbmIndex ouIndex = new JdbmIndex( SchemaConstants.OU_AT_OID, false );
ouIndex.setWkDirPath( wkdir.toURI() );
store.addIndex( ouIndex );
- JdbmIndex uidIndex = new JdbmIndex( SchemaConstants.UID_AT_OID );
+ JdbmIndex uidIndex = new JdbmIndex( SchemaConstants.UID_AT_OID, false );
uidIndex.setWkDirPath( wkdir.toURI() );
store.addIndex( uidIndex );
@@ -204,24 +203,24 @@ public class JdbmStoreTest
store2.setCacheSize( 10 );
store2.setPartitionPath( wkdir2.toURI() );
store2.setSyncOnWrite( false );
- store2.addIndex( new JdbmIndex( SchemaConstants.OU_AT_OID ) );
- store2.addIndex( new JdbmIndex( SchemaConstants.UID_AT_OID ) );
+ store2.addIndex( new JdbmIndex( SchemaConstants.OU_AT_OID, false ) );
+ store2.addIndex( new JdbmIndex( SchemaConstants.UID_AT_OID, false ) );
store2.setSuffixDn( EXAMPLE_COM );
store2.initialize();
// inject context entry
Dn suffixDn = new Dn( schemaManager, "dc=example,dc=com" );
Entry entry = new DefaultEntry( schemaManager, suffixDn,
- "objectClass: top",
+ "objectClass: top",
"objectClass: domain",
"dc: example",
SchemaConstants.ENTRY_CSN_AT, new CsnFactory( 0 ).newInstance().toString(),
SchemaConstants.ENTRY_UUID_AT, UUID.randomUUID().toString() );
-
+
store2.add( new AddOperationContext( null, entry ) );
// lookup the context entry
- Long id = store2.getEntryId( suffixDn );
+ String id = store2.getEntryId( suffixDn );
Entry lookup = store2.lookup( id, suffixDn );
assertEquals( 2, lookup.getDn().size() );
@@ -237,8 +236,9 @@ public class JdbmStoreTest
jdbmPartition.setSyncOnWrite( true ); // for code coverage
assertNull( jdbmPartition.getAliasIndex() );
- Index<String, Entry, Long> index = new JdbmIndex<String, Entry>( ApacheSchemaConstants.APACHE_ALIAS_AT_OID );
- ( ( Store<Entry, Long> ) jdbmPartition ).addIndex( index );
+ Index<String, Entry, String> index = new JdbmIndex<String, Entry>( ApacheSchemaConstants.APACHE_ALIAS_AT_OID,
+ true );
+ ( ( Store ) jdbmPartition ).addIndex( index );
assertNotNull( jdbmPartition.getAliasIndex() );
assertEquals( JdbmPartition.DEFAULT_CACHE_SIZE, jdbmPartition.getCacheSize() );
@@ -246,7 +246,7 @@ public class JdbmStoreTest
assertEquals( 24, jdbmPartition.getCacheSize() );
assertNull( jdbmPartition.getPresenceIndex() );
- jdbmPartition.addIndex( new JdbmIndex<String, Entry>( ApacheSchemaConstants.APACHE_PRESENCE_AT_OID ) );
+ jdbmPartition.addIndex( new JdbmIndex<String, Entry>( ApacheSchemaConstants.APACHE_PRESENCE_AT_OID, false ) );
assertNotNull( jdbmPartition.getPresenceIndex() );
assertNull( jdbmPartition.getId() );
@@ -254,16 +254,16 @@ public class JdbmStoreTest
assertEquals( "foo", jdbmPartition.getId() );
assertNull( jdbmPartition.getRdnIndex() );
- jdbmPartition.addIndex( new JdbmRdnIndex( ApacheSchemaConstants.APACHE_RDN_AT_OID ) );
+ jdbmPartition.addIndex( new JdbmRdnIndex() );
assertNotNull( jdbmPartition.getRdnIndex() );
assertNull( jdbmPartition.getOneAliasIndex() );
- ( ( Store<Entry, Long> ) jdbmPartition ).addIndex( new JdbmIndex<Long, Entry>(
- ApacheSchemaConstants.APACHE_ONE_ALIAS_AT_OID ) );
+ ( ( Store ) jdbmPartition ).addIndex( new JdbmIndex<Long, Entry>(
+ ApacheSchemaConstants.APACHE_ONE_ALIAS_AT_OID, true ) );
assertNotNull( jdbmPartition.getOneAliasIndex() );
assertNull( jdbmPartition.getSubAliasIndex() );
- jdbmPartition.addIndex( new JdbmIndex<Long, Entry>( ApacheSchemaConstants.APACHE_SUB_ALIAS_AT_OID ) );
+ jdbmPartition.addIndex( new JdbmIndex<Long, Entry>( ApacheSchemaConstants.APACHE_SUB_ALIAS_AT_OID, true ) );
assertNotNull( jdbmPartition.getSubAliasIndex() );
assertNull( jdbmPartition.getSuffixDn() );
@@ -273,7 +273,7 @@ public class JdbmStoreTest
assertNotNull( jdbmPartition.getSuffixDn() );
assertFalse( jdbmPartition.getUserIndices().hasNext() );
- jdbmPartition.addIndex( new JdbmIndex<Object, Entry>( "2.5.4.3" ) );
+ jdbmPartition.addIndex( new JdbmIndex<Object, Entry>( "2.5.4.3", false ) );
assertEquals( true, jdbmPartition.getUserIndices().hasNext() );
assertNull( jdbmPartition.getPartitionPath() );
@@ -297,7 +297,7 @@ public class JdbmStoreTest
assertNotNull( store.getAliasIndex() );
try
{
- store.addIndex( new JdbmIndex<String, Entry>( ApacheSchemaConstants.APACHE_ALIAS_AT_OID ) );
+ store.addIndex( new JdbmIndex<String, Entry>( ApacheSchemaConstants.APACHE_ALIAS_AT_OID, true ) );
fail();
}
catch ( IllegalStateException e )
@@ -316,7 +316,7 @@ public class JdbmStoreTest
assertNotNull( store.getPresenceIndex() );
try
{
- store.addIndex( new JdbmIndex<String, Entry>( ApacheSchemaConstants.APACHE_PRESENCE_AT_OID ) );
+ store.addIndex( new JdbmIndex<String, Entry>( ApacheSchemaConstants.APACHE_PRESENCE_AT_OID, false ) );
fail();
}
catch ( IllegalStateException e )
@@ -333,12 +333,10 @@ public class JdbmStoreTest
{
}
- assertNotNull( store.getEntryUuidIndex() );
-
assertNotNull( store.getRdnIndex() );
try
{
- store.addIndex( new JdbmRdnIndex( ApacheSchemaConstants.APACHE_RDN_AT_OID ) );
+ store.addIndex( new JdbmRdnIndex() );
fail();
}
catch ( IllegalStateException e )
@@ -348,7 +346,7 @@ public class JdbmStoreTest
assertNotNull( store.getOneAliasIndex() );
try
{
- store.addIndex( new JdbmIndex<Long, Entry>( ApacheSchemaConstants.APACHE_ONE_ALIAS_AT_OID ) );
+ store.addIndex( new JdbmIndex<Long, Entry>( ApacheSchemaConstants.APACHE_ONE_ALIAS_AT_OID, true ) );
fail();
}
catch ( IllegalStateException e )
@@ -358,7 +356,7 @@ public class JdbmStoreTest
assertNotNull( store.getSubAliasIndex() );
try
{
- store.addIndex( new JdbmIndex<Long, Entry>( ApacheSchemaConstants.APACHE_SUB_ALIAS_AT_OID ) );
+ store.addIndex( new JdbmIndex<Long, Entry>( ApacheSchemaConstants.APACHE_SUB_ALIAS_AT_OID, true ) );
fail();
}
catch ( IllegalStateException e )
@@ -377,7 +375,7 @@ public class JdbmStoreTest
Iterator<String> systemIndices = store.getSystemIndices();
- for ( int ii = 0; ii < 8; ii++ )
+ for ( int i = 0; i < 7; i++ )
{
assertTrue( systemIndices.hasNext() );
assertNotNull( systemIndices.next() );
@@ -425,7 +423,7 @@ public class JdbmStoreTest
assertNotNull( userIndices.next() );
assertFalse( userIndices.hasNext() );
assertNotNull( store.getUserIndex( OU_AT ) );
-
+
try
{
store.getUserIndex( SN_AT );
@@ -464,71 +462,72 @@ public class JdbmStoreTest
public void testFreshStore() throws Exception
{
Dn dn = new Dn( schemaManager, "o=Good Times Co." );
- assertEquals( 1L, ( long ) store.getEntryId( dn ) );
+ assertEquals( Strings.getUUID( 1L ), store.getEntryId( dn ) );
assertEquals( 11, store.count() );
- assertEquals( "o=Good Times Co.", store.getEntryDn( 1L ).getName() );
- assertEquals( dn.getNormName(), store.getEntryDn( 1L ).getNormName() );
- assertEquals( dn.getName(), store.getEntryDn( 1L ).getName() );
+ assertEquals( "o=Good Times Co.", store.getEntryDn( Strings.getUUID( 1L ) ).getName() );
+ assertEquals( dn.getNormName(), store.getEntryDn( Strings.getUUID( 1L ) ).getNormName() );
+ assertEquals( dn.getName(), store.getEntryDn( Strings.getUUID( 1L ) ).getName() );
// note that the suffix entry returns 0 for it's parent which does not exist
- assertEquals( 0L, ( long ) store.getParentId( store.getEntryId( dn ) ) );
- assertNull( store.getParentId( 0L ) );
+ assertEquals( Strings.getUUID( 0L ), store.getParentId( store.getEntryId( dn ) ) );
+ assertNull( store.getParentId( Strings.getUUID( 0L ) ) );
// should NOW be allowed
- store.delete( 1L );
+ store.delete( Strings.getUUID( 1L ) );
}
+ /*
@Test
public void testEntryOperations() throws Exception
{
- assertEquals( 3, store.getChildCount( 1L ) );
+ assertEquals( 3, store.getChildCount( Strings.getUUID( 1L ) ) );
- Cursor<IndexEntry<Long, Long>> cursor = store.list( 1L );
+ Cursor<IndexEntry<String, String>> cursor = store.list( Strings.getUUID( 1L ) );
assertNotNull( cursor );
cursor.beforeFirst();
assertTrue( cursor.next() );
- assertEquals( 3L, ( long ) cursor.get().getId() );
+ assertEquals( Strings.getUUID( 3L ), cursor.get().getId() );
assertTrue( cursor.next() );
- assertEquals( 4L, ( long ) cursor.get().getId() );
+ assertEquals( Strings.getUUID( 4L ), cursor.get().getId() );
assertTrue( cursor.next() );
- assertEquals( 2L, ( long ) cursor.get().getId() );
+ assertEquals( Strings.getUUID( 2L ), cursor.get().getId() );
assertFalse( cursor.next() );
-
+
cursor.close();
-
- assertEquals( 3, store.getChildCount( 1L ) );
- store.delete( 2L );
- assertEquals( 2, store.getChildCount( 1L ) );
+ assertEquals( 3, store.getChildCount( Strings.getUUID( 1L ) ) );
+
+ store.delete( Strings.getUUID( 2L ) );
+ assertEquals( 2, store.getChildCount( Strings.getUUID( 1L ) ) );
assertEquals( 10, store.count() );
// add an alias and delete to test dropAliasIndices method
Dn dn = new Dn( schemaManager, "commonName=Jack Daniels,ou=Apache,ou=Board of Directors,o=Good Times Co." );
Entry entry = new DefaultEntry( schemaManager, dn,
- "objectClass: top",
- "objectClass: alias",
+ "objectClass: top",
+ "objectClass: alias",
"objectClass: extensibleObject",
"ou: Apache",
"commonName: Jack Daniels",
"aliasedObjectName: cn=Jack Daniels,ou=Engineering,o=Good Times Co.",
"entryCSN", new CsnFactory( 1 ).newInstance().toString(),
- "entryUUID", UUID.randomUUID().toString() );
+ "entryUUID", Strings.getUUID( 12L ).toString() );
AddOperationContext addContext = new AddOperationContext( null, entry );
store.add( addContext );
- store.delete( 12L ); // drops the alias indices
+ store.delete( Strings.getUUID( 12L ) ); // drops the alias indices
}
-
+ */
@Test(expected = LdapNoSuchObjectException.class)
public void testAddWithoutParentId() throws Exception
{
Dn dn = new Dn( schemaManager, "cn=Marting King,ou=Not Present,o=Good Times Co." );
Entry entry = new DefaultEntry( schemaManager, dn,
- "objectClass: top",
- "objectClass: person",
+ "objectClass: top",
+ "objectClass: person",
"objectClass: organizationalPerson",
"ou: Not Present",
"cn: Martin King" );
@@ -568,8 +567,8 @@ public class JdbmStoreTest
{
Dn dn = new Dn( schemaManager, "cn=Private Ryan,ou=Engineering,o=Good Times Co." );
Entry entry = new DefaultEntry( schemaManager, dn,
- "objectClass: top",
- "objectClass: person",
+ "objectClass: top",
+ "objectClass: person",
"objectClass: organizationalPerson",
"ou: Engineering",
"cn: Private Ryan",
@@ -595,8 +594,8 @@ public class JdbmStoreTest
{
Dn dn = new Dn( schemaManager, "cn=Private Ryan,ou=Engineering,o=Good Times Co." );
Entry entry = new DefaultEntry( schemaManager, dn,
- "objectClass: top",
- "objectClass: person",
+ "objectClass: top",
+ "objectClass: person",
"objectClass: organizationalPerson",
"ou: Engineering",
"cn: Private Ryan",
@@ -611,7 +610,7 @@ public class JdbmStoreTest
store.rename( dn, rdn, true, null );
Dn dn2 = new Dn( schemaManager, "sn=Ja\\+es,ou=Engineering,o=Good Times Co." );
- Long id = store.getEntryId( dn2 );
+ String id = store.getEntryId( dn2 );
assertNotNull( id );
Entry entry2 = store.lookup( id, dn2 );
assertEquals( "Ja+es", entry2.get( "sn" ).getString() );
@@ -623,8 +622,8 @@ public class JdbmStoreTest
{
Dn childDn = new Dn( schemaManager, "cn=Private Ryan,ou=Engineering,o=Good Times Co." );
Entry childEntry = new DefaultEntry( schemaManager, childDn,
- "objectClass: top",
- "objectClass: person",
+ "objectClass: top",
+ "objectClass: person",
"objectClass: organizationalPerson",
"ou", "Engineering",
"cn", "Private Ryan",
@@ -734,8 +733,8 @@ public class JdbmStoreTest
{
Dn dn = new Dn( schemaManager, "cn=Tim B,ou=Sales,o=Good Times Co." );
Entry entry = new DefaultEntry( schemaManager, dn,
- "objectClass: top",
- "objectClass: person",
+ "objectClass: top",
+ "objectClass: person",
"objectClass: organizationalPerson",
"cn", "Tim B",
"entryCSN", new CsnFactory( 1 ).newInstance().toString(),
@@ -766,22 +765,17 @@ public class JdbmStoreTest
File ouIndexDbFile = new File( wkdir, SchemaConstants.OU_AT_OID + ".db" );
File ouIndexTxtFile = new File( wkdir, SchemaConstants.OU_AT_OID + "-ou.txt" );
File uuidIndexDbFile = new File( wkdir, SchemaConstants.ENTRY_UUID_AT_OID + ".db" );
- File uuidIndexTxtFile = new File( wkdir, SchemaConstants.ENTRY_UUID_AT_OID + "-entryUUID.txt" );
assertTrue( ouIndexDbFile.exists() );
assertTrue( ouIndexTxtFile.exists() );
- assertTrue( uuidIndexDbFile.exists() );
- assertTrue( uuidIndexTxtFile.exists() );
// destroy the store to manually start the init phase
// by keeping the same work dir
store.destroy();
- // just assert again that ou and entryUUID files exist even after destroying the store
+ // just assert again that ou files exist even after destroying the store
assertTrue( ouIndexDbFile.exists() );
assertTrue( ouIndexTxtFile.exists() );
- assertTrue( uuidIndexDbFile.exists() );
- assertTrue( uuidIndexTxtFile.exists() );
store = new JdbmPartition( schemaManager );
store.setId( "example" );
@@ -789,7 +783,7 @@ public class JdbmStoreTest
store.setPartitionPath( wkdir.toURI() );
store.setSyncOnWrite( false );
// do not add ou index this time
- store.addIndex( new JdbmIndex( SchemaConstants.UID_AT_OID ) );
+ store.addIndex( new JdbmIndex( SchemaConstants.UID_AT_OID, false ) );
Dn suffixDn = new Dn( schemaManager, "o=Good Times Co." );
store.setSuffixDn( suffixDn );
@@ -798,8 +792,5 @@ public class JdbmStoreTest
assertFalse( ouIndexDbFile.exists() );
assertFalse( ouIndexTxtFile.exists() );
-
- assertTrue( uuidIndexDbFile.exists() );
- assertTrue( uuidIndexTxtFile.exists() );
}
}
Modified: directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyBTreeCursorTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyBTreeCursorTest.java?rev=1389184&r1=1389183&r2=1389184&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyBTreeCursorTest.java (original)
+++ directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyBTreeCursorTest.java Mon Sep 24 02:17:13 2012
@@ -36,6 +36,7 @@ import jdbm.helper.Tuple;
import jdbm.helper.TupleBrowser;
import jdbm.recman.BaseRecordManager;
+import org.apache.directory.shared.util.Strings;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -51,7 +52,6 @@ import org.slf4j.LoggerFactory;
public class KeyBTreeCursorTest
{
private static final Logger LOG = LoggerFactory.getLogger( KeyBTreeCursorTest.class.getSimpleName() );
- private static final byte[] EMPTY_BYTES = new byte[0];
private static final String TEST_OUTPUT_PATH = "test.output.path";
File dbFile;
@@ -78,16 +78,16 @@ public class KeyBTreeCursorTest
bt = new BTree<String, byte[]>( recman, comparator );
// add some data to it
- bt.insert( "0", EMPTY_BYTES, true );
- bt.insert( "1", EMPTY_BYTES, true );
- bt.insert( "2", EMPTY_BYTES, true );
- bt.insert( "3", EMPTY_BYTES, true );
- bt.insert( "4", EMPTY_BYTES, true );
- bt.insert( "5", EMPTY_BYTES, true );
- bt.insert( "6", EMPTY_BYTES, true );
- bt.insert( "7", EMPTY_BYTES, true );
- bt.insert( "8", EMPTY_BYTES, true );
- bt.insert( "9", EMPTY_BYTES, true );
+ bt.insert( "0", Strings.EMPTY_BYTES, true );
+ bt.insert( "1", Strings.EMPTY_BYTES, true );
+ bt.insert( "2", Strings.EMPTY_BYTES, true );
+ bt.insert( "3", Strings.EMPTY_BYTES, true );
+ bt.insert( "4", Strings.EMPTY_BYTES, true );
+ bt.insert( "5", Strings.EMPTY_BYTES, true );
+ bt.insert( "6", Strings.EMPTY_BYTES, true );
+ bt.insert( "7", Strings.EMPTY_BYTES, true );
+ bt.insert( "8", Strings.EMPTY_BYTES, true );
+ bt.insert( "9", Strings.EMPTY_BYTES, true );
cursor = new KeyBTreeCursor<String>( bt, comparator );
LOG.debug( "Created new KeyBTreeCursor and populated it's btree" );
@@ -106,7 +106,7 @@ public class KeyBTreeCursorTest
new File( fileToDelete + ".lg" ).delete();
dbFile = null;
-
+
cursor.close();
}
Modified: directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyCursorTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyCursorTest.java?rev=1389184&r1=1389183&r2=1389184&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyCursorTest.java (original)
+++ directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyCursorTest.java Mon Sep 24 02:17:13 2012
@@ -36,6 +36,7 @@ import jdbm.helper.Tuple;
import jdbm.helper.TupleBrowser;
import jdbm.recman.BaseRecordManager;
+import org.apache.directory.shared.util.Strings;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -51,7 +52,6 @@ import org.slf4j.LoggerFactory;
public class KeyCursorTest
{
private static final Logger LOG = LoggerFactory.getLogger( KeyCursorTest.class.getSimpleName() );
- private static final byte[] EMPTY_BYTES = new byte[0];
private static final String TEST_OUTPUT_PATH = "test.output.path";
File dbFile;
@@ -78,16 +78,16 @@ public class KeyCursorTest
bt = new BTree<String, byte[]>( recman, comparator );
// add some data to it
- bt.insert( "0", EMPTY_BYTES, true );
- bt.insert( "1", EMPTY_BYTES, true );
- bt.insert( "2", EMPTY_BYTES, true );
- bt.insert( "3", EMPTY_BYTES, true );
- bt.insert( "4", EMPTY_BYTES, true );
- bt.insert( "5", EMPTY_BYTES, true );
- bt.insert( "6", EMPTY_BYTES, true );
- bt.insert( "7", EMPTY_BYTES, true );
- bt.insert( "8", EMPTY_BYTES, true );
- bt.insert( "9", EMPTY_BYTES, true );
+ bt.insert( "0", Strings.EMPTY_BYTES, true );
+ bt.insert( "1", Strings.EMPTY_BYTES, true );
+ bt.insert( "2", Strings.EMPTY_BYTES, true );
+ bt.insert( "3", Strings.EMPTY_BYTES, true );
+ bt.insert( "4", Strings.EMPTY_BYTES, true );
+ bt.insert( "5", Strings.EMPTY_BYTES, true );
+ bt.insert( "6", Strings.EMPTY_BYTES, true );
+ bt.insert( "7", Strings.EMPTY_BYTES, true );
+ bt.insert( "8", Strings.EMPTY_BYTES, true );
+ bt.insert( "9", Strings.EMPTY_BYTES, true );
cursor = new KeyBTreeCursor<String>( bt, comparator );
LOG.debug( "Created new KeyBTreeCursor and populated it's btree" );
@@ -106,7 +106,7 @@ public class KeyCursorTest
new File( fileToDelete + ".lg" ).delete();
dbFile = null;
-
+
cursor.close();
}
Modified: directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyTupleArrayCursorTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyTupleArrayCursorTest.java?rev=1389184&r1=1389183&r2=1389184&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyTupleArrayCursorTest.java (original)
+++ directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyTupleArrayCursorTest.java Mon Sep 24 02:17:13 2012
@@ -26,6 +26,7 @@ import static junit.framework.Assert.ass
import java.util.Comparator;
import org.apache.directory.server.core.avltree.ArrayTree;
+import org.apache.directory.server.xdbm.KeyTupleArrayCursor;
import org.apache.directory.shared.ldap.model.cursor.InvalidCursorPositionException;
import org.apache.directory.shared.ldap.model.cursor.Tuple;
import org.junit.After;
Modified: directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/StringSerializerTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/StringSerializerTest.java?rev=1389184&r1=1389183&r2=1389184&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/StringSerializerTest.java (original)
+++ directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/StringSerializerTest.java Mon Sep 24 02:17:13 2012
@@ -20,15 +20,16 @@
package org.apache.directory.server.core.partition.impl.btree.jdbm;
+import static org.junit.Assert.assertEquals;
+
import java.io.IOException;
import org.apache.commons.lang.RandomStringUtils;
-import com.mycila.junit.concurrent.Concurrency;
-import com.mycila.junit.concurrent.ConcurrentJunitRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
-import static org.junit.Assert.assertEquals;
+import com.mycila.junit.concurrent.Concurrency;
+import com.mycila.junit.concurrent.ConcurrentJunitRunner;
/**
@@ -42,10 +43,11 @@ public class StringSerializerTest
@Test
public void testRandom() throws IOException
{
- StringSerializer serializer = new StringSerializer();
- for ( int ii = 0; ii < 100; ii++ )
+ StringSerializer serializer = StringSerializer.INSTANCE;
+
+ for ( int i = 0; i < 100; i++ )
{
- String str = RandomStringUtils.random( ii );
+ String str = RandomStringUtils.random( i );
byte[] serialized = serializer.serialize( str );
String deserialized = ( String ) serializer.deserialize( serialized );
assertEquals( str, deserialized );
@@ -57,6 +59,7 @@ public class StringSerializerTest
{
int ch = bites[0] << 8 & 0x0000FF00;
ch |= bites[1] & 0x000000FF;
+
return ( char ) ch;
}
@@ -66,6 +69,7 @@ public class StringSerializerTest
byte[] bites = new byte[2];
bites[0] = ( byte ) ( ch >> 8 & 0x00FF );
bites[1] = ( byte ) ( ch & 0x00FF );
+
return bites;
}
Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/Des3CbcSha1KdEncryption.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/Des3CbcSha1KdEncryption.java?rev=1389184&r1=1389183&r2=1389184&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/Des3CbcSha1KdEncryption.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/Des3CbcSha1KdEncryption.java Mon Sep 24 02:17:13 2012
@@ -31,12 +31,13 @@ import javax.crypto.spec.IvParameterSpec
import javax.crypto.spec.SecretKeySpec;
import org.apache.directory.server.kerberos.shared.crypto.checksum.ChecksumEngine;
-import org.apache.directory.shared.kerberos.exceptions.KerberosException;
import org.apache.directory.shared.kerberos.codec.types.EncryptionType;
import org.apache.directory.shared.kerberos.components.EncryptedData;
import org.apache.directory.shared.kerberos.components.EncryptionKey;
import org.apache.directory.shared.kerberos.crypto.checksum.ChecksumType;
import org.apache.directory.shared.kerberos.exceptions.ErrorType;
+import org.apache.directory.shared.kerberos.exceptions.KerberosException;
+import org.apache.directory.shared.util.Strings;
/**
@@ -172,7 +173,7 @@ public class Des3CbcSha1KdEncryption ext
int kBytes = 24;
byte[] result = new byte[kBytes];
- byte[] fillingKey = new byte[0];
+ byte[] fillingKey = Strings.EMPTY_BYTES;
int pos = 0;
Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/TransitedEncoding.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/TransitedEncoding.java?rev=1389184&r1=1389183&r2=1389184&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/TransitedEncoding.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/TransitedEncoding.java Mon Sep 24 02:17:13 2012
@@ -27,9 +27,9 @@ import java.util.Arrays;
import org.apache.directory.server.i18n.I18n;
import org.apache.directory.shared.asn1.AbstractAsn1Object;
import org.apache.directory.shared.asn1.EncoderException;
+import org.apache.directory.shared.asn1.ber.tlv.BerValue;
import org.apache.directory.shared.asn1.ber.tlv.TLV;
import org.apache.directory.shared.asn1.ber.tlv.UniversalTag;
-import org.apache.directory.shared.asn1.ber.tlv.BerValue;
import org.apache.directory.shared.kerberos.KerberosConstants;
import org.apache.directory.shared.kerberos.codec.types.TransitedEncodingType;
import org.apache.directory.shared.util.Strings;
@@ -80,7 +80,7 @@ public class TransitedEncoding extends A
public TransitedEncoding()
{
trType = TransitedEncodingType.NULL;
- contents = new byte[0];
+ contents = Strings.EMPTY_BYTES;
}
Modified: directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/KerberosTestUtils.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/KerberosTestUtils.java?rev=1389184&r1=1389183&r2=1389184&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/KerberosTestUtils.java (original)
+++ directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/KerberosTestUtils.java Mon Sep 24 02:17:13 2012
@@ -42,6 +42,7 @@ import javax.security.auth.login.LoginEx
import org.apache.directory.ldap.client.api.Krb5LoginConfiguration;
import org.apache.directory.server.i18n.I18n;
+import org.apache.directory.shared.util.Strings;
import org.ietf.jgss.GSSContext;
import org.ietf.jgss.GSSCredential;
import org.ietf.jgss.GSSException;
@@ -392,9 +393,9 @@ public class KerberosTestUtils
context.requestConf( true );
context.requestInteg( true );
- context.initSecContext( new byte[0], 0, 0 );
+ context.initSecContext( Strings.EMPTY_BYTES, 0, 0 );
- // byte[] outToken = context.initSecContext( new byte[0], 0, 0 );
+ // byte[] outToken = context.initSecContext( Strings.EMPTY_BYTES, 0, 0 );
// System.out.println(new BASE64Encoder().encode(outToken));
context.dispose();
Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java?rev=1389184&r1=1389183&r2=1389184&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java (original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java Mon Sep 24 02:17:13 2012
@@ -127,9 +127,9 @@ public class LdapConnectionTest extends
"objectClass: top",
"uid: kayyagari",
"ref: ldap://ad.example.com/uid=kayyagari,ou=system"
- })
- @Test
- public void testLookup() throws Exception
+ })
+@Test
+public void testLookup() throws Exception
{
Entry entry = connection.lookup( ADMIN_DN );
assertNull( entry.get( SchemaConstants.ENTRY_UUID_AT ) );
@@ -174,22 +174,22 @@ public class LdapConnectionTest extends
config.setBinaryAttributeDetector( new DefaultConfigurableBinaryAttributeDetector() );
LdapConnection myConnection = new LdapNetworkConnection( config );
-
+
// Remove the UserPassword from the list
- ((ConfigurableBinaryAttributeDetector)config.getBinaryAttributeDetector()).
+ ( ( ConfigurableBinaryAttributeDetector ) config.getBinaryAttributeDetector() ).
removeBinaryAttribute( "userPassword" );
myConnection.bind( "uid=admin,ou=system", "secret" );
Entry entry = myConnection.lookup( "uid=admin,ou=system" );
assertTrue( entry.get( SchemaConstants.USER_PASSWORD_AT ).get().isHumanReadable() );
-
+
// Now, load a new binary Attribute
- ((ConfigurableBinaryAttributeDetector)config.getBinaryAttributeDetector()).
+ ( ( ConfigurableBinaryAttributeDetector ) config.getBinaryAttributeDetector() ).
addBinaryAttribute( "userPassword" );
entry = myConnection.lookup( "uid=admin,ou=system" );
assertFalse( entry.get( SchemaConstants.USER_PASSWORD_AT ).get().isHumanReadable() );
// Now, test using the scerver's schema
- ((LdapNetworkConnection)connection).loadSchema();
+ ( ( LdapNetworkConnection ) connection ).loadSchema();
connection.bind( "uid=admin,ou=system", "secret" );
// Use the default list of binary Attributes
@@ -243,8 +243,8 @@ public class LdapConnectionTest extends
assertTrue( connection.isAuthenticated() );
connection.close();
}
-
-
+
+
/**
* Test a connection which does not have any schemaManager loaded
*/
@@ -257,20 +257,20 @@ public class LdapConnectionTest extends
"objectClass: top",
"uid: kayyagari",
"ref: ldap://ad.example.com/uid=kayyagari,ou=system"
- })
- @Test
- public void testNoSchemaConnection() throws Exception
+ })
+@Test
+public void testNoSchemaConnection() throws Exception
{
LdapConnection ldapConnection = new LdapNetworkConnection( "localHost", ldapServer.getPort() );
-
+
ldapConnection.bind( "uid=admin,ou=system", "secret" );
-
+
// Try to retrieve a binary attribute : it should be seen as a String
Entry entry = ldapConnection.lookup( "uid=admin,ou=system" );
assertTrue( entry.get( SchemaConstants.USER_PASSWORD_AT ).get().isHumanReadable() );
}
-
-
+
+
/**
* Test a connection which does not have any schemaManager loaded but in which connection we
* inject a BinaryAttributeDetector
@@ -282,11 +282,11 @@ public class LdapConnectionTest extends
config.setLdapHost( "localhost" );
config.setLdapPort( ldapServer.getPort() );
config.setBinaryAttributeDetector( new DefaultConfigurableBinaryAttributeDetector() );
-
+
LdapConnection ldapConnection = new LdapNetworkConnection( config );
-
+
ldapConnection.bind( "uid=admin,ou=system", "secret" );
-
+
// Try to retrieve a binary attribute : it should be seen as a byte[]
Entry entry = ldapConnection.lookup( "uid=admin,ou=system" );
assertFalse( entry.get( SchemaConstants.USER_PASSWORD_AT ).get().isHumanReadable() );
Modified: directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/AbstractLdifPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/AbstractLdifPartition.java?rev=1389184&r1=1389183&r2=1389184&view=diff
==============================================================================
--- directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/AbstractLdifPartition.java (original)
+++ directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/AbstractLdifPartition.java Mon Sep 24 02:17:13 2012
@@ -23,6 +23,7 @@ package org.apache.directory.server.core
import java.net.URI;
+import org.apache.directory.server.core.api.partition.Partition;
import org.apache.directory.server.core.partition.impl.avl.AvlPartition;
import org.apache.directory.shared.ldap.model.csn.CsnFactory;
import org.apache.directory.shared.ldap.model.schema.SchemaManager;
@@ -55,9 +56,9 @@ public abstract class AbstractLdifPartit
/**
* {@inheritDoc}
*/
- public Long getDefaultId()
+ public String getDefaultId()
{
- return 1L;
+ return Partition.DEFAULT_ID;
}
Modified: directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java?rev=1389184&r1=1389183&r2=1389184&view=diff
==============================================================================
--- directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java (original)
+++ directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java Mon Sep 24 02:17:13 2012
@@ -34,13 +34,12 @@ import org.apache.directory.server.core.
import org.apache.directory.server.core.api.interceptor.context.MoveOperationContext;
import org.apache.directory.server.core.api.interceptor.context.RenameOperationContext;
import org.apache.directory.server.i18n.I18n;
-import org.apache.directory.server.xdbm.ForwardIndexEntry;
-import org.apache.directory.server.xdbm.IndexCursor;
import org.apache.directory.server.xdbm.IndexEntry;
import org.apache.directory.server.xdbm.ParentIdAndRdn;
import org.apache.directory.server.xdbm.SingletonIndexCursor;
-import org.apache.directory.server.xdbm.search.impl.DescendantCursor;
+import org.apache.directory.server.xdbm.search.cursor.DescendantCursor;
import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.model.cursor.Cursor;
import org.apache.directory.shared.ldap.model.entry.DefaultEntry;
import org.apache.directory.shared.ldap.model.entry.Entry;
import org.apache.directory.shared.ldap.model.entry.Modification;
@@ -149,10 +148,7 @@ public class LdifPartition extends Abstr
throw new LdapInvalidDnException( msg );
}
- if ( !suffixDn.isSchemaAware() )
- {
- suffixDn.apply( schemaManager );
- }
+ suffixDn.apply( schemaManager );
String suffixDirName = getFileName( suffixDn );
suffixDirectory = new File( partitionDir, suffixDirName );
@@ -226,7 +222,7 @@ public class LdifPartition extends Abstr
/**
* {@inheritDoc}
*/
- public void delete( Long id ) throws LdapException
+ public void delete( String id ) throws LdapException
{
Entry entry = lookup( id );
@@ -258,7 +254,7 @@ public class LdifPartition extends Abstr
*/
public void modify( ModifyOperationContext modifyContext ) throws LdapException
{
- Long id = getEntryId( modifyContext.getDn() );
+ String id = getEntryId( modifyContext.getDn() );
try
{
@@ -297,7 +293,7 @@ public class LdifPartition extends Abstr
public void move( MoveOperationContext moveContext ) throws LdapException
{
Dn oldDn = moveContext.getDn();
- Long id = getEntryId( oldDn );
+ String id = getEntryId( oldDn );
super.move( moveContext );
@@ -321,7 +317,7 @@ public class LdifPartition extends Abstr
public void moveAndRename( MoveAndRenameOperationContext moveAndRenameContext ) throws LdapException
{
Dn oldDn = moveAndRenameContext.getDn();
- Long id = getEntryId( oldDn );
+ String id = getEntryId( oldDn );
super.moveAndRename( moveAndRenameContext );
@@ -346,7 +342,7 @@ public class LdifPartition extends Abstr
public void rename( RenameOperationContext renameContext ) throws LdapException
{
Dn oldDn = renameContext.getDn();
- Long id = getEntryId( oldDn );
+ String id = getEntryId( oldDn );
// Create the new entry
super.rename( renameContext );
@@ -379,30 +375,31 @@ public class LdifPartition extends Abstr
* @param deleteOldEntry a flag to tell whether to delete the old entry files
* @throws Exception
*/
- private void entryMoved( Dn oldEntryDn, Entry modifiedEntry, Long entryIdOld ) throws Exception
+ private void entryMoved( Dn oldEntryDn, Entry modifiedEntry, String entryIdOld ) throws Exception
{
// First, add the new entry
addEntry( modifiedEntry );
-
- Long baseId = getEntryId( modifiedEntry.getDn() );
- ParentIdAndRdn<Long> parentIdAndRdn = getRdnIndex().reverseLookup( baseId );
- IndexEntry indexEntry = new ForwardIndexEntry();
-
- indexEntry.setId(baseId);
+ String baseId = getEntryId( modifiedEntry.getDn() );
+
+ ParentIdAndRdn parentIdAndRdn = getRdnIndex().reverseLookup( baseId );
+ IndexEntry indexEntry = new IndexEntry();
+
+ indexEntry.setId( baseId );
indexEntry.setKey( parentIdAndRdn );
- IndexCursor<ParentIdAndRdn<Long>,Entry, Long> cursor = new SingletonIndexCursor<ParentIdAndRdn<Long>, Long>( indexEntry );
- Long parentId = parentIdAndRdn.getParentId();
+ Cursor<IndexEntry<ParentIdAndRdn, String>> cursor = new SingletonIndexCursor<ParentIdAndRdn>(
+ indexEntry );
+ String parentId = parentIdAndRdn.getParentId();
- IndexCursor<Long, Entry, Long> scopeCursor = new DescendantCursor( this, baseId, parentId, cursor );
+ Cursor<IndexEntry<String, String>> scopeCursor = new DescendantCursor( this, baseId, parentId, cursor );
// Then, if there are some children, move then to the new place
try
{
while ( scopeCursor.next() )
{
- IndexEntry<Long, Long> entry = scopeCursor.get();
+ IndexEntry<String, String> entry = scopeCursor.get();
// except the parent entry add the rest of entries
if ( entry.getId() != entryIdOld )
@@ -417,7 +414,7 @@ public class LdifPartition extends Abstr
{
throw new LdapOperationException( e.getMessage(), e );
}
-
+
// And delete the old entry's LDIF file
File file = getFile( oldEntryDn, DELETE );
boolean deleted = deleteFile( file );
Modified: directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartition.java?rev=1389184&r1=1389183&r2=1389184&view=diff
==============================================================================
--- directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartition.java (original)
+++ directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartition.java Mon Sep 24 02:17:13 2012
@@ -35,11 +35,10 @@ import org.apache.directory.server.core.
import org.apache.directory.server.core.api.interceptor.context.MoveOperationContext;
import org.apache.directory.server.core.api.interceptor.context.RenameOperationContext;
import org.apache.directory.server.i18n.I18n;
-import org.apache.directory.server.xdbm.ForwardIndexEntry;
-import org.apache.directory.server.xdbm.IndexCursor;
import org.apache.directory.server.xdbm.IndexEntry;
import org.apache.directory.server.xdbm.ParentIdAndRdn;
import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.model.cursor.Cursor;
import org.apache.directory.shared.ldap.model.entry.DefaultEntry;
import org.apache.directory.shared.ldap.model.entry.Entry;
import org.apache.directory.shared.ldap.model.entry.Modification;
@@ -117,10 +116,7 @@ public class SingleFileLdifPartition ext
throw new LdapInvalidDnException( msg );
}
- if ( !suffixDn.isSchemaAware() )
- {
- suffixDn.apply( schemaManager );
- }
+ suffixDn.apply( schemaManager );
super.doInit();
@@ -262,7 +258,7 @@ public class SingleFileLdifPartition ext
@Override
- public void delete( Long id ) throws LdapException
+ public void delete( String id ) throws LdapException
{
synchronized ( lock )
{
@@ -292,22 +288,22 @@ public class SingleFileLdifPartition ext
{
ldifFile.setLength( 0 ); // wipe the file clean
- Long suffixId = getEntryId( suffixDn );
+ String suffixId = getEntryId( suffixDn );
if ( suffixId == null )
{
return;
}
- ParentIdAndRdn<Long> suffixEntry = rdnIdx.reverseLookup( suffixId );
-
+ ParentIdAndRdn suffixEntry = rdnIdx.reverseLookup( suffixId );
+
if ( suffixEntry != null )
{
Entry entry = master.get( suffixId );
entry.setDn( suffixDn );
appendLdif( entry );
-
+
appendRecursive( suffixId, suffixEntry.getNbChildren() );
}
@@ -324,36 +320,36 @@ public class SingleFileLdifPartition ext
}
}
-
- private void appendRecursive( Long id, int nbSibbling ) throws Exception
+
+ private void appendRecursive( String id, int nbSibbling ) throws Exception
{
// Start with the root
- IndexCursor<ParentIdAndRdn<Long>,Entry,Long> cursor = rdnIdx.forwardCursor();
-
- IndexEntry<ParentIdAndRdn<Long>, Long> startingPos = new ForwardIndexEntry<ParentIdAndRdn<Long>, Long>();
- startingPos.setKey( new ParentIdAndRdn<Long>( id, (Rdn[]) null ) );
+ Cursor<IndexEntry<ParentIdAndRdn, String>> cursor = rdnIdx.forwardCursor();
+
+ IndexEntry<ParentIdAndRdn, String> startingPos = new IndexEntry<ParentIdAndRdn, String>();
+ startingPos.setKey( new ParentIdAndRdn( id, ( Rdn[] ) null ) );
cursor.before( startingPos );
int countChildren = 0;
-
+
while ( cursor.next() && ( countChildren < nbSibbling ) )
{
- IndexEntry<ParentIdAndRdn<Long>, Long> element = cursor.get();
- Long childId = element.getId();
+ IndexEntry<ParentIdAndRdn, String> element = cursor.get();
+ String childId = element.getId();
Entry entry = lookup( childId );
appendLdif( entry );
countChildren++;
-
+
// And now, the children
int nbChildren = element.getKey().getNbChildren();
-
+
if ( nbChildren > 0 )
{
appendRecursive( childId, nbChildren );
}
}
-
+
cursor.close();
}
Modified: directory/apacheds/trunk/ldif-partition/src/main/resources/ads-2.ldif
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldif-partition/src/main/resources/ads-2.ldif?rev=1389184&r1=1389183&r2=1389184&view=diff
==============================================================================
--- directory/apacheds/trunk/ldif-partition/src/main/resources/ads-2.ldif (original)
+++ directory/apacheds/trunk/ldif-partition/src/main/resources/ads-2.ldif Mon Sep 24 02:17:13 2012
@@ -430,6 +430,18 @@ m-ordering: integerOrderingMatch
m-syntax: 1.3.6.1.4.1.1466.115.121.1.27
m-singleValue: TRUE
+dn: m-oid=1.3.6.1.4.1.18060.0.4.1.2.165,ou=attributeTypes,cn=adsconfig,ou=schema
+m-singlevalue: TRUE
+m-oid: 1.3.6.1.4.1.18060.0.4.1.2.165
+m-description: A flag telling if the index has a reverse table
+objectclass: top
+objectclass: metaTop
+objectclass: metaAttributeType
+m-syntax: 1.3.6.1.4.1.1466.115.121.1.7
+m-name: ads-indexHasReverse
+creatorsname: uid=admin,ou=system
+m-equality: booleanMatch
+
dn: m-oid=1.3.6.1.4.1.18060.0.4.1.2.250, ou=attributeTypes, cn=ads-2, ou=schema
objectclass: metaAttributeType
objectclass: metaTop
@@ -980,6 +992,7 @@ m-name: ads-index
m-description: A generic indexed attribute
m-typeObjectClass: ABSTRACT
m-must: ads-indexAttributeId
+m-must: ads-indexHasReverse
dn: m-oid=1.3.6.1.4.1.18060.0.4.1.3.161, ou=objectClasses, cn=ads-2, ou=schema
objectclass: metaObjectClass
Modified: directory/apacheds/trunk/ldif-partition/src/main/resources/sample-config.ldif
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldif-partition/src/main/resources/sample-config.ldif?rev=1389184&r1=1389183&r2=1389184&view=diff
==============================================================================
--- directory/apacheds/trunk/ldif-partition/src/main/resources/sample-config.ldif (original)
+++ directory/apacheds/trunk/ldif-partition/src/main/resources/sample-config.ldif Mon Sep 24 02:17:13 2012
@@ -62,4 +62,5 @@ objectClass: ads-jdbmIndex
objectClass: ads-index
objectClass: top
ads-indexAttributeId: ou
+ads-indexHasReverse: FALSE
Modified: directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartitionTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartitionTest.java?rev=1389184&r1=1389183&r2=1389184&view=diff
==============================================================================
--- directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartitionTest.java (original)
+++ directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartitionTest.java Mon Sep 24 02:17:13 2012
@@ -51,7 +51,6 @@ import org.apache.directory.server.core.
import org.apache.directory.server.core.api.interceptor.context.RenameOperationContext;
import org.apache.directory.server.core.api.interceptor.context.SearchOperationContext;
import org.apache.directory.server.core.api.normalization.FilterNormalizingVisitor;
-import org.apache.directory.server.core.partition.ldif.SingleFileLdifPartition;
import org.apache.directory.shared.ldap.model.constants.AuthenticationLevel;
import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
import org.apache.directory.shared.ldap.model.csn.CsnFactory;
@@ -277,7 +276,7 @@ public class SingleFileLdifPartitionTest
partition.add( addCtx );
- Long id = partition.getEntryId( contextEntry.getDn() );
+ String id = partition.getEntryId( contextEntry.getDn() );
assertNotNull( id );
assertEquals( contextEntry, partition.lookup( id ) );
@@ -676,16 +675,16 @@ public class SingleFileLdifPartitionTest
assertEquals( 3, nbRes );
assertEquals( 0, expectedDns.size() );
-
+
cursor.close();
}
-
-
+
+
@Test
public void testLdifMoveEntry() throws Exception
{
SingleFileLdifPartition partition = injectEntries();
-
+
Entry childEntry1 = partition.lookup( partition.getEntryId( new Dn( schemaManager,
"dc=child1,ou=test,ou=system" ) ) );
Entry childEntry2 = partition.lookup( partition.getEntryId( new Dn( schemaManager,
@@ -844,7 +843,7 @@ public class SingleFileLdifPartitionTest
partition.add( addCtx );
// search works fine
- Long id = partition.getEntryId( contextEntry.getDn() );
+ String id = partition.getEntryId( contextEntry.getDn() );
assertNotNull( id );
assertEquals( contextEntry, partition.lookup( id ) );