directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1202451 [1/2] - in /directory/apacheds/trunk/core-integ/src: main/java/org/apache/directory/server/core/integ/ test/java/org/apache/directory/server/core/schema/
Date Tue, 15 Nov 2011 22:37:12 GMT
Author: elecharny
Date: Tue Nov 15 22:37:11 2011
New Revision: 1202451

URL: http://svn.apache.org/viewvc?rev=1202451&view=rev
Log:
Removed the JNDI imports

Modified:
    directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/IntegrationUtils.java
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/AbstractMetaSchemaObjectHandler.java
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaMatchingRuleHandlerIT.java
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaNormalizerHandlerIT.java
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaObjectClassHandlerIT.java
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSchemaHandlerIT.java
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSyntaxCheckerHandlerIT.java

Modified: directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/IntegrationUtils.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/IntegrationUtils.java?rev=1202451&r1=1202450&r2=1202451&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/IntegrationUtils.java (original)
+++ directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/IntegrationUtils.java Tue Nov 15 22:37:11 2011
@@ -25,9 +25,6 @@ import java.util.ArrayList;
 import java.util.List;
 
 import javax.naming.NamingException;
-import javax.naming.directory.BasicAttribute;
-import javax.naming.directory.DirContext;
-import javax.naming.directory.ModificationItem;
 import javax.naming.ldap.LdapContext;
 import javax.naming.ldap.LdapName;
 
@@ -48,6 +45,9 @@ import org.apache.directory.shared.ldap.
 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;
+import org.apache.directory.shared.ldap.model.entry.DefaultModification;
+import org.apache.directory.shared.ldap.model.entry.Modification;
+import org.apache.directory.shared.ldap.model.entry.ModificationOperation;
 import org.apache.directory.shared.ldap.model.exception.LdapException;
 import org.apache.directory.shared.ldap.model.ldif.ChangeType;
 import org.apache.directory.shared.ldap.model.ldif.LdifEntry;
@@ -301,25 +301,24 @@ public class IntegrationUtils
 
     public static void enableSchema( DirectoryService service, String schemaName ) throws Exception
     {
-        LdapContext schemaRoot = getSchemaContext( service );
+        LdapConnection connection = getAdminConnection( service );
 
         // now enable the test schema
-        ModificationItem[] mods = new ModificationItem[1];
-        javax.naming.directory.Attribute attr = new BasicAttribute( "m-disabled", "FALSE" );
-        mods[0] = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr );
-        schemaRoot.modifyAttributes( "cn=" + schemaName, mods );
+        connection.modify( "cn=" + schemaName + ",ou=schema",
+            new DefaultModification(
+                ModificationOperation.REPLACE_ATTRIBUTE, "m-disabled", "FALSE" ) );
     }
 
 
     public static void disableSchema( DirectoryService service, String schemaName ) throws Exception
     {
-        LdapContext schemaRoot = getSchemaContext( service );
+        LdapConnection connection = getAdminConnection( service );
 
         // now enable the test schema
-        ModificationItem[] mods = new ModificationItem[1];
-        javax.naming.directory.Attribute attr = new BasicAttribute( "m-disabled", "TRUE" );
-        mods[0] = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr );
-        schemaRoot.modifyAttributes( "cn=" + schemaName, mods );
+        Modification mod = new DefaultModification(
+            ModificationOperation.REPLACE_ATTRIBUTE, "m-disabled", "TRUE" );
+        
+        connection.modify( "cn=" + schemaName + ",ou=schema", mod );
     }
 
 

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/AbstractMetaSchemaObjectHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/AbstractMetaSchemaObjectHandler.java?rev=1202451&r1=1202450&r2=1202451&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/AbstractMetaSchemaObjectHandler.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/AbstractMetaSchemaObjectHandler.java Tue Nov 15 22:37:11 2011
@@ -67,29 +67,6 @@ public abstract class AbstractMetaSchema
 
 
     /**
-     * Get the path on disk where a specific SchemaObject is stored
-     *
-     * @param dn the SchemaObject Dn
-     */
-    protected String getSchemaPath0( Dn dn )
-    {
-        StringBuilder sb = new StringBuilder();
-
-        sb.append( workingDir ).append( '/' ).append( getService().getSchemaPartition().getId() ).append( '/' ).append( "ou=schema" );
-
-        for ( Rdn rdn : dn )
-        {
-            sb.append( '/' );
-            sb.append( Strings.toLowerCase( rdn.getName() ) );
-        }
-
-        sb.append( ".ldif" );
-
-        return sb.toString();
-    }
-
-
-    /**
      * Check that a specific SchemaObject is stored on the disk at the
      * correct position in the Ldif partition
      *
@@ -108,24 +85,6 @@ public abstract class AbstractMetaSchema
 
 
     /**
-     * Check that a specific SchemaObject is stored on the disk at the
-     * correct position in the Ldif partition
-     *
-     * @param dn The SchemaObject Dn
-     */
-    protected boolean isOnDisk0( Dn dn )
-    {
-        // do not change the value of getSchemaPath to lowercase
-        // on Linux this gives a wrong path
-        String schemaObjectFileName = getSchemaPath0( dn );
-
-        File file = new File( schemaObjectFileName );
-
-        return file.exists();
-    }
-
-
-    /**
      * Gets relative Dn to ou=schema.
      *
      * @param schemaName the name of the schema
@@ -136,57 +95,4 @@ public abstract class AbstractMetaSchema
     {
         return new Dn( "cn=" + schemaName );
     }
-
-
-    /**
-     * Get relative Dn to ou=schema for MatchingRules
-     *
-     * @param schemaName the name of the schema
-     * @return the dn to the ou under which MatchingRules are found for a schema
-     * @throws Exception if there are dn construction issues
-     */
-    protected Dn getMatchingRuleContainer( String schemaName ) throws Exception
-    {
-        return new Dn( "ou=matchingRules,cn=" + schemaName );
-    }
-
-
-    /**
-     * Gets relative Dn to ou=schema.
-     *
-     * @param schemaName the name of the schema
-     * @return the dn of the container which contains objectClasses
-     * @throws Exception on error
-     */
-    protected Dn getObjectClassContainer( String schemaName ) throws Exception
-    {
-        return new Dn( "ou=objectClasses,cn=" + schemaName );
-    }
-
-
-
-    /**
-     * Get relative Dn to ou=schema for Syntaxes
-     *
-     * @param schemaName the name of the schema
-     * @return the dn of the container holding syntaxes for the schema
-     * @throws Exception on dn parse errors
-     */
-    protected Dn getSyntaxContainer( String schemaName ) throws Exception
-    {
-        return new Dn( "ou=syntaxes,cn=" + schemaName );
-    }
-
-
-    /**
-     * Get relative Dn to ou=schema for SyntaxCheckers
-     *
-     * @param schemaName the name of the schema
-     * @return the dn of the container holding syntax checkers for the schema
-     * @throws Exception on dn parse errors
-     */
-    protected Dn getSyntaxCheckerContainer( String schemaName ) throws Exception
-    {
-        return new Dn( "ou=syntaxCheckers,cn=" + schemaName );
-    }
 }

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaMatchingRuleHandlerIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaMatchingRuleHandlerIT.java?rev=1202451&r1=1202450&r2=1202451&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaMatchingRuleHandlerIT.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaMatchingRuleHandlerIT.java Tue Nov 15 22:37:11 2011
@@ -65,7 +65,6 @@ public class MetaMatchingRuleHandlerIT e
     private static final String OID = "1.3.6.1.4.1.18060.0.4.0.1.100000";
     private static final String NEW_OID = "1.3.6.1.4.1.18060.0.4.0.1.100001";
 
-
     public static SchemaManager schemaManager;
     private static LdapConnection connection;
 

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaNormalizerHandlerIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaNormalizerHandlerIT.java?rev=1202451&r1=1202450&r2=1202451&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaNormalizerHandlerIT.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaNormalizerHandlerIT.java Tue Nov 15 22:37:11 2011
@@ -418,7 +418,7 @@ public class MetaNormalizerHandlerIT ext
         // Create a new Normalizer
         testAddNormalizerToEnabledSchema();
         assertTrue( isOnDisk( nDn ) );
-        assertTrue( getService().getSchemaManager().getNormalizerRegistry().contains( OID ) );
+        assertTrue( schemaManager.getNormalizerRegistry().contains( OID ) );
 
         // Create a MR using this Normalizer
         Dn mrDn = new Dn( "m-oid=" + OID + ",ou=matchingrules,cn=apachemeta,ou=schema" );
@@ -434,14 +434,14 @@ public class MetaNormalizerHandlerIT ext
 
         // Pre-checks
         assertFalse( isOnDisk( mrDn ) );
-        assertFalse( getService().getSchemaManager().getMatchingRuleRegistry().contains( OID ) );
+        assertFalse( schemaManager.getMatchingRuleRegistry().contains( OID ) );
 
         // MatchingRule Addition
         connection.add( entry );
 
         // Post-checks
         assertTrue( isOnDisk( mrDn ) );
