@Test
public void testAddAndRemove() throws Exception
{
DirectoryServiceFactory dsFactory = DefaultDirectoryServiceFactory.class.newInstance();
PartitionFactory partitionFactory = dsFactory.getPartitionFactory();
Partition partition = partitionFactory.createPartition( getService().getSchemaManager(), "removable",
"ou=removable", 100, getService()
.getInstanceLayout().getPartitionsDirectory() );
// Test AddContextPartition
getService().addPartition( partition );
Dn suffixDn = new Dn( getService().getSchemaManager(), "ou=removable" );
Entry ctxEntry = new DefaultEntry(
getService().getSchemaManager(),
suffixDn.toString(),
"objectClass: top",
"objectClass: organizationalUnit",
"ou: removable",
"entryCSN", new CsnFactory( 1 ).newInstance().toString(),
"entryUUID", UUID.randomUUID().toString() );
partition.add( new AddOperationContext( getService().getAdminSession(), ctxEntry ) );
LdapConnection connection = IntegrationUtils.getAdminConnection( getService() );
assertNotNull( connection.lookup( "ou=removable" ) );