public void testLdapClassLoaderWithClassLoadedAtDefaultSearchSubtree() throws Exception
{
LdapContext root = getRootContext( service );
// get default naming context to work on
ServerLdapContext defaultContext = ( ServerLdapContext ) root.lookup( "ou=system" );
// create an extensible object for holding custom config data
Attributes classLoaderDefaultSearchContextConfig = new BasicAttributes( true );
Attribute objectClass = new BasicAttribute( "objectClass" );
objectClass.add( "top" );
objectClass.add( "javaContainer" );
// We need to ad this extensibleObject OC in order to avoid an error
// with the classLoaderDefaultSearchContext AT used later (no OC contains
// this AT)
objectClass.add( "extensibleObject" );
// create custom config entry
classLoaderDefaultSearchContextConfig.put( objectClass );
classLoaderDefaultSearchContextConfig.put( new BasicAttribute( "cn", "classLoaderDefaultSearchContext" ) );
// add a default search context to the configuration
classLoaderDefaultSearchContextConfig.put( new BasicAttribute( "classLoaderDefaultSearchContext", "ou=system" ) );
// add the configuration entry to the DIT
ServerLdapContext configContext = ( ServerLdapContext ) defaultContext.lookup( "ou=configuration" );
configContext.createSubcontext( "cn=classLoaderDefaultSearchContext", classLoaderDefaultSearchContextConfig );
// create a class holder entry and add it to the DIT
Attributes attributes = new BasicAttributes( "objectClass", "top", true );
attributes.get( "objectClass" ).add( "javaClass" );
attributes.put( "fullyQualifiedJavaClassName", "HelloWorld" );