-        assertTrue( getService().getSchemaManager().getMatchingRuleRegistry().contains( OID ) );
+        assertTrue( schemaManager.getMatchingRuleRegistry().contains( OID ) );
 
         try
         {

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaObjectClassHandlerIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaObjectClassHandlerIT.java?rev=1202451&r1=1202450&r2=1202451&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaObjectClassHandlerIT.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaObjectClassHandlerIT.java Tue Nov 15 22:37:11 2011
@@ -20,31 +20,27 @@
 package org.apache.directory.server.core.schema;
 
 
-import static org.apache.directory.server.core.integ.IntegrationUtils.getSchemaContext;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
-import javax.naming.InvalidNameException;
-import javax.naming.NameNotFoundException;
-import javax.naming.NamingException;
-import javax.naming.OperationNotSupportedException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.BasicAttribute;
-import javax.naming.directory.BasicAttributes;
-import javax.naming.directory.DirContext;
-import javax.naming.directory.ModificationItem;
-
+import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.server.core.annotations.CreateDS;
 import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.server.core.integ.IntegrationUtils;
+import org.apache.directory.shared.ldap.model.entry.DefaultEntry;
+import org.apache.directory.shared.ldap.model.entry.DefaultModification;
+import org.apache.directory.shared.ldap.model.entry.Entry;
+import org.apache.directory.shared.ldap.model.entry.Modification;
+import org.apache.directory.shared.ldap.model.entry.ModificationOperation;
 import org.apache.directory.shared.ldap.model.exception.LdapException;
-import org.apache.directory.shared.ldap.model.ldif.LdifUtils;
 import org.apache.directory.shared.ldap.model.name.Dn;
+import org.apache.directory.shared.ldap.model.name.Rdn;
 import org.apache.directory.shared.ldap.model.schema.ObjectClass;
+import org.apache.directory.shared.ldap.model.schema.SchemaManager;
 import org.apache.directory.shared.ldap.model.schema.registries.ObjectClassRegistry;
-import org.apache.directory.shared.ldap.util.JndiUtils;
+import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -72,15 +68,31 @@ public class MetaObjectClassHandlerIT ex
     private static final String DEPENDEE_OID = "1.3.6.1.4.1.18060.0.4.0.3.100002";
 
 
+
+    public static SchemaManager schemaManager;
+    private static LdapConnection connection;
+
+
+    @Before
+    public void setup() throws Exception
+    {
+        super.init();
+        connection = IntegrationUtils.getAdminConnection( getService() );
+        schemaManager = getService().getSchemaManager();
+    }
+
     private static ObjectClassRegistry getObjectClassRegistry()
     {
-        return getService().getSchemaManager().getObjectClassRegistry();
+        return schemaManager.getObjectClassRegistry();
     }
 
 
     private Dn addObjectClass() throws Exception
     {
-        Attributes attrs = LdifUtils.createJndiAttributes(
+        Dn dn = new Dn( "m-oid=" + OID + ",ou=objectClasses,cn=apacheMeta,ou=schema" );
+
+        Entry entry = new DefaultEntry(
+            dn,
             "objectClass: top",
             "objectClass: metaTop",
             "objectClass: metaObjectClass",
@@ -91,9 +103,7 @@ public class MetaObjectClassHandlerIT ex
             "m-must: cn",
             "m-may: ou" );
 
-        Dn dn = getObjectClassContainer( "apachemeta" );
-        dn = dn.add( "m-oid" + "=" + OID );
-        getSchemaContext( getService() ).createSubcontext( JndiUtils.toName( dn ), attrs );
+        connection.add( entry );
 
         return dn;
     }
@@ -109,7 +119,7 @@ public class MetaObjectClassHandlerIT ex
 
         assertTrue( getObjectClassRegistry().contains( OID ) );
         assertEquals( getObjectClassRegistry().getSchemaName( OID ), "apachemeta" );
-        assertTrue( isOnDisk0( dn ) );
+        assertTrue( isOnDisk( dn ) );
     }
 
 
@@ -120,14 +130,17 @@ public class MetaObjectClassHandlerIT ex
 
         assertFalse( "adding new objectClass to disabled schema should not register it into the registries",
             getObjectClassRegistry().contains( OID ) );
-        assertTrue( isOnDisk0( dn ) );
+        assertTrue( isOnDisk( dn ) );
     }
 
 
     @Test
     public void testAddObjectClassToUnloadedSchema() throws Exception
     {
-        Attributes attrs = LdifUtils.createJndiAttributes(
+        Dn dn = new Dn( "m-oid=" + OID + ",ou=objectClasses,cn=notloaded,ou=schema" );
+
+        Entry entry = new DefaultEntry(
+            dn,
             "objectClass: top",
             "objectClass: metaTop",
             "objectClass: metaObjectClass",
@@ -138,37 +151,34 @@ public class MetaObjectClassHandlerIT ex
             "m-must: cn",
             "m-may: ou" );
 
-        Dn dn = getObjectClassContainer( "notloaded" );
-        dn = dn.add( "m-oid" + "=" + OID );
-
         try
         {
-            getSchemaContext( getService() ).createSubcontext( JndiUtils.toName( dn ), attrs );
+            connection.add( entry );
             fail( "Should not be there" );
         }
-        catch( NameNotFoundException nnfe )
+        catch( LdapException le )
         {
             // Excpected result
         }
 
         assertFalse( "adding new objectClass to disabled schema should not register it into the registries",
             getObjectClassRegistry().contains( OID ) );
-        assertFalse( isOnDisk0( dn ) );
+        assertFalse( isOnDisk( dn ) );
     }
 
 
     @Test
     public void testDeleteObjectClassFromEnabledSchema() throws Exception
     {
-        Dn dn = getObjectClassContainer( "apachemeta" );
-        dn = dn.add( "m-oid" + "=" + OID );
+        Dn dn = new Dn( "m-oid=" + OID + ",ou=objectClasses,cn=apacheMeta,ou=schema" );
+
         addObjectClass();
 
         assertTrue( "objectClass should be removed from the registry after being deleted",
             getObjectClassRegistry().contains( OID ) );
-        assertTrue( isOnDisk0( dn ) );
+        assertTrue( isOnDisk( dn ) );
 
-        getSchemaContext( getService() ).destroySubcontext( JndiUtils.toName( dn ) );
+        connection.delete( dn );
 
         assertFalse( "objectClass should be removed from the registry after being deleted",
             getObjectClassRegistry().contains( OID ) );
@@ -182,22 +192,22 @@ public class MetaObjectClassHandlerIT ex
         {
         }
 
-        assertFalse( isOnDisk0( dn ) );
+        assertFalse( isOnDisk( dn ) );
     }
 
 
     @Test
     public void testDeleteObjectClassFromDisabledSchema() throws Exception
     {
-        Dn dn = getObjectClassContainer( "nis" );
-        dn = dn.add( "m-oid" + "=" + OID );
+        Dn dn = new Dn( "m-oid=" + OID + ",ou=objectClasses,cn=nis,ou=schema" );
+
         addObjectClassToDisabledSchema();
 
         assertFalse( "objectClass should be removed from the registry after being deleted",
             getObjectClassRegistry().contains( OID ) );
-        assertTrue( isOnDisk0( dn ) );
+        assertTrue( isOnDisk( dn ) );
 
-        getSchemaContext( getService() ).destroySubcontext( JndiUtils.toName( dn ) );
+        connection.delete( dn );
 
         assertFalse( "objectClass should be removed from the registry after being deleted",
             getObjectClassRegistry().contains( OID ) );
@@ -211,7 +221,7 @@ public class MetaObjectClassHandlerIT ex
         {
         }
 
-        assertFalse( isOnDisk0( dn ) );
+        assertFalse( isOnDisk( dn ) );
     }
 
 
@@ -219,13 +229,13 @@ public class MetaObjectClassHandlerIT ex
     @Ignore
     public void testRenameObjectClassType() throws Exception
     {
-        Dn dn = getObjectClassContainer( "apachemeta" );
-        dn = dn.add( "m-oid" + "=" + OID );
+        Dn dn = new Dn( "m-oid=" + OID + ",ou=objectClasses,cn=nis,ou=schema" );
+
         addObjectClass();
 
-        Dn newdn = getObjectClassContainer( "apachemeta" );
-        newdn = newdn.add( "m-oid" + "=" + NEW_OID );
-        getSchemaContext( getService() ).rename( JndiUtils.toName( dn ), JndiUtils.toName( newdn ) );
+        Dn newDn = new Dn( "m-oid=" + NEW_OID + ",ou=objectClasses,cn=apachemeta,ou=schema" );
+
+        connection.move( dn, newDn );
 
         assertFalse( "old objectClass OID should be removed from the registry after being renamed",
             getObjectClassRegistry().contains( OID ) );
@@ -250,13 +260,11 @@ public class MetaObjectClassHandlerIT ex
     {
         addObjectClass();
 
-        Dn dn = getObjectClassContainer( "apachemeta" );
-        dn = dn.add( "m-oid" + "=" + OID );
+        Dn dn = new Dn( "m-oid=" + OID + ",ou=objectClasses,cn=apacheMeta,ou=schema" );
 
-        Dn newdn = getObjectClassContainer( "apache" );
-        newdn = newdn.add( "m-oid" + "=" + OID );
+        Dn newDn = new Dn( "m-oid=" + OID + ",ou=objectClasses,cn=apache,ou=schema" );
 
-        getSchemaContext( getService() ).rename( JndiUtils.toName( dn ), JndiUtils.toName( newdn ) );
+        connection.move( dn, newDn );
 
         assertTrue( "objectClass OID should still be present",
             getObjectClassRegistry().contains( OID ) );
@@ -272,13 +280,11 @@ public class MetaObjectClassHandlerIT ex
     {
         addObjectClass();
 
-        Dn dn = getObjectClassContainer( "apachemeta" );
-        dn = dn.add( "m-oid" + "=" + OID );
+        Dn dn = new Dn( "m-oid=" + OID + ",ou=objectClasses,cn=apacheMeta,ou=schema" );
 
-        Dn newdn = getObjectClassContainer( "apache" );
-        newdn = newdn.add( "m-oid" + "=" + NEW_OID );
+        Dn newDn = new Dn( "m-oid=" + NEW_OID + ",ou=objectClasses,cn=apache,ou=schema" );
 
-        getSchemaContext( getService() ).rename( JndiUtils.toName( dn ), JndiUtils.toName( newdn ) );
+        connection.move( dn, newDn );
 
         assertFalse( "old objectClass OID should NOT be present",
             getObjectClassRegistry().contains( OID ) );
@@ -301,15 +307,14 @@ public class MetaObjectClassHandlerIT ex
         assertEquals( oc.getDescription(), DESCRIPTION0 );
         assertEquals( oc.getName(), NAME );
 
-        Dn dn = getObjectClassContainer( "apachemeta" );
-        dn = dn.add( "m-oid" + "=" + OID );
+        Dn dn = new Dn( "m-oid=" + OID + ",ou=objectClasses,cn=apacheMeta,ou=schema" );
 
-        ModificationItem[] mods = new ModificationItem[2];
-        Attribute attr = new BasicAttribute( "m-description", DESCRIPTION1 );
-        mods[0] = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr );
-        attr = new BasicAttribute( "m-name", NEW_NAME );
-        mods[1] = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr );
-        getSchemaContext( getService() ).modifyAttributes( JndiUtils.toName( dn ), mods );
+        Modification mod1 = new DefaultModification(
+            ModificationOperation.REPLACE_ATTRIBUTE, "m-description", DESCRIPTION1 );
+        Modification mod2 = new DefaultModification(
+            ModificationOperation.REPLACE_ATTRIBUTE, "m-name", NEW_NAME );
+        
+        connection.modify( dn, mod1, mod2 );
 
         assertTrue( "objectClass OID should still be present",
             getObjectClassRegistry().contains( OID ) );
@@ -333,13 +338,14 @@ public class MetaObjectClassHandlerIT ex
         assertEquals( oc.getDescription(), DESCRIPTION0 );
         assertEquals( oc.getName(), NAME );
 
-        Dn dn = getObjectClassContainer( "apachemeta" );
-        dn = dn.add( "m-oid" + "=" + OID );
+        Dn dn = new Dn( "m-oid=" + OID + ",ou=objectClasses,cn=apacheMeta,ou=schema" );
 
-        Attributes mods = new BasicAttributes( true );
-        mods.put( "m-description", DESCRIPTION1 );
-        mods.put( "m-name", NEW_NAME );
-        getSchemaContext( getService() ).modifyAttributes( JndiUtils.toName( dn ), DirContext.REPLACE_ATTRIBUTE, mods );
+        Modification mod1 = new DefaultModification(
+            ModificationOperation.REPLACE_ATTRIBUTE, "m-description", DESCRIPTION1 );
+        Modification mod2 = new DefaultModification(
+            ModificationOperation.REPLACE_ATTRIBUTE, "m-name", NEW_NAME );
+
+        connection.modify( dn, mod1, mod2 );
 
         assertTrue( "objectClass OID should still be present",
             getObjectClassRegistry().contains( OID ) );
@@ -358,22 +364,22 @@ public class MetaObjectClassHandlerIT ex
     // ----------------------------------------------------------------------
     private void addDependeeObjectClass() throws Exception
     {
-        Attributes attrs = new BasicAttributes( true );
-        Attribute oc = new BasicAttribute( "objectClass", "top" );
-        oc.add( "metaTop" );
-        oc.add( "metaObjectClass" );
-        attrs.put( oc );
-        attrs.put( "m-oid", DEPENDEE_OID );
-        attrs.put( "m-name", DEPENDEE_NAME );
-        attrs.put( "m-description", DESCRIPTION0 );
-        attrs.put( "m-typeObjectClass", "AUXILIARY" );
-        attrs.put( "m-must", "cn" );
-        attrs.put( "m-may", "ou" );
-        attrs.put( "m-supObjectClass", OID );
-
-        Dn dn = getObjectClassContainer( "apachemeta" );
-        dn = dn.add( "m-oid" + "=" + DEPENDEE_OID );
-        getSchemaContext( getService() ).createSubcontext( JndiUtils.toName( dn ), attrs );
+        Dn dn = new Dn( "m-oid=" + DEPENDEE_OID + ",ou=objectClasses,cn=apacheMeta,ou=schema" );
+        
+        Entry entry = new DefaultEntry(
+            dn,
+            "objectClass: top",
+            "objectClass: metaTop",
+            "objectClass: metaObjectClass",
+            "m-oid", DEPENDEE_OID,
+            "m-name", DEPENDEE_NAME,
+            "m-description", DESCRIPTION0,
+            "m-typeObjectClass", "AUXILIARY",
+            "m-must: cn",
+            "m-may: ou",
+            "m-supObjectClass", OID );
+
+        connection.add( entry );
 
         assertTrue( getObjectClassRegistry().contains( DEPENDEE_OID ) );
         assertEquals( getObjectClassRegistry().getSchemaName( DEPENDEE_OID ), "apachemeta" );
@@ -383,17 +389,17 @@ public class MetaObjectClassHandlerIT ex
     @Test
     public void testDeleteObjectClassWhenInUse() throws Exception
     {
-        Dn dn = getObjectClassContainer( "apachemeta" );
-        dn = dn.add( "m-oid" + "=" + OID );
+        Dn dn = new Dn( "m-oid=" + OID + ",ou=objectClasses,cn=apacheMeta,ou=schema" );
+
         addObjectClass();
         addDependeeObjectClass();
 
         try
         {
-            getSchemaContext( getService() ).destroySubcontext( JndiUtils.toName( dn ) );
+            connection.delete( dn );
             fail( "should not be able to delete a objectClass in use" );
         }
-        catch( OperationNotSupportedException e )
+        catch( LdapException e )
         {
         }
 
@@ -409,18 +415,16 @@ public class MetaObjectClassHandlerIT ex
         addObjectClass();
         addDependeeObjectClass();
 
-        Dn dn = getObjectClassContainer( "apachemeta" );
-        dn = dn.add( "m-oid" + "=" + OID );
+        Dn dn = new Dn( "m-oid=" + OID + ",ou=objectClasses,cn=apacheMeta,ou=schema" );
 
-        Dn newdn = getObjectClassContainer( "apache" );
-        newdn = newdn.add( "m-oid" + "=" + OID );
+        Dn newDn = new Dn( "m-oid=" + OID + ",ou=objectClasses,cn=apache,ou=schema" );
 
         try
         {
-            getSchemaContext( getService() ).rename( JndiUtils.toName(dn), JndiUtils.toName( newdn ) );
+            connection.move( dn, newDn );
             fail( "should not be able to move a objectClass in use" );
         }
-        catch( OperationNotSupportedException e )
+        catch( LdapException e )
         {
         }
 
@@ -436,18 +440,16 @@ public class MetaObjectClassHandlerIT ex
         addObjectClass();
         addDependeeObjectClass();
 
-        Dn dn = getObjectClassContainer( "apachemeta" );
-        dn = dn.add( "m-oid" + "=" + OID );
+        Dn dn = new Dn( "m-oid=" + OID + ",ou=objectClasses,cn=apacheMeta,ou=schema" );
 
-        Dn newdn = getObjectClassContainer( "apache" );
-        newdn = newdn.add( "m-oid" + "=" + NEW_OID );
+        Dn newDn = new Dn( "m-oid=" + NEW_OID + ",ou=objectClasses,cn=apache,ou=schema" );
 
         try
         {
-            getSchemaContext( getService() ).rename( JndiUtils.toName( dn ), JndiUtils.toName( newdn ) );
+            connection.move( dn, newDn );
             fail( "should not be able to move an objectClass in use" );
         }
-        catch( OperationNotSupportedException e )
+        catch( LdapException e )
         {
         }
 
@@ -460,20 +462,19 @@ public class MetaObjectClassHandlerIT ex
     @Ignore
     public void testRenameObjectClassWhenInUse() throws Exception
     {
-        Dn dn = getObjectClassContainer( "apachemeta" );
-        dn = dn.add( "m-oid" + "=" + OID );
+        Dn dn = new Dn( "m-oid=" + OID + ",ou=objectClasses,cn=apacheMeta,ou=schema" );
+
         addObjectClass();
         addDependeeObjectClass();
 
-        Dn newdn = getObjectClassContainer( "apachemeta" );
-        newdn = newdn.add( "m-oid" + "=" + NEW_OID );
+        Rdn rdn = new Rdn( "m-oid=" + NEW_OID );
 
         try
         {
-            getSchemaContext( getService() ).rename( JndiUtils.toName( dn ), JndiUtils.toName( newdn ) );
+            connection.rename( dn, rdn );
             fail( "should not be able to rename an objectClass in use" );
         }
-        catch( OperationNotSupportedException e )
+        catch ( LdapException e )
         {
         }
 
@@ -491,18 +492,16 @@ public class MetaObjectClassHandlerIT ex
     {
         addObjectClass();
 
-        Dn dn = getObjectClassContainer( "apachemeta" );
-        dn = dn.add( "m-oid" + "=" + OID );
+        Dn dn = new Dn( "m-oid=" + OID + ",ou=objectClasses,cn=apacheMeta,ou=schema" );
 
-        Dn top = new Dn();
-        top.add( "m-oid" + "=" + OID );
+        Dn top = new Dn( "m-oid=" + OID );
 
         try
         {
-            getSchemaContext( getService() ).rename( JndiUtils.toName( dn ), JndiUtils.toName( top ) );
+            connection.move( dn, top );
             fail( "should not be able to move a objectClass up to ou=schema" );
         }
-        catch( InvalidNameException e )
+        catch ( LdapException e )
         {
         }
 
@@ -517,18 +516,16 @@ public class MetaObjectClassHandlerIT ex
     {
         addObjectClass();
 
-        Dn dn = getObjectClassContainer( "apachemeta" );
-        dn = dn.add( "m-oid" + "=" + OID );
+        Dn dn = new Dn( "m-oid=" + OID + ",ou=objectClasses,cn=apacheMeta,ou=schema" );
 
-        Dn newdn = new Dn( "ou=comparators,cn=apachemeta" );
-        newdn = newdn.add( "m-oid" + "=" + OID );
+        Dn newDn = new Dn( "m-oid=" + OID + ",ou=comparators,cn=apachemeta,ou=schema" );
 
         try
         {
-            getSchemaContext( getService() ).rename( JndiUtils.toName( dn ), JndiUtils.toName( newdn ) );
+            connection.move( dn, newDn );
             fail( "should not be able to move a objectClass into comparators container" );
         }
-        catch( InvalidNameException e )
+        catch( LdapException e )
         {
         }
 
@@ -539,7 +536,10 @@ public class MetaObjectClassHandlerIT ex
 
     private Dn addObjectClassToDisabledSchema() throws Exception
     {
-        Attributes attrs = LdifUtils.createJndiAttributes(
+        Dn dn = new Dn( "m-oid=" + OID + ",ou=objectClasses,cn=nis,ou=schema" );
+
+        Entry entry = new DefaultEntry(
+            dn,
             "objectClass: top",
             "objectClass: metaTop",
             "objectClass: metaObjectClass",
@@ -550,9 +550,7 @@ public class MetaObjectClassHandlerIT ex
             "m-must: cn",
             "m-may: ou" );
 
-        Dn dn = getObjectClassContainer( "nis" );
-        dn = dn.add( "m-oid" + "=" + OID );
-        getSchemaContext( getService() ).createSubcontext( JndiUtils.toName( dn ), attrs );
+        connection.add( entry );
 
         return dn;
     }
@@ -564,14 +562,12 @@ public class MetaObjectClassHandlerIT ex
     {
         addObjectClass();
 
-        Dn dn = getObjectClassContainer( "apachemeta" );
-        dn = dn.add( "m-oid" + "=" + OID );
+        Dn dn = new Dn( "m-oid=" + OID + ",ou=objectClasses,cn=apacheMeta,ou=schema" );
 
         // nis is inactive by default
-        Dn newdn = getObjectClassContainer( "nis" );
-        newdn = newdn.add( "m-oid" + "=" + OID );
+        Dn newDn = new Dn( "m-oid=" + OID + ",ou=objectClasses,cn=nis,ou=schema" );
 
-        getSchemaContext( getService() ).rename( JndiUtils.toName( dn ), JndiUtils.toName( newdn ) );
+        connection.move( dn, newDn );
 
         assertFalse( "objectClass OID should no longer be present",
             getObjectClassRegistry().contains( OID ) );
@@ -585,16 +581,14 @@ public class MetaObjectClassHandlerIT ex
         addObjectClassToDisabledSchema();
 
         // nis is inactive by default
-        Dn dn = getObjectClassContainer( "nis" );
-        dn = dn.add( "m-oid" + "=" + OID );
+        Dn dn = new Dn( "m-oid=" + OID + ",ou=objectClasses,cn=nis,ou=schema" );
 
         assertFalse( "objectClass OID should NOT be present when added to disabled nis schema",
             getObjectClassRegistry().contains( OID ) );
 
-        Dn newdn = getObjectClassContainer( "apachemeta" );
-        newdn = newdn.add( "m-oid" + "=" + OID );
+        Dn newDn = new Dn( "m-oid=" + OID + ",ou=objectClasses,cn=apachemeta,ou=schema" );
 
-        getSchemaContext( getService() ).rename( JndiUtils.toName( dn ), JndiUtils.toName( newdn ) );
+        connection.move( dn, newDn );
 
         assertTrue( "objectClass OID should be present when moved to enabled schema",
             getObjectClassRegistry().contains( OID ) );
@@ -602,6 +596,7 @@ public class MetaObjectClassHandlerIT ex
         assertEquals( "objectClass should be in apachemeta schema after move",
             getObjectClassRegistry().getSchemaName( OID ), "apachemeta" );
     }
+    
 
     // ----------------------------------------------------------------------
     // Let's test the Abstract, Auiliary and Structural inheritence enforcement
@@ -612,23 +607,22 @@ public class MetaObjectClassHandlerIT ex
     @Test
     public void testAddAbstractOCinheritingFromAbstractOC() throws Exception
     {
-        Attributes attrs = new BasicAttributes( true );
-        Attribute oc = new BasicAttribute( "objectClass", "top" );
-        oc.add( "metaTop" );
-        oc.add( "metaObjectClass" );
-        attrs.put( oc );
-
-        attrs.put( "m-oid", OID );
-        attrs.put( "m-name", "abstractOCtest");
-        attrs.put( "m-description", "An abstract oC inheriting from top" );
-        attrs.put( "m-typeObjectClass", "ABSTRACT" );
-        attrs.put( "m-supObjectClass", "top" );
-        attrs.put( "m-must", "cn" );
-        attrs.put( "m-may", "ou" );
-
-        Dn dn = getObjectClassContainer( "apachemeta" );
-        dn = dn.add( "m-oid" + "=" + OID );
-        getSchemaContext( getService() ).createSubcontext( JndiUtils.toName( dn ), attrs );
+        Dn dn = new Dn( "m-oid=" + OID + ",ou=objectClasses,cn=apacheMeta,ou=schema" );
+
+        Entry entry = new DefaultEntry(
+            dn,
+            "objectClass: top",
+            "objectClass: metaTop",
+            "objectClass: metaObjectClass",
+            "m-oid", OID,
+            "m-name: abstractOCtest",
+            "m-description: An abstract oC inheriting from top",
+            "m-typeObjectClass: ABSTRACT",
+            "m-supObjectClass: top",
+            "m-must: cn",
+            "m-may: ou" );
+
+        connection.add( entry );
 
         assertTrue( getObjectClassRegistry().contains( OID ) );
         assertEquals( getObjectClassRegistry().getSchemaName( OID ), "apachemeta" );
@@ -641,33 +635,28 @@ public class MetaObjectClassHandlerIT ex
     @Test
     public void testAddAbstractOCinheritingFromAuxiliaryOC() throws Exception
     {
-        Attributes attrs = new BasicAttributes( true );
-        Attribute oc = new BasicAttribute( "objectClass", "top" );
-        oc.add( "metaTop" );
-        oc.add( "metaObjectClass" );
-        attrs.put( oc );
-
-        attrs.put( "m-oid", OID );
-        attrs.put( "m-name", "abstractOCtest");
-        attrs.put( "m-description", "An abstract oC inheriting from top" );
-        attrs.put( "m-typeObjectClass", "ABSTRACT" );
-        attrs.put( "m-must", "cn" );
-        attrs.put( "m-may", "ou" );
-
-        Attribute sup = new BasicAttribute( "m-supObjectClass" );
-        sup.add( "top" );
-        sup.add( "javaSerializedObject");
-        attrs.put( sup );
+        Dn dn = new Dn( "m-oid=" + OID + ",ou=objectClasses,cn=apacheMeta,ou=schema" );
 
-        Dn dn = getObjectClassContainer( "apachemeta" );
-        dn = dn.add( "m-oid" + "=" + OID );
+        Entry entry = new DefaultEntry(
+            dn,
+            "objectClass: top",
+            "objectClass: metaTop",
+            "objectClass: metaObjectClass",
+            "m-oid", OID,
+            "m-name: abstractOCtest",
+            "m-description: An abstract oC inheriting from top",
+            "m-typeObjectClass: ABSTRACT",
+            "m-supObjectClass: top",
+            "m-supObjectClass: javaSerializedObject",
+            "m-must: cn",
+            "m-may: ou" );
 
         try
         {
-            getSchemaContext( getService() ).createSubcontext( JndiUtils.toName( dn ), attrs );
+            connection.add( entry );
             fail();
         }
-        catch ( NamingException ne )
+        catch ( LdapException ne )
         {
             assertTrue( true );
         }
@@ -680,33 +669,28 @@ public class MetaObjectClassHandlerIT ex
     @Test
     public void testAddAbstractOCinheritingFromStructuralOC() throws Exception
     {
-        Attributes attrs = new BasicAttributes( true );
-        Attribute oc = new BasicAttribute( "objectClass", "top" );
-        oc.add( "metaTop" );
-        oc.add( "metaObjectClass" );
-        attrs.put( oc );
-
-        attrs.put( "m-oid", OID );
-        attrs.put( "m-name", "abstractOCtest");
-        attrs.put( "m-description", "An abstract oC inheriting from top" );
-        attrs.put( "m-typeObjectClass", "ABSTRACT" );
-        attrs.put( "m-must", "cn" );
-        attrs.put( "m-may", "ou" );
-
-        Attribute sup = new BasicAttribute( "m-supObjectClass" );
-        sup.add( "top" );
-        sup.add( "person");
-        attrs.put( sup );
+        Dn dn = new Dn( "m-oid=" + OID + ",ou=objectClasses,cn=apacheMeta,ou=schema" );
 
-        Dn dn = getObjectClassContainer( "apachemeta" );
-        dn = dn.add( "m-oid" + "=" + OID );
+        Entry entry = new DefaultEntry(
+            dn,
+            "objectClass: top",
+            "objectClass: metaTop",
+            "objectClass: metaObjectClass",
+            "m-oid", OID,
+            "m-name: abstractOCtest",
+            "m-description: An abstract oC inheriting from top",
+            "m-typeObjectClass: ABSTRACT",
+            "m-supObjectClass: top",
+            "m-supObjectClass: person",
+            "m-must: cn",
+            "m-may: ou" );
 
         try
         {
-            getSchemaContext( getService() ).createSubcontext( JndiUtils.toName( dn ), attrs );
+            connection.add( entry );
             fail();
         }
-        catch ( NamingException ne )
+        catch ( LdapException ne )
         {
             assertTrue( true );
         }
@@ -719,23 +703,22 @@ public class MetaObjectClassHandlerIT ex
     @Test
     public void testAddAuxiliaryOCinheritingFromAbstractOC() throws Exception
     {
-        Attributes attrs = new BasicAttributes( true );
-        Attribute oc = new BasicAttribute( "objectClass", "top" );
-        oc.add( "metaTop" );
-        oc.add( "metaObjectClass" );
-        attrs.put( oc );
-
-        attrs.put( "m-oid", NEW_OID );
-        attrs.put( "m-name", "abstractOCtest");
-        attrs.put( "m-description", "An abstract oC inheriting from top" );
-        attrs.put( "m-typeObjectClass", "AUXILIARY" );
-        attrs.put( "m-supObjectClass", "top" );
-        attrs.put( "m-must", "cn" );
-        attrs.put( "m-may", "ou" );
-
-        Dn dn = getObjectClassContainer( "apachemeta" );
-        dn = dn.add( "m-oid" + "=" + NEW_OID );
-        getSchemaContext( getService() ).createSubcontext( JndiUtils.toName( dn ), attrs );
+        Dn dn = new Dn( "m-oid=" + NEW_OID + ",ou=objectClasses,cn=apacheMeta,ou=schema" );
+
+        Entry entry = new DefaultEntry(
+            dn,
+            "objectClass: top",
+            "objectClass: metaTop",
+            "objectClass: metaObjectClass",
+            "m-oid", NEW_OID,
+            "m-name: abstractOCtest",
+            "m-description: An abstract oC inheriting from top",
+            "m-typeObjectClass: AUXILIARY",
+            "m-supObjectClass: top",
+            "m-must: cn",
+            "m-may: ou" );
+
+        connection.add( entry );
 
         assertTrue( getObjectClassRegistry().contains( NEW_OID ) );
         assertEquals( getObjectClassRegistry().getSchemaName( NEW_OID ), "apachemeta" );
@@ -748,27 +731,23 @@ public class MetaObjectClassHandlerIT ex
     @Test
     public void testAddAuxiliaryOCinheritingFromAuxiliaryOC() throws Exception
     {
-        Attributes attrs = new BasicAttributes( true );
-        Attribute oc = new BasicAttribute( "objectClass", "top" );
-        oc.add( "metaTop" );
-        oc.add( "metaObjectClass" );
-        attrs.put( oc );
-
-        attrs.put( "m-oid", NEW_OID );
-        attrs.put( "m-name", "abstractOCtest");
-        attrs.put( "m-description", "An abstract oC inheriting from top" );
-        attrs.put( "m-typeObjectClass", "AUXILIARY" );
-        attrs.put( "m-must", "cn" );
-        attrs.put( "m-may", "ou" );
-
-        Attribute sup = new BasicAttribute( "m-supObjectClass" );
-        sup.add( "top" );
-        sup.add( "javaNamingReference");
-        attrs.put( sup );
-
-        Dn dn = getObjectClassContainer( "apachemeta" );
-        dn = dn.add( "m-oid" + "=" + NEW_OID );
-        getSchemaContext( getService() ).createSubcontext( JndiUtils.toName( dn ), attrs );
+        Dn dn = new Dn( "m-oid=" + NEW_OID + ",ou=objectClasses,cn=apacheMeta,ou=schema" );
+
+        Entry entry = new DefaultEntry(
+            dn,
+            "objectClass: top",
+            "objectClass: metaTop",
+            "objectClass: metaObjectClass",
+            "m-oid", NEW_OID,
+            "m-name: abstractOCtest",
+            "m-description: An abstract oC inheriting from top",
+            "m-typeObjectClass: AUXILIARY",
+            "m-supObjectClass: top",
+            "m-supObjectClass: javaNamingReference",
+            "m-must: cn",
+            "m-may: ou" );
+
+        connection.add( entry );
 
         assertTrue( getObjectClassRegistry().contains( NEW_OID ) );
         assertEquals( getObjectClassRegistry().getSchemaName( NEW_OID ), "apachemeta" );
@@ -781,33 +760,28 @@ public class MetaObjectClassHandlerIT ex
     @Test
     public void testAddAuxiliaryOCinheritingFromStructuralOC() throws Exception
     {
-        Attributes attrs = new BasicAttributes( true );
-        Attribute oc = new BasicAttribute( "objectClass", "top" );
-        oc.add( "metaTop" );
-        oc.add( "metaObjectClass" );
-        attrs.put( oc );
-
-        attrs.put( "m-oid", OID );
-        attrs.put( "m-name", "abstractOCtest");
-        attrs.put( "m-description", "An abstract oC inheriting from top" );
-        attrs.put( "m-typeObjectClass", "ABSTRACT" );
-        attrs.put( "m-must", "cn" );
-        attrs.put( "m-may", "ou" );
-
-        Attribute sup = new BasicAttribute( "m-supObjectClass" );
-        sup.add( "top" );
-        sup.add( "person");
-        attrs.put( sup );
+        Dn dn = new Dn( "m-oid=" + OID + ",ou=objectClasses,cn=apacheMeta,ou=schema" );
 
-        Dn dn = getObjectClassContainer( "apachemeta" );
-        dn = dn.add( "m-oid" + "=" + OID );
+        Entry entry = new DefaultEntry(
+            dn,
+            "objectClass: top",
+            "objectClass: metaTop",
+            "objectClass: metaObjectClass",
+            "m-oid", OID,
+            "m-name: abstractOCtest",
+            "m-description: An abstract oC inheriting from top",
+            "m-typeObjectClass: ABSTRACT",
+            "m-supObjectClass: top",
+            "m-supObjectClass: person",
+            "m-must: cn",
+            "m-may: ou" );
 
         try
         {
-            getSchemaContext( getService() ).createSubcontext( JndiUtils.toName( dn ), attrs );
+            connection.add( entry );
             fail();
         }
-        catch ( NamingException ne )
+        catch ( LdapException ne )
         {
             assertTrue( true );
         }
@@ -820,23 +794,22 @@ public class MetaObjectClassHandlerIT ex
     @Test
     public void testAddStructuralOCinheritingFromAbstractOC() throws Exception
     {
-        Attributes attrs = new BasicAttributes( true );
-        Attribute oc = new BasicAttribute( "objectClass", "top" );
-        oc.add( "metaTop" );
-        oc.add( "metaObjectClass" );
-        attrs.put( oc );
-
-        attrs.put( "m-oid", NEW_OID );
-        attrs.put( "m-name", "abstractOCtest");
-        attrs.put( "m-description", "An abstract oC inheriting from top" );
-        attrs.put( "m-typeObjectClass", "STRUCTURAL" );
-        attrs.put( "m-supObjectClass", "top" );
-        attrs.put( "m-must", "cn" );
-        attrs.put( "m-may", "ou" );
-
-        Dn dn = getObjectClassContainer( "apachemeta" );
-        dn = dn.add( "m-oid" + "=" + NEW_OID );
-        getSchemaContext( getService() ).createSubcontext( JndiUtils.toName( dn ), attrs );
+        Dn dn = new Dn( "m-oid=" + NEW_OID + ",ou=objectClasses,cn=apacheMeta,ou=schema" );
+        
+        Entry entry = new DefaultEntry(
+            dn,
+            "objectClass: top",
+            "objectClass: metaTop",
+            "objectClass: metaObjectClass",
+            "m-oid", NEW_OID,
+            "m-name: abstractOCtest",
+            "m-description: An abstract oC inheriting from top",
+            "m-typeObjectClass: STRUCTURAL",
+            "m-supObjectClass: top",
+            "m-must: cn",
+            "m-may: ou" );
+
+        connection.add( entry );
 
         assertTrue( getObjectClassRegistry().contains( NEW_OID ) );
         assertEquals( getObjectClassRegistry().getSchemaName( NEW_OID ), "apachemeta" );
@@ -849,33 +822,28 @@ public class MetaObjectClassHandlerIT ex
     @Test
     public void testAddStructuralOCinheritingFromAuxiliaryOC() throws Exception
     {
-        Attributes attrs = new BasicAttributes( true );
-        Attribute oc = new BasicAttribute( "objectClass", "top" );
-        oc.add( "metaTop" );
-        oc.add( "metaObjectClass" );
-        attrs.put( oc );
-
-        attrs.put( "m-oid", NEW_OID );
-        attrs.put( "m-name", "abstractOCtest");
-        attrs.put( "m-description", "An abstract oC inheriting from top" );
-        attrs.put( "m-typeObjectClass", "STRUCTURAL" );
-        attrs.put( "m-must", "cn" );
-        attrs.put( "m-may", "ou" );
-
-        Attribute sup = new BasicAttribute( "m-supObjectClass" );
-        sup.add( "top" );
-        sup.add( "javaNamingReference");
-        attrs.put( sup );
-
-        Dn dn = getObjectClassContainer( "apachemeta" );
-        dn = dn.add( "m-oid" + "=" + NEW_OID );
+        Dn dn = new Dn( "m-oid=" + NEW_OID + ",ou=objectClasses,cn=apacheMeta,ou=schema" );
+        
+        Entry entry = new DefaultEntry(
+            dn,
+            "objectClass: top",
+            "objectClass: metaTop",
+            "objectClass: metaObjectClass",
+            "m-oid", NEW_OID,
+            "m-name: abstractOCtest",
+            "m-description: An abstract oC inheriting from top",
+            "m-typeObjectClass: STRUCTURAL",
+            "m-supObjectClass: top",
+            "m-supObjectClass: javaNamingReference",
+            "m-must: cn",
+            "m-may: ou" );
 
         try
         {
-            getSchemaContext( getService() ).createSubcontext( JndiUtils.toName( dn ), attrs );
+            connection.add( entry );
             fail();
         }
-        catch ( NamingException ne )
+        catch ( LdapException ne )
         {
             assertTrue( true );
         }
@@ -888,27 +856,23 @@ public class MetaObjectClassHandlerIT ex
     @Test
     public void testAddStructuralOCinheritingFromStructuralOC() throws Exception
     {
-        Attributes attrs = new BasicAttributes( true );
-        Attribute oc = new BasicAttribute( "objectClass", "top" );
-        oc.add( "metaTop" );
-        oc.add( "metaObjectClass" );
-        attrs.put( oc );
-
-        attrs.put( "m-oid", NEW_OID );
-        attrs.put( "m-name", "abstractOCtest");
-        attrs.put( "m-description", "An abstract oC inheriting from top" );
-        attrs.put( "m-typeObjectClass", "STRUCTURAL" );
-        attrs.put( "m-must", "cn" );
-        attrs.put( "m-may", "ou" );
-
-        Attribute sup = new BasicAttribute( "m-supObjectClass" );
-        sup.add( "top" );
-        sup.add( "person");
-        attrs.put( sup );
-
-        Dn dn = getObjectClassContainer( "apachemeta" );
-        dn = dn.add( "m-oid" + "=" + NEW_OID );
-        getSchemaContext( getService() ).createSubcontext( JndiUtils.toName( dn ), attrs );
+        Dn dn = new Dn( "m-oid=" + NEW_OID + ",ou=objectClasses,cn=apacheMeta,ou=schema" );
+        
+        Entry entry = new DefaultEntry(
+            dn,
+            "objectClass: top",
+            "objectClass: metaTop",
+            "objectClass: metaObjectClass",
+            "m-oid", NEW_OID,
+            "m-name: abstractOCtest",
+            "m-description: An abstract oC inheriting from top",
+            "m-typeObjectClass: STRUCTURAL",
+            "m-supObjectClass: top",
+            "m-supObjectClass: person",
+            "m-must: cn",
+            "m-may: ou" );
+
+        connection.add( entry );
 
         assertTrue( getObjectClassRegistry().contains( NEW_OID ) );
         assertEquals( getObjectClassRegistry().getSchemaName( NEW_OID ), "apachemeta" );

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSchemaHandlerIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSchemaHandlerIT.java?rev=1202451&r1=1202450&r2=1202451&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSchemaHandlerIT.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSchemaHandlerIT.java Tue Nov 15 22:37:11 2011
@@ -20,30 +20,26 @@
 package org.apache.directory.server.core.schema;
 
 
-import static org.apache.directory.server.core.integ.IntegrationUtils.getSchemaContext;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
-import javax.naming.NameNotFoundException;
-import javax.naming.NamingException;
-import javax.naming.OperationNotSupportedException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.BasicAttribute;
-import javax.naming.directory.DirContext;
-import javax.naming.directory.ModificationItem;
-import javax.naming.ldap.LdapContext;
-
+import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.server.core.annotations.CreateDS;
 import org.apache.directory.server.core.integ.FrameworkRunner;
 import org.apache.directory.server.core.integ.IntegrationUtils;
 import org.apache.directory.shared.ldap.model.constants.MetaSchemaConstants;
 import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
-import org.apache.directory.shared.ldap.model.ldif.LdifUtils;
+import org.apache.directory.shared.ldap.model.entry.Attribute;
+import org.apache.directory.shared.ldap.model.entry.DefaultEntry;
+import org.apache.directory.shared.ldap.model.entry.DefaultModification;
+import org.apache.directory.shared.ldap.model.entry.Entry;
+import org.apache.directory.shared.ldap.model.entry.ModificationOperation;
+import org.apache.directory.shared.ldap.model.exception.LdapException;
 import org.apache.directory.shared.ldap.model.name.Dn;
+import org.apache.directory.shared.ldap.model.schema.SchemaManager;
 import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
@@ -104,19 +100,24 @@ public class MetaSchemaHandlerIT extends
     /** Another test attribute : krb5principalName taken from the Krb5Kdc schema */
     private static final String KRB5_PRINCIPAL_NAME_ATTR = "krb5PrincipalName";
     
+    public static SchemaManager schemaManager;
+    private static LdapConnection connection;
+
 
     @Before
-    public void checkSambaSchema() throws Exception
+    public void setup() throws Exception
     {
-        LdapContext schemaRoot = getSchemaContext( getService() );
+        super.init();
+        connection = IntegrationUtils.getAdminConnection( getService() );
+        schemaManager = getService().getSchemaManager();
 
         // check that there is a samba schema installed and that is is disabled
-        Attributes attributes = schemaRoot.getAttributes( "cn=samba" );
-        assertNotNull( attributes );
-        assertTrue( attributes.get( MetaSchemaConstants.M_DISABLED_AT ).contains( "TRUE" ) );
-        attributes = schemaRoot.getAttributes( "ou=attributeTypes,cn=samba" );
-        assertNotNull( attributes );
-        assertTrue( attributes.get( SchemaConstants.OU_AT ).contains( "attributetypes" ) );
+        Entry entry = connection.lookup( "cn=samba,ou=schema" );
+        assertNotNull( entry );
+        assertTrue( entry.get( MetaSchemaConstants.M_DISABLED_AT ).contains( "TRUE" ) );
+        entry = connection.lookup( "ou=attributeTypes,cn=samba,ou=schema" );
+        assertNotNull( entry );
+        assertTrue( entry.get( SchemaConstants.OU_AT ).contains( "attributetypes" ) );
         
         // Disable the NIS schema
         IntegrationUtils.disableSchema( getService(), "nis" );
@@ -125,30 +126,32 @@ public class MetaSchemaHandlerIT extends
     
     private void createDisabledBrokenSchema() throws Exception
     {
-        LdapContext schemaRoot = getSchemaContext( getService() );
-
+        Dn dn = new Dn( "cn=broken,ou=schema" );
+    
         // Create the schema
-        Attributes dummySchema = LdifUtils.createJndiAttributes(
+        Entry dummySchema = new DefaultEntry(
+            dn,
             "objectClass: top",
             "objectClass", MetaSchemaConstants.META_SCHEMA_OC,
             "cn: broken",
             MetaSchemaConstants.M_DISABLED_AT, "TRUE" );
         
-        schemaRoot.createSubcontext( "cn=broken", dummySchema );
+        connection.add( dummySchema );
     }
 
     
     private void createEnabledValidSchema( String schemaName ) throws Exception
     {
-        LdapContext schemaRoot = getSchemaContext( getService() );
+        Dn dn = new Dn( "cn=" + schemaName + ",ou=schema" );
 
         // Create the schema
-        Attributes dummySchema = LdifUtils.createJndiAttributes(
+        Entry entry = new DefaultEntry(
+            dn,
             "objectClass: top",
             "objectClass", MetaSchemaConstants.META_SCHEMA_OC,
             "cn", schemaName );
         
-        schemaRoot.createSubcontext( "cn=" + schemaName, dummySchema );
+        connection.add( entry );
     }
 
     // -----------------------------------------------------------------------
@@ -172,7 +175,7 @@ public class MetaSchemaHandlerIT extends
         
         // double check and make sure an attribute from that schema is
         // not in the AttributeTypeRegistry
-        assertFalse( getService().getSchemaManager().getAttributeTypeRegistry().contains( UID_NUMBER_ATTR ) );
+        assertFalse( schemaManager.getAttributeTypeRegistry().contains( UID_NUMBER_ATTR ) );
         
         // now enable the test schema
         IntegrationUtils.enableSchema( getService(), "nis" );
@@ -182,7 +185,7 @@ public class MetaSchemaHandlerIT extends
         
         // double check and make sure the test attribute from the
         // test schema is now loaded and present within the attr registry
-        assertTrue( getService().getSchemaManager().getAttributeTypeRegistry().contains( UID_NUMBER_ATTR ) );
+        assertTrue( schemaManager.getAttributeTypeRegistry().contains( UID_NUMBER_ATTR ) );
     }
 
 
@@ -203,7 +206,7 @@ public class MetaSchemaHandlerIT extends
             IntegrationUtils.enableSchema( getService(), "wrong" );
             fail();
         }
-        catch ( NameNotFoundException lnnfe )
+        catch ( LdapException lnnfe )
         {
             // Expected
             assertTrue( true );
@@ -231,7 +234,7 @@ public class MetaSchemaHandlerIT extends
         
         // double check and make sure an attribute from that schema is
         // not in the AttributeTypeRegistry
-        assertFalse( getService().getSchemaManager().getAttributeTypeRegistry().contains( UID_NUMBER_ATTR ) );
+        assertFalse( schemaManager.getAttributeTypeRegistry().contains( UID_NUMBER_ATTR ) );
         
         // now enable the test schema
         IntegrationUtils.enableSchema( getService(), "nis" );
@@ -244,7 +247,7 @@ public class MetaSchemaHandlerIT extends
         
         // double check and make sure the test attribute from the
         // test schema is now loaded and present within the attr registry
-        assertTrue( getService().getSchemaManager().getAttributeTypeRegistry().contains( UID_NUMBER_ATTR ) );
+        assertTrue( schemaManager.getAttributeTypeRegistry().contains( UID_NUMBER_ATTR ) );
     }
 
     
@@ -282,7 +285,7 @@ public class MetaSchemaHandlerIT extends
         
         // double check and make sure an attribute from that schema is
         // in the AttributeTypeRegistry
-        assertTrue( getService().getSchemaManager().getAttributeTypeRegistry().contains( KRB5_PRINCIPAL_NAME_ATTR ) );
+        assertTrue( schemaManager.getAttributeTypeRegistry().contains( KRB5_PRINCIPAL_NAME_ATTR ) );
         
         // now disable the krb5kdc schema
         IntegrationUtils.disableSchema( getService(), "krb5kdc" );
@@ -292,7 +295,7 @@ public class MetaSchemaHandlerIT extends
         
         // double check and make sure the test attribute from the
         // test schema is now loaded and present within the attr registry
-        assertFalse( getService().getSchemaManager().getAttributeTypeRegistry().contains( KRB5_PRINCIPAL_NAME_ATTR ) );
+        assertFalse( schemaManager.getAttributeTypeRegistry().contains( KRB5_PRINCIPAL_NAME_ATTR ) );
     }
 
 
@@ -313,7 +316,7 @@ public class MetaSchemaHandlerIT extends
             IntegrationUtils.disableSchema( getService(), "wrong" );
             fail();
         }
-        catch ( NameNotFoundException lnnfe )
+        catch ( LdapException lnnfe )
         {
             // Expected
             assertTrue( true );
@@ -334,14 +337,14 @@ public class MetaSchemaHandlerIT extends
     public void testDisableSchemaAlreadyDisabled() throws Exception
     {
         // check that the nis schema is loaded
-        assertTrue( IntegrationUtils.isLoaded(  getService(), "nis" ) );
+        assertTrue( IntegrationUtils.isLoaded( getService(), "nis" ) );
         
         // Check that it's not enabled
         assertTrue( IntegrationUtils.isDisabled( getService(), "nis" ) );
         
         // double check and make sure an attribute from that schema is
         // not in the AttributeTypeRegistry
-        assertFalse( getService().getSchemaManager().getAttributeTypeRegistry().contains( UID_NUMBER_ATTR ) );
+        assertFalse( schemaManager.getAttributeTypeRegistry().contains( UID_NUMBER_ATTR ) );
         
         // now disable the test schema again
         IntegrationUtils.disableSchema( getService(), "nis" );
@@ -351,7 +354,7 @@ public class MetaSchemaHandlerIT extends
         
         // double check and make sure the test attribute from the
         // test schema is not loaded and present within the attr registry
-        assertFalse( getService().getSchemaManager().getAttributeTypeRegistry().contains( UID_NUMBER_ATTR ) );
+        assertFalse( schemaManager.getAttributeTypeRegistry().contains( UID_NUMBER_ATTR ) );
     }
 
     
@@ -372,7 +375,7 @@ public class MetaSchemaHandlerIT extends
         
         // double check and make sure an attribute from that schema is
         // in the AttributeTypeRegistry
-        assertTrue( getService().getSchemaManager().getAttributeTypeRegistry().contains( "cn" ) );
+        assertTrue( schemaManager.getAttributeTypeRegistry().contains( "cn" ) );
         
         // now disable the system schema : it should break the registries, thus being rejected
         IntegrationUtils.disableSchema( getService(), "system" );
@@ -382,7 +385,7 @@ public class MetaSchemaHandlerIT extends
         
         // double check and make sure the test attribute from the
         // test schema is loaded and present within the attr registry
-        assertTrue( getService().getSchemaManager().getAttributeTypeRegistry().contains( "cn" ) );
+        assertTrue( schemaManager.getAttributeTypeRegistry().contains( "cn" ) );
     }
 
     // -----------------------------------------------------------------------
@@ -394,18 +397,16 @@ public class MetaSchemaHandlerIT extends
     @Test
     public void testAddEnabledValidSchema() throws Exception
     {
-        Dn dn = getSchemaContainer( "dummy" );
+        Dn dn = new Dn( "cn=dummy,ou=schema" );
 
-        assertFalse( isOnDisk0( dn ) );
+        assertFalse( isOnDisk( dn ) );
 
-        LdapContext schemaRoot = getSchemaContext( getService() );
-        
         createEnabledValidSchema( "dummy" );
         
         assertTrue( IntegrationUtils.isEnabled( getService(), "dummy" ) );
-        assertNotNull( schemaRoot.lookup( "cn=dummy" ) );
+        assertNotNull( connection.lookup( "cn=dummy,ou=schema" ) );
         
-        assertTrue( isOnDisk0( dn ) );
+        assertTrue( isOnDisk( dn ) );
     }
     
     
@@ -415,25 +416,25 @@ public class MetaSchemaHandlerIT extends
     @Test
     public void testAddEnabledSchemaWithExistingEnabledDeps() throws Exception
     {
-        Dn dn = getSchemaContainer( "dummy" );
+        Dn dn = new Dn( "cn=dummy,ou=schema" );
 
-        assertFalse( isOnDisk0( dn ) );
+        assertFalse( isOnDisk( dn ) );
 
-        LdapContext schemaRoot = getSchemaContext( getService() );
-        Attributes dummySchema = LdifUtils.createJndiAttributes(
-                "objectClass: top",
-                "objectClass", MetaSchemaConstants.META_SCHEMA_OC,
-                "cn: dummy",
-                "m-dependencies: core",
-                "m-dependencies: system",
-                MetaSchemaConstants.M_DISABLED_AT, "FALSE");
+        Entry dummySchema = new DefaultEntry(
+            dn,
+            "objectClass: top",
+            "objectClass", MetaSchemaConstants.META_SCHEMA_OC,
+            "cn: dummy",
+            "m-dependencies: core",
+            "m-dependencies: system",
+            MetaSchemaConstants.M_DISABLED_AT, "FALSE");
         
-        schemaRoot.createSubcontext( "cn=dummy", dummySchema );
+        connection.add( dummySchema );
         
         assertTrue( IntegrationUtils.isEnabled( getService(), "dummy" ) );
-        assertNotNull( schemaRoot.lookup( "cn=dummy" ) );
+        assertNotNull( connection.lookup( "cn=dummy, ou=schema" ) );
         
-        assertTrue( isOnDisk0( dn ) );
+        assertTrue( isOnDisk( dn ) );
     }
     
     
@@ -443,12 +444,12 @@ public class MetaSchemaHandlerIT extends
     @Test
     public void testAddEnabledSchemaWithExistingDisabledDeps() throws Exception
     {
-        Dn dn = getSchemaContainer( "dummy" );
+        Dn dn = new Dn( "cn=dummy,ou=schema" );
 
-        assertFalse( isOnDisk0( dn ) );
+        assertFalse( isOnDisk( dn ) );
 
-        LdapContext schemaRoot = getSchemaContext( getService() );
-        Attributes dummySchema = LdifUtils.createJndiAttributes(
+        Entry dummySchema = new DefaultEntry(
+            dn,
             "objectClass: top",
             "objectClass", MetaSchemaConstants.META_SCHEMA_OC,
             "cn: dummy",
@@ -458,16 +459,16 @@ public class MetaSchemaHandlerIT extends
         
         try
         {
-            schemaRoot.createSubcontext( "cn=dummy", dummySchema );
+            connection.add( dummySchema );
             fail();
         }
-        catch ( OperationNotSupportedException lonse )
+        catch ( LdapException lonse )
         {
             // expected
         }
         
         assertFalse( IntegrationUtils.isLoaded( getService(), "dummy" ) );
-        assertFalse( isOnDisk0( dn ) );
+        assertFalse( isOnDisk( dn ) );
     }
     
     
@@ -477,12 +478,12 @@ public class MetaSchemaHandlerIT extends
     @Test
     public void testAddEnabledSchemaWithNotExistingDeps() throws Exception
     {
-        Dn dn = getSchemaContainer( "dummy" );
+        Dn dn = new Dn( "cn=dummy,ou=schema" );
 
-        assertFalse( isOnDisk0( dn ) );
+        assertFalse( isOnDisk( dn ) );
 
-        LdapContext schemaRoot = getSchemaContext( getService() );
-        Attributes dummySchema = LdifUtils.createJndiAttributes(
+        Entry dummySchema = new DefaultEntry(
+            dn,
             "objectClass: top",
             "objectClass", MetaSchemaConstants.META_SCHEMA_OC,
             "cn: dummy",
@@ -492,16 +493,16 @@ public class MetaSchemaHandlerIT extends
         
         try
         {
-            schemaRoot.createSubcontext( "cn=dummy", dummySchema );
+            connection.add( dummySchema );
             fail();
         }
-        catch ( OperationNotSupportedException lonse )
+        catch ( LdapException lonse )
         {
             // expected
         }
         
         assertFalse( IntegrationUtils.isLoaded( getService(), "dummy" ) );
-        assertFalse( isOnDisk0( dn ) );
+        assertFalse( isOnDisk( dn ) );
     }
 
     
@@ -514,23 +515,19 @@ public class MetaSchemaHandlerIT extends
     @Test
     public void testDeleteEnabledValidSchema() throws Exception
     {
-        Dn dn = getSchemaContainer( "dummy" );
-        LdapContext schemaRoot = getSchemaContext( getService() );
+        Dn dn = new Dn( "cn=dummy,ou=schema" );
         
         // Create a schema we will delete
         createEnabledValidSchema( "dummy" );
-        assertTrue( isOnDisk0( dn ) );
+        assertTrue( isOnDisk( dn ) );
         assertTrue( IntegrationUtils.isLoaded( getService(), "dummy" ) );
 
         // Delete the schema
-        schemaRoot.destroySubcontext( "cn=dummy" );
+        connection.delete( dn );
 
-        assertFalse( isOnDisk0( dn ) );
+        assertFalse( isOnDisk( dn ) );
         assertFalse( IntegrationUtils.isLoaded( getService(), "dummy" ) );
     }
-
-    
-    
     
     
     /**
@@ -543,17 +540,19 @@ public class MetaSchemaHandlerIT extends
     @Ignore
     public void testAddDisabledSchemaNoDeps() throws Exception
     {
-        LdapContext schemaRoot = getSchemaContext( getService() );
-        Attributes dummySchema = LdifUtils.createJndiAttributes(
+        Dn dn = new Dn( "cn=dummy,ou=schema" );
+
+        Entry dummySchema = new DefaultEntry(
+            dn,
             "objectClass: top",
             "objectClass", MetaSchemaConstants.META_SCHEMA_OC,
             "cn: dummy",
             MetaSchemaConstants.M_DISABLED_AT, "TRUE" );
         
-        schemaRoot.createSubcontext( "cn=dummy", dummySchema );
+        connection.add( dummySchema );
         
         assertFalse( IntegrationUtils.isEnabled( getService(), "dummy" ) );
-        assertNotNull( schemaRoot.lookup( "cn=dummy" ) );
+        assertNotNull( connection.lookup( "cn=dummy,ou=schema" ) );
     }
     
     
@@ -567,8 +566,10 @@ public class MetaSchemaHandlerIT extends
     @Ignore
     public void testAddDisabledSchemaWithDeps() throws Exception
     {
-        LdapContext schemaRoot = getSchemaContext( getService() );
-        Attributes dummySchema = LdifUtils.createJndiAttributes(
+        Dn dn = new Dn( "cn=dummy,ou=schema" );
+
+        Entry dummySchema = new DefaultEntry(
+            dn,
             "objectClass: top",
             "objectClass", MetaSchemaConstants.META_SCHEMA_OC,
             "cn: dummy",
@@ -576,10 +577,10 @@ public class MetaSchemaHandlerIT extends
             "m-dependencies: nis",
             "m-dependencies: core" );
         
-        schemaRoot.createSubcontext( "cn=dummy", dummySchema );
+        connection.add( dummySchema );
         
         assertFalse( IntegrationUtils.isEnabled( getService(), "dummy" ) );
-        assertNotNull( schemaRoot.lookup( "cn=dummy" ) );
+        assertNotNull( connection.lookup( "cn=dummy,ou=schema" ) );
     }
     
     
@@ -593,8 +594,10 @@ public class MetaSchemaHandlerIT extends
     @Ignore
     public void testRejectDisabledSchemaAddWithMissingDeps() throws Exception
     {
-        LdapContext schemaRoot = getSchemaContext( getService() );
-        Attributes dummySchema = LdifUtils.createJndiAttributes(
+        Dn dn = new Dn( "cn=dummy,ou=schema" );
+
+        Entry dummySchema = new DefaultEntry(
+            dn,
             "objectClass: top",
             "objectClass", MetaSchemaConstants.META_SCHEMA_OC,
             "cn: dummy",
@@ -604,9 +607,9 @@ public class MetaSchemaHandlerIT extends
         
         try
         {
-            schemaRoot.createSubcontext( "cn=dummy", dummySchema );
+            connection.add( dummySchema );
         }
-        catch( OperationNotSupportedException e )
+        catch( LdapException e )
         {
             // expected
         }
@@ -616,14 +619,15 @@ public class MetaSchemaHandlerIT extends
         //noinspection EmptyCatchBlock
         try
         {
-            schemaRoot.lookup( "cn=dummy" );
+            connection.lookup( "cn=dummy,ou=schema" );
             fail( "schema should not be added to schema partition" );
         }
-        catch( NamingException e )
+        catch( LdapException e )
         {
         }
     }
     
+    
     /**
      * Tests the addition of a new metaSchema object that is enabled
      * on addition and has no dependencies.
@@ -634,17 +638,19 @@ public class MetaSchemaHandlerIT extends
     @Ignore
     public void testAddEnabledSchemaNoDeps() throws Exception
     {
-        LdapContext schemaRoot = getSchemaContext( getService() );
-        Attributes dummySchema = LdifUtils.createJndiAttributes(
+        Dn dn = new Dn( "cn=dummy,ou=schema" );
+
+        Entry dummySchema = new DefaultEntry(
+            dn,
             "objectClass: top",
             "objectClass: metaSchema",
             "cn: dummy"
             );
 
-        schemaRoot.createSubcontext( "cn=dummy", dummySchema );
+        connection.add( dummySchema );
         
         assertTrue( IntegrationUtils.isEnabled( getService(), "dummy" ) );
-        assertNotNull( schemaRoot.lookup( "cn=dummy" ) );
+        assertNotNull( connection.lookup( "cn=dummy,ou=schema" ) );
     }
     
     
@@ -658,8 +664,10 @@ public class MetaSchemaHandlerIT extends
     @Ignore
     public void testRejectEnabledSchemaAddWithDisabledDeps() throws Exception
     {
-        LdapContext schemaRoot = getSchemaContext( getService() );
-        Attributes dummySchema = LdifUtils.createJndiAttributes(
+        Dn dn = new Dn( "cn=dummy,ou=schema" );
+
+        Entry dummySchema = new DefaultEntry(
+            dn,
             "objectClass: top",
             "objectClass", MetaSchemaConstants.META_SCHEMA_OC,
             "cn: dummy",
@@ -667,10 +675,10 @@ public class MetaSchemaHandlerIT extends
         
         try
         {
-            schemaRoot.createSubcontext( "cn=dummy", dummySchema );
+            connection.add( dummySchema );
             fail( "should not be able to add enabled schema with deps on disabled schemas" );
         }
-        catch( OperationNotSupportedException e )
+        catch( LdapException e )
         {
             // expected
         }
@@ -680,10 +688,10 @@ public class MetaSchemaHandlerIT extends
         //noinspection EmptyCatchBlock
         try
         {
-            schemaRoot.lookup( "cn=dummy" );
+            connection.lookup( "cn=dummy,ou=schema" );
             fail( "schema should not be added to schema partition" );
         }
-        catch( NamingException e )
+        catch( LdapException e )
         {
         }
     }
@@ -703,14 +711,14 @@ public class MetaSchemaHandlerIT extends
     @Ignore
     public void testDeleteSchemaNoDependents() throws Exception
     {
-        LdapContext schemaRoot = getSchemaContext( getService() );
+        Dn dn = new Dn( "cn=dummy,ou=schema" );
 
         // add the dummy schema enabled
         testAddEnabledSchemaNoDeps();
         assertTrue( IntegrationUtils.isEnabled( getService(), "dummy" ) );
         
         // delete it now
-        schemaRoot.destroySubcontext( "cn=dummy" );
+        connection.delete( dn );
         assertFalse( IntegrationUtils.isEnabled( getService(), "dummy" ) );
     }
     
@@ -724,25 +732,21 @@ public class MetaSchemaHandlerIT extends
     @Ignore
     public void testRejectSchemaDeleteWithDependents() throws Exception
     {
-        LdapContext schemaRoot = getSchemaContext( getService() );
-
         // add the dummy schema enabled
         testAddEnabledSchemaNoDeps();
         assertTrue( IntegrationUtils.isEnabled( getService(), "dummy" ) );
         
         // make the nis schema depend on the dummy schema
-        ModificationItem[] mods = new ModificationItem[1];
-        mods[0] = new ModificationItem( DirContext.ADD_ATTRIBUTE,
-                new BasicAttribute( "m-dependencies", "dummy" ) );
-        schemaRoot.modifyAttributes( "cn=nis", mods );
+        connection.modify( "cn=nis,ou=schema",
+            new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, "m-dependencies", "dummy" ) );
         
         // attempt to delete it now & it should fail
         try
         {
-            schemaRoot.destroySubcontext( "cn=dummy" );
+            connection.delete( "cn=dummy,ou=schema" );
             fail( "should not be able to delete a schema with dependents" );
         }
-        catch ( OperationNotSupportedException e )
+        catch ( LdapException e )
         {
             // expected
         }
@@ -761,9 +765,10 @@ public class MetaSchemaHandlerIT extends
     @Ignore
     public void testRejectEnabledSchemaAddWithMisingDeps() throws Exception
     {
-        LdapContext schemaRoot = getSchemaContext( getService() );
+        Dn dn = new Dn( "cn=dummy,ou=schema" );
 
-        Attributes dummySchema = LdifUtils.createJndiAttributes(
+        Entry dummySchema = new DefaultEntry(
+            dn,
             "objectClass: top",
             "objectClass", MetaSchemaConstants.META_SCHEMA_OC,
             "cn: dummy",
@@ -771,10 +776,10 @@ public class MetaSchemaHandlerIT extends
         
         try
         {
-            schemaRoot.createSubcontext( "cn=dummy", dummySchema );
+            connection.add( dummySchema );
             fail( "should not be able to add enabled schema with deps on missing schemas" );
         }
-        catch( OperationNotSupportedException e )
+        catch( LdapException e )
         {
             // expected
         }
@@ -784,10 +789,10 @@ public class MetaSchemaHandlerIT extends
         //noinspection EmptyCatchBlock
         try
         {
-            schemaRoot.lookup( "cn=dummy" );
+            connection.lookup( "cn=dummy,ou=schema" );
             fail( "schema should not be added to schema partition" );
         }
-        catch( NamingException e )
+        catch( LdapException e )
         {
         }
     }
@@ -804,8 +809,6 @@ public class MetaSchemaHandlerIT extends
     @Ignore
     public void testDisableSchemaWithEnabledDependents() throws Exception
     {
-        LdapContext schemaRoot = getSchemaContext( getService() );
-
         // let's enable the test schema and add the dummy schema
         // as enabled by default and dependends on the test schema
         
@@ -813,13 +816,16 @@ public class MetaSchemaHandlerIT extends
         testEnableExistingSchema();
         
         // adds enabled dummy schema that depends on the test schema
-        Attributes dummySchema = LdifUtils.createJndiAttributes(
+        Dn dn = new Dn( "cn=dummy, ou=schema" );
+        
+        Entry dummySchema = new DefaultEntry(
+            dn,
             "objectClass: top",
             "objectClass", MetaSchemaConstants.META_SCHEMA_OC,
             "cn: dummy",
             "m-dependencies: nis" );
         
-        schemaRoot.createSubcontext( "cn=dummy", dummySchema );
+        connection.add( dummySchema );
         
         // check that the nis schema is loaded and the dummy schema is loaded
         assertTrue( IntegrationUtils.isEnabled( getService(), "nis" ) );
@@ -827,20 +833,17 @@ public class MetaSchemaHandlerIT extends
         
         // double check and make sure an attribute from that schema is
         // in the AttributeTypeRegistry
-        assertTrue( getService().getSchemaManager().getAttributeTypeRegistry().contains( UID_NUMBER_ATTR ) );
+        assertTrue( schemaManager.getAttributeTypeRegistry().contains( UID_NUMBER_ATTR ) );
         
         // now try to disable the test schema which should fail
         // since it's dependent, the dummy schema, is enabled
-        ModificationItem[] mods = new ModificationItem[1];
-        Attribute attr = new BasicAttribute( "m-disabled", "TRUE" );
-        mods[0] = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr );
-        
         try
         {
-            schemaRoot.modifyAttributes( "cn=nis", mods );
+            connection.modify( "cn=nis,ou=schema",
+                new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, "m-disabled", "TRUE" ) );
             fail( "attempt to disable schema with enabled dependents should fail" );
         }
-        catch ( OperationNotSupportedException e )
+        catch ( LdapException e )
         {
             // expected
         }
@@ -851,7 +854,7 @@ public class MetaSchemaHandlerIT extends
         
         // double check and make sure the test attribute from the test
         // schema is still loaded and present within the attr registry
-        assertTrue( getService().getSchemaManager().getAttributeTypeRegistry().contains( UID_NUMBER_ATTR ) );
+        assertTrue( schemaManager.getAttributeTypeRegistry().contains( UID_NUMBER_ATTR ) );
     }
     
     
@@ -869,25 +872,24 @@ public class MetaSchemaHandlerIT extends
     @Ignore
     public void testSchemaRenameDisabledSchema() throws Exception
     {
-        LdapContext schemaRoot = getSchemaContext( getService() );
-        schemaRoot.rename( "cn=samba", "cn=foo" );
-        assertNotNull( schemaRoot.lookup( "cn=foo" ) );
+        connection.rename( "cn=samba,ou=schema", "cn=foo" );
+        assertNotNull( connection.lookup( "cn=foo,ou=schema" ) );
 
         // check that there is a samba schema installed and that is is disabled
-        Attributes attributes = schemaRoot.getAttributes( "cn=foo" );
-        assertNotNull( attributes );
-        assertTrue( attributes.get( MetaSchemaConstants.M_DISABLED_AT ).contains( "TRUE" ) );
-        attributes = schemaRoot.getAttributes( "ou=attributeTypes,cn=foo" );
-        assertNotNull( attributes );
-        assertTrue( attributes.get( SchemaConstants.OU_AT ).contains( "attributetypes" ) );
+        Entry entry = connection.lookup( "cn=foo,ou=schema" );
+        assertNotNull( entry );
+        assertTrue( entry.get( MetaSchemaConstants.M_DISABLED_AT ).contains( "TRUE" ) );
+        entry = connection.lookup( "ou=attributeTypes,cn=foo,ou=schema" );
+        assertNotNull( entry );
+        assertTrue( entry.get( SchemaConstants.OU_AT ).contains( "attributetypes" ) );
 
         //noinspection EmptyCatchBlock
         try
         {
-            schemaRoot.lookup( "cn=samba" );
+            connection.lookup( "cn=samba,ou=schema" );
             fail( "the samba schema should not be present after a rename to foo" );
         }
-        catch( NameNotFoundException e )
+        catch( LdapException e )
         {
         }
     }
@@ -904,26 +906,25 @@ public class MetaSchemaHandlerIT extends
     @Ignore
     public void testRejectSchemaRenameWithDeps() throws Exception
     {
-        LdapContext schemaRoot = getSchemaContext( getService() );
         try
         {
-            schemaRoot.rename( "cn=nis", "cn=foo" );
+            connection.rename( "cn=nis,ou=schema", "cn=foo" );
             fail( "should not be able to rename nis which has samba as it's dependent" );
         }
-        catch ( OperationNotSupportedException onse )
+        catch ( LdapException onse )
         {
             // expected
         }
         
-        assertNotNull( schemaRoot.lookup( "cn=nis" ) );
+        assertNotNull( connection.lookup( "cn=nis,ou=schema" ) );
 
         //noinspection EmptyCatchBlock
         try
         {
-            schemaRoot.lookup( "cn=foo" );
+            connection.lookup( "cn=foo,ou=schema" );
             fail( "the foo schema should not be present after rejecting the rename" );
         }
-        catch( NameNotFoundException e )
+        catch( LdapException e )
         {
         }
     }
@@ -940,24 +941,22 @@ public class MetaSchemaHandlerIT extends
     @Ignore
     public void testSchemaRenameEnabledSchema() throws Exception
     {
-        LdapContext schemaRoot = getSchemaContext( getService() );
-
         IntegrationUtils.enableSchema( getService(), "samba" );
-        assertTrue( getService().getSchemaManager().getAttributeTypeRegistry().contains( "sambaNTPassword" ) );
-        assertEquals( "samba", getService().getSchemaManager().getAttributeTypeRegistry().getSchemaName( "sambaNTPassword" ) );
+        assertTrue( schemaManager.getAttributeTypeRegistry().contains( "sambaNTPassword" ) );
+        assertEquals( "samba", schemaManager.getAttributeTypeRegistry().getSchemaName( "sambaNTPassword" ) );
         
-        schemaRoot.rename( "cn=samba", "cn=foo" );
-        assertNotNull( schemaRoot.lookup( "cn=foo" ) );
-        assertTrue( getService().getSchemaManager().getAttributeTypeRegistry().contains( "sambaNTPassword" ) );
-        assertEquals( "foo", getService().getSchemaManager().getAttributeTypeRegistry().getSchemaName( "sambaNTPassword" ) );
+        connection.rename( "cn=samba,ou=schema", "cn=foo" );
+        assertNotNull( connection.lookup( "cn=foo, ou=schema" ) );
+        assertTrue( schemaManager.getAttributeTypeRegistry().contains( "sambaNTPassword" ) );
+        assertEquals( "foo", schemaManager.getAttributeTypeRegistry().getSchemaName( "sambaNTPassword" ) );
 
         //noinspection EmptyCatchBlock
         try
         {
-            schemaRoot.lookup( "cn=samba" );
+            connection.lookup( "cn=samba, ou=schema" );
             fail( "the samba schema should not be present after a rename to foo" );
         }
-        catch( NameNotFoundException e )
+        catch( LdapException e )
         {
         }
     }
@@ -976,18 +975,13 @@ public class MetaSchemaHandlerIT extends
     @Ignore
     public void testRejectAddBogusDependency() throws Exception
     {
-        LdapContext schemaRoot = getSchemaContext( getService() );
-
-        ModificationItem[] mods = new ModificationItem[1];
-        Attribute attr = new BasicAttribute( "m-dependencies", "bogus" );
-        mods[0] = new ModificationItem( DirContext.ADD_ATTRIBUTE, attr );
-        
         try
         {
-            schemaRoot.modifyAttributes( "cn=nis", mods );
+            connection.modify( "cn=nis,ou=schema",
+                new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, "m-dependencies", "bogus" ));
             fail( "Should not be able to add bogus dependency to schema" );
         }
-        catch ( OperationNotSupportedException onse )
+        catch ( LdapException onse )
         {
             // expected
         }
@@ -1006,18 +1000,15 @@ public class MetaSchemaHandlerIT extends
     @Ignore
     public void testRejectAddOfDisabledDependencyToEnabledSchema() throws Exception
     {
-        LdapContext schemaRoot = getSchemaContext( getService() );
         IntegrationUtils.enableSchema( getService(), "nis" );
-        ModificationItem[] mods = new ModificationItem[1];
-        Attribute attr = new BasicAttribute( "m-dependencies", "mozilla" );
-        mods[0] = new ModificationItem( DirContext.ADD_ATTRIBUTE, attr );
         
         try
         {
-            schemaRoot.modifyAttributes( "cn=nis", mods );
+            connection.modify( "cn=nis,ou=schema",
+                new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, "m-dependencies", "mozilla" ) );
             fail( "Should not be able to add disabled dependency to schema" );
         }
-        catch ( OperationNotSupportedException onse )
+        catch ( LdapException onse )
         {
             // expected
         }
@@ -1034,13 +1025,11 @@ public class MetaSchemaHandlerIT extends
     @Ignore
     public void testAddOfDisabledDependencyToDisabledSchema() throws Exception
     {
-        LdapContext schemaRoot = getSchemaContext( getService() );
-        ModificationItem[] mods = new ModificationItem[1];
-        Attribute attr = new BasicAttribute( "m-dependencies", "mozilla" );
-        mods[0] = new ModificationItem( DirContext.ADD_ATTRIBUTE, attr );
-        schemaRoot.modifyAttributes( "cn=nis", mods );
-        Attributes attrs = schemaRoot.getAttributes( "cn=nis" );
-        Attribute dependencies = attrs.get( "m-dependencies" );
+        connection.modify( "cn=nis,ou=schema",
+            new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, "m-dependencies", "mozilla" ) );
+
+        Entry entry = connection.lookup( "cn=nis,ou=schema" );
+        Attribute dependencies = entry.get( "m-dependencies" );
         assertTrue( dependencies.contains( "mozilla" ) );
     }
 
@@ -1055,13 +1044,10 @@ public class MetaSchemaHandlerIT extends
     @Ignore
     public void testAddOfEnabledDependencyToDisabledSchema() throws Exception
     {
-        LdapContext schemaRoot = getSchemaContext( getService() );
-        ModificationItem[] mods = new ModificationItem[1];
-        Attribute attr = new BasicAttribute( "m-dependencies", "java" );
-        mods[0] = new ModificationItem( DirContext.ADD_ATTRIBUTE, attr );
-        schemaRoot.modifyAttributes( "cn=nis", mods );
-        Attributes attrs = schemaRoot.getAttributes( "cn=nis" );
-        Attribute dependencies = attrs.get( "m-dependencies" );
+        connection.modify( "cn=nis,ou=schema",
+            new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, "m-dependencies", "java" ) );
+        Entry entry = connection.lookup( "cn=nis,ou=schema" );
+        Attribute dependencies = entry.get( "m-dependencies" );
         assertTrue( dependencies.contains( "java" ) );
     }
 }



Mime
View raw message