* Add a child
*/
@Test
public void testAddChild() throws Exception
{
LdapConnection connection = IntegrationUtils.getAdminConnection( getService() );
Map<String, Entry> results = getAllEntries( connection, "dc=test,dc=example,dc=com" );
// System.out.println( "Entries found :");
// System.out.println( "--------------");
//
// for ( String dn : results.keySet() )
// {
// System.out.println( dn );
// }
//
// connection.close();
// System.out.println( "Stopping the service---------------------------------");
// System.out.println();
// Shutdown the DirectoryService
getService().shutdown();
assertFalse( getService().isStarted() );
// System.out.println( "Starting the service---------------------------------");
// And restart it
getService().startup();
assertTrue( getService().isStarted() );
connection = IntegrationUtils.getAdminConnection( getService() );
// Add the child
Entry child2 = new DefaultEntry(
"cn=child2,cn=imadmin,ou=groups,dc=test,dc=example,dc=com",
"objectClass: top",
"objectClass: groupOfUniqueNames",
"cn: child2",
"uniqueMember: uid=dummy2",
"description: child2" );
// SchemaManager schemaManager = getService().getSchemaManager();
// Dn contextDn = new Dn( schemaManager, "dc=example,dc=com" );
// MavibotPartition partition = ( MavibotPartition ) getService().getPartitionNexus().getPartition( contextDn );
// partition.dumpRdnIdx( Partition.ROOT_ID, "" );
// System.out.println( "Adding child2 : " + child2.getDn() );
connection.add( child2 );
// partition.dumpRdnIdx( Partition.ROOT_ID, "" );
// Entry found = connection.lookup( "cn=child2,cn=imadmin,ou=groups,dc=test,dc=example,dc=com" );
// System.out.println( "Child2 exists :\n" + found);
assertTrue( connection.exists( "cn=child2,cn=imadmin,ou=groups,dc=test,dc=example,dc=com" ) );
results = getAllEntries( connection, "dc=test,dc=example,dc=com" );
// System.out.println( "Entries found :");
// System.out.println( "--------------");
//
// for ( String dn : results.keySet() )
// {
// System.out.println( dn );
// }
// --------------------------------------------------------------------
// Make sure entries not selected by subentryA do not have the mark
// --------------------------------------------------------------------
connection.close();
// System.out.println( "Stopping the service---------------------------------");
System.out.println();
// Now shutdown the DirectoryService
getService().shutdown();
assertFalse( getService().isStarted() );
// System.out.println( "Starting the service---------------------------------");
// And restart it
getService().startup();
assertTrue( getService().isStarted() );
// Fetch the entries again
connection = IntegrationUtils.getAdminConnection( getService() );
Entry found = connection.lookup( "cn=child2,cn=imadmin,ou=groups,dc=test,dc=example,dc=com" );
// System.out.println( "Child2 STILL exists :\n" + found);
// Check the resulting modifications
results = getAllEntries( connection, "dc=test,dc=example,dc=com" );
System.out.println();
// System.out.println( "Entries found :");
// System.out.println( "--------------");
int count = 0;
for ( String dn : results.keySet() )
{
count++;
// System.out.println( dn );
}
connection.close();
assertEquals( 4, count );
}