You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ka...@apache.org on 2010/09/24 11:52:13 UTC
svn commit: r1000781 -
/directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/SingleFileLdifPartitionTest.java
Author: kayyagari
Date: Fri Sep 24 09:52:13 2010
New Revision: 1000781
URL: http://svn.apache.org/viewvc?rev=1000781&view=rev
Log:
o fixed delete test
o added a reusable method to check the existence of an entry
Modified:
directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/SingleFileLdifPartitionTest.java
Modified: directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/SingleFileLdifPartitionTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/SingleFileLdifPartitionTest.java?rev=1000781&r1=1000780&r2=1000781&view=diff
==============================================================================
--- directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/SingleFileLdifPartitionTest.java (original)
+++ directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/SingleFileLdifPartitionTest.java Fri Sep 24 09:52:13 2010
@@ -117,7 +117,7 @@ public class SingleFileLdifPartitionTest
if ( workingDirectory == null )
{
- String path = LdifPartitionTest.class.getResource( "" ).getPath();
+ String path = SingleFileLdifPartitionTest.class.getResource( "" ).getPath();
int targetPos = path.indexOf( "target" );
workingDirectory = path.substring( 0, targetPos + 6 );
}
@@ -225,6 +225,17 @@ public class SingleFileLdifPartitionTest
return createPartition( ldifFileInUse.getAbsolutePath(), false );
}
+
+ private void checkExists( SingleFileLdifPartition partition, Entry entry ) throws LdapException
+ {
+ LookupOperationContext opCtx = new LookupOperationContext( mockSession );
+ opCtx.setDn( entry.getDn() );
+
+ Entry fetched = partition.lookup( opCtx );
+
+ assertNotNull( fetched );
+ assertEquals( entry, fetched );
+ }
//-------------------------------------------------------------------------
// Partition.add() tests
@@ -248,11 +259,7 @@ public class SingleFileLdifPartitionTest
assertEquals( getEntryLdifLen( contextEntry ) + 1, file.length() );
partition = reloadPartition();
- LookupOperationContext lookupContext = new LookupOperationContext( mockSession );
- lookupContext.setDn( contextEntry.getDn() );
-
- ClonedServerEntry entry = partition.lookup( lookupContext );
- assertEquals( contextEntry, entry );
+ checkExists( partition, contextEntry );
}
@@ -311,6 +318,12 @@ public class SingleFileLdifPartitionTest
Entry fromFetched = new DefaultEntry( schemaManager, fetchedLdif.getEntry() );
assertEquals( entryMvrdn, fromFetched );
+
+ partition = reloadPartition();
+ checkExists( partition, contextEntry );
+ checkExists( partition, entry1 );
+ checkExists( partition, entry2 );
+ checkExists( partition, entryMvrdn );
}
@@ -453,6 +466,11 @@ public class SingleFileLdifPartitionTest
ldifEntry = reader.parseLdif( ldif ).get( 0 );
assertEquals( entry1, new DefaultEntry( schemaManager, ldifEntry.getEntry() ) );
+
+ partition = reloadPartition();
+ checkExists( partition, contextEntry );
+ checkExists( partition, entry1 );
+ checkExists( partition, entry2 );
}
@@ -499,6 +517,11 @@ public class SingleFileLdifPartitionTest
{
assertTrue( true );
}
+
+ partition = reloadPartition();
+ checkExists( partition, contextEntry );
+ checkExists( partition, entry1 );
+ checkExists( partition, entry2 );
}
@@ -528,7 +551,11 @@ public class SingleFileLdifPartitionTest
assertEquals( 0L, file.length() );
assertNull( partition.getContextEntry() );
- /*
+ addCtx = new AddOperationContext( mockSession );
+ addCtx.setEntry( contextEntry );
+
+ partition.add( addCtx );
+
ClonedServerEntry entry1 = createEntry( "dc=test,ou=test,ou=system" );
entry1.put( "ObjectClass", "top", "domain" );
entry1.put( "dc", "test" );
@@ -557,14 +584,15 @@ public class SingleFileLdifPartitionTest
partition.add( addCtx );
- DeleteOperationContext delCtx = new DeleteOperationContext( session );
-
- DN dn = new DN( "dc=test1,dc=test,ou=test,ou=system", schemaManager );
-
- delCtx.setDn( dn );
+ DeleteOperationContext delCtx = new DeleteOperationContext( mockSession );
+ delCtx.setDn( entryMvrdn.getDn() );
partition.delete( delCtx );
- */
+
+ partition = reloadPartition();
+ checkExists( partition, entry1 );
+ checkExists( partition, entry2 );
+ checkExists( partition, entry3 );
